/* DemandScout — components
   Plain CSS, no build. All values come from tokens.css.
   Phone layout is driven by a container query on .app, so it works
   at 390px in a browser window or inside any fixed-width frame. */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }
.app, .sheet {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: var(--fw-regular);
  color: var(--text);
  background: var(--bg);
  font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, pre { margin: 0; }
ul, ol { padding: 0; list-style: none; }
.prose ul { list-style: disc; padding-left: var(--s-5); }
a { color: var(--accent-text); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius); }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
svg.i--sm { width: 14px; height: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num, .tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.mono, code, pre, kbd { font-family: var(--font-mono); font-size: var(--fs-table); }
.muted { color: var(--text-2); }
.meta { color: var(--text-3); font-size: var(--fs-meta); }
.strong { font-weight: var(--fw-strong); }
.h-title { font-size: var(--fs-title); line-height: var(--lh-tight); font-weight: var(--fw-strong); letter-spacing: -0.01em; }
.h-section { font-size: var(--fs-body); font-weight: var(--fw-strong); }
.h-label { font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- App shell ---------- */
.app { container-type: inline-size; container-name: app; min-height: 100vh; }
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.shell--collapsed { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
.main { min-width: 0; display: flex; flex-direction: column; }
.page { width: 100%; max-width: var(--page-max); padding: var(--s-6) var(--s-8) var(--s-12); display: flex; flex-direction: column; gap: var(--s-8); }
.page--narrow { max-width: 760px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-3) var(--s-6); }
.page-head__title { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.page-head__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.crumbs { display: flex; flex-wrap: wrap; gap: var(--s-1); font-size: var(--fs-meta); color: var(--text-3); }
.crumbs a { color: var(--text-3); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }
.crumbs span[aria-hidden] { color: var(--border-strong); }
.section { display: flex; flex-direction: column; gap: var(--s-3); }
.section__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s-2) var(--s-4); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--s-8); align-items: start; }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-8); }
.stack { display: flex; flex-direction: column; gap: var(--s-3); }
.stack--lg { gap: var(--s-6); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.row--between { justify-content: space-between; }
.reading { max-width: var(--measure); }
.rule { border: 0; border-top: var(--line) solid var(--border); margin: 0; }

/* ---------- Sidebar ---------- */
.sidebar { border-right: var(--line) solid var(--border); background: var(--surface); display: flex; flex-direction: column; gap: var(--s-4); padding: var(--s-4) var(--s-3); min-width: 0; }
.sidebar__top { display: flex; align-items: center; justify-content: space-between; padding: 0 var(--s-2); height: var(--control-h); }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav__group { display: flex; flex-direction: column; gap: 1px; padding-top: var(--s-3); }
.nav__heading { padding: 0 var(--s-2) var(--s-1); font-size: var(--fs-meta); color: var(--text-3); }
.nav-item { display: flex; align-items: center; gap: var(--s-2); height: 32px; padding: 0 var(--s-2); border-radius: var(--radius); color: var(--text-2); text-decoration: none; font-size: var(--fs-body); white-space: nowrap; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--accent-weak); color: var(--accent-text); font-weight: var(--fw-strong); }
.nav-item__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item__tail { font-size: var(--fs-meta); color: var(--text-3); }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-size: var(--fs-meta); font-weight: var(--fw-strong); font-variant-numeric: tabular-nums; }
.count--quiet { background: var(--surface-3); color: var(--text-2); }
.sidebar__foot { margin-top: auto; display: flex; flex-direction: column; gap: 1px; }
.shell--collapsed .nav-item__label, .shell--collapsed .nav-item__tail, .shell--collapsed .nav__heading, .shell--collapsed .switcher__text, .shell--collapsed .brand__word { display: none; }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: var(--s-2); text-decoration: none; color: var(--text); }
.brand__mark { width: 20px; height: 20px; border-radius: var(--radius); background: var(--text); color: var(--bg); display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 11px; font-weight: var(--fw-strong); letter-spacing: -0.04em; }
.brand__word { font-weight: var(--fw-strong); letter-spacing: -0.01em; }
.brand__word b { font-weight: var(--fw-regular); color: var(--text-2); }

