:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-soft: #ffffff;
  --ink: #262427;
  --muted: #847f7b;
  --line: #f0ece8;
  --accent: #ef5a52;
  --accent-dark: #db4944;
  --accent-soft: #ffe5e1;
  --danger: #ef5a52;
  --warn: #d8a355;
  --ok: #2c8b61;
  --shadow: 0 22px 60px rgba(33, 31, 29, 0.05);
  --shadow-soft: 0 14px 34px rgba(33, 31, 29, 0.035);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background-color: #ffffff;
  background:
    radial-gradient(circle at 50% 14%, rgba(255,255,255,1), rgba(255,255,255,0) 26%),
    radial-gradient(circle at 84% 18%, rgba(244,244,244,0.54), rgba(244,244,244,0) 20%),
    radial-gradient(circle at 16% 22%, rgba(246,246,246,0.42), rgba(246,246,246,0) 18%),
    linear-gradient(180deg, #fcfcfc 0%, #f8f8f8 100%);
  color: var(--ink);
  font-family: "Century Gothic", "Bahnschrift", "Trebuchet MS", sans-serif;
  overflow-x: hidden;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 380px 1fr;
}

.sidebar {
  border-right: 1px solid rgba(241, 239, 236, 0.88);
  padding: 28px 24px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(14px);
}

.brand {
  margin-bottom: 34px;
}

.brand-logo-wrap {
  width: 230px;
  max-width: 100%;
  margin-bottom: 14px;
}

.brand-logo-image {
  display: block;
  width: 100%;
  height: auto;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin-top: 4px;
  max-width: 250px;
}

body.guest-mode #sidebarPrimaryAction,
body.guest-mode #historyPanel,
body.guest-mode #launchView,
body.guest-mode .content-header-actions,
body.guest-mode #runJobStatus {
  display: none !important;
}

body.guest-mode #guestLeadPanel {
  display: block !important;
}

html.guest-pending #sidebarPrimaryAction,
html.guest-pending #historyPanel,
html.guest-pending #launchView,
html.guest-pending .content-header-actions,
html.guest-pending #runJobStatus,
html.guest-pending .tab-button[data-tab="pages"],
html.guest-pending .tab-button[data-tab="queries"] {
  display: none !important;
}

body.guest-mode .brand {
  margin-bottom: 0;
}

.guest-lead-panel {
  display: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.995), rgba(252,252,252,0.995));
  color: var(--ink);
  border: 1px solid rgba(241, 239, 236, 0.92);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
  padding: 28px 26px 24px;
}

.guest-lead-inner {
  padding-right: 8px;
}

.guest-lead-inner h2 {
  margin: 0 0 22px;
  font-size: 26px;
  line-height: 1.08;
  letter-spacing: -0.05em;
  color: var(--ink);
}

.guest-lead-inner h2 span {
  color: var(--accent);
}

.guest-lead-form label {
  color: var(--muted);
}

.guest-lead-form input,
.guest-lead-form textarea {
  width: 100%;
  border: 1px solid rgba(222, 215, 202, 0.9);
  background: rgba(255, 255, 255, 0.98);
  color: var(--ink);
  border-radius: 20px;
  padding: 16px 18px;
  margin-bottom: 12px;
  font-size: 15px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.guest-lead-form textarea {
  resize: vertical;
  min-height: 110px;
  font-family: inherit;
}

.guest-lead-form input::placeholder,
.guest-lead-form textarea::placeholder {
  color: #9c9590;
}

.guest-lead-form input:focus,
.guest-lead-form textarea:focus {
  outline: none;
  border-color: rgba(239, 90, 82, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 0 0 4px rgba(239, 90, 82, 0.08);
}

#guestLeadSubmit {
  width: 100%;
  margin-top: 6px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 14px 30px rgba(239, 90, 82, 0.24);
  font-size: 15px;
  padding: 16px 18px;
}

.guest-lead-status {
  margin-top: 12px;
  min-height: 20px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

body.guest-mode .sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

body.guest-mode .brand {
  margin-bottom: 0;
}

body.guest-mode .guest-lead-panel {
  margin-bottom: 0;
}

body.guest-mode .guest-lead-inner h2 {
  max-width: 280px;
}

body.guest-mode .guest-lead-form {
  margin-top: 20px;
}

.panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.995), rgba(252,252,252,0.995));
  border: 1px solid rgba(241, 239, 236, 0.92);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.guest-report-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.guest-report-panel h2 {
  margin-bottom: 8px;
}

