/* Editorial refresh (docs/UI_UX_PLAN.md). Loaded last; removing the <link>
   restores the prototype skin. Builds on prototype.css tokens — the
   prototype's original theme.js palette (--p-*), the red-orange accent,
   square corners — and adds what was missing. Every colour here is a
   palette token or a color-mix() of palette tokens. */

/* ---- Tokens ----------------------------------------------------------- */
/* --accent-ink: accent-coloured TEXT (dark acc2: 5.6:1 on surface, 5.3:1 on
   --accent-bg; light done: 7.8:1 and 6.4:1 — light acc is 4.4:1 on white,
   so it stays a fill and rule colour).
   --band-N: the risk-band scale, Preservation (1) → Aggressive (5), cool to
   warm from the palette only: dark dim → blue2 → yel → amb → acc2, light
   mute2 → blue → yel → amb → acc. An aggressive profile is a choice, not an
   error: bands carry their label, errors carry an icon and a message.
   Fill ≥ 3:1 on the ground; -ink is for text (≥ 4.5:1 on bg, surface and its
   -soft tint; light yel/amb are darkened toward ink by color-mix for that);
   -soft is a color-mix tint (cool bands over panel, warm bands over sel so
   no tint turns olive). The scale lives on the same scopes as the palette,
   so public pages follow the selected theme too. */
:root, [data-theme="dark"] {
  --accent-ink: var(--p-acc2);
  --band-1: var(--p-dim);   --band-1-ink: var(--p-mute);  --band-1-soft: color-mix(in srgb, var(--p-dim) 14%, var(--p-panel));
  --band-2: var(--p-blue2); --band-2-ink: var(--p-blue);  --band-2-soft: color-mix(in srgb, var(--p-blue2) 14%, var(--p-panel));
  --band-3: var(--p-yel);   --band-3-ink: var(--p-yel);   --band-3-soft: color-mix(in srgb, var(--p-yel) 14%, var(--p-sel));
  --band-4: var(--p-amb);   --band-4-ink: var(--p-amb);   --band-4-soft: color-mix(in srgb, var(--p-amb) 14%, var(--p-sel));
  --band-5: var(--p-acc2);  --band-5-ink: var(--p-acc2);  --band-5-soft: var(--p-sel);
  --marker: var(--p-ink);
  --topbar: 60px;
}
[data-theme="light"] {
  --accent-ink: var(--p-done);
  --band-1: var(--p-mute2); --band-1-ink: var(--p-mute);  --band-1-soft: color-mix(in srgb, var(--p-mute2) 14%, var(--p-panel));
  --band-2: var(--p-blue);  --band-2-ink: var(--p-blue3); --band-2-soft: color-mix(in srgb, var(--p-blue) 14%, var(--p-panel));
  --band-3: var(--p-yel);   --band-3-ink: color-mix(in srgb, var(--p-yel) 75%, var(--p-ink)); --band-3-soft: color-mix(in srgb, var(--p-yel) 14%, var(--p-panel));
  --band-4: var(--p-amb);   --band-4-ink: color-mix(in srgb, var(--p-amb) 75%, var(--p-ink)); --band-4-soft: color-mix(in srgb, var(--p-amb) 14%, var(--p-panel));
  --band-5: var(--p-acc);   --band-5-ink: var(--p-done);  --band-5-soft: color-mix(in srgb, var(--p-acc) 14%, var(--p-panel));
}

/* ---- Type by role ------------------------------------------------------ */
/* Figures in tables, metrics and scores line up (Hanken's digits are already
   equal-width; this keeps the fallbacks honest too). */
table, .metrics, .metric-value, .score-mini, .decision-number, .field-pair,
.distribution-labels, .dimension-row, .comparison-row, .factor-value,
.funding-value, .market-kpis, .mini-kpi-list, .fact-strip, .band-gauge {
  font-variant-numeric: tabular-nums lining-nums;
}
/* The id · type · date line sits inside the H1: reset the headline tracking,
   weight and face so it reads as metadata, not squeezed display type. */
h1 .profile-meta { font-family: var(--font-mono); font-weight: 400; letter-spacing: .02em; line-height: 1.4; }
/* Accent-coloured small text uses the ink variant. */
.shell .text-button:hover, .shell .eyebrow-accent { color: var(--accent-ink); }
.nav-item.active .nav-count, [data-theme="dark"] .nav-item.active .nav-count { color: var(--accent-ink); }

