/* ==========================================================================
   Shell: base elements, the app frame (rail and top bar), page frames and
   headers, and the sticky case dossier header.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar-h) + var(--dossier-h) + var(--sp-4));
}
body {
  margin: 0; min-height: 100vh; padding-left: var(--rail-w);
  background: var(--bg); color: var(--text);
  font: var(--fs-md)/var(--lh) var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 500; letter-spacing: 0; }
h1 { font: 400 var(--fs-3xl)/1.15 var(--display); letter-spacing: -0.01em; }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p { margin: 0; }
a { color: var(--text); text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-text); text-decoration-color: currentColor; }
ul, ol { margin: 0; padding: 0; }
img { max-width: 100%; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; border-radius: var(--r-xs);
  border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--surface-2);
  font: 500 11px/1.5 var(--font); color: var(--text-2); text-align: center;
}
code { font: 500 12px/1.4 var(--mono); padding: 1px 5px; border-radius: var(--r-xs); background: var(--surface-3); color: var(--text); white-space: nowrap; }
[x-cloak] { display: none !important; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* identifiers (UEN, list entry ids, hashes): IBM Plex Mono. Everything else is the text face. */
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: 0; font-size: 0.92em; }
body { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.icon { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.icon-xl { width: 32px; height: 32px; }

/* bar widths in 5% steps, set by class (no inline style): .w-0 … .w-100 */
.w-0{--w:0%} .w-5{--w:5%} .w-10{--w:10%} .w-15{--w:15%} .w-20{--w:20%} .w-25{--w:25%} .w-30{--w:30%} .w-35{--w:35%} .w-40{--w:40%} .w-45{--w:45%} .w-50{--w:50%} .w-55{--w:55%} .w-60{--w:60%} .w-65{--w:65%} .w-70{--w:70%} .w-75{--w:75%} .w-80{--w:80%} .w-85{--w:85%} .w-90{--w:90%} .w-95{--w:95%} .w-100{--w:100%}
.bar-fill, .score-fill, .section-bar span, .heat-bar span, .age-meter span, .checks-bar span { width: var(--w, 0%); }

/* visible focus everywhere */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-xs); }

.skip-link {
  position: fixed; left: calc(var(--rail-w) + var(--sp-4)); top: -60px; z-index: 100; padding: var(--sp-2) var(--sp-4);
  background: var(--accent); color: var(--on-accent); border-radius: var(--r-md); font-weight: 600;
}
.skip-link:focus { top: var(--sp-2); color: var(--on-accent); }

/* ---------------------------------------------------------------- the app frame: rail */

.rail {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 46; width: var(--rail-w);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-5); padding: 10px 0 var(--sp-4);
  background: var(--shell-bg);
  border-right: 1px solid var(--shell-border);
  color: var(--shell-text-2);
}
.rail-brand {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-md); color: var(--on-accent);
  background: var(--accent);
}
.rail-brand:hover { color: var(--on-accent); background: var(--accent-hover); }
.rail-brand:focus-visible { outline-color: var(--shell-accent); outline-offset: 3px; }
.brand-mark { width: 20px; height: 20px; }
.rail-nav { display: flex; flex-direction: column; gap: var(--sp-1); }
.rail-nav a {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; width: 58px; padding: 8px 0 6px;
  border-radius: var(--r-md); color: var(--shell-text-2); text-decoration: none; font-size: var(--fs-xs); font-weight: 500;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.rail-nav a .icon { width: 18px; height: 18px; }
.rail-nav a:hover { background: var(--shell-2); color: var(--shell-text); }
.rail-nav a[aria-current="page"] { background: var(--shell-3); color: var(--shell-text); }
.rail-nav a:focus-visible { outline-color: var(--shell-accent); }
.rail-new { margin-top: var(--sp-2); }
.rail-new .icon { padding: 1px; border-radius: var(--r-sm); border: 1.5px solid currentColor; }

/* ---------------------------------------------------------------- the app frame: top bar */

.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--sp-5); padding: 0 var(--sp-6);
  background: var(--shell-bg);
  border-bottom: 1px solid var(--shell-border); color: var(--shell-text);
}
.brand { display: flex; align-items: baseline; gap: var(--sp-2); color: var(--shell-text); text-decoration: none; flex: none; }
.brand:hover { color: var(--shell-text); }
.brand:focus-visible { outline-color: var(--shell-accent); }
.brand-name { font-weight: 600; font-size: var(--fs-md); }
.brand-tag { font-size: var(--fs-sm); color: var(--shell-text-2); }
.topbar-context { min-width: 0; flex: 1; color: var(--shell-text-2); font-size: var(--fs-sm); }
.crumbs { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; padding-left: var(--sp-5); border-left: 1px solid var(--shell-border); }
.crumbs a { color: var(--shell-text-2); text-decoration: none; font-weight: 500; }
.crumbs a:hover { color: var(--shell-text); text-decoration: underline; }
.crumbs a:focus-visible { outline-color: var(--shell-accent); }
.crumbs > span[aria-current] { color: var(--shell-text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); }
.user { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--shell-text-2); font-size: var(--fs-sm); white-space: nowrap; }
.user-mark {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font: 600 11px/1 var(--font);
  color: var(--shell-text); background: var(--shell-3);
}
.btn.btn-shell { --btn-bg: transparent; --btn-fg: var(--shell-text); --btn-border: var(--shell-border); box-shadow: none; }
.btn.btn-shell:hover { background: var(--shell-2); color: var(--shell-text); }
.btn.btn-shell:focus-visible { outline-color: var(--shell-accent); }
.read-only-tag { display: inline-flex; align-items: center; gap: var(--sp-2); padding: 4px var(--sp-3); border: 1px solid var(--shell-border); border-radius: var(--r-sm); color: var(--shell-text); font-size: var(--fs-sm); }