.guest-report-panel p {
  margin: 0;
  color: var(--muted);
}

.guest-report-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.panel h2 {
  margin: 0 0 12px 0;
  font-size: 20px;
  letter-spacing: -0.04em;
}

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(222, 215, 202, 0.9);
  background: rgba(255, 255, 255, 0.98);
  border-radius: 20px;
  padding: 16px 18px;
  margin-bottom: 14px;
  font-size: 15px;
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 52px;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(38, 36, 39, 0.62) 50%),
    linear-gradient(135deg, rgba(38, 36, 39, 0.62) 50%, transparent 50%);
  background-position:
    calc(100% - 26px) calc(50% - 3px),
    calc(100% - 18px) calc(50% - 3px);
  background-size: 8px 8px, 8px 8px;
  background-repeat: no-repeat;
  cursor: pointer;
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(239, 90, 82, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 0 0 4px rgba(239, 90, 82, 0.08);
}

button {
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
}

#runButton {
  width: 100%;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 14px 30px rgba(239, 90, 82, 0.24);
  font-size: 15px;
}

.ghost-button {
  background: #fbfbfb;
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

.sidebar-primary-action {
  margin-bottom: 18px;
}

.sidebar-primary-action .ghost-button {
  width: 100%;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 14px 30px rgba(239, 90, 82, 0.24);
  font-size: 15px;
}

.job-status {
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.launch-status-panel {
  margin-bottom: 18px;
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(250,250,250,0.98));
  border: 1px solid rgba(241, 239, 236, 0.92);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  box-shadow: var(--shadow-soft);
}

.runs-list {
  display: grid;
  gap: 10px;
  max-height: 44vh;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
}

.run-item {
  padding: 14px;
  border: 1px solid rgba(241, 239, 236, 0.95);
  border-radius: 22px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-soft);
  min-width: 0;
  width: 100%;
}

.run-item.active {
  border-color: rgba(239, 90, 82, 0.18);
  background: linear-gradient(180deg, #fffafa, #ffffff);
}

.run-item-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.run-item-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.run-item-stage {
  margin-top: 8px;
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
}

.content {
  position: relative;
  padding: 32px 38px 42px;
  min-width: 0;
}

.content::before {
  content: "";
  position: absolute;
  top: -30px;
  right: -40px;
  width: min(62vw, 1080px);
  height: 360px;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 24% 34%, rgba(255,255,255,0.985), rgba(255,255,255,0) 36%),
    radial-gradient(ellipse at 58% 28%, rgba(244,244,244,0.34), rgba(244,244,244,0) 38%),
    radial-gradient(ellipse at 88% 24%, rgba(255,255,255,0.94), rgba(255,255,255,0) 28%);
  filter: blur(20px);
  opacity: 0.98;
  z-index: 0;
}

.content > * {
  position: relative;
  z-index: 1;
}

.view-screen {
  display: none;
}

.view-screen.active {
  display: block;
}

.content-header h1 {
  margin: 0;
  font-size: 56px;
  line-height: 0.96;
  font-weight: 800;
  letter-spacing: -0.075em;
  max-width: 820px;
}

.content-header p {
  margin: 14px 0 0 0;
  color: var(--muted);
  font-size: 18px;
}

.content-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.content-header-actions {
  flex-shrink: 0;
}

#runView .content-header-actions {
  display: none;
}

.helper-text {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.launch-panel {
  max-width: 980px;
}

.audit-source-switch {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  margin: 4px 0 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(248, 246, 243, 0.9);
}

.audit-source-button {
  width: auto;
  min-width: 190px;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  font-size: 14px;
}

.audit-source-button.active {
  background: #fff;
  color: var(--accent-dark);
  box-shadow: var(--shadow-soft);
}

.sf-import-panel {
  margin: 0 0 20px;
  padding: 20px;
  border: 1px solid rgba(239, 90, 82, 0.2);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(255, 249, 247, 0.96), rgba(255, 255, 255, 0.98));
}

