/* Torv Control. Layout: dark top bar, side menu that stacks on a phone, one content column.
   Colors and type follow the Torv brand guide v1.0 (10/20/26, torv/brand): Deep Ink, Cobalt, Ice, Terminal Mint, White;
   Arial. Cobalt marks the main action, active states and key navigation; Ink carries the hierarchy and the top bar;
   Ice groups content without a wall of borders; Mint is status only. Small Cobalt text on Ice uses --accent-ink (5.5:1). */
:root {
  --bg: #EFF3FF; --surface: #ffffff; --ink: #17243A; --ink-2: #33415C; --muted: #5B6B85;
  --line: #D9E0EE; --line-2: #E8ECF6; --cobalt: #4668F5; --accent: #3553E0; --accent-ink: #2B47C4; --ice: #EFF3FF; --accent-soft: #E4EAFF;
  --mint: #10B981;
  --ok-bg: #E3F6EE; --ok: #047857; --info-bg: #E9EEFF; --info: #2B47C4; --warn-bg: #fdf1dc; --warn: #7a4a06; --bad-bg: #fbe4e1; --bad: #9b1c12;
  --bar: #17243A; --bar-ink: #ffffff; --bar-muted: #C9D2E3;
  --sans: Arial, 'Helvetica Neue', Helvetica, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--sans); font-size: 15px; font-weight: 400; line-height: 1.45; color: var(--ink); background: var(--bg); }
