:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --surface-1: #ffffff;
  --surface-2: #f7f7f4;
  --surface-3: #efefeb;
  --line: #e6e5e0;
  --line-soft: #efeee9;
  --text-primary: #18181a;
  --text-secondary: #55554f;
  --text-muted: #8b8a83;
  --accent: #2a78d6;
  --accent-soft: #eaf2fc;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --good: #0c8a3e;
  --good-soft: #e8f6ee;
  --warning: #b77900;
  --warning-soft: #fdf5e3;
  --critical: #c93636;
  --critical-soft: #fdecec;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 18, 0.04), 0 1px 3px rgba(20, 20, 18, 0.04);
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text-primary); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { letter-spacing: -0.01em; }

/* shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface-1); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 14px; }
.brand b { display: block; font-size: 15px; }
.brand small { color: var(--text-muted); font-size: 12px; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: var(--text-primary); position: relative; }
.logo::after { content: ''; position: absolute; inset: 9px; border-radius: 50%; background: #fff; }
nav { padding: 4px 10px 16px; flex: 1; }
.nav-group { margin: 16px 0 4px; padding: 0 10px; font-size: 12px; color: var(--text-muted); font-weight: 500; }
.nav-item { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; border-radius: 8px; color: var(--text-secondary); cursor: pointer; font-size: 14px; }
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); text-decoration: none; }
.nav-item.active { background: var(--surface-3); color: var(--text-primary); font-weight: 500; }
.badge { min-width: 20px; padding: 0 7px; border-radius: 10px; background: var(--surface-3); color: var(--text-secondary); font-size: 12px; text-align: center; font-weight: 500; }
.badge.hot { background: var(--accent); color: #fff; }
.side-foot { padding: 14px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-muted); }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 14px 32px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); }
.topbar h1 { font-size: 20px; margin: 0; font-weight: 600; }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.view { padding: 8px 32px 64px; max-width: 1280px; }

/* controls */
select, input, textarea { background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 13px; }
select:focus, input:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { width: 100%; min-height: 120px; resize: vertical; }
.btn { border: 1px solid var(--line); background: var(--surface-1); color: var(--text-primary); border-radius: 8px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; box-shadow: var(--shadow); }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--text-primary); border-color: var(--text-primary); color: #fff; }
.btn.primary:hover { background: #333; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--text-secondary); }
.btn.ghost:hover { background: var(--surface-3); }
.btn.warn.on { background: var(--warning-soft); color: var(--warning); border-color: #f0dca8; }
.btn.danger { color: var(--critical); }
.btn.danger.on { background: var(--critical); color: #fff; border-color: var(--critical); }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.icon-btn { background: none; border: 0; color: var(--text-primary); font-size: 18px; cursor: pointer; }

.banner { margin: 0 32px 8px; padding: 10px 14px; border-radius: 10px; border: 1px solid; }
.banner.kill { background: var(--critical-soft); border-color: #f3c4c4; color: var(--critical); }
.banner.pause { background: var(--warning-soft); border-color: #f0dca8; color: var(--warning); }

/* layout */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.card { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; min-width: 0; box-shadow: var(--shadow); }
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card h2 .sub, .card h2 a { font-size: 13px; font-weight: 400; color: var(--text-muted); }
.card h2 a { color: var(--accent); }
.card h3 { font-size: 14px; margin: 0 0 6px; }
.section-title { font-size: 13px; color: var(--text-muted); margin: 28px 0 10px; font-weight: 500; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 16px; }

/* hero / greeting */
.hello { margin: 4px 0 20px; }
.hello h2 { font-size: 26px; font-weight: 600; margin: 0 0 4px; }
.hello p { margin: 0; color: var(--text-secondary); font-size: 15px; }

/* needs-you card */
.todo { border-color: #d7e6f8; background: linear-gradient(180deg, #f6faff, #fff); }
.todo-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.todo-item:first-of-type { border-top: 0; padding-top: 2px; }
.todo-item .num { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 600; background: var(--accent-soft); color: var(--accent); flex: none; }
.todo-item .num.warn { background: var(--warning-soft); color: var(--warning); }
.todo-item .txt { flex: 1; min-width: 0; }
.todo-item .txt b { display: block; font-weight: 500; }
.todo-item .txt span { color: var(--text-muted); font-size: 13px; }

/* stat tiles */
.tile .label { color: var(--text-secondary); font-size: 13px; }
.tile .value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; }
.tile .value.unknown { color: var(--text-muted); font-size: 22px; }
.tile .foot { margin-top: 2px; font-size: 12px; color: var(--text-muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.scope { font-size: 11px; padding: 0 6px; border-radius: 4px; background: var(--surface-3); color: var(--text-muted); }
.scope.production { background: var(--good-soft); color: var(--good); }

/* tags — quiet; FACT renders nothing */
.tag { display: inline-block; font-size: 11px; font-weight: 500; padding: 0 6px; border-radius: 4px; margin-right: 6px; vertical-align: 1px; }
.tag.INTERPRETATION, .tag.ASSUMPTION { background: var(--warning-soft); color: var(--warning); }
.tag.HYPOTHESIS { background: #f1effd; color: #5a4bc4; }
.tag.UNKNOWN { background: var(--surface-3); color: var(--text-muted); }
.tag.DATA { background: var(--accent-soft); color: var(--accent); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #c5c4bd; }
.status.ok::before, .status.success::before, .status.CONNECTED::before, .status.verified::before { background: var(--good); }
.status.partial::before, .status.DEGRADED::before, .status.paused::before, .status.degraded::before { background: #e3a21a; }
.status.failed::before, .status.disabled::before { background: var(--critical); }
.status.running::before { background: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* lists */
.changes { margin: 0; padding: 0; list-style: none; }
.changes li { padding: 8px 0; border-top: 1px solid var(--line-soft); display: flex; gap: 10px; }
.changes li:first-child { border-top: 0; padding-top: 0; }
.changes li::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-top: 8px; flex: none; }
.quiet { color: var(--text-muted); font-size: 13px; }
.lead-row { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); cursor: pointer; }
.lead-row:first-of-type { border-top: 0; padding-top: 0; }
.lead-row:hover b { color: var(--accent); }
.lead-row .score { width: 30px; height: 30px; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
.lead-row .body { min-width: 0; }
.lead-row .body span { display: block; color: var(--text-muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--text-muted); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-1); }
td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; font-size: 13.5px; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 28px; text-align: center; color: var(--text-muted); border: 1px dashed var(--line); border-radius: 10px; font-size: 13px; }
.list { margin: 0; padding-left: 18px; }
.list li { margin: 4px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-1); cursor: pointer; font-size: 13px; color: var(--text-secondary); }
.chip.active { background: var(--text-primary); color: #fff; border-color: var(--text-primary); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 12px; color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--text-primary); border-color: var(--text-primary); font-weight: 500; }
.tabs a:hover { text-decoration: none; color: var(--text-primary); }
.alert { padding: 10px 14px; border-radius: 10px; background: var(--warning-soft); color: #6b4a00; margin-bottom: 8px; font-size: 13.5px; }
.alert.crit { background: var(--critical-soft); color: #8a2222; }
.note { padding: 10px 14px; border-radius: 10px; background: var(--surface-2); color: var(--text-secondary); font-size: 13.5px; }

/* charts */
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-text { fill: var(--text-muted); font-size: 11px; }
.chart .label-text { fill: var(--text-secondary); font-size: 12.5px; }
.chart .value-text { fill: var(--text-primary); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 12.5px; box-shadow: 0 8px 24px rgba(0,0,0,.08); max-width: 280px; }

/* drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw); background: var(--surface-1); border-left: 1px solid var(--line); z-index: 40; overflow-y: auto; padding: 22px 24px; box-shadow: -20px 0 50px rgba(0,0,0,.08); }
.drawer h2 { margin: 0 0 4px; font-size: 18px; }
.drawer .close { position: absolute; right: 16px; top: 16px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 12px 0; font-size: 13.5px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; }
.msg { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 10px 0; background: var(--surface-1); white-space: pre-wrap; font-size: 13.5px; }
.msg.in { border-left: 3px solid var(--series-3); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text-primary); color: #fff; padding: 9px 16px; border-radius: 9px; z-index: 60; font-size: 13px; }
details summary { cursor: pointer; color: var(--text-secondary); font-size: 13px; }
.md { line-height: 1.65; max-width: 860px; }
.md h1 { font-size: 22px; } .md h2 { font-size: 17px; margin-top: 26px; } .md h3 { font-size: 15px; }
.md code { font-family: var(--mono); background: var(--surface-3); padding: 0 4px; border-radius: 4px; }
.md table td, .md table th { border: 1px solid var(--line-soft); }
.slider-row { display: grid; grid-template-columns: 1fr 110px; gap: 4px 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.slider-row input { width: 100%; accent-color: var(--accent); }
.slider-row .note { grid-column: 1 / -1; font-size: 12px; color: var(--text-muted); }
.mobile-only { display: none; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; width: 240px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .mobile-only { display: inline-block; }
  .view { padding: 8px 16px 60px; }
  .topbar { padding: 12px 16px; }
  .banner { margin: 0 16px 8px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2, .span3 { grid-column: auto; }
  .kv { grid-template-columns: 1fr; }
}

/* ── login ── */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: min(380px, 100%); padding: 28px; display: grid; gap: 12px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card label { display: grid; gap: 4px; font-size: 13px; color: var(--text-secondary); }
.login-card input { padding: 9px 11px; font-size: 14px; }
.login-card .btn { padding: 9px; font-size: 14px; }
.side-foot .me { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; color: var(--text-primary); }

/* ── shared bits ── */
.mt { margin-top: 16px; }
.nowrap { white-space: nowrap; }
.pill { display: inline-block; font-size: 11.5px; font-weight: 500; padding: 1px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-secondary); white-space: nowrap; }
.pill.warn { background: var(--warning-soft); color: var(--warning); }
.pill.p-hot { background: var(--critical-soft); color: var(--critical); }
.pill.p-warm { background: var(--warning-soft); color: var(--warning); }
.pill.p-cold { background: var(--accent-soft); color: var(--accent); }
.good { color: var(--good); }
.warn { color: var(--warning); }
.status.idle::before { background: #c5c4bd; }
.status.fulfilled::before { background: var(--good); }
.status.in-progress::before { background: var(--accent); }
.mini-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 12px; }
.mini-tiles .value { font-size: 22px; }

/* ── pricing ── */
.plans { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.plan { display: flex; flex-direction: column; gap: 4px; padding: 18px; }
.plan.featured { border-color: var(--text-primary); box-shadow: 0 0 0 1px var(--text-primary), var(--shadow); }
.plan-name { font-weight: 600; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.plan-price { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; }
.plan-price small { font-size: 13px; font-weight: 400; color: var(--text-muted); }
.plan-credits { margin-top: 8px; font-size: 14px; }
.plan-list { list-style: none; padding: 0; margin: 8px 0 0; font-size: 12.5px; color: var(--text-secondary); display: grid; gap: 5px; flex: 1; }
.plan-list li::before { content: '·'; margin-right: 6px; color: var(--text-muted); }
.plan-margin { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-soft); font-size: 12.5px; color: var(--text-muted); }
.plan-margin b { color: var(--good); }
.calc-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.calc-grid label { display: grid; gap: 4px; font-size: 12.5px; color: var(--text-secondary); }
.calc-out { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.calc-out > div { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; display: grid; gap: 2px; }
.calc-out b { font-size: 20px; font-weight: 600; }

/* ── beta leads grid ── */
.bl-stats { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; }
.bl-stat { background: var(--surface-1); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); }
.bl-stat b { display: block; font-size: 20px; font-weight: 600; }
.bl-stat span { font-size: 12px; color: var(--text-muted); }
.grid-card { padding: 0; overflow: hidden; }
.bl-wrap { overflow: auto; max-height: calc(100vh - 290px); min-height: 240px; }
table.bl th { position: sticky; top: 0; z-index: 2; cursor: pointer; user-select: none; background: var(--surface-2); }
table.bl th.sorted { color: var(--text-primary); }
table.bl td { padding: 7px 10px; font-size: 13px; vertical-align: middle; }
table.bl td.c-long { min-width: 260px; max-width: 360px; white-space: normal; color: var(--text-secondary); font-size: 12.5px; }
table.bl tr > :first-child { position: sticky; left: 0; background: var(--surface-1); z-index: 1; }
table.bl th:first-child { z-index: 3; background: var(--surface-2); }
table.bl tr.click:hover td { background: var(--surface-2); }
.inline { padding: 3px 6px; font-size: 12.5px; border-color: transparent; background: transparent; }
.inline:hover, .inline:focus { border-color: var(--line); background: var(--surface-1); }
.yn { border: 1px solid var(--line); background: var(--surface-1); color: var(--text-muted); border-radius: 999px; font: inherit; font-size: 12px; padding: 1px 10px; cursor: pointer; }
.yn.on { background: var(--good-soft); color: var(--good); border-color: #bfe5cd; font-weight: 500; }
.colpick { position: relative; }
.colpick summary { list-style: none; }
.colpick summary::-webkit-details-marker { display: none; }
.colpick-menu { position: absolute; right: 0; top: 34px; z-index: 20; background: var(--surface-1); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.1); padding: 10px 12px; width: 260px; max-height: 360px; overflow: auto; display: grid; gap: 4px; font-size: 13px; }
.bl-form { display: grid; gap: 10px; margin-top: 14px; }
.bl-form label { display: grid; gap: 4px; font-size: 12.5px; color: var(--text-muted); }
.bl-form textarea { min-height: 64px; }

@media (max-width: 1100px) { .plans { grid-template-columns: repeat(3, minmax(0, 1fr)); } .bl-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .plans, .calc-grid, .calc-out { grid-template-columns: 1fr; }
  .bl-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bl-wrap { max-height: none; }
}
[hidden] { display: none !important; }
#secret-fields, #user-fields { display: grid; gap: 12px; }
