:root {
  --ink: #1F2937;
  --muted: #667085;
  --line: #D0D5DD;
  --soft-line: #E7E9ED;
  --page: #F3F4F6;
  --panel: #FFFFFF;
  --success: #18864B;
  --success-soft: #ECFDF3;
  --danger: #B42318;
  --danger-soft: #FEF3F2;
  --warning: #B54708;
  --shadow: 0 16px 44px rgba(16, 24, 40, 0.10);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { min-width: 320px; margin: 0; font-family: Arial, Helvetica, sans-serif; background: var(--page); color: var(--ink); }
button, input { font: inherit; }
button, a, input { outline-offset: 3px; }

.site-header { width: min(1400px, calc(100% - 48px)); margin: 0 auto; padding: 20px 0; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand, .back-link { text-decoration: none; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--navy); font-weight: 700; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; background: var(--navy); color: var(--ivory); font-size: 12px; letter-spacing: .06em; }
.back-link { color: var(--muted); font-size: 14px; }
.back-link:hover { color: var(--ink); }

main { width: min(1400px, calc(100% - 48px)); margin: 0 auto; padding: 54px 0 88px; }
.intro { max-width: 900px; margin-bottom: 32px; }
.eyebrow, .step-label { margin: 0; color: var(--blue); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 10px 0 16px; color: var(--navy); font-size: clamp(48px, 7vw, 76px); line-height: 1; letter-spacing: -.045em; }
.intro-copy { max-width: 820px; margin: 0; color: #475467; font-size: 19px; line-height: 1.6; }
.project-facts { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 9px; }
.project-facts span { padding: 7px 10px; border: 1px solid var(--blue-border); border-radius: 999px; background: var(--blue-soft); color: var(--blue-text); font-size: 12px; font-weight: 700; }
.privacy-note { margin: 14px 0 0; color: var(--muted); font-size: 13px; }

.card { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); }
.recording { margin: 0 0 28px; padding: 24px; display: grid; grid-template-columns: minmax(240px, .45fr) minmax(0, 1fr); align-items: center; gap: 30px; }
.recording h2 { margin: 6px 0 8px; color: var(--navy); font-size: 24px; }
.recording p:last-child { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.demo-video { display: block; width: 100%; aspect-ratio: 16 / 9; border: 1px solid var(--line); border-radius: 7px; background: #111; }

.workspace { display: grid; gap: 20px; }
.workspace-header, .panel-heading { padding: 20px 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--soft-line); }
.workspace-header h2, .panel-heading h2 { margin: 5px 0 0; color: var(--navy); font-size: 21px; }
.workspace-header p:last-child, .panel-heading p:last-child { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.button-row { display: flex; gap: 9px; }
.button { min-height: 40px; padding: 0 15px; border: 1px solid transparent; border-radius: 6px; cursor: pointer; font-weight: 700; }
.button:disabled { cursor: wait; opacity: .6; }
.button-primary { background: var(--blue); color: white; }
.button-primary:hover:not(:disabled) { background: var(--blue-dark); }
.button-secondary { border-color: var(--line); background: white; color: #344054; }
.button-secondary:hover:not(:disabled) { background: #F8F9FA; }

.scenario-controls { padding: 16px 22px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; background: #F8F9FA; }
.control label { display: flex; justify-content: space-between; gap: 12px; color: #475467; font-size: 12px; font-weight: 700; }
.control output { color: var(--blue); }
.control input[type="range"] { width: 100%; margin-top: 9px; accent-color: var(--blue); }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { padding: 18px; }
.kpi span { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.kpi strong { margin-top: 8px; display: block; color: var(--navy); font-size: clamp(24px, 3vw, 34px); letter-spacing: -.03em; }
.kpi small { margin-top: 6px; display: block; color: var(--muted); font-size: 11px; }
.kpi.positive strong { color: var(--success); }
.kpi.negative strong { color: var(--danger); }

.analysis-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .75fr); gap: 20px; }
.table-card, .driver-card, .source-card, .pipeline-card, .output-card { overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 12px; border-bottom: 1px solid var(--line); background: #F8F9FA; color: #475467; font-size: 10px; letter-spacing: .05em; text-align: left; text-transform: uppercase; }
td { padding: 10px 12px; border-bottom: 1px solid var(--soft-line); color: #344054; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
.row-status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.row-status::before { width: 7px; height: 7px; border-radius: 50%; background: #98A2B3; content: ""; }
tr.processing .row-status { color: var(--blue); }
tr.processing .row-status::before { background: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
tr.complete .row-status { color: var(--success); }
tr.complete .row-status::before { background: var(--success); }
.positive-value { color: var(--success); font-weight: 700; }
.negative-value { color: var(--danger); font-weight: 700; }
.empty-row td { padding: 34px 16px; color: var(--muted); text-align: center; }

.driver-list { padding: 16px 18px 20px; display: grid; gap: 16px; }
.driver { display: grid; gap: 7px; }
.driver-label { display: flex; justify-content: space-between; gap: 12px; color: #475467; font-size: 12px; }
.driver-label strong { color: var(--ink); }
.driver-track { height: 8px; overflow: hidden; border-radius: 99px; background: #EEF1F5; }
.driver-fill { width: 0; height: 100%; border-radius: inherit; background: var(--blue); transition: width 400ms ease; }
.driver-fill.negative { margin-left: auto; background: var(--danger); }

.progress-header { padding: 16px 22px 12px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.progress-header h2 { margin: 5px 0 0; color: var(--navy); font-size: 20px; }
.run-status { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #98A2B3; }
.status-dot.running { background: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.status-dot.complete { background: var(--success); }
.progress-track { height: 4px; background: #E4E7EC; }
.progress-fill { width: 0; height: 100%; background: var(--blue); transition: width 180ms ease; }

.pipeline-layout { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 20px; }
.pipeline-steps { padding: 18px 20px 22px; display: grid; gap: 12px; }
.pipeline-step { padding: 13px 14px; display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 11px; border: 1px solid var(--soft-line); border-radius: 7px; background: #FAFAFA; }
.step-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #EAECF0; color: var(--muted); font-size: 11px; font-weight: 700; }
.pipeline-step strong { display: block; color: #344054; font-size: 13px; }
.pipeline-step span:last-child, .pipeline-step p { color: var(--muted); font-size: 11px; }
.pipeline-step p { margin: 3px 0 0; }
.pipeline-step.active { border-color: var(--blue-active-border); background: var(--blue-soft); }
.pipeline-step.active .step-icon { background: var(--blue); color: white; }
.pipeline-step.complete { border-color: #ABEFC6; background: var(--success-soft); }
.pipeline-step.complete .step-icon { background: var(--success); color: white; }
.pipeline-step.complete > span:last-child { color: var(--success); font-weight: 700; }

.log-panel { padding: 16px 20px 20px; border-top: 1px solid var(--soft-line); background: #F8F9FA; }
.log-panel h3 { margin: 0 0 10px; color: #344054; font-size: 12px; }
.log-list { max-height: 150px; margin: 0; padding: 0; display: grid; gap: 6px; overflow-y: auto; list-style: none; }
.log-list li { color: #475467; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10px; line-height: 1.4; }
.log-list time { margin-right: 7px; color: var(--muted); }

.source-table input { width: 100%; min-width: 92px; padding: 7px 8px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--ink); }
.source-table input:hover, .source-table input:focus { border-color: var(--blue); background: white; }

footer { padding: 0 24px 40px; color: var(--muted); font-size: 12px; text-align: center; }
footer p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

html.recording-mode .site-header,
html.recording-mode .intro,
html.recording-mode .recording,
html.recording-mode footer {
  display: none;
}

html.recording-mode body { background: #E9EDF3; }
html.recording-mode main { width: calc(100% - 28px); max-width: none; padding: 14px 0; }
html.recording-mode .workspace { gap: 12px; }
html.recording-mode .workspace-header { padding: 12px 16px; }
html.recording-mode .workspace-header h2 { font-size: 18px; }
html.recording-mode .workspace-header p:last-child { display: none; }
html.recording-mode .scenario-controls { padding: 10px 16px; }
html.recording-mode .kpi { padding: 13px; }
html.recording-mode .kpi strong { font-size: 27px; }
html.recording-mode .analysis-grid { gap: 12px; }
html.recording-mode .panel-heading { padding: 12px 16px; }
html.recording-mode .panel-heading h2 { font-size: 17px; }
html.recording-mode .panel-heading p:last-child { display: none; }
html.recording-mode .table-card,
html.recording-mode .driver-card { min-height: 440px; }
html.recording-mode .pipeline-layout { gap: 12px; }
html.recording-mode .source-card,
html.recording-mode .pipeline-card,
html.recording-mode .output-card { box-shadow: none; }
html.recording-mode .pipeline-steps { padding: 12px 14px; gap: 8px; }
html.recording-mode .pipeline-step { padding: 9px 10px; }
html.recording-mode .log-panel { padding: 10px 14px; }
html.recording-mode .output-card { grid-column: 1 / -1; }
html.recording-mode th,
html.recording-mode td { padding: 7px 9px; font-size: 10px; }

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analysis-grid, .pipeline-layout { grid-template-columns: 1fr; }
  .recording { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
  .site-header, main { width: min(100% - 28px, 1400px); }
  main { padding: 38px 0 64px; }
  .workspace-header, .panel-heading, .progress-header { align-items: stretch; flex-direction: column; }
  .scenario-controls { grid-template-columns: 1fr; }
  .button-row { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