.sf-import-intro {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.sf-import-intro span,
.sf-file-help {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.sf-import-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.sf-file-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 16px;
  border: 1px dashed rgba(239, 90, 82, 0.32);
  border-radius: 18px;
  background: #fff;
  cursor: pointer;
}

.sf-file-title {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.sf-file-card input[type="file"] {
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  border-radius: 12px;
  font-size: 12px;
}

.sf-enrich-toggle {
  margin-top: 14px;
}

.launch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 0 18px;
}

.launch-grid-metrics {
  margin-top: 6px;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.launch-metrics-toggle {
  margin: 2px 0 8px;
}

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.check-inline input {
  width: 18px;
  height: 18px;
  margin: 0;
  box-shadow: none;
}

.launch-actions {
  margin-top: 10px;
  max-width: 280px;
}

.tabs {
  display: flex;
  gap: 12px;
  margin: 34px 0 26px;
  flex-wrap: wrap;
  padding: 6px 0;
}

.tab-button {
  background: linear-gradient(180deg, rgba(255,255,255,1), rgba(252,252,252,0.995));
  color: var(--ink);
  padding: 15px 22px;
  border-radius: 20px;
  font-size: 16px;
  letter-spacing: -0.03em;
  border: 1px solid rgba(243, 240, 236, 0.95);
  box-shadow:
    0 16px 34px rgba(33, 31, 29, 0.055),
    0 2px 0 rgba(255, 255, 255, 0.9) inset;
}

.tab-button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  border-color: transparent;
  box-shadow: 0 16px 28px rgba(239, 90, 82, 0.22);
}

.tabs.tabs-stage-flow {
  gap: 10px;
  margin-bottom: 18px;
}

.tabs.tabs-stage-flow .tab-button {
  border-radius: 999px;
}

.tabs.tabs-stage-flow .tab-button.active {
  background: rgba(239, 90, 82, 0.1);
  color: var(--accent-dark);
  border: 1px solid rgba(239, 90, 82, 0.2);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.85),
    0 8px 20px rgba(33, 31, 29, 0.05);
}

.tab-panel { display: none; }
.tab-panel.active {
  display: block;
  min-width: 0;
}

.summary-cards,
.results-grid,
.files-grid {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.tabular-shell {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.table-head-card,
.table-body-card {
  background: var(--panel);
  border: 1px solid rgba(241, 239, 236, 0.92);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.table-head-card {
  border-radius: 22px;
  padding: 0 22px;
}

.table-body-card {
  border-radius: 26px;
  padding: 0 22px;
  overflow: hidden;
}

.table-grid {
  width: 100%;
}

.table-grid-header,
.table-grid-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.15fr) minmax(220px, 0.95fr) 150px minmax(260px, 1.2fr);
  gap: 22px;
  align-items: start;
}

.table-grid-header > div,
.table-grid-row > div {
  min-width: 0;
}

.table-grid-header {
  padding: 24px 14px;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.045em;
}

.table-grid-row {
  padding: 24px 14px;
  border-bottom: 1px solid var(--line);
  transition: background 0.16s ease;
}

.table-grid-row:hover {
  background: rgba(248, 248, 248, 0.8);
}

.table-grid-row:last-child {
  border-bottom: 0;
}

.table-grid-pages-header,
.table-grid-pages-row {
  display: grid;
  grid-template-columns: 104px minmax(260px, 1.1fr) minmax(220px, 0.95fr) minmax(220px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.table-grid-queries-header,
.table-grid-queries-row {
  display: grid;
  grid-template-columns: 110px minmax(260px, 1fr) minmax(340px, 1.2fr) minmax(200px, 0.8fr) 100px;
  gap: 18px;
  align-items: start;
}

.table-grid-pages-header {
  padding: 24px 14px;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.045em;
}

.table-grid-pages-row {
  padding: 24px 14px;
  border-bottom: 1px solid var(--line);
}

.table-grid-pages-row:last-child {
  border-bottom: 0;
}

.table-grid-pages-header > div,
.table-grid-pages-row > div {
  min-width: 0;
}

.table-grid-queries-header {
  padding: 24px 14px;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.045em;
}

.table-grid-queries-row {
  padding: 24px 14px;
  border-bottom: 1px solid var(--line);
}

.table-grid-queries-row:last-child {
  border-bottom: 0;
}

.table-grid-queries-header > div,
.table-grid-queries-row > div {
  min-width: 0;
}

.review-check-col {
  padding-top: 4px;
}

.review-check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--ink);
}

.review-check input {
  width: 18px;
  height: 18px;
  margin: 0;
  border-radius: 6px;
  box-shadow: none;
}

.review-note-input {
  display: block;
  width: 100%;
  max-width: 100%;
  resize: vertical;
  min-height: 88px;
  box-sizing: border-box;
  border: 1px solid rgba(222, 215, 202, 0.9);
  border-radius: 16px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.98);
}