/* ---------- Product switcher ---------- */
.switcher { display: flex; align-items: center; gap: var(--s-2); width: 100%; height: 40px; padding: 0 var(--s-2); border: var(--line) solid var(--border); border-radius: var(--radius); background: var(--surface); text-align: left; cursor: pointer; text-decoration: none; color: var(--text); }
.switcher:hover { border-color: var(--border-strong); }
.switcher__avatar { width: 22px; height: 22px; border-radius: var(--radius); background: var(--surface-3); color: var(--text); display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-meta); font-weight: var(--fw-strong); flex: none; }
.switcher__text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.switcher__name { font-weight: var(--fw-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switcher__sub { font-size: var(--fs-meta); color: var(--text-3); }

/* ---------- Top bar ---------- */
.topbar { height: 52px; display: none; align-items: center; gap: var(--s-3); padding: 0 var(--s-8); border-bottom: var(--line) solid var(--border); background: var(--surface); }
.topbar__spacer { flex: 1; }
.topbar__mobile { display: none; }

/* ---------- Phone tab bar ---------- */
.tabbar { display: none; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--control-h); padding: 0 var(--s-3); border: var(--line) solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: var(--fs-body); font-weight: var(--fw-strong); line-height: 1; white-space: nowrap; cursor: pointer; text-decoration: none; transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn--quiet { border-color: transparent; background: transparent; color: var(--text-2); }
.btn--quiet:hover { background: var(--surface-2); color: var(--text); }
.btn--danger { color: var(--critical); }
.btn--danger-solid { background: var(--critical); border-color: var(--critical); color: var(--surface); }
.btn--danger-solid:hover { background: var(--critical); color: var(--surface); filter: brightness(0.92); }
.btn--sm { height: 28px; padding: 0 var(--s-2); font-size: var(--fs-table); }
.btn--icon { width: var(--control-h); padding: 0; }
.btn--sm.btn--icon { width: 28px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn-group { display: inline-flex; flex-wrap: wrap; gap: var(--s-2); }
.kbd, kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px; border: var(--line) solid var(--border-strong); border-bottom-width: 2px; border-radius: var(--radius); background: var(--surface); color: var(--text-2); font-size: 11px; line-height: 1; }
.btn .kbd { margin-left: 2px; border-color: currentColor; color: inherit; background: transparent; opacity: 0.7; }

/* ---------- Form fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: var(--fs-table); font-weight: var(--fw-strong); }
.field__hint { font-size: var(--fs-meta); color: var(--text-3); }
.field__error { font-size: var(--fs-meta); color: var(--critical); display: flex; gap: 4px; align-items: center; }
.input, .select, .textarea { width: 100%; min-height: var(--control-h); padding: 6px var(--s-3); border: var(--line) solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: var(--fs-body); }
.textarea { min-height: 96px; line-height: var(--lh-body); resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--accent); }
.input[aria-invalid="true"] { border-color: var(--critical); }
.input--search { padding-left: 32px; }
.input-wrap { position: relative; }
.input-wrap > .i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.suggested { background: var(--surface-2); border-style: dashed; }
.suggested-tag { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-meta); color: var(--text-3); font-weight: var(--fw-regular); }
.check { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-body); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: var(--s-5); border-bottom: var(--line) solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 40px; color: var(--text-2); text-decoration: none; white-space: nowrap; font-size: var(--fs-body); }
.tab:hover { color: var(--text); }
.tab[aria-current="page"], .tab[aria-selected="true"] { color: var(--text); font-weight: var(--fw-strong); }
.tab[aria-current="page"]::after, .tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: var(--line) solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text-2); font-size: var(--fs-table); cursor: pointer; white-space: nowrap; text-decoration: none; }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip[aria-pressed="true"] { border-color: var(--text); color: var(--text); background: var(--surface-2); font-weight: var(--fw-strong); }
.chip .count { height: 16px; min-width: 16px; font-size: 11px; padding: 0 4px; }
.filters__sep { width: 1px; height: 20px; background: var(--border); }
.filters__end { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }

/* ---------- Badges and severity ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: var(--radius); font-size: var(--fs-meta); font-weight: var(--fw-strong); white-space: nowrap; background: var(--neutral-weak); color: var(--neutral); }
.badge--critical { background: var(--critical-weak); color: var(--critical); }
.badge--important { background: var(--important-weak); color: var(--important); }
.badge--minor { background: var(--minor-weak); color: var(--minor); }
.badge--success { background: var(--success-weak); color: var(--success); }
.badge--accent { background: var(--accent-weak); color: var(--accent-text); }
.badge--outline { background: transparent; border: var(--line) solid var(--border-strong); color: var(--text-2); }
.badge--plain { background: transparent; padding: 0; color: var(--text-2); font-weight: var(--fw-regular); }
.badge .i { width: 12px; height: 12px; stroke-width: 2; }
/* Severity: shape + text, so it never depends on color alone */
.sev { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.sev i { display: block; width: 3px; border-radius: 1px; background: var(--border-strong); }
.sev i:nth-child(1) { height: 5px; } .sev i:nth-child(2) { height: 8px; } .sev i:nth-child(3) { height: 12px; }
.sev--critical i { background: var(--critical); }
.sev--important i:nth-child(-n+2) { background: var(--important-mark); }
.sev--minor i:nth-child(1) { background: var(--minor); }
.sevlabel { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-meta); font-weight: var(--fw-strong); white-space: nowrap; }
.sevlabel--critical { color: var(--critical); } .sevlabel--important { color: var(--important); } .sevlabel--minor { color: var(--minor); }
/* Relevance 0–100 for opportunities */
.relevance { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-meta); color: var(--text-2); font-variant-numeric: tabular-nums; }
.relevance__bar { width: 36px; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.relevance__bar span { display: block; height: 100%; background: var(--text-2); }
/* State dot for module/finding state lists */
.state { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-meta); color: var(--text-2); white-space: nowrap; }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid currentColor; flex: none; }
.state--on::before { background: var(--success); border-color: var(--success); }
.state--attention { color: var(--important); } .state--attention::before { background: var(--important-mark); border-color: var(--important-mark); border-radius: 1px; transform: rotate(45deg) scale(0.85); }
.state--critical { color: var(--critical); } .state--critical::before { background: var(--critical); border-color: var(--critical); border-radius: 1px; transform: rotate(45deg) scale(0.85); }
.state--paused::before { border-style: double; border-width: 0 3px; border-radius: 0; height: 8px; width: 7px; }
.state--off { color: var(--text-3); } .state--off::before { border-style: dashed; }
.state--limit { color: var(--important); } .state--limit::before { border-color: var(--important-mark); background: linear-gradient(var(--important-mark), var(--important-mark)) center / 100% 1.5px no-repeat; }
.state--later { color: var(--text-3); } .state--later::before { border-style: dotted; }

/* ---------- Delta and freshness ---------- */
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-meta); font-variant-numeric: tabular-nums; color: var(--text-2); white-space: nowrap; }
.delta__v { font-weight: var(--fw-strong); }
.delta--up .delta__v { color: var(--success); }
.delta--down .delta__v { color: var(--critical); }
.delta--flat .delta__v { color: var(--text-2); }
.fresh { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-meta); color: var(--text-3); white-space: nowrap; }
.fresh--stale { color: var(--important); }
time[title] { text-decoration: underline dotted var(--border-strong); text-underline-offset: 3px; cursor: help; }
.nodata { color: var(--text-3); font-style: italic; font-weight: var(--fw-regular); }

/* ---------- Truncated URL (keeps domain and end) ---------- */
.url { display: inline-flex; max-width: 100%; min-width: 0; font-family: var(--font-mono); font-size: var(--fs-table); color: var(--text); white-space: nowrap; }
.url__start { overflow: hidden; text-overflow: ellipsis; min-width: 2ch; flex: 0 1 auto; }
.url__end { flex: none; }
a.url { text-decoration: none; } a.url:hover .url__end, a.url:hover .url__start { text-decoration: underline; }

/* ---------- Tables ---------- */
.table-box { border-top: var(--line) solid var(--border); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-table); }
.table th { height: 32px; padding: 0 var(--s-3); text-align: left; font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--text-3); border-bottom: var(--line) solid var(--border); white-space: nowrap; }
.table th[aria-sort] { color: var(--text); }
.table th .sort { display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; padding: 0; cursor: pointer; color: inherit; font-weight: inherit; font-size: inherit; }
.table td { height: var(--row-h); padding: 6px var(--s-3); border-bottom: var(--line) solid var(--border); vertical-align: middle; }
.table tr:hover td { background: var(--surface-2); }
.table .num, .table th.num { text-align: right; }
.table td:first-child, .table th:first-child { padding-left: 0; }
.table td:last-child, .table th:last-child { padding-right: 0; }
.table .cell-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.table .cell-link { color: var(--text); text-decoration: none; font-weight: var(--fw-strong); }
.table .cell-link:hover { text-decoration: underline; }
.table .w-url { max-width: 320px; }
.table tr.is-selected td { background: var(--accent-weak); }