/* the theme switch (shown by app.js; without JavaScript the page follows the system) */
.theme-switch { display: inline-flex; padding: 2px; border-radius: var(--r-md); background: var(--shell-2); }
.theme-switch button {
  display: grid; place-items: center; width: 28px; height: 26px; padding: 0; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--shell-text-2); cursor: pointer; transition: background-color .15s var(--ease), color .15s var(--ease);
}
.theme-switch button:hover { color: var(--shell-text); }
.theme-switch button[aria-pressed="true"] { background: var(--shell-bg); color: var(--shell-text); box-shadow: var(--shadow-sm); }
.theme-switch button:focus-visible { outline-color: var(--shell-accent); outline-offset: 1px; }

/* ---------------------------------------------------------------- page frames */

.page { max-width: 1240px; margin: 0 auto; padding: var(--sp-8) var(--sp-8) var(--sp-12); }
.page-wide { max-width: none; padding: 0 var(--sp-6) var(--sp-12); }
.page-narrow { max-width: 720px; }
.page-report { max-width: 1280px; }
main:focus { outline: none; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-6); margin-bottom: var(--sp-6); }
.page-header h1 { font-size: 40px; letter-spacing: -0.015em; }
.page-header-center { flex-direction: column; align-items: flex-start; gap: 0; }
.page-header-center h1 { font-size: var(--fs-3xl); }
.page-sub { margin-top: var(--sp-2); color: var(--text-2); max-width: 72ch; font-size: var(--fs-md); }
.breadcrumb { margin-bottom: var(--sp-2); font-size: var(--fs-sm); }
.breadcrumb a { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); text-decoration: none; font-weight: 500; }
.breadcrumb a:hover { color: var(--text); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); }
.eyebrow { font-size: var(--fs-sm); color: var(--text-3); margin-bottom: 4px; }

/* ---------------------------------------------------------------- the case dossier header (sticky) */

.page-case { --dossier-h: 0px; }
.dossier {
  position: sticky; top: var(--topbar-h); z-index: 30;
  margin: 0 calc(-1 * var(--sp-6)) var(--sp-6); padding: var(--sp-4) var(--sp-6) var(--sp-4);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.case-header-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-6); }
