:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #080b0e;
  color: #edf4f6;
  font-synthesis: none;
  --bg: #080b0e;
  --surface: #0f151a;
  --surface-2: #151e24;
  --line: #26343c;
  --muted: #8fa0aa;
  --accent: #6be0bd;
  --accent-2: #62a9ff;
  --danger: #ff7878;
  --warning: #f0c264;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 9px; color: var(--accent); font-size: .7rem; font-weight: 800; letter-spacing: .16em; }
.status { min-height: 22px; color: var(--muted); }

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(360px, .7fr); }
.auth-intro { display: flex; flex-direction: column; justify-content: center; padding: clamp(44px, 9vw, 130px); background: radial-gradient(circle at 25% 20%, #1c3540, #0b1014 52%, #080b0e); }
.auth-intro h1 { max-width: 820px; margin: 8px 0 26px; font-size: clamp(3rem, 7vw, 7rem); line-height: .92; letter-spacing: -.065em; }
.auth-intro > p:last-child { max-width: 640px; color: #a8b8c0; font-size: 1.05rem; line-height: 1.7; }
.auth-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(30px, 6vw, 84px); border-left: 1px solid var(--line); background: #0d1216; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 24px; padding: 4px; border-radius: 12px; background: #080c0f; }
.tab { padding: 10px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); }
.tab.active { background: var(--surface-2); color: white; }
.stack { display: grid; gap: 16px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

label { display: grid; gap: 7px; color: var(--muted); font-size: .76rem; font-weight: 650; letter-spacing: .02em; }
input, select { min-width: 0; width: 100%; padding: 11px 12px; border: 1px solid #34444d; border-radius: 9px; outline: none; background: #090e12; color: #f0f5f6; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #6be0bd1f; }
button { align-self: end; min-height: 40px; padding: 10px 15px; border: 1px solid var(--accent); border-radius: 9px; background: var(--accent); color: #06110e; font-weight: 800; }
button:hover { filter: brightness(1.07); }
button:disabled { cursor: not-allowed; opacity: .45; }
button.secondary { border-color: #40525d; background: #151f25; color: #e8f0f2; }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button.danger { border-color: #693838; background: #2a1717; color: #ffb7b7; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 16px; border-right: 1px solid var(--line); background: #0b1014; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 28px; color: white; font-weight: 900; letter-spacing: .13em; text-decoration: none; }
.brand-mark { display: grid; width: 32px; height: 32px; place-items: center; border: 1px solid #4c776b; border-radius: 9px; color: var(--accent); background: #10231e; }
.nav-label { margin: 0 10px 8px; color: #61717a; font-size: .66rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
#primary-nav { display: grid; gap: 3px; }
.nav-button { display: flex; align-items: center; width: 100%; min-height: 38px; padding: 9px 11px; border: 0; border-radius: 8px; background: transparent; color: #9babb3; font-size: .84rem; font-weight: 650; text-align: left; }
.nav-button:hover, .nav-button.active { background: #151e24; color: white; filter: none; }
.nav-button.active { box-shadow: inset 2px 0 var(--accent); }
.truth-boundary { display: flex; gap: 10px; align-items: flex-start; margin-top: auto; padding: 13px; border: 1px solid #26463d; border-radius: 11px; background: #0f1c18; }
.truth-boundary strong, .truth-boundary small { display: block; }
.truth-boundary strong { font-size: .73rem; }
.truth-boundary small { margin-top: 3px; color: #86a096; font-size: .65rem; }
.signal { width: 8px; height: 8px; flex: 0 0 auto; margin-top: 4px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px #6be0bd1a; }

.workspace-shell { min-width: 0; }
.topbar { min-height: 88px; display: flex; justify-content: space-between; gap: 20px; align-items: center; padding: 18px 36px; border-bottom: 1px solid var(--line); background: #0a0f12e8; backdrop-filter: blur(12px); }
.topbar h2 { margin: 0; font-size: 1.5rem; letter-spacing: -.025em; }
.topbar-actions { display: flex; align-items: end; gap: 8px; }
.project-picker { min-width: 220px; }
.notice { margin: 0; padding: 8px 36px 0; }
#screen-root { padding: 26px 36px 80px; }
.screen { display: grid; gap: 18px; max-width: 1440px; margin: 0 auto; }
.section-heading { display: flex; justify-content: space-between; gap: 30px; align-items: end; margin-bottom: 4px; }
.section-heading h3 { margin: 0; font-size: 2rem; letter-spacing: -.035em; }
.section-heading > p { max-width: 440px; margin: 0; color: var(--muted); line-height: 1.5; text-align: right; }
.hero-panel { display: flex; justify-content: space-between; gap: 32px; align-items: center; min-height: 210px; padding: 34px; border: 1px solid #29423b; border-radius: 18px; background: radial-gradient(circle at 10% 10%, #1a3a32, #10181b 56%, #0d1317); }
.hero-panel h3 { margin: 0; font-size: clamp(2rem, 4vw, 4rem); letter-spacing: -.05em; }
.hero-panel p:last-child { color: #9eb0b6; }
.source-badge { padding: 8px 10px; border: 1px solid #356052; border-radius: 999px; color: var(--accent); font-size: .68rem; font-weight: 800; letter-spacing: .08em; }

.panel, .form-card, .inline-form, .entity-card { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.panel { padding: 22px; overflow-x: auto; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.panel-heading h3 { margin: 0; }
.panel-heading span { color: var(--muted); font-size: .75rem; }
.form-card, .inline-form { padding: 18px; }
.grid-form { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 13px; align-items: end; }
.wide-form { grid-template-columns: repeat(5, minmax(140px, 1fr)); }
.inline-form { display: flex; gap: 12px; align-items: end; }
.inline-form label { flex: 1; }
.check { display: flex; flex-direction: row; gap: 9px; align-items: center; min-height: 40px; }
.check input { width: auto; }
.card-list { display: grid; gap: 10px; }
.entity-card { display: grid; grid-template-columns: minmax(180px, 1.2fr) repeat(3, minmax(120px, .7fr)) auto; gap: 14px; align-items: center; padding: 16px 18px; }
.entity-card h4 { margin: 0 0 5px; font-size: .98rem; }
.entity-card p, .entity-card small { margin: 0; color: var(--muted); }
.entity-card small { display: block; }
.entity-actions { display: flex; gap: 7px; justify-content: end; }
.entity-actions button { min-height: 34px; padding: 7px 10px; font-size: .74rem; }
.empty { padding: 28px; border: 1px dashed #34444d; border-radius: 13px; color: var(--muted); text-align: center; }
.pill { display: inline-flex; width: fit-content; padding: 5px 8px; border-radius: 999px; background: #1b252b; color: #b9c7cc; font-size: .68rem; font-weight: 800; letter-spacing: .05em; }
.pill.good { background: #112c24; color: var(--accent); }
.pill.bad { background: #321b1b; color: #ff9b9b; }
.pill.warn { background: #302817; color: var(--warning); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .75rem; word-break: break-all; }

.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.metric { min-height: 126px; display: flex; flex-direction: column; justify-content: space-between; padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.metric span, .metric small { color: var(--muted); }
.metric strong { font-size: 1.75rem; letter-spacing: -.04em; }
.metric small { margin-top: 8px; line-height: 1.35; }
.workflow-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0; padding: 0; list-style: none; counter-reset: workflow; }
.workflow-list li { min-height: 78px; padding: 14px; border-radius: 11px; background: var(--surface-2); color: var(--muted); }
.workflow-list li::before { counter-increment: workflow; content: counter(workflow, decimal-leading-zero); display: block; margin-bottom: 8px; color: #5b6c75; font-size: .65rem; }
.workflow-list li.done { color: white; box-shadow: inset 0 0 0 1px #315a4e; }
.workflow-list li.done::after { content: "✓"; float: right; color: var(--accent); }

#results, #comparison { display: grid; gap: 14px; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 9px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; }

@media (max-width: 1150px) {
  .grid-form, .wide-form { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .workflow-list { grid-template-columns: repeat(2, 1fr); }
  .entity-card { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 780px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-intro { min-height: 48vh; padding: 42px 24px; }
  .auth-panel { padding: 36px 24px; border: 0; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  #primary-nav { grid-template-columns: repeat(3, 1fr); }
  .truth-boundary { display: none; }
  .topbar { align-items: flex-start; padding: 18px; }
  .topbar-actions { flex-wrap: wrap; justify-content: end; }
  #screen-root { padding: 22px 18px 60px; }
  .notice { padding-left: 18px; }
  .grid-form, .wide-form, .kpi-grid, .workflow-list { grid-template-columns: 1fr; }
  .inline-form, .section-heading { align-items: stretch; flex-direction: column; }
  .section-heading > p { text-align: left; }
  .entity-card { grid-template-columns: 1fr; }
  .entity-actions { justify-content: start; }
}