/* ---------- Data list (dl) ---------- */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--s-2) var(--s-5); font-size: var(--fs-table); }
.kv dt { color: var(--text-3); }
.kv dd { min-width: 0; }

/* ---------- Module icon ---------- */
.modicon { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: var(--radius); border: var(--line) solid var(--border); color: var(--text-2); background: var(--surface); flex: none; }
.modicon .i { width: 14px; height: 14px; }
.modtag { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-meta); color: var(--text-2); white-space: nowrap; }

/* ---------- Finding row (list) ---------- */
.flist { border-top: var(--line) solid var(--border); }
.frow { border-bottom: var(--line) solid var(--border); }
.frow__line { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: var(--s-3); min-height: 52px; padding: var(--s-2) 0; list-style: none; cursor: pointer; }
.frow__line::-webkit-details-marker { display: none; }
.frow__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.frow__title { font-weight: var(--fw-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); text-decoration: none; }
.frow__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--s-3); font-size: var(--fs-meta); color: var(--text-3); }
.frow__aside { display: flex; align-items: center; gap: var(--s-3); }
.frow__decide { display: flex; gap: var(--s-1); }
.frow__chev { color: var(--text-3); transition: transform var(--dur) var(--ease); }
.frow[open] > .frow__line .frow__chev { transform: rotate(180deg); }
.frow[open] > .frow__line { padding-bottom: var(--s-2); }
.frow__expand { padding: var(--s-1) 0 var(--s-5) 36px; display: flex; flex-direction: column; gap: var(--s-5); }
.frow.is-focused > .frow__line { box-shadow: inset 2px 0 0 var(--accent); padding-left: var(--s-2); margin-left: calc(-1 * var(--s-2)); }
.frow.is-done { opacity: 0.55; }
.frow__check { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.expires { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-meta); color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.expires--soon { color: var(--important); font-weight: var(--fw-strong); }

/* ---------- Finding card (full) ---------- */
.fcard { display: flex; flex-direction: column; gap: var(--s-6); }
.fcard__head { display: flex; flex-direction: column; gap: var(--s-2); }
.fcard__facts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); }
.why { display: flex; gap: var(--s-2); font-size: var(--fs-table); color: var(--text-2); max-width: var(--measure); }
.why__k { font-weight: var(--fw-strong); color: var(--text); flex: none; }
.panel { border: var(--line) solid var(--border); border-radius: var(--radius); background: var(--surface); }
.panel__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-3) var(--s-4); border-bottom: var(--line) solid var(--border); }
.panel__body { padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-4); }
.panel__foot { padding: var(--s-3) var(--s-4); border-top: var(--line) solid var(--border); display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }

/* ---------- Evidence: Observed / Conclusion / Unknown ---------- */
.evidence { display: grid; grid-template-columns: 112px minmax(0, 1fr); border-top: var(--line) solid var(--border); }
.evidence__k { padding: var(--s-3) 0; display: flex; align-items: flex-start; gap: 6px; font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--text-3); border-bottom: var(--line) solid var(--border); }
.evidence__v { padding: var(--s-3) 0; border-bottom: var(--line) solid var(--border); min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.observed { font-family: var(--font-mono); font-size: var(--fs-table); background: var(--surface-2); border: var(--line) solid var(--border); border-radius: var(--radius); padding: var(--s-2) var(--s-3); overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
.observed mark { background: transparent; color: var(--text); box-shadow: inset 0 -2px 0 var(--important-mark); }
.observed__src { display: flex; flex-wrap: wrap; gap: 4px var(--s-3); font-size: var(--fs-meta); color: var(--text-3); align-items: center; }
.conclusion { font-size: var(--fs-body); max-width: var(--measure); }
.unknown { font-size: var(--fs-table); color: var(--text-2); font-style: italic; max-width: var(--measure); }

/* ---------- Action ---------- */
.action { display: flex; flex-direction: column; gap: var(--s-3); }
.action__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); }
.action__what { font-weight: var(--fw-strong); flex: 1 1 280px; min-width: 0; }
.who { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--text-2); white-space: nowrap; }
.who--you { color: var(--text); }
.astate { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: var(--radius); font-size: var(--fs-meta); font-weight: var(--fw-strong); border: var(--line) solid var(--border-strong); color: var(--text-2); white-space: nowrap; }
.astate--awaiting { border-color: var(--accent); color: var(--accent-text); }
.astate--approved, .astate--done { background: var(--success-weak); border-color: transparent; color: var(--success); }
.astate--measured { background: var(--success-weak); border-color: transparent; color: var(--success); }
.astate--failed { background: var(--critical-weak); border-color: transparent; color: var(--critical); }
.astate--cancelled { color: var(--text-3); border-style: dashed; text-decoration: line-through; }
.astate--draft { border-style: dashed; }
.content-box { position: relative; border: var(--line) solid var(--border); border-radius: var(--radius); background: var(--surface); }
.content-box__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: 4px 4px 4px var(--s-3); border-bottom: var(--line) solid var(--border); font-size: var(--fs-meta); color: var(--text-3); }
.content-box__body { padding: var(--s-3); font-size: var(--fs-body); white-space: pre-wrap; max-width: var(--measure); }
.content-box pre { margin: 0; padding: var(--s-3); overflow-x: auto; font-size: var(--fs-table); line-height: 1.55; white-space: pre; background: var(--surface-2); }
.copied { display: inline-flex; align-items: center; gap: 4px; color: var(--success); font-size: var(--fs-meta); font-weight: var(--fw-strong); }
.action__buttons { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.action__buttons .spacer { flex: 1; }
.reject-reasons { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-3); border: var(--line) solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-float); max-width: 320px; }
.reject-reasons .filters { gap: 6px; }

/* ---------- Measurement: Direct vs Coincided ---------- */
.measure { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
.mcard { padding: var(--s-3) var(--s-4); border-radius: var(--radius); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mcard__k { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-meta); font-weight: var(--fw-strong); }
.mcard__v { font-size: var(--fs-title); font-weight: var(--fw-strong); line-height: var(--lh-tight); font-variant-numeric: tabular-nums; }
.mcard__v small { font-size: var(--fs-body); font-weight: var(--fw-regular); color: var(--text-2); }
.mcard__note { font-size: var(--fs-meta); color: var(--text-3); }
.mcard--direct { border: var(--line) solid var(--border-strong); background: var(--surface); }
.mcard--direct .mcard__k { color: var(--text); }
.mcard--coincided { border: var(--line) dashed var(--border-strong); background: transparent; }
.mcard--coincided .mcard__k, .mcard--coincided .mcard__v { color: var(--text-2); font-weight: var(--fw-regular); }
.mcard--measuring { border: var(--line) dashed var(--border); color: var(--text-2); }
.pdot { width: 8px; height: 8px; border-radius: 50%; background: var(--text); flex: none; }
.pdot--hollow { background: transparent; border: 1.5px dashed var(--text-2); }
.progress { height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--text-2); }
.progress--accent > span { background: var(--accent); }