.case-identity { min-width: 0; flex: 1; }
.dossier-eyebrow { margin-bottom: 2px; }
.case-identity h1 {
  font-size: 28px; line-height: 1.15; letter-spacing: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.case-meta {
  display: flex; align-items: center; gap: var(--sp-2) var(--sp-4); margin-top: var(--sp-2); color: var(--text-3); font-size: var(--fs-sm);
  flex-wrap: nowrap; overflow: hidden; white-space: nowrap;
}
.meta-item { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.meta-item.mono { overflow: hidden; text-overflow: ellipsis; }
.live-tag { color: var(--accent-text); font-weight: 500; }
.uen-pill { display: inline-flex; align-items: center; gap: 6px; color: var(--text); flex: none; }
.uen-pill .mono { font-weight: 500; font-size: var(--fs-sm); }
.uen-label { font-size: var(--fs-sm); color: var(--text-3); }
.btn-copy { height: 24px; min-width: 24px; }
.copy-done { font-size: var(--fs-xs); color: var(--ok-text); font-weight: 600; }
.case-actions { display: flex; align-items: center; gap: var(--sp-3); flex: none; }
/* the case's five steps: tabs under the title. The one for the panel shown is marked from the
   panel's :target (no JS needed); app.js keeps aria-current in step. */
.case-steps-row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-2) var(--sp-6); margin: var(--sp-3) 0 calc(-1 * var(--sp-4) - 1px); }
.case-steps { min-width: 0; overflow-x: auto; scrollbar-width: none; }
.case-steps ol { list-style: none; display: flex; gap: var(--sp-1); }
.case-step {
  display: flex; flex-direction: column; gap: 1px; padding: var(--sp-2) var(--sp-4) 10px; white-space: nowrap;
  color: var(--text-2); text-decoration: none; border-bottom: 2px solid transparent;
  transition: color .12s var(--ease), border-color .12s var(--ease);
}
.case-step:hover { color: var(--text); border-bottom-color: var(--border-strong); }
.step-title { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-md); font-weight: 600; }
.step-n {
  display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--border-strong); font: 500 11px/1 var(--mono); color: var(--text-2);
}
.step-n .icon { width: 11px; height: 11px; }
.case-step.is-done .step-n { background: var(--high-bg); border-color: var(--high-border); color: var(--high-text); }
.step-sub { font-size: var(--fs-xs); color: var(--text-3); padding-left: 26px; }
.case-step.is-todo .step-sub { color: var(--accent-text); }
.case-step.is-ready .step-sub { color: var(--ok-text); }
.case-step[aria-current],
.page-case:not(:has(.review-center > .tab-panel:not(#overview):target, .review-center > .tab-panel:not(#overview) :target)) #step-overview,
.page-case:has(#findings:target, #findings :target) #step-findings,
.page-case:has(#matches:target, #matches :target) #step-matches,
.page-case:has(#tasks:target, #tasks :target) #step-tasks,
.page-case:has(#signoff:target, #signoff :target) #step-signoff { color: var(--text); border-bottom-color: var(--accent); }
.case-step[aria-current] .step-n,
.page-case:not(:has(.review-center > .tab-panel:not(#overview):target, .review-center > .tab-panel:not(#overview) :target)) #step-overview .step-n,
.page-case:has(#findings:target, #findings :target) #step-findings .step-n,
.page-case:has(#matches:target, #matches :target) #step-matches .step-n,
.page-case:has(#tasks:target, #tasks :target) #step-tasks .step-n,
.page-case:has(#signoff:target, #signoff :target) #step-signoff .step-n { background: var(--text); border-color: var(--text); color: var(--bg); }
.next-step { flex: none; margin-bottom: var(--sp-2); }
.next-step .icon { width: 16px; height: 16px; }

/* the dossier sticks while there is room for it; on short screens it scrolls away */
@media (min-height: 760px) {
  .page-case:has(.dossier) { --dossier-h: 116px; }
  .page-case:has(.dossier.has-steps) { --dossier-h: 168px; }
  html:has(.page-case .dossier) { scroll-padding-top: calc(var(--topbar-h) + 132px); }
  html:has(.page-case .dossier.has-steps) { scroll-padding-top: calc(var(--topbar-h) + 184px); }
}
@media (max-width: 1279px) {
  .case-meta .meta-item.mono { display: none; } /* the website: the dossier keeps to one line */
  .case-step .step-n { display: none; } /* the steps keep what is left; the numbers make way */
  .step-sub { padding-left: 0; }
  .case-step { padding-left: var(--sp-3); padding-right: var(--sp-3); }
}
@media (max-height: 759px) {
  .dossier { position: relative; top: auto; }
}