.page-type-cell {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.page-type-select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid rgba(222, 215, 202, 0.9);
  border-radius: 14px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.98);
  appearance: auto;
}

.table-grid-pages-row .cell-text,
.table-grid-pages-row .cell-title,
.table-grid-pages-row .cell-sub,
.table-grid-pages-row textarea {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.review-query-note-input {
  width: 100%;
  max-width: 100%;
  resize: vertical;
  min-height: 88px;
  box-sizing: border-box;
  border: 1px solid rgba(222, 215, 202, 0.9);
  border-radius: 16px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.98);
}

.page-url-title {
  font-size: 16px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.review-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.pipeline-note {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 247, 245, 0.95), rgba(255, 255, 255, 0.98));
  border: 1px solid rgba(239, 90, 82, 0.12);
}

.pipeline-note-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.pipeline-note-text {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
}

.page-type-legend {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(222, 215, 202, 0.55);
}

.page-type-legend-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.page-type-legend-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.page-type-legend-item {
  display: grid;
  gap: 4px;
}

.page-type-legend-code {
  font-family: Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-dark);
}

.page-type-legend-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.upload-label {
  display: inline-flex;
  cursor: pointer;
}

.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 18px;
  border-radius: 999px;
  background: #fbfbfb;
  color: var(--ink);
  box-shadow: var(--shadow-soft);
  font-size: 14px;
  font-weight: 700;
}

.cell-title {
  font-size: 19px;
  line-height: 1.22;
  font-weight: 700;
  letter-spacing: -0.045em;
}