/* ---------- Autonomy segmented control ---------- */
.seg { display: inline-flex; border: var(--line) solid var(--border-strong); border-radius: var(--radius); background: var(--surface); padding: 2px; gap: 2px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: inline-flex; align-items: center; justify-content: center; height: 24px; min-width: 44px; padding: 0 var(--s-2); border-radius: 2px; font-size: var(--fs-table); color: var(--text-2); cursor: pointer; }
.seg input:checked + span { background: var(--text); color: var(--surface); font-weight: var(--fw-strong); }
.seg input:focus-visible + span { box-shadow: var(--focus); }
.seg input:disabled + span { color: var(--text-3); cursor: not-allowed; text-decoration: line-through; text-decoration-color: var(--border-strong); }
.autonomy { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); }
.autonomy__ceiling { font-size: var(--fs-meta); color: var(--text-3); display: inline-flex; gap: 4px; align-items: center; }
.nudge { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); padding: var(--s-2) var(--s-3); border: var(--line) solid var(--border); border-radius: var(--radius); background: var(--surface-2); font-size: var(--fs-table); }

/* ---------- Module tile ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: var(--line) solid var(--border); border-left: var(--line) solid var(--border); }
.tile { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-4); border-right: var(--line) solid var(--border); border-bottom: var(--line) solid var(--border); background: var(--surface); text-decoration: none; color: var(--text); min-height: 128px; min-width: 0; }
a.tile:hover { background: var(--surface-2); }
.tile__head { display: flex; align-items: center; gap: var(--s-2); font-weight: var(--fw-strong); }
.tile__value { font-size: var(--fs-title); font-weight: var(--fw-strong); font-variant-numeric: tabular-nums; line-height: var(--lh-tight); }
.tile__value small { font-size: var(--fs-table); font-weight: var(--fw-regular); color: var(--text-2); }
.tile__note { font-size: var(--fs-meta); color: var(--text-2); }
.tile--quiet { background: var(--bg); }
.tile--quiet .tile__head { color: var(--text-2); }

/* ---------- Headline metric ---------- */
.metric { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.metric__k { font-size: var(--fs-table); color: var(--text-2); display: flex; align-items: center; gap: var(--s-2); }
.metric__line { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-2) var(--s-3); }
.metric__v { font-size: var(--fs-title); font-weight: var(--fw-strong); font-variant-numeric: tabular-nums; line-height: var(--lh-tight); }
.metric__unit { font-size: var(--fs-body); color: var(--text-2); }
.metric__spark { width: 120px; height: 28px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-6); }
.metric--block { padding-top: var(--s-3); border-top: var(--line) solid var(--border); }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; font-family: var(--font-sans); }
.chart text { font-size: 11px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis { stroke: var(--border-strong); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--chart-line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .compare { fill: none; stroke: var(--chart-compare); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .area { fill: var(--accent); opacity: 0.08; }
.chart .bar { fill: var(--chart-line); }
.chart .bar--compare { fill: var(--chart-compare); }
.chart .bar--muted { fill: var(--surface-3); }
.chart .marker-line { stroke: var(--chart-marker); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.5; }
.chart .marker { fill: var(--surface); stroke: var(--chart-marker); stroke-width: 1.5; }
.chart .marker-label { fill: var(--text); font-size: 11px; font-weight: 600; }
.chart .dot { fill: var(--chart-line); stroke: var(--surface); stroke-width: 2; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); font-size: var(--fs-meta); color: var(--text-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg-line { width: 16px; height: 2px; background: var(--chart-line); }
.lg-compare { width: 16px; height: 0; border-top: 1.5px dashed var(--chart-compare); }
.lg-marker { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--chart-marker); background: var(--surface); }
.chart-tip { position: absolute; padding: var(--s-2) var(--s-3); background: var(--surface); border: var(--line) solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-float); font-size: var(--fs-table); display: flex; flex-direction: column; gap: 2px; max-width: 260px; }
.chart-wrap { position: relative; }
.chart-tip--static { position: static; }
.hbars { display: flex; flex-direction: column; gap: 6px; }
.hbar { display: grid; grid-template-columns: 88px minmax(0, 1fr) 48px; align-items: center; gap: var(--s-3); font-size: var(--fs-table); }
.hbar__track { height: 8px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.hbar__fill { display: block; height: 100%; background: var(--chart-line); }
.hbar__fill--muted { background: var(--chart-compare); }
.hbar .num { text-align: right; }

/* ---------- Budget meter ---------- */
.meter { display: flex; flex-direction: column; gap: 6px; }
.meter__track { position: relative; height: 8px; background: var(--surface-3); border-radius: 2px; overflow: visible; }
.meter__fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--text-2); border-radius: 2px; }
.meter__cap { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); }

/* ---------- Banners and empty states ---------- */
.banner { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--s-2) var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--radius); border: var(--line) solid var(--border); background: var(--surface); font-size: var(--fs-table); }
.banner__body { flex: 1 1 280px; display: flex; flex-direction: column; gap: 2px; }
.banner--critical { border-color: var(--critical); background: var(--critical-weak); }
.banner--critical > .i { color: var(--critical); }
.banner--important { border-color: var(--important-mark); background: var(--important-weak); }
.banner--important > .i { color: var(--important); }
.banner--info > .i { color: var(--text-2); }
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-3); padding: var(--s-8) var(--s-6); border: var(--line) dashed var(--border-strong); border-radius: var(--radius); max-width: 100%; }
.empty__title { font-weight: var(--fw-strong); }
.empty__text { color: var(--text-2); max-width: var(--measure); font-size: var(--fs-table); }
.empty--error { border-style: solid; border-color: var(--critical); }
.skeleton { display: block; height: 12px; border-radius: 2px; background: var(--surface-3); }

