/* inflowIQ — one stylesheet, no framework. Light and dark are the same tokens with different values. */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f8fafc; --ink: #0f172a; --muted: #64748b; --faint: #94a3b8;
  --line: #e4e7ec; --line-strong: #cbd5e1;
  --accent: #0f766e; --accent-ink: #ffffff; --accent-soft: #d9f5f0; --accent-line: #99e0d4;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2;
  --info: #1d4ed8; --info-soft: #dbeafe; --violet: #6d28d9; --violet-soft: #ede9fe; --orange: #c2410c; --orange-soft: #ffedd5;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 1px rgba(15, 23, 42, .04);
  --shadow-lg: 0 18px 50px rgba(15, 23, 42, .22);
  --radius: 10px; --radius-sm: 6px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0a1016; --surface: #111a23; --surface-2: #0e1720; --ink: #e8eef4; --muted: #93a3b5; --faint: #66778a;
  --line: #1e2b37; --line-strong: #2c3c4b;
  --accent: #2dd4bf; --accent-ink: #04211d; --accent-soft: #0f2d2a; --accent-line: #17504a;
  --ok: #4ade80; --ok-soft: #10301d; --warn: #fbbf24; --warn-soft: #3a2a0a; --bad: #f87171; --bad-soft: #3b1414;
  --info: #7aa7ff; --info-soft: #14274a; --violet: #b69cff; --violet-soft: #271b4d; --orange: #fb923c; --orange-soft: #3a1d0b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5); --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; } .mono { font-family: var(--mono); font-size: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; } .gap-s { gap: 6px; } .gap-l { gap: 18px; }
.stack { display: flex; flex-direction: column; gap: 14px; } .stack-s { display: flex; flex-direction: column; gap: 6px; }
.right { margin-left: auto; } .hide { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* shell */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-weight: 700; font-size: 16px; letter-spacing: -.02em; }
.brand-img { width: 30px; height: 30px; border-radius: 8px; flex: none; } .brand .iq { color: var(--accent); font-weight: 800; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 14px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--ink); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav .ico { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav .badge { margin-left: auto; }
.side-foot { margin-top: auto; padding: 10px 8px 2px; border-top: 1px solid var(--line); }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: var(--bg); position: sticky; top: 0; z-index: 5; border-bottom: 1px solid transparent; }
.top.scrolled { border-bottom-color: var(--line); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); }
.search { position: relative; flex: 1; max-width: 460px; }
.search input { width: 100%; padding: 8px 12px 8px 34px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; }
.search svg { position: absolute; left: 11px; top: 9px; width: 16px; height: 16px; color: var(--faint); }
.search kbd { position: absolute; right: 10px; top: 7px; font: 11px var(--mono); color: var(--faint); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; background: var(--surface-2); }
.search-results { position: absolute; top: 40px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 360px; overflow: auto; z-index: 20; padding: 4px; }
.search-results button { display: flex; gap: 10px; width: 100%; align-items: center; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; }
.search-results button:hover, .search-results button[aria-selected="true"] { background: var(--surface-2); }
.page { padding: 8px 28px 56px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin: 6px 0 20px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 2px; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 13px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 550; white-space: nowrap; }
.btn:hover { background: var(--surface-2); } .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); } .btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); } .btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn .spin { width: 14px; height: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--faint); }
.input, select.input, textarea.input { width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }
textarea.input { min-height: 120px; resize: vertical; font-family: inherit; }
.input:disabled { background: var(--surface-2); color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 6px 12px; cursor: pointer; font-weight: 550; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; cursor: pointer; font-weight: 550; color: var(--muted); }
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .n { font-variant-numeric: tabular-nums; opacity: .75; font-weight: 600; }

/* surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px 0; }
.card-b { padding: 14px 18px 18px; }
.grid { display: grid; gap: 16px; } .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.kpi .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .v { font-size: 24px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.bad .v { color: var(--bad); } .kpi.warn .v { color: var(--warn); } .kpi.ok .v { color: var(--ok); }

/* tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; padding: 9px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
.t td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr.click { cursor: pointer; } .t tbody tr.click:hover td { background: var(--surface-2); }
.t th.num, .t td.num { text-align: right; }
.cust { font-weight: 600; } .sub { color: var(--muted); font-size: 12px; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; } .pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; } .pill.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pill.violet { background: var(--violet-soft); color: var(--violet); border-color: transparent; } .pill.orange { background: var(--orange-soft); color: var(--orange); border-color: transparent; }
.badge { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 11.5px; font-weight: 700; text-align: center; }

/* charts */
.aging { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; align-items: end; height: 300px; padding-top: 10px; }
.aging .col { display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; height: 100%; gap: 6px; text-align: center; cursor: default; }
.aging .bar { border-radius: 6px 6px 2px 2px; min-height: 3px; transition: height .35s ease; }
.aging .amt { font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
.aging .lbl { font-size: 11.5px; color: var(--muted); }
.hbar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); } .hbar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.stackbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