.cell-sub {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.cell-text {
  font-size: 15px;
  line-height: 1.65;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.table-grid-row .cell-title,
.table-grid-row .cell-sub {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.cell-links {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

.status-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  padding-left: 6px;
}

.status-icon {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 800;
}

.status-icon.ok {
  color: var(--ok);
  background: rgba(44, 139, 97, 0.12);
}

.status-icon.problem {
  color: var(--danger);
  background: rgba(239, 90, 82, 0.12);
}

.status-icon.access {
  color: var(--warn);
  background: rgba(226, 166, 58, 0.14);
}

.status-icon.na {
  color: #7f7f7f;
  background: rgba(127, 127, 127, 0.1);
}

.optimization-table {
  width: 1720px;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
  min-width: 1720px;
  max-width: none;
  transition: transform 0.08s linear;
  will-change: transform;
}

.optimization-table-wrap {
  width: 100%;
  overflow: hidden;
  padding-bottom: 6px;
  position: relative;
}

.optimization-table th,
.optimization-table td {
  padding: 20px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.sync-range-row {
  margin: 18px 0 14px;
}

.sync-range-row-bottom {
  margin: 8px 0 18px;
}

.sync-bar {
  width: 100%;
}

.sync-bar-track {
  position: relative;
  height: 18px;
  background: rgba(244, 240, 236, 0.95);
  border-radius: 999px;
  overflow: hidden;
  cursor: pointer;
}

.sync-bar-thumb {
  position: absolute;
  top: 0;
  left: 0;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(239, 90, 82, 0.9), rgba(219, 73, 68, 0.9));
  border: 3px solid rgba(244, 240, 236, 0.95);
  cursor: ew-resize;
  box-sizing: border-box;
}

.optimization-table th {
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.optimization-head-card {
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: 14px;
}

.optimization-table-wrap-head {
  overflow: hidden;
  padding-bottom: 0;
}

.optimization-table-head th {
  border-bottom: 0;
}

.optimization-scroll-shell {
  display: grid;
  gap: 0;
}

.summary-cards {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 22px;
}

.business-metrics-panel {
  margin-top: 4px;
}

.business-metrics-panel h2,
.business-metrics-empty h2 {
  margin: 0 0 12px;
  font-size: 28px;
  letter-spacing: -0.05em;
}

.business-metrics-head p,
.business-metrics-empty p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.business-metrics-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px 16px;
  margin: 22px 0 26px;
  color: var(--ink);
  font-size: 15px;
}

.business-funnels-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 20px;
}

.business-funnel-card {
  background: linear-gradient(180deg, #fffaf9, #fffefe);
  border: 1px solid rgba(241, 239, 236, 0.92);
  border-radius: 26px;
  padding: 24px 22px 26px;
  box-shadow: var(--shadow);
}

.business-funnel-card.is-growth {
  background: linear-gradient(180deg, #fff8f7, #ffffff);
}

.business-funnel-title {
  margin-bottom: 18px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.funnel-scenario-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: -4px 0 12px;
}

.funnel-scenario-button {
  min-width: 0;
  padding: 9px 8px;
  border: 1px solid rgba(229, 92, 78, 0.18);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.funnel-scenario-button.is-active {
  border-color: #e85c4e;
  background: #e85c4e;
  color: #fff;
  box-shadow: 0 10px 20px rgba(219, 73, 68, 0.18);
}

.business-funnel-note {
  min-height: 42px;
  margin: 0 4px 15px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.funnel-stack {
  display: grid;
  gap: 12px;
}

.funnel-stage {
  position: relative;
  margin: 0 auto;
  min-height: 78px;
  padding: 16px 26px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 18px;
  box-shadow: 0 16px 24px rgba(219, 73, 68, 0.16);
  clip-path: polygon(8% 0, 92% 0, 100% 100%, 0 100%);
}

.is-current .funnel-stage {
  background: linear-gradient(180deg, #ef5a52, #d84b45);
}

.is-growth .funnel-stage {
  background: linear-gradient(180deg, #ef7b5e, #df5b49);
}

.funnel-stage-1 { width: 100%; }
.funnel-stage-2 { width: 86%; }
.funnel-stage-3 { width: 72%; }
.funnel-stage-4 {
  width: 58%;
  min-height: 88px;
}

.funnel-stage-label {
  display: block;
  font-size: 15px;
  font-weight: 700;
}

.funnel-stage strong {
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -0.04em;
  text-align: right;
  padding-left: 18px;
  margin-left: auto;
}

.funnel-stage-delta {
  display: block;
  margin-top: 5px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.funnel-stage-delta.is-negative {
  color: #fff2d5;
}

.business-funnel-card.is-empty {
  display: flex;
  flex-direction: column;
}

.forecast-funnel-empty {
  flex: 1;
  min-height: 390px;
  padding: 34px;
  border: 1px dashed rgba(229, 92, 78, 0.28);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(255, 244, 241, 0.9), rgba(255, 255, 255, 0.96));
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.forecast-funnel-empty strong {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 20px;
}

.forecast-funnel-empty p {
  max-width: 390px;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.business-metrics-notes {
  margin-top: 18px;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.forecast-panel {
  margin-top: 24px;
  border-top: 1px solid rgba(241, 239, 236, 0.92);
  padding-top: 24px;
}

.forecast-head h2 {
  margin: 0 0 10px;
  font-size: 28px;
  letter-spacing: -0.05em;
}

.forecast-head p,
.forecast-empty p,
.forecast-build-status,
.forecast-notes {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.forecast-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(190px, 1fr));
  gap: 16px 18px;
  align-items: end;
  margin: 20px 0 22px;
}

.forecast-field {
  display: grid;
  gap: 8px;
}

.forecast-field input {
  height: 58px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 18px;
  font: inherit;
  color: var(--ink);
}

.forecast-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.forecast-model-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 8px 0 26px;
}

.forecast-model-card {
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(145deg, #fff, #fff8f6);
}

.forecast-model-card span,
.forecast-model-card small {
  color: var(--muted);
  line-height: 1.45;
}

.forecast-model-card strong {
  color: var(--ink);
  font-size: 27px;
  letter-spacing: -0.035em;
}

.forecast-model-card.is-achievable {
  border-color: rgba(239, 82, 77, 0.28);
  box-shadow: 0 18px 40px rgba(239, 82, 77, 0.10);
}

.forecast-model-card.is-capacity {
  background: linear-gradient(145deg, #fffaf2, #fff);
}

.forecast-download-button {
  text-decoration: none;
}

.forecast-build-status {
  grid-column: 1 / -1;
}

.portfolio-forecast-panel {
  margin-top: 34px;
}

.portfolio-region-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 20px;
}

.portfolio-region-chips span {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.25;
}

.portfolio-controls {
  display: grid;
  grid-template-columns: minmax(260px, 1.6fr) repeat(4, minmax(150px, 1fr));
  gap: 14px;
  align-items: end;
  margin: 0 0 20px;
}

.portfolio-controls .field {
  display: grid;
  gap: 8px;
}

.portfolio-controls .field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.portfolio-controls input {
  width: 100%;
  min-width: 0;
  height: 56px;
  padding: 0 17px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.portfolio-controls input[type="file"] {
  padding: 14px 16px;
  font-size: 13px;
}

.portfolio-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 24px 0;
}

.portfolio-summary-grid > div {
  display: grid;
  gap: 7px;
  min-height: 108px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(145deg, #fff, #fff8f6);
}

.portfolio-summary-grid span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.portfolio-summary-grid strong {
  align-self: end;
  color: var(--ink);
  font-size: 26px;
  letter-spacing: -0.035em;
}

.portfolio-region-table-wrap {
  overflow-x: auto;
  margin-top: 26px;
  padding-bottom: 6px;
}

.portfolio-region-table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0 9px;
}

.portfolio-region-table th {
  padding: 0 14px 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.portfolio-region-table td {
  padding: 15px 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 14px;
}

.portfolio-region-table td:first-child {
  border-left: 1px solid var(--line);
  border-radius: 18px 0 0 18px;
  font-weight: 700;
}

.portfolio-region-table td:last-child {
  border-right: 1px solid var(--line);
  border-radius: 0 18px 18px 0;
}

.portfolio-region-table a {
  color: var(--accent);
  overflow-wrap: anywhere;
}

.forecast-charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
}

.forecast-chart-card {
  position: relative;
  background: linear-gradient(180deg, #fffaf9, #ffffff);
  border: 1px solid rgba(241, 239, 236, 0.92);
  border-radius: 24px;
  padding: 28px 26px 22px;
  box-shadow: var(--shadow);
}

.forecast-chart-hint {
  color: var(--muted);
  font-size: 14px;
}

.forecast-chart-head {
  display: grid;
  gap: 12px;
  margin-bottom: 8px;
}

.forecast-chart-head h3 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.04em;
}

.forecast-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 16px;
}

.forecast-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.forecast-legend i {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 999px;
}

.forecast-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.forecast-month-guide {
  stroke: rgba(44, 34, 48, 0.055);
  stroke-width: 1;
  stroke-dasharray: 5 7;
}

.forecast-chart-point {
  stroke: #fff;
  stroke-width: 3;
  pointer-events: none;
}

.forecast-hover-zone {
  fill: transparent;
  cursor: crosshair;
}

.forecast-chart-tooltip {
  position: absolute;
  z-index: 4;
  display: none;
  min-width: 245px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(39, 33, 39, 0.95);
  color: #fff;
  box-shadow: 0 16px 40px rgba(39, 33, 39, 0.25);
  pointer-events: none;
}

.forecast-chart-tooltip.is-visible {
  display: grid;
  gap: 8px;
}

.forecast-chart-tooltip strong {
  margin-bottom: 2px;
  font-size: 17px;
}

.forecast-chart-tooltip span {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.forecast-chart-tooltip i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.forecast-chart-tooltip .is-pessimistic { background: #d9554c; }
.forecast-chart-tooltip .is-neutral { background: #f08a45; }
.forecast-chart-tooltip .is-optimistic { background: #c13fd6; }

.forecast-axis-label {
  fill: #8d847e;
  font-size: 15px;
}

.forecast-notes {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.card,
.result-card,
.file-card {
  background: var(--panel);
  border: 1px solid rgba(241, 239, 236, 0.92);
  border-radius: 26px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-label {
  font-size: 12px;
  color: var(--muted);
}

.card-value {
  margin-top: 10px;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.06em;
}

.card-note {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.card-score {
  position: relative;
  overflow: hidden;
}

.card-score::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  border-radius: 26px 0 0 26px;
  background: #d8d8d8;
}

.card-score-good::before {
  background: linear-gradient(180deg, #2c8b61, #49b07f);
}

.card-score-medium::before {
  background: linear-gradient(180deg, #d8a355, #efbf76);
}

.card-score-poor::before {
  background: linear-gradient(180deg, #ef5a52, #db4944);
}

.card-score-good .card-value {
  color: #2c8b61;
}

.card-score-medium .card-value {
  color: #b67a24;
}

.card-score-poor .card-value {
  color: #d94640;
}

.result-card h3,
.file-card h3 {
  margin: 0 0 10px 0;
  font-size: 18px;
  letter-spacing: -0.03em;
}

.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  margin-right: 8px;
}

.badge.ok { background: rgba(43, 138, 87, 0.12); color: var(--ok); }
.badge.problem { background: rgba(239, 90, 82, 0.12); color: var(--danger); }
.badge.na { background: #f3efe8; color: var(--muted); }
.badge.access { background: rgba(226, 166, 58, 0.16); color: var(--warn); }

.result-meta {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.result-list {
  margin: 0;
  padding-left: 18px;
}

.result-list li {
  margin-bottom: 6px;
}

.job-log {
  font-family: Consolas, monospace;
  font-size: 13px;
  background: #252325;
  color: #f5f1ea;
  border-radius: 22px;
  padding: 14px;
  min-height: 160px;
  white-space: pre-wrap;
}

.file-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 14px 26px rgba(239, 90, 82, 0.22);
}

.action-link:hover,
#runButton:hover {
  box-shadow: 0 18px 34px rgba(239, 90, 82, 0.3);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .launch-grid {
    grid-template-columns: 1fr;
  }

  .sf-import-grid {
    grid-template-columns: 1fr;
  }

  .launch-grid-metrics,
  .business-metrics-stats,
  .business-funnels-grid,
  .forecast-charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .audit-source-switch {
    display: flex;
    width: 100%;
    border-radius: 20px;
  }

  .audit-source-button {
    flex: 1;
    min-width: 0;
    padding: 11px 10px;
  }
}

@media (max-width: 980px) {
  .content {
    padding: 22px 18px 34px;
  }

  .content::before {
    right: -180px;
    top: -30px;
    width: 120vw;
    height: 240px;
    filter: blur(16px);
  }

  .content-header h1 {
    font-size: 42px;
  }

  .content-header-row {
    flex-direction: column;
  }

  .table-grid-header,
  .table-grid-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .table-grid-pages-header,
  .table-grid-pages-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .table-grid-queries-header,
  .table-grid-queries-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .table-grid-header {
    display: none;
  }

  .table-grid-pages-header {
    display: none;
  }

  .table-grid-queries-header {
    display: none;
  }

  .table-body-card {
    padding: 0 12px;
  }

  .page-type-legend-grid {
    grid-template-columns: 1fr;
  }

  .table-grid-row {
    padding: 16px 10px;
  }

  .brand-logo-wrap {
    width: 200px;
  }

  .forecast-controls {
    grid-template-columns: 1fr;
  }

  .forecast-model-summary {
    grid-template-columns: 1fr;
  }

  .portfolio-controls,
  .portfolio-summary-grid {
    grid-template-columns: 1fr;
  }
}