/* ---------- Steps (wizard) ---------- */
.steps { display: flex; gap: var(--s-2); counter-reset: step; }
.step { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-meta); color: var(--text-3); min-width: 0; }
.step::before { content: ""; height: 3px; border-radius: 2px; background: var(--surface-3); }
.step--done::before { background: var(--text-2); }
.step--current { color: var(--text); font-weight: var(--fw-strong); }
.step--current::before { background: var(--accent); }
.wizard { display: flex; flex-direction: column; gap: var(--s-6); }
.wizard__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); padding-top: var(--s-4); border-top: var(--line) solid var(--border); }
.choice { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: var(--s-1) var(--s-3); padding: var(--s-3) var(--s-4); border: var(--line) solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.choice input { margin: 3px 0 0; accent-color: var(--accent); width: 16px; height: 16px; }
.choice:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.choice__title { font-weight: var(--fw-strong); }
.choice__text { grid-column: 2; font-size: var(--fs-table); color: var(--text-2); }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
.source-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-2) var(--s-4); align-items: center; padding: var(--s-3) 0; border-bottom: var(--line) solid var(--border); }
.log { font-family: var(--font-mono); font-size: var(--fs-table); display: flex; flex-direction: column; gap: 4px; color: var(--text-2); }
.log .ok { color: var(--success); }

/* ---------- History timeline ---------- */
.timeline { display: flex; flex-direction: column; }
.timeline li { display: grid; grid-template-columns: 96px 16px minmax(0, 1fr); gap: var(--s-3); font-size: var(--fs-table); padding-bottom: var(--s-3); position: relative; }
.timeline li::after { content: ""; position: absolute; left: calc(96px + var(--s-3) + 7px); top: 14px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline__dot { width: 9px; height: 9px; margin: 5px 0 0 3px; border-radius: 50%; border: 1.5px solid var(--text-3); background: var(--surface); }
.timeline__dot--scout { background: var(--text-3); }
.timeline__dot--ok { background: var(--success); border-color: var(--success); }
.timeline__when { color: var(--text-3); font-size: var(--fs-meta); padding-top: 1px; }

/* ---------- Floating: toast, dialog, menu, shortcuts ---------- */
.toast { display: inline-flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4); border-radius: var(--radius); background: var(--text); color: var(--surface); box-shadow: var(--shadow-float); font-size: var(--fs-table); }
.toast .btn { background: transparent; color: var(--surface); border-color: transparent; text-decoration: underline; }
.toast .btn:hover { background: rgba(127, 127, 127, 0.2); color: var(--surface); }
.toast__timer { width: 48px; height: 2px; background: rgba(127, 127, 127, 0.4); border-radius: 1px; overflow: hidden; }
.toast__timer span { display: block; height: 100%; width: 60%; background: currentColor; }
.toast-region { position: fixed; left: 50%; bottom: var(--s-6); transform: translateX(-50%); z-index: 20; }
.dialog { width: 100%; max-width: 480px; border: var(--line) solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow-float); padding: 0; display: flex; flex-direction: column; }
.dialog__head { padding: var(--s-4) var(--s-5) 0; display: flex; flex-direction: column; gap: var(--s-1); }
.dialog__body { padding: var(--s-4) var(--s-5); display: flex; flex-direction: column; gap: var(--s-3); font-size: var(--fs-table); }
.dialog__foot { padding: var(--s-3) var(--s-5) var(--s-4); display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-2); }
.dialog .kv { padding: var(--s-3); border: var(--line) solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.scrim { background: var(--overlay); display: flex; align-items: center; justify-content: center; padding: var(--s-6); }
.menu { min-width: 240px; padding: var(--s-1); border: var(--line) solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-float); display: flex; flex-direction: column; }
.menu__item { display: flex; align-items: center; gap: var(--s-2); height: 36px; padding: 0 var(--s-2); border-radius: 2px; color: var(--text); text-decoration: none; font-size: var(--fs-body); }
.menu__item:hover, .menu__item[aria-current="true"] { background: var(--surface-2); }
.menu__sep { height: 1px; margin: var(--s-1) 0; background: var(--border); }
.shortcuts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--s-2) var(--s-4); font-size: var(--fs-table); align-items: center; }
.shortcuts dt { display: flex; gap: 4px; }

/* ---------- Catalog page helpers (components.html only) ---------- */
.sheet { min-height: 100vh; }
.catalog { max-width: 1280px; padding: var(--s-8); display: flex; flex-direction: column; gap: var(--s-12); }
.spec { display: flex; flex-direction: column; gap: var(--s-4); }
.spec__head { display: flex; align-items: baseline; gap: var(--s-3); padding-bottom: var(--s-2); border-bottom: var(--line) solid var(--border); }
.spec__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-6); }
.spec__grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.spec__cell { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.spec__cap { font-size: var(--fs-meta); color: var(--text-3); }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s-3); }
.swatch { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-meta); }
.swatch__chip { height: 40px; border-radius: var(--radius); border: var(--line) solid var(--border); display: flex; align-items: center; padding: 0 var(--s-2); font-weight: var(--fw-strong); }
.theme-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.theme-pane { padding: var(--s-6); background: var(--bg); color: var(--text); display: flex; flex-direction: column; gap: var(--s-4); }
.favicon-demo { display: flex; align-items: center; gap: var(--s-4); }
.favicon-demo .brand__mark { width: 32px; height: 32px; font-size: 15px; }
.tabchip { display: inline-flex; align-items: center; gap: var(--s-2); height: 32px; padding: 0 var(--s-3); border: var(--line) solid var(--border); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; background: var(--surface); font-size: var(--fs-meta); }
.tabchip .brand__mark { width: 14px; height: 14px; font-size: 8px; border-radius: 2px; }

/* ---------- Auth / error pages ---------- */
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--s-6); }
.auth { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: var(--s-6); }


/* ---------- Width steps for bars (no inline styles) ---------- */
.w0 { width: 0%; }
.w5 { width: 5%; }
.w10 { width: 10%; }
.w15 { width: 15%; }
.w20 { width: 20%; }
.w25 { width: 25%; }
.w30 { width: 30%; }
.w35 { width: 35%; }
.w40 { width: 40%; }
.w45 { width: 45%; }
.w50 { width: 50%; }
.w55 { width: 55%; }
.w60 { width: 60%; }
.w65 { width: 65%; }
.w70 { width: 70%; }
.w75 { width: 75%; }
.w80 { width: 80%; }
.w85 { width: 85%; }
.w90 { width: 90%; }
.w95 { width: 95%; }
.w100 { width: 100%; }