/* ---- Slim shell ---------------------------------------------------------- */
/* One calm 60px row instead of 76px: smaller wordmark, quieter controls. The
   sidebar and shell follow --topbar. The phone layout (≤720px, two rows) keeps
   its own rules from prototype.css. Header items never shrink the brand. */
@media (min-width: 721px) {
  .workspace-topbar { height: var(--topbar); padding-inline: 20px; gap: 18px; border-bottom: 1px solid var(--line); }
  .workspace-topbar .brand { flex-shrink: 0; gap: 10px; }
  .workspace-topbar .brand-symbol { width: 24px; height: 26px; }
  .workspace-topbar .brand-title { font-size: 20px; letter-spacing: -.02em; }
  /* The brand block is exactly the sidebar's width, and its rule continues
     the sidebar's edge: the tenant switch starts where the content does. */
  .workspace-topbar .brand { box-sizing: border-box; inline-size: calc(var(--sidebar) - 20px); border-inline-end: 1px solid var(--line); }
  .workspace-topbar .tenant-switch { padding-block: 4px; padding-inline-start: 0; border-inline-start: 0; }
  .workspace-topbar .tenant-monogram { width: 28px; height: 28px; font-size: 12px; }
  .workspace-topbar .tenant-meta strong { font-size: 14px; }
  .workspace-topbar .topbar-search { height: 36px; font-size: 13px; }
  .sidebar, [dir="rtl"] .sidebar { top: var(--topbar); }
  .shell { min-height: calc(100vh - var(--topbar)); }
}
/* The navigation owns its scroll. Account controls stay compact and pinned. */
:root:has(#app > .workspace-topbar), body:has(#app > .workspace-topbar) { overflow: hidden; overscroll-behavior-y: none; }
/* Anchor the workspace to the viewport, independently of document scroll
   restoration. Only .shell scrolls; the frame must never become a second
   scroll container through focus, anchors, or a retained outer-page offset. */
#app:has(> .workspace-topbar) { position: fixed; inset: 0; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: clip; }
#app > .workspace-topbar { grid-row: 1; }
#app > .shell { grid-row: 2; min-height: 0; min-width: 0; overflow: auto; overscroll-behavior: contain; }
/* A translated page temporarily extends scrollable overflow past its footer. */
.shell > .page.page-enter { animation-name: workspace-fade; }
@keyframes workspace-fade { from { opacity: 0; } to { opacity: 1; } }
.sidebar { overflow: hidden; overscroll-behavior: contain; }
.sidebar .nav-scroll { min-height: 0; overscroll-behavior-y: contain; }
.sidebar-bottom { display: flex; align-items: center; gap: 6px; padding: 8px 10px; flex-shrink: 0; }
.sidebar-quick-action { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; height: 34px; padding: 0 9px; border: 1px solid var(--line); background: transparent; color: var(--text); font: 12px var(--font-ui); text-align: start; }
.sidebar-quick-action:hover { border-color: var(--accent); background: var(--accent-bg); }
.sidebar-quick-action .icon { width: 15px; height: 15px; flex-shrink: 0; }
.sidebar-quick-action span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-bottom .sidebar-website { width: 34px; height: 34px; flex-shrink: 0; }
.sidebar-bottom > .nav-item { padding: 7px 9px; font-size: 12px; }
.sidebar .user-block { min-height: 58px; flex-shrink: 0; padding: 10px; gap: 8px; }
.user-block .avatar { width: 28px; height: 28px; flex-shrink: 0; }
.user-meta { min-width: 0; flex: 1; }
.user-meta strong, .user-meta small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; line-height: 1.6; }
.user-meta strong { font-size: 12px; }
.user-meta small { font-size: 10px; }
.user-controls { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.user-controls .icon-btn { width: 28px; height: 32px; padding: 5px; }
.user-controls .icon { width: 16px; height: 16px; }

/* ---- Risk bands (figures.js) ------------------------------------------- */
.band-fill-1 { background: var(--band-1); } .band-fill-2 { background: var(--band-2); }
.band-fill-3 { background: var(--band-3); } .band-fill-4 { background: var(--band-4); }
.band-fill-5 { background: var(--band-5); }
.badge.band-1 { color: var(--band-1-ink); background: var(--band-1-soft); border-color: var(--band-1); }
.badge.band-2 { color: var(--band-2-ink); background: var(--band-2-soft); border-color: var(--band-2); }
.badge.band-3 { color: var(--band-3-ink); background: var(--band-3-soft); border-color: var(--band-3); }
.badge.band-4 { color: var(--band-4-ink); background: var(--band-4-soft); border-color: var(--band-4); }
.badge.band-5 { color: var(--band-5-ink); background: var(--band-5-soft); border-color: var(--band-5); }
.score-mini .progress > i { background: var(--muted); }
.score-mini.band-1 .progress > i { background: var(--band-1); } .score-mini.band-2 .progress > i { background: var(--band-2); }
.score-mini.band-3 .progress > i { background: var(--band-3); } .score-mini.band-4 .progress > i { background: var(--band-4); }
.score-mini.band-5 .progress > i { background: var(--band-5); }
.band-stack { border-radius: 0; gap: 2px; height: 10px; }
.distribution-labels small { font-size: 11px; display: flex; align-items: center; gap: 5px; }
.distribution-labels .legend-dot { width: 8px; height: 8px; margin: 0; border-radius: 0; flex: none; }
.distribution-labels strong { font-family: var(--font-ui); font-size: 18px; letter-spacing: -.01em; }

/* The governed decision gauge: ceiling (rule), target (ring), governed score
   (filled, in its band colour). Hatched = above the ceiling, not permitted. */
.band-gauge { margin: 20px 0 16px; }
.gauge-labels { position: relative; height: 20px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.gauge-labels.top { margin-bottom: 6px; }
.gauge-labels.bottom { margin-top: 8px; }
.gauge-label { position: absolute; top: 0; white-space: nowrap; line-height: 20px; }
.gauge-label b { color: var(--text); font-weight: 500; }
.gauge-label.center { transform: translateX(-50%); }
.gauge-label.end { transform: translateX(-100%); }
[dir="rtl"] .gauge-label.center { transform: translateX(50%); }
[dir="rtl"] .gauge-label.end { transform: translateX(100%); }
.gauge-track { position: relative; height: 12px; background: var(--surface2); }
.gauge-seg { position: absolute; top: 0; bottom: 0; opacity: .45; }
.gauge-excluded { position: absolute; top: 0; bottom: 0;
  background: repeating-linear-gradient(135deg, transparent 0 4px, color-mix(in srgb, var(--text) 30%, transparent) 4px 5px); }
.gauge-cap { position: absolute; top: 50%; border-top: 2px dashed var(--marker); }
.gauge-ceiling { position: absolute; top: -9px; bottom: -9px; width: 2px; margin-inline-start: -1px; background: var(--marker); }
.gauge-target, .gauge-final { position: absolute; top: 50%; border-radius: 50%; transform: translate(-50%, -50%); }
[dir="rtl"] :is(.gauge-target, .gauge-final) { transform: translate(50%, -50%); }
.gauge-target { width: 14px; height: 14px; border: 2px solid var(--marker); background: var(--surface); }
.gauge-final { width: 16px; height: 16px; border: 2px solid var(--marker); background: var(--muted); }
.gauge-final.band-1, .gauge-key.band-1 { background: var(--band-1); } .gauge-final.band-2, .gauge-key.band-2 { background: var(--band-2); }
.gauge-final.band-3, .gauge-key.band-3 { background: var(--band-3); } .gauge-final.band-4, .gauge-key.band-4 { background: var(--band-4); }
.gauge-final.band-5, .gauge-key.band-5 { background: var(--band-5); }
.band-gauge figcaption { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.band-gauge figcaption b { color: var(--text); font-weight: 600; }
.gauge-key { display: inline-block; width: 10px; height: 10px; flex: none; }
.gauge-key.final { border-radius: 50%; border: 1.5px solid var(--marker); }
.gauge-key.excluded { margin-inline-start: 12px; border: 1px solid var(--line2);
  background: repeating-linear-gradient(135deg, transparent 0 2px, color-mix(in srgb, var(--text) 35%, transparent) 2px 3px); }

/* ---- Illustrations (figures.js instrument) ----------------------------- */
/* Procedural, seeded by the object's id; tagged "Illustration". Neutral
   rules and dots with the accent for the chosen answer — never band colours,
   which are reserved for results. */
.fig-illustration { position: relative; margin: 0; }
.fig-illustration svg { display: block; width: 100%; height: auto; }
.fig-illustration figcaption { position: absolute; bottom: 7px; inset-inline-end: 10px; font-family: var(--font-mono); font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.fig-ground { fill: var(--surface2); }
.fig-rule { stroke: var(--line2); stroke-width: 1; fill: none; }
.fig-dot { fill: var(--muted); opacity: .7; }
.fig-pick { fill: var(--accent); }
.fig-num { fill: var(--line2); }
.fig-path { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linejoin: round; }
.model-card .fig-illustration { margin: -24px -24px 8px; border-bottom: 1px solid var(--line); }
.model-card .uppercase.teal { color: var(--accent-ink); }
.model-card h3 { font-size: 17px; letter-spacing: -.01em; }

/* ---- Empty states ------------------------------------------------------- */
/* Led by the four-bar mark drawn empty: no data yet, one sentence on what to
   do next. Pure CSS so every existing empty state picks it up. */
.empty-state { padding: 40px 20px 44px; }
.empty-state::before {
  content: ''; display: block; width: 64px; height: 40px; margin: 0 auto 16px; background: var(--line2);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 40'%3E%3Cg fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M2 39h60' stroke-dasharray='3 3'/%3E%3Crect x='12' y='21' width='6' height='15'/%3E%3Crect x='24' y='12' width='6' height='24'/%3E%3Crect x='36' y='17' width='6' height='19'/%3E%3Crect x='48' y='5' width='6' height='31'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 40'%3E%3Cg fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M2 39h60' stroke-dasharray='3 3'/%3E%3Crect x='12' y='21' width='6' height='15'/%3E%3Crect x='24' y='12' width='6' height='24'/%3E%3Crect x='36' y='17' width='6' height='19'/%3E%3Crect x='48' y='5' width='6' height='31'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}
.empty-state h3 { font-size: 16px; }

/* ---- Website: landing and pricing (marketing.js) ----------------------- */
/* Built on the theme tokens only; the landing keeps its dark presentation
   through the .landing token block in prototype.css. */
.lp-kicker { display: block; font-family: var(--font-mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--accent-ink); margin-bottom: 14px; }
.lp-head { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 40px; align-items: end; margin-bottom: 36px; }
.lp-head h2 { font-size: clamp(30px, 3.4vw, 46px); line-height: 1.08; letter-spacing: -.03em; font-weight: 700; color: var(--text); }
.lp-head h2 > span { color: var(--muted); }
.lp-head > p { color: var(--muted); font-size: 16px; line-height: 1.6; max-width: 520px; }
.lp-grid { display: grid; gap: 0; border-top: 1px solid var(--line); border-inline-start: 1px solid var(--line); }
.lp-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.lp-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lp-card, .lp-proof-item { padding: 26px 24px 28px; border-inline-end: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); }
.lp-card .icon, .lp-proof-item .icon { width: 22px; height: 22px; color: var(--accent); }
.lp-card-top { display: flex; justify-content: space-between; align-items: center; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.lp-card h3, .lp-proof-item h3 { font-size: 18px; letter-spacing: -.01em; margin: 22px 0 8px; color: var(--text); }
.lp-card p, .lp-proof-item p { color: var(--muted); font-size: 14px; line-height: 1.6; }
.lp-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; counter-reset: step; }
.lp-steps > li { border-top: 2px solid var(--text); padding-top: 16px; min-width: 0; }
.lp-step-figure { min-height: 150px; display: flex; align-items: center; background: var(--surface2); margin-bottom: 18px; position: relative; }
.lp-step-figure > * { width: 100%; }
.lp-step-num { font-family: var(--font-mono); font-size: 12px; color: var(--accent-ink); }
.lp-steps h3 { font-size: 22px; margin: 6px 0 8px; color: var(--text); }
.lp-steps p { color: var(--muted); font-size: 14px; line-height: 1.6; }
.lp-ceilings { padding: 18px 16px 30px; display: grid; gap: 12px; }
.lp-ceilings > div { display: grid; grid-template-columns: 92px 1fr 26px; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); }
.lp-ceilings i { display: block; height: 6px; background: var(--line2); }
.lp-ceilings i.binding { background: var(--accent); }
.lp-ceilings b { font-family: var(--font-mono); font-weight: 500; color: var(--text); text-align: end; }
.lp-gauge { padding: 4px 14px 26px; position: relative; }
.lp-gauge .band-gauge figcaption { display: none; }
.lp-tag, .lp-step-figure figcaption { position: absolute; bottom: 7px; inset-inline-end: 10px; font-family: var(--font-mono); font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.lp-trace ol { list-style: none; margin: 0; padding: 18px 18px 32px; display: grid; gap: 10px; }
.lp-trace li { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.lp-trace li::before { content: ''; width: 10px; height: 10px; border: 1.5px solid var(--line2); border-radius: 50%; flex: none; }
.lp-trace li.done { color: var(--text); } .lp-trace li.done::before { background: var(--text); border-color: var(--text); }
.lp-trace li.current { color: var(--accent-ink); } .lp-trace li.current::before { border-color: var(--accent); background: var(--accent-bg); }
.lp-formula { margin-top: 28px; padding: 20px 24px; border: 1px solid var(--line); border-inline-start: 3px solid var(--accent); display: grid; gap: 8px; background: var(--surface); }
.lp-formula .lp-kicker { margin: 0; }
.lp-formula code { font-family: var(--font-mono); font-size: clamp(13px, 1.5vw, 17px); color: var(--text); overflow-wrap: anywhere; }
.lp-formula > span:last-child { color: var(--muted); font-size: 14px; }
.lp-plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.lp-plan { display: flex; flex-direction: column; gap: 18px; padding: 26px 24px; border: 1px solid var(--line); background: var(--surface); }
.lp-plan.self-service { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.lp-plan header .lp-kicker { margin-bottom: 8px; color: var(--muted); }
.lp-plan h3 { font-size: 24px; color: var(--text); }
.lp-price { font-size: 30px; font-weight: 700; letter-spacing: -.02em; color: var(--text); margin: 8px 0 10px; font-variant-numeric: tabular-nums; }
.lp-plan header p:last-child { color: var(--muted); font-size: 14px; line-height: 1.55; }
.lp-limits, .lp-features { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.lp-limits { padding-block: 14px; border-block: 1px solid var(--line); color: var(--text); font-variant-numeric: tabular-nums; }
.lp-features li { display: flex; gap: 8px; align-items: flex-start; color: var(--text); }
.lp-features li .icon { width: 16px; height: 16px; margin-top: 2px; color: var(--accent); }
.lp-features li.off { color: var(--muted); } .lp-features li.off .icon { color: var(--line2); }
.lp-plan > .land-button { margin-top: auto; justify-content: center; }
.lp-footnote { margin-top: 18px; color: var(--muted); font-size: 13px; max-width: 900px; }
.shell .lp-pricing { padding: 8px 0 0; }
.shell .lp-pricing .lp-head { display: none; }
@media (max-width: 1100px) {
  .lp-grid.four, .lp-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lp-plans, .lp-grid.three { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .lp-head { grid-template-columns: 1fr; gap: 14px; }
  .lp-grid.four, .lp-steps { grid-template-columns: 1fr; }
}

/* The older marketing stylesheet hard-codes mint and teal greys; the parts of
   the landing that remain take the neutral tokens instead. */
.landing { background: var(--bg); }
.landing .land-section h2, .landing .land-final h2 { color: var(--text); }
.landing .land-faq summary, .landing .land-faq-list summary { color: var(--text); }
.landing .land-faq p, .landing .land-final p, .landing .land-footer, .landing .land-footer span, .landing .land-footer small, .landing .land-footer button { color: var(--muted); }
.landing .land-faq-list details, .landing .land-faq { border-color: var(--line); }
.landing .land-faq summary span, .landing .land-faq summary .icon { color: var(--muted); border-color: var(--line2); }
.landing .land-section { border-color: var(--line); }
.landing .land-final h2 > span, .landing .lp-head h2 > span { color: var(--muted); }
.landing .land-final h2 > span { color: var(--accent); }
.landing .land-menu-button { color: var(--text); }
.landing .land-footer > small { border-top-color: var(--line); font-size: 11px; }