a { color: var(--accent); } a:hover { color: var(--accent-ink); }
h1 { margin: 0; font-size: 32px; line-height: 38px; font-weight: 700; text-wrap: balance; } /* guide: page title 32/38 bold */
h2 { margin: 0; font-size: 18px; line-height: 24px; font-weight: 700; } /* card headings; page sections use .h-section (22/28) */
.h-section { font-size: 22px; line-height: 28px; }
p { line-height: 1.55; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 12px 20px; background: var(--bar); color: var(--bar-ink); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--bar-ink); }
.brand img { display: block; height: 32px; width: auto; }
.brand span { font-size: 12px; line-height: 16px; font-weight: 700; color: #9FB3FF; letter-spacing: 0.12em; text-transform: uppercase; padding: 4px 0 4px 12px; border-left: 1px solid #33415C; }
.topbar .me { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: #D5DCEA; }
.avatar { display: inline-flex; width: 32px; height: 32px; border-radius: 999px; background: var(--cobalt); color: #fff; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.topbar button { background: transparent; color: #D5DCEA; border: 1px solid #33415C; border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 13px; cursor: pointer; }

.demobar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 8px 20px; background: var(--warn-bg); color: #5e3a05; font-size: 13px; border-bottom: 1px solid #f1d39e; }
.demobar select { max-width: 100%; }
.demobar select, .demobar button { font: inherit; font-size: 13px; padding: 4px 8px; border-radius: 6px; border: 1px solid #e0bf86; background: #fff; color: var(--ink); }

.layout { display: flex; flex-wrap: wrap; gap: 24px; padding: 24px 20px; max-width: 1440px; margin: 0 auto; }
.nav { flex: 1 1 200px; max-width: 240px; display: flex; flex-direction: column; gap: 2px; align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.nav a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 400; }
.nav a:hover { background: #F0F3FA; color: var(--ink); }
.nav a.on { background: var(--ice); color: var(--accent-ink); font-weight: 700; }
.nav .group { margin: 14px 12px 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.nav .soon { font-size: 11px; font-weight: 700; color: var(--muted); }
main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }

.head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.head > div { flex: 1 1 320px; min-width: 0; }
.head p { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.crumbs { font-size: 13px; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.flush { padding: 0; gap: 0; }
.card.flush > .card-head { padding: 14px 16px; border-bottom: 1px solid var(--line-2); display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.row > .grow { flex: 999 1 460px; min-width: 0; }
.row > .side { flex: 1 1 280px; min-width: 0; }

.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 13px; color: var(--muted); }
.kpi .sub.good { color: var(--ok); }
.section-label { margin: 0; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.info { background: var(--info-bg); color: var(--info); }
.pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.none { background: #EEF1F7; color: var(--muted); }
.ex { font-size: 11px; font-weight: 700; color: var(--warn); letter-spacing: 0.03em; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th { font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
th.r, td.r { text-align: right; }
td.num, td.r { font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); }
.btn.danger { color: var(--bad); border-color: #f0b8b1; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn:focus-visible, .nav a:focus-visible, .seg:focus-visible, .sw:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.field input, .field select, .field textarea, .inline-select { padding: 9px 11px; border-radius: 8px; border: 1px solid #C5CEDF; font: inherit; font-size: 14px; font-weight: 400; background: #fff; color: var(--ink); }
.check { display: flex; gap: 10px; align-items: center; font-size: 14px; min-height: 40px; }
.check input { width: 18px; height: 18px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form .actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.error { color: var(--bad); font-size: 13px; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 14px; color: var(--ink-2); text-decoration: none; border-bottom: 3px solid transparent; font-size: 15px; }
.tabs a.on { border-bottom-color: var(--cobalt); color: var(--ink); font-weight: 700; }

.seg-group { display: flex; }
.seg { min-height: 38px; padding: 0 14px; border: 1px solid #C5CEDF; background: #fff; font: inherit; font-size: 13px; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.seg + .seg { border-left: 0; }
.seg:first-child { border-radius: 8px 0 0 8px; } .seg:last-child { border-radius: 0 8px 8px 0; }
.seg[aria-pressed="true"] { background: var(--cobalt); color: #fff; border-color: var(--cobalt); }

.sw { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 2px; border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; flex: 0 0 auto; }
.sw .track { width: 42px; height: 24px; border-radius: 999px; background: #C5CEDF; position: relative; }
.sw .knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 999px; background: #fff; transition: left 0.15s; }
.sw[aria-pressed="true"] { color: var(--ink); } .sw[aria-pressed="true"] .track { background: var(--cobalt); } .sw[aria-pressed="true"] .knob { left: 21px; }
.sw:disabled { cursor: not-allowed; opacity: 0.7; }
@media (prefers-reduced-motion: reduce) { .sw .knob { transition: none; } }

.feature { display: flex; gap: 12px; align-items: center; border-top: 1px solid #EEF1F7; padding-top: 10px; }
.feature:first-of-type { border-top: 0; padding-top: 0; }
.feature .what { flex: 1 1 auto; min-width: 0; }
.feature .what b { font-size: 14px; }
.feature .what div { font-size: 13px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.feature .what .includes { font-size: 12px; color: var(--ink-2); }

.bars { display: flex; align-items: stretch; gap: 8px; height: 200px; border-bottom: 1px solid #C5CEDF; }
.bars .col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.bars .v { font-size: 11px; color: var(--ink-2); text-align: center; font-variant-numeric: tabular-nums; }
.bars .area { flex: 1 1 auto; display: flex; align-items: flex-end; }
.bars .bar { width: 100%; background: var(--cobalt); border-radius: 4px 4px 0 0; min-height: 1px; }
.bar-labels { display: flex; gap: 8px; }
.bar-labels span { flex: 1 1 0; min-width: 0; font-size: 11px; color: var(--muted); text-align: center; }
.hbar { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 2fr) 40px; gap: 8px; align-items: center; font-size: 13px; }
.hbar .track { background: #EEF1F7; border-radius: 4px; height: 12px; }
.hbar .fill { height: 12px; background: var(--cobalt); border-radius: 4px; }
.hbar .n { text-align: right; font-variant-numeric: tabular-nums; }

.kv { display: grid; grid-template-columns: minmax(0, 170px) minmax(0, 1fr); gap: 8px 12px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.log li { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.log .when { font-family: var(--mono); font-size: 12px; color: var(--muted); min-width: 120px; }
.note { font-size: 13px; color: #5e3a05; background: var(--warn-bg); border: 1px solid #f1d39e; border-radius: 10px; padding: 10px 14px; }
.empty { padding: 24px 16px; color: var(--muted); text-align: center; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,0.2); z-index: 10; max-width: calc(100% - 32px); }
.toast.bad { background: var(--bad); }

.signin { max-width: 420px; margin: 12vh auto 0; padding: 0 16px; display: flex; flex-direction: column; gap: 16px; text-align: center; }
.signin-logo { align-self: center; height: 48px; width: auto; }

/* New client wizard */
.sr { position: absolute; left: -9999px; }
.card-title { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 12px; }
.wizard-steps { max-width: 260px; }
.steps { margin: 0; padding: 8px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; gap: 2px; }
.step-link { display: flex; gap: 10px; align-items: center; width: 100%; min-height: 44px; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; font: inherit; font-size: 14px; color: var(--ink-2); text-align: left; }
button.step-link { cursor: pointer; } button.step-link:hover { background: #F0F3FA; }
.steps .n { display: inline-flex; flex: 0 0 auto; width: 26px; height: 26px; border-radius: 999px; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; background: var(--line-2); color: var(--ink-2); }
.steps .done .n { background: var(--cobalt); color: #fff; }
.steps .now .step-link { background: var(--accent-soft); color: var(--ink); font-weight: 700; }
.steps .now .n { background: var(--ink); color: #fff; }
.store-box { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 14px; margin: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.store-box legend { padding: 0 6px; font-weight: 700; }
.feature.pick { cursor: pointer; align-items: flex-start; }
.feature.pick input { width: 20px; height: 20px; margin-top: 2px; flex: 0 0 auto; }
.feature.pick .what { display: flex; flex-direction: column; gap: 2px; }
.feature.pick .desc { font-size: 13px; color: var(--muted); }
.feature.pick .includes { font-size: 12px; color: var(--ink-2); }
.seg-field { border: 0; padding: 0; margin: 0; } .seg-field legend { font-size: 13px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.seg-radio { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border: 1px solid #C5CEDF; background: #fff; font-size: 14px; font-weight: 700; cursor: pointer; }
.seg-radio + .seg-radio { border-left: 0; } .seg-radio:first-child { border-radius: 8px 0 0 8px; } .seg-radio:last-child { border-radius: 0 8px 8px 0; }
.seg-radio:has(input:checked) { background: var(--accent-soft); border-color: var(--cobalt); }
.addr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; } .addr input { flex: 1 1 180px; min-width: 0; }
.checklist li { display: flex; gap: 12px; align-items: flex-start; border-top: 1px solid #EEF1F7; padding-top: 10px; }
.checklist li:first-child { border-top: 0; padding-top: 0; }
.checklist .box { flex: 0 0 auto; width: 20px; height: 20px; border: 2px solid #C5CEDF; border-radius: 5px; margin-top: 2px; }
.checklist .check { align-items: flex-start; min-height: 0; } .checklist .check input { margin-top: 2px; flex: 0 0 auto; }

/* Releases */
.waves { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.wave { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; font-size: 13px; }
.wave.next { border-color: var(--cobalt); box-shadow: inset 0 3px 0 var(--cobalt); }
.wave-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; font-size: 14px; }
.wave .who { color: var(--ink-2); }
.wave-form .actions { justify-content: flex-start; }

/* Dashboard charts (10/20/26): charts.js draws the SVG; these color it from the brand tokens */
.ch-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 900px) { .row2 { grid-template-columns: 1fr; } }
.kpi.mini { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.kpi.mini .value { font-size: 22px; }
.kpi .sub.bad { color: var(--bad); }
.ch-sum { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; color: var(--ink-2); padding: 8px 12px; background: var(--ice); border-radius: 8px; }
.ch-sum b { color: var(--ink); } .ch-sum .good { color: var(--ok); font-weight: 700; } .ch-sum .bad { color: var(--bad); font-weight: 700; }

/* Dashboard KPI cards on two rows (10/21/26, layout B): 6 + 7 across, 3 + 4 on a narrow column, 2 on a phone */
.head > .period-bar { flex: 0 1 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.period-pick { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.period-pick select, .rb-f input, .rb-f select { font: inherit; font-size: 14px; min-height: 38px; padding: 0 10px; border: 1px solid #C5CEDF; border-radius: 8px; background: #fff; color: var(--ink); }
.period-pick select { font-weight: 700; min-width: 190px; }
.period-dates { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.range-bar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.rb-f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.kpis { container-type: inline-size; display: flex; flex-direction: column; gap: 8px; }
.kpis .section-label + .krow { margin-bottom: 8px; }
.section-label .aside { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 8px; }
.krow { display: grid; gap: 10px; grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr)); }
.krow.r6 { --n: 6; } .krow.r7 { --n: 7; }
@container (max-width: 940px) { .krow.r6 { --n: 3; } .krow.r7 { --n: 4; } }
@container (max-width: 520px) { .krow.r6, .krow.r7 { --n: 2; } }
.kc { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; display: flex; flex-direction: column; }
.kc-l { font-size: 12.5px; line-height: 16px; color: var(--muted); }
.kc-v { font-size: 22px; line-height: 28px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; overflow-wrap: anywhere; }
.kc-s { font-size: 12px; line-height: 16px; color: var(--muted); } .kc-s.good { color: var(--ok); } .kc-s.bad { color: var(--bad); }
.kc-tr { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 8px; min-height: 32px; }
.kc-tr svg { flex: 1 1 auto; min-width: 0; height: 24px; display: block; }
.kc-tr .sp { fill: none; stroke: var(--cobalt); stroke-width: 1.6; vector-effect: non-scaling-stroke; } .kc-tr .spa { fill: var(--accent-soft); } .kc-tr .flat { stroke: var(--line); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.kc-none { flex: 1; font-size: 11.5px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 3px; }
.kchip { flex: none; font-size: 11.5px; font-weight: 700; padding: 2px 6px; border-radius: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kchip.good { color: var(--ok); background: var(--ok-bg); } .kchip.bad { color: var(--bad); background: var(--bad-bg); } .kchip.flat { color: var(--muted); background: var(--line-2); }
@media (max-width: 700px) { .head > .period-bar { align-items: flex-start; } .period-dates { text-align: left; } }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; }
.legend .lg-bar { background: #C9D4FD; } .legend .lg-cur, .legend .lg-active { background: var(--cobalt); } .legend .lg-trial { background: #C9D4FD; }
.legend .lg-setup { background: var(--ice); border: 1px solid var(--line); } .legend .lg-new { background: var(--mint); } .legend .lg-lost { background: var(--bad); }
.legend .lg-line, .legend .lg-avg { height: 3px; width: 16px; border-radius: 2px; vertical-align: 3px; background: var(--ink); } .legend .lg-avg { background: var(--mint); }
.ch { width: 100%; height: auto; display: block; overflow: visible; }
.ch text { font-family: var(--sans); font-size: 11px; fill: var(--muted); }
.ch .ch-grid { stroke: var(--line-2); stroke-width: 1; } .ch .ch-axis { stroke: var(--line); stroke-width: 1; }
.ch .ch-bar { fill: #C9D4FD; } .ch .ch-bar.cur, .ch .ch-bar:hover { fill: var(--cobalt); }
.ch .ch-line { fill: none; stroke: var(--ink); stroke-width: 2.5; } .ch .ch-line-dot { fill: #fff; stroke: var(--ink); stroke-width: 2; }
.ch .ch-avg { fill: none; stroke: var(--mint); stroke-width: 2.5; } .ch .ch-avg-dot { fill: #fff; stroke: var(--mint); stroke-width: 2; }
.ch .ch-val { fill: var(--ink-2); font-weight: 700; }
.ch .ch-active { fill: var(--cobalt); } .ch .ch-trial { fill: #C9D4FD; } .ch .ch-setup { fill: var(--ice); stroke: var(--line); }
.ch .ch-new { fill: var(--mint); } .ch .ch-lost { fill: var(--bad); }