/* ---------- Phone (≤ 720px app width) ---------- */
@container app (max-width: 720px) {
  .shell, .shell--collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { display: flex; padding: 0 var(--s-4); height: 52px; position: sticky; top: 0; z-index: 5; }
  .topbar__desk { display: none; }
  .topbar__mobile { display: flex; align-items: center; gap: var(--s-2); flex: 1; min-width: 0; }
  .topbar__mobile .switcher { border: 0; padding: 0; height: var(--touch); flex: 1; min-width: 0; }
  .page { padding: var(--s-4) var(--s-4) 96px; gap: var(--s-6); }
  .split, .cols-2 { grid-template-columns: minmax(0, 1fr); gap: var(--s-6); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile { min-height: 104px; padding: var(--s-3); }
  .choices { grid-template-columns: minmax(0, 1fr); }
  .measure { grid-template-columns: minmax(0, 1fr); }
  .btn { height: var(--touch); padding: 0 var(--s-4); }
  .btn--sm { height: 36px; }
  .btn--icon { width: var(--touch); }
  .chip { height: 36px; padding: 0 12px; }
  .input, .select { min-height: var(--touch); font-size: 16px; }
  .tab { height: var(--touch); }
  .tabbar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: sticky; bottom: 0; z-index: 6; background: var(--surface); border-top: var(--line) solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar__item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 56px; color: var(--text-2); text-decoration: none; font-size: 11px; position: relative; }
  .tabbar__item .i { width: 20px; height: 20px; }
  .tabbar__item[aria-current="page"] { color: var(--accent-text); font-weight: var(--fw-strong); }
  .tabbar__item .count { position: absolute; top: 4px; left: calc(50% + 6px); height: 16px; min-width: 16px; font-size: 10px; padding: 0 4px; }
  /* Tables turn into lists: keep the cells marked as key */
  .table--stack thead { display: none; }
  .table--stack, .table--stack tbody, .table--stack tr { display: block; width: 100%; }
  .table--stack tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--s-3); padding: var(--s-3) 0; border-bottom: var(--line) solid var(--border); }
  .table--stack td { display: block; height: auto; padding: 0; border: 0; }
  .table--stack td.hide-sm { display: none; }
  .table--stack td.sm-wide { grid-column: 1 / -1; }
  .table--stack tr:hover td { background: transparent; }
  .table-box { overflow-x: visible; }
  .frow__line { grid-template-columns: 24px minmax(0, 1fr) auto; min-height: 64px; }
  .frow__title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .frow__decide { display: none; }
  .frow__expand { padding-left: 0; }
  .frow__hide-sm { display: none; }
  .evidence { grid-template-columns: minmax(0, 1fr); }
  .evidence__k { border-bottom: 0; padding-bottom: 0; }
  .decide-bar { position: sticky; bottom: 56px; z-index: 4; display: grid; grid-template-columns: 1fr 1fr 2fr; gap: var(--s-2); padding: var(--s-3) var(--s-4); margin: 0 calc(-1 * var(--s-4)); background: var(--surface); border-top: var(--line) solid var(--border); }
  .decide-bar .btn { width: 100%; }
  .desk-only { display: none; }
  .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--s-4)); padding: 0 var(--s-4); }
  .filters__end { display: none; }
  .timeline li { grid-template-columns: 72px 16px minmax(0, 1fr); }
  .timeline li::after { left: calc(72px + var(--s-3) + 7px); }
  .hbar { grid-template-columns: 64px minmax(0, 1fr) 40px; }
  .page-head__actions .btn--quiet { display: none; }
  .action:has(.decide-bar) .action__buttons { display: none; }
  .kbd { display: none; }
  .toast-region { left: var(--s-4); right: var(--s-4); bottom: 72px; transform: none; }
  .toast { display: flex; }
  .toast > span:first-child { flex: 1; }
  .spec__grid, .spec__grid--2, .theme-pair { grid-template-columns: minmax(0, 1fr); }
}
@container app (min-width: 721px) {
  .phone-only { display: none; }
  .decide-bar { display: none; }
}

/* ---------- Catalog swatches ---------- */
.pal-text { color: var(--text); } .pal-text-2 { color: var(--text-2); } .pal-text-3 { color: var(--text-3); }
.pal-accent-text { color: var(--accent-text); } .pal-critical { color: var(--critical); } .pal-important { color: var(--important); }
.pal-success { color: var(--success); } .pal-minor { color: var(--minor); }
.swatch__chip[class*="pal-"] { background: var(--surface); }
.fill-bg { background: var(--bg); } .fill-surface { background: var(--surface); } .fill-surface-2 { background: var(--surface-2); }
.fill-border { background: var(--border); } .fill-accent { background: var(--accent); } .fill-critical-weak { background: var(--critical-weak); }
.fill-important-weak { background: var(--important-weak); } .fill-success-weak { background: var(--success-weak); }
.btn.is-focus { box-shadow: var(--focus); }

/* ---------- Fixes: link rows, expanded rows, sidebar buttons ---------- */
.frow__line a.frow__title:hover { text-decoration: underline; }
.frow[open] > .frow__line .frow__decide { display: none; }
button.nav-item { width: 100%; border: 0; background: none; text-align: left; cursor: pointer; font: inherit; }
.tile__value .nodata { font-size: var(--fs-body); }
.chart.metric__spark { width: 120px; height: 28px; }
.metric__v .nodata { font-size: var(--fs-body); }

/* =====================================================================
   Part 2 components
   ===================================================================== */

/* ---------- Large button (Stop all) ---------- */
.btn--lg { height: 40px; padding: 0 var(--s-5); }

/* ---------- Directory matrix: directory × stream ---------- */
.matrix { width: 100%; border-collapse: collapse; font-size: var(--fs-table); }
.matrix th, .matrix td { height: var(--row-h); padding: 4px var(--s-2); border-bottom: var(--line) solid var(--border); text-align: left; white-space: nowrap; }
.matrix thead th { font-size: var(--fs-meta); color: var(--text-3); font-weight: var(--fw-strong); }
.matrix tbody th { font-weight: var(--fw-strong); padding-left: 0; }
.matrix td + td, .matrix th + th { border-left: var(--line) solid var(--border); }
.mc { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-meta); color: var(--text-2); }
.mc .i { width: 13px; height: 13px; }
.mc--listed { color: var(--success); font-weight: var(--fw-strong); }
.mc--submitted { color: var(--text-2); }
.mc--none { color: var(--text-3); }
.mc--rejected { color: var(--critical); font-weight: var(--fw-strong); }
.mc--fix { color: var(--important); font-weight: var(--fw-strong); }
.mc--na { color: var(--border-strong); }
td.is-fix { background: var(--important-weak); }