/* drawer + dialog */
.scrim { position: fixed; inset: 0; background: rgba(8, 15, 24, .45); z-index: 40; animation: fade .15s ease; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(600px, 100vw); background: var(--surface); z-index: 41; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .2s ease; }
.drawer-h { padding: 18px 22px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.drawer-b { padding: 18px 22px 28px; overflow: auto; flex: 1; }
.dialog { position: fixed; z-index: 51; left: 50%; top: 8vh; transform: translateX(-50%); width: min(640px, 94vw); max-height: 84vh; overflow: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); animation: pop .15s ease; }
.dialog-h { padding: 18px 22px 0; } .dialog-b { padding: 14px 22px; } .dialog-f { padding: 12px 22px 18px; display: flex; gap: 8px; justify-content: flex-end; }
@keyframes fade { from { opacity: 0; } } @keyframes slide { from { transform: translateX(24px); opacity: 0; } } @keyframes pop { from { opacity: 0; transform: translate(-50%, 6px); } }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; }
.fact .k { font-size: 11.5px; color: var(--muted); font-weight: 600; } .fact .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.tl { position: relative; padding-left: 22px; margin: 0; list-style: none; }
.tl::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl li { position: relative; padding: 0 0 14px; } .tl li::before { content: ""; position: absolute; left: -21px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.tl li.warn::before { border-color: var(--warn); } .tl li.bad::before { border-color: var(--bad); } .tl li.ok::before { border-color: var(--ok); }
.msg { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; }
.callout { padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); }
.callout.info { background: var(--info-soft); border-color: transparent; color: var(--info); } .callout.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.callout.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); } .callout.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); } .empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.skel { background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: sh 1.3s infinite; border-radius: 6px; height: 14px; } @keyframes sh { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow-lg); max-width: 380px; animation: fade .15s; }
.toast.bad { background: var(--bad); color: #fff; }
.spin { animation: rot .8s linear infinite; } @keyframes rot { to { transform: rotate(360deg); } }
.drop { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 38px 20px; text-align: center; background: var(--surface-2); cursor: pointer; }
.drop.over, .drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.steps { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; }
.step { display: flex; gap: 8px; align-items: center; color: var(--faint); font-weight: 600; } .step .n { width: 22px; height: 22px; border-radius: 50%; border: 2px solid currentColor; display: grid; place-items: center; font-size: 12px; }
.step.on { color: var(--accent); } .step.done { color: var(--ok); } .steps hr { flex: 0 0 28px; border: 0; border-top: 2px solid var(--line); }
.ladder { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ladder .rung { padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font-size: 12.5px; }
.ladder .rung b { display: block; font-size: 13px; }
.ladder .arrow { color: var(--faint); }

/* sign in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(420px, 100%); padding: 28px; }
.auth .brand { padding: 0 0 18px; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 8px; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 4px 8px; } .nav-label, .side-foot { display: none; } .nav { display: flex; flex-wrap: wrap; gap: 2px; } .nav a span.txt { display: none; } .nav a { padding: 8px; }
  .top, .page { padding-left: 16px; padding-right: 16px; } .g2, .g3, .g-main { grid-template-columns: 1fr; } .facts { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.page:focus, .dialog:focus, .drawer:focus { outline: none; }
.dialog-f { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); }
@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, 1fr); } .facts { grid-template-columns: 1fr 1fr; }
  .page-head { flex-direction: column; align-items: stretch; } .search { max-width: none; }
  .t th, .t td { padding: 8px 10px; } .drawer { width: 100vw; } .dialog { top: 2vh; max-height: 96vh; }
}

/* phase 2 */
button.kpi { text-align: left; font: inherit; color: inherit; cursor: pointer; width: 100%; } button.kpi:hover { border-color: var(--accent); }
.conf { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.conf .meter { width: 54px; height: 7px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; display: inline-block; }
.conf .meter i { display: block; height: 100%; background: currentColor; } .conf.ok { color: var(--ok); } .conf.warn { color: var(--warn); } .conf.bad { color: var(--bad); }
.cols { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 12px; align-items: end; padding-top: 6px; }
.cols .c { display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; gap: 5px; text-align: center; min-height: 210px; }
.cols .bar { border-radius: 6px 6px 2px 2px; } .cols .amt { font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; } .cols .lbl { font-size: 12px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12.5px; }
.spark { width: 100%; height: 120px; display: block; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.bridge { display: grid; gap: 8px; } .bridge .b { display: grid; grid-template-columns: 170px minmax(0, 1fr) 110px; gap: 12px; align-items: center; }
.bridge .track { height: 22px; border-radius: 5px; background: var(--surface-2); position: relative; overflow: hidden; border: 1px solid var(--line); }
.bridge .track i { position: absolute; top: 0; bottom: 0; border-radius: 4px; } .bridge .lab { font-weight: 600; } .bridge .sub { font-size: 12px; font-weight: 400; color: var(--muted); display: block; }
.delta.up { color: var(--bad); } .delta.down { color: var(--ok); } .delta { font-variant-numeric: tabular-nums; font-weight: 600; }
.say { display: flex; flex-direction: column; gap: 8px; } .say p { line-height: 1.55; }
.evid { display: flex; flex-wrap: wrap; gap: 6px; }
.evid button, .evid a { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; cursor: pointer; font-size: 12.5px; font-weight: 550; color: var(--ink); text-decoration: none; }
.evid button:hover, .evid a:hover { border-color: var(--accent); text-decoration: none; }
.fact-item { padding: 10px 14px; border: 1px solid var(--line); border-left: 3px solid var(--ok); border-radius: var(--radius-sm); background: var(--surface); }
.fact-item.ai { border-left-color: var(--violet); background: var(--violet-soft); } .fact-item.gap { border-left-color: var(--warn); background: var(--warn-soft); }
.tag { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.rank { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; flex: none; }
.cap { height: 10px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; } .cap i { display: block; height: 100%; background: var(--accent); }
details.more > summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 12.5px; } details.more[open] > summary { margin-bottom: 8px; }
.ask { display: flex; gap: 10px; align-items: flex-start; } .ask textarea { min-height: 62px; }
.q-chip { font-size: 12.5px; }
.scopebar { display: flex; gap: 8px 14px; flex-wrap: wrap; align-items: center; padding: 10px 14px; border: 1px solid var(--accent-line); background: var(--accent-soft); border-radius: var(--radius); margin-bottom: 18px; color: var(--ink); }
.scopebar .label { color: var(--accent); }
.mapgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
@media (max-width: 640px) { .bridge .b { grid-template-columns: 1fr; gap: 3px; } .mapgrid { grid-template-columns: 1fr; } }