/* ---------- Week calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: var(--line) solid var(--border); border-left: var(--line) solid var(--border); }
.cal__day { min-height: 168px; padding: var(--s-2); border-right: var(--line) solid var(--border); border-bottom: var(--line) solid var(--border); display: flex; flex-direction: column; gap: 6px; background: var(--surface); min-width: 0; }
.cal__day--today { box-shadow: inset 0 2px 0 var(--accent); }
.cal__day--past { background: var(--bg); }
.cal__date { display: flex; justify-content: space-between; font-size: var(--fs-meta); color: var(--text-3); }
.cal__date strong { color: var(--text); }
.cal__item { display: flex; flex-direction: column; gap: 2px; padding: 6px var(--s-2); border: var(--line) solid var(--border-strong); border-radius: var(--radius); background: var(--surface); font-size: var(--fs-meta); cursor: grab; text-decoration: none; color: var(--text); }
.cal__item:hover { border-color: var(--text-3); }
.cal__item--done { border-style: solid; border-color: var(--border); background: var(--bg); color: var(--text-2); cursor: default; }
.cal__item--awaiting { border-color: var(--accent); }
.cal__item--drag { box-shadow: var(--shadow-float); }
.cal__item-top { display: flex; align-items: center; gap: 4px; color: var(--text-2); }
.cal__item-title { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cal__drop { border: var(--line) dashed var(--accent); border-radius: var(--radius); height: 44px; }

/* ---------- Post preview (generic, per channel) ---------- */
.post { border: var(--line) solid var(--border); border-radius: var(--radius); background: var(--surface); padding: var(--s-3) var(--s-4); display: flex; flex-direction: column; gap: var(--s-2); max-width: 520px; }
.post__head { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-table); }
.post__avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); display: inline-flex; align-items: center; justify-content: center; font-weight: var(--fw-strong); font-size: var(--fs-meta); }
.post__body { white-space: pre-wrap; font-size: var(--fs-body); }
.post__media { height: 140px; border-radius: var(--radius); background: var(--surface-2); border: var(--line) solid var(--border); display: flex; align-items: center; justify-content: center; font-size: var(--fs-meta); color: var(--text-3); }
.post__foot { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-3); font-size: var(--fs-meta); color: var(--text-3); }
.ailabel { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-meta); color: var(--text-2); border: var(--line) solid var(--border-strong); border-radius: var(--radius); padding: 0 6px; height: 20px; }

/* ---------- Funnel ---------- */
.funnel { display: flex; flex-direction: column; gap: var(--s-1); }
.funnel__step { display: grid; grid-template-columns: 200px minmax(0, 1fr) 96px 120px; align-items: center; gap: var(--s-4); font-size: var(--fs-table); min-height: 44px; }
.funnel__bar { height: 24px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.funnel__bar > span { display: block; height: 100%; background: var(--chart-line); }
.funnel__drop { font-size: var(--fs-meta); color: var(--text-2); padding-left: 216px; display: flex; gap: var(--s-2); align-items: center; }
.funnel__drop--worst { color: var(--important); font-weight: var(--fw-strong); }

/* ---------- Screenshot with pins ---------- */
.shot { position: relative; border: var(--line) solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); overflow: hidden; font-family: var(--font-sans); }
.shot__bar { height: 28px; background: var(--surface-2); border-bottom: var(--line) solid var(--border); display: flex; align-items: center; gap: 6px; padding: 0 var(--s-3); font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }
.shot__page { display: grid; grid-template-columns: 1.2fr 1fr; gap: var(--s-6); padding: var(--s-8); min-height: 320px; }
.shot__nav { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 12px; opacity: 0.8; }
.shot__h { font-size: 20px; font-weight: 600; line-height: 1.2; }
.shot__p { font-size: 13px; opacity: 0.75; }
.shot__btn { display: inline-flex; height: 32px; padding: 0 var(--s-3); align-items: center; border: 1px solid var(--text); border-radius: 2px; font-size: 12px; width: max-content; }
.shot__art { border: 1px dashed var(--border-strong); border-radius: 2px; display: flex; align-items: center; justify-content: center; font-size: 11px; opacity: 0.6; }
.shot__col { display: flex; flex-direction: column; gap: var(--s-3); }
.pin { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: var(--fs-meta); font-weight: var(--fw-strong); flex: none; box-shadow: 0 0 0 2px var(--surface); }
.pin--bad { background: var(--important-mark); color: var(--on-mark); }
.pin--ok { background: var(--success); color: var(--surface); }
.shot .pin { position: static; }
.notes { display: flex; flex-direction: column; }
.note { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: var(--s-3); padding: var(--s-3) 0; border-bottom: var(--line) solid var(--border); font-size: var(--fs-table); }

/* ---------- Assistant answer ---------- */
.answer { font-size: var(--fs-body); line-height: 1.65; max-width: var(--measure); display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4); border: var(--line) solid var(--border); border-radius: var(--radius); background: var(--surface); }
.answer mark { background: transparent; color: inherit; }
.answer .hl-you { background: var(--accent-weak); color: var(--accent-text); font-weight: var(--fw-strong); padding: 0 2px; border-radius: 2px; }
.answer .hl-other { box-shadow: inset 0 -1.5px 0 var(--text-3); }
.answer .hl-wrong { box-shadow: inset 0 -2px 0 var(--important-mark); }
.answer ol { list-style: decimal; padding-left: var(--s-5); display: flex; flex-direction: column; gap: 4px; }
.named { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-meta); white-space: nowrap; }
.named--yes { color: var(--success); font-weight: var(--fw-strong); }
.named--no { color: var(--text-3); }
.named--wrong { color: var(--important); font-weight: var(--fw-strong); }
.named .i { width: 13px; height: 13px; }

/* ---------- Email thread ---------- */
.thread { display: flex; flex-direction: column; border-top: var(--line) solid var(--border); }
.msg { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-4) 0; border-bottom: var(--line) solid var(--border); }
.msg__head { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); align-items: baseline; font-size: var(--fs-table); }
.msg__body { white-space: pre-wrap; max-width: var(--measure); font-size: var(--fs-body); }
.msg--them { padding-left: var(--s-4); border-left: 2px solid var(--border-strong); }
.limitbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); font-size: var(--fs-table); }
.limitbar .progress { width: 120px; }

/* ---------- Report (reading document) ---------- */
.doc { max-width: 760px; display: flex; flex-direction: column; gap: var(--s-8); }
.doc__section { display: flex; flex-direction: column; gap: var(--s-3); }
.doc ul.bullets { display: flex; flex-direction: column; gap: 6px; padding-left: var(--s-5); list-style: disc; }
.verdict { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- Checklist (launch plan) ---------- */
.checklist { display: flex; flex-direction: column; border-top: var(--line) solid var(--border); }
.checklist li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: var(--s-3); align-items: start; padding: var(--s-3) 0; border-bottom: var(--line) solid var(--border); font-size: var(--fs-body); }
.checklist input { width: 16px; height: 16px; margin: 3px 0 0; accent-color: var(--accent); }
.checklist .is-done { color: var(--text-3); text-decoration: line-through; }

/* ---------- Settings ---------- */
.settings-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-2) var(--s-6); align-items: center; padding: var(--s-3) 0; border-bottom: var(--line) solid var(--border); }
.settings-row__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.settings-group { display: flex; flex-direction: column; }
.settings-group__head { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-4) 0 var(--s-2); border-bottom: var(--line) solid var(--border); }
.secret { font-family: var(--font-mono); font-size: var(--fs-table); color: var(--text-2); letter-spacing: 0.02em; }
.diff-old { background: var(--critical-weak); color: var(--critical); text-decoration: line-through; padding: 0 2px; border-radius: 2px; }
.diff-new { background: var(--success-weak); color: var(--success); padding: 0 2px; border-radius: 2px; }

/* ---------- Big status code page ---------- */
.errpage { width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: var(--s-4); }
.errpage__code { font-family: var(--font-mono); font-size: var(--fs-table); color: var(--text-3); }

/* ---------- States demo page ---------- */
.state-demo { display: grid; grid-template-columns: 200px minmax(0, 1fr) minmax(0, 1fr); gap: var(--s-6); padding: var(--s-6) 0; border-bottom: var(--line) solid var(--border); align-items: start; }
.state-demo__name { display: flex; flex-direction: column; gap: var(--s-1); }
.chart-frame { position: relative; border: var(--line) solid var(--border); border-radius: var(--radius); padding: var(--s-4); min-height: 196px; display: flex; flex-direction: column; gap: var(--s-2); background: var(--surface); }
.chart-frame__over { position: absolute; inset: 40px var(--s-4) var(--s-4); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-2); text-align: center; font-size: var(--fs-table); color: var(--text-2); background: var(--surface); }
.chart--faded { opacity: 0.35; filter: grayscale(1); }
.list-frame { border: var(--line) solid var(--border); border-radius: var(--radius); padding: 0 var(--s-4); background: var(--surface); }
.skeleton-row { display: grid; grid-template-columns: 24px minmax(0, 1fr) 80px; gap: var(--s-3); align-items: center; height: 52px; border-bottom: var(--line) solid var(--border); }
.skeleton--w60 { width: 60%; } .skeleton--w40 { width: 40%; } .skeleton--box { width: 24px; height: 24px; }

/* ---------- Proxy metric (no direct counter) ---------- */
.proxy-note { display: flex; gap: var(--s-2); align-items: flex-start; font-size: var(--fs-table); color: var(--text-2); max-width: var(--measure); }
.source-tag { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-meta); color: var(--text-3); white-space: nowrap; }

@container app (max-width: 720px) {
  .cal { grid-template-columns: minmax(0, 1fr); }
  .cal__day { min-height: 0; }
  .funnel__step { grid-template-columns: minmax(0, 1fr) 64px; }
  .funnel__step .funnel__bar { grid-column: 1 / -1; grid-row: 2; }
  .funnel__step .hide-sm { display: none; }
  .funnel__drop { padding-left: 0; }
  .shot__page { grid-template-columns: minmax(0, 1fr); padding: var(--s-5); }
  .state-demo { grid-template-columns: minmax(0, 1fr); }
  .matrix-box { overflow-x: auto; }
  .settings-row { grid-template-columns: minmax(0, 1fr); }
}

/* =====================================================================
   Part 3: inline reject reasons, wide timeline
   ===================================================================== */
.frow--rejecting > .frow__line { box-shadow: inset 2px 0 0 var(--accent); padding-left: var(--s-2); margin-left: calc(-1 * var(--s-2)); }
.reject-inline { display: flex; flex-direction: column; gap: var(--s-3); margin: 0 0 var(--s-4) 36px; padding: var(--s-3) var(--s-4); border: var(--line) solid var(--border); border-radius: var(--radius); background: var(--surface); max-width: 640px; }
.reject-inline .chip .kbd { margin-right: 2px; height: 16px; min-width: 16px; font-size: 10px; }
.timeline--wide li { grid-template-columns: 160px 16px minmax(0, 1fr); }
.timeline--wide li::after { left: calc(160px + var(--s-3) + 7px); }
@container app (max-width: 720px) {
  .reject-inline { margin-left: 0; }
  .timeline--wide li { grid-template-columns: 96px 16px minmax(0, 1fr); }
  .timeline--wide li::after { left: calc(96px + var(--s-3) + 7px); }
}
.stack--tight { gap: 2px; }

/* ---------- Part 3 QA fixes (390 / dark / +30% text) ---------- */
.crumbs span[aria-hidden] { color: var(--text-3); }
.metric__k { flex-wrap: wrap; }
.content-box__bar { flex-wrap: wrap; }
.content-box__bar > .row { flex-wrap: nowrap; margin-left: auto; }
.content-box__bar > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.frow__title { overflow-wrap: anywhere; }
.page-head__title .h-title { overflow-wrap: anywhere; }
@container app (max-width: 720px) {
  /* 44 px touch area without making controls look bigger */
  .btn--sm, .chip, .tab, .seg label { position: relative; }
  .btn--sm::after, .chip::after { content: ""; position: absolute; left: 0; right: 0; top: -4px; bottom: -4px; }
  .seg span { height: 36px; min-width: 52px; }
  .seg label::after { content: ""; position: absolute; left: 0; right: 0; top: -4px; bottom: -4px; }
  .frow__check { width: 24px; height: 24px; }
  .toast { width: 100%; }
  .toast__timer { display: none; }
  .settings-row .autonomy { justify-content: flex-start; }
  .page-head__actions { width: 100%; }
  .wizard__foot .btn { flex: 1; }
  .source-row { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px var(--s-3); }
  .kv dd { margin-bottom: var(--s-2); }
}
@container app (max-width: 720px) { .btn--lg { height: var(--touch); } }
@container app (max-width: 720px) {
  .filters .input-wrap { flex: 0 0 220px; }
  .decide-bar--two { grid-template-columns: 1fr 2fr; }
}
