/* ============================================================================
   Base Agency Design System — Application shell, components, utilities
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--ink);
  background: var(--plane);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[dir="rtl"] body,
body[dir="rtl"] { font-family: var(--font-rtl); }

h1, h2, h3, h4, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ---- Focus: never removed, always visible ------------------------------ */
:focus-visible {
  outline: 2px solid var(--series-1);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.on-dark :focus-visible { outline-color: var(--brand-yellow); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; inset-inline-start: var(--space-4); top: -100px;
  z-index: var(--z-toast); background: var(--surface); color: var(--ink);
  padding: var(--space-3) var(--space-5); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); font-weight: 600;
  transition: top var(--dur-quick) var(--ease-out);
}
.skip-link:focus { top: var(--space-4); }

/* ============================================================================
   APP FRAME
   ========================================================================= */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100dvh;
}

/* ---- Sidebar ----------------------------------------------------------- */
.sidebar {
  grid-column: 1;
  background: var(--sidebar);
  color: var(--ink-on-dark);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  z-index: var(--z-drawer);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-5);
  height: var(--topbar-h);
  flex: 0 0 auto;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}
.sidebar__crest {
  width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: var(--radius);
  background: var(--brand-yellow);
  color: var(--brand-navy);
  display: grid; place-items: center;
  /* three letters in a 34px tile — sized so the mark keeps its inset */
  font-weight: 700; font-size: var(--text-2xs); letter-spacing: 0.03em;
}
.sidebar__wordmark { min-width: 0; }
.sidebar__name {
  display: block;
  font-size: var(--text-base); font-weight: 600; letter-spacing: -0.01em;
  /* the product name is longer than the rail in all three languages —
     wrap it rather than truncating the word "System" to an ellipsis */
  line-height: 1.2;
}
.sidebar__sub {
  font-size: 10px; color: var(--ink-on-dark-dim);
  letter-spacing: 0.045em; text-transform: uppercase;
  display: block; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.sidebar__scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--space-4) var(--space-3) var(--space-6);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.sidebar__scroll::-webkit-scrollbar { width: 8px; }
.sidebar__scroll::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.16); border-radius: var(--radius-pill);
}

.navgroup + .navgroup { margin-top: var(--space-5); }
.navgroup__label {
  font-size: var(--text-2xs); font-weight: 600; letter-spacing: 0.09em;
  text-transform: uppercase; color: rgba(255, 255, 255, 0.44);
  padding: 0 var(--space-3) var(--space-2);
}

.navitem {
  display: flex; align-items: center; gap: var(--space-3);
  width: 100%; min-height: 40px;
  padding: var(--space-2) var(--space-3);
  border: 0; background: none; cursor: pointer;
  border-radius: var(--radius);
  color: rgba(255, 255, 255, 0.78);
  font-size: var(--text-base); font-weight: 500; text-align: start;
  position: relative;
  transition: background var(--dur-micro) var(--ease-out),
              color var(--dur-micro) var(--ease-out);
}
.navitem:hover { background: var(--sidebar-hover); color: #fff; }
.navitem__num {
  font-size: var(--text-2xs); font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.4);
  min-width: 17px; flex: 0 0 auto;
}
.navitem__icon { flex: 0 0 auto; width: 18px; height: 18px; opacity: 0.9; }
.navitem__label {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Active location: yellow rail + weight + surface — three channels, not colour alone */
.navitem[aria-current="page"] {
  background: rgba(254, 205, 8, 0.13);
  color: #fff; font-weight: 600;
}
.navitem[aria-current="page"] .navitem__num { color: var(--brand-yellow); }
.navitem[aria-current="page"]::before {
  content: ""; position: absolute;
  inset-inline-start: -12px; top: 50%; translate: 0 -50%;
  width: 3px; height: 22px;
  background: var(--brand-yellow);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
[dir="rtl"] .navitem[aria-current="page"]::before {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.sidebar__foot {
  flex: 0 0 auto;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  font-size: var(--text-2xs);
  color: rgba(255, 255, 255, 0.5);
  display: flex; align-items: center; gap: var(--space-2);
}
.sidebar__foot img { height: 13px; width: auto; opacity: 0.85; }

/* ---- Main column ------------------------------------------------------- */
.main { grid-column: 2; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  height: var(--topbar-h); flex: 0 0 auto;
  display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-6);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar__menu { display: none; }
.topbar__spacer { flex: 1 1 auto; }

.search { position: relative; flex: 0 1 320px; min-width: 0; }
.search__icon {
  position: absolute; inset-inline-start: 10px; top: 50%; translate: 0 -50%;
  width: 15px; height: 15px; color: var(--ink-muted); pointer-events: none;
}
.search input {
  width: 100%; height: 34px;
  padding-inline: 32px var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-sunken);
  font-size: var(--text-sm);
  transition: border-color var(--dur-micro) var(--ease-out),
              background var(--dur-micro) var(--ease-out);
}
.search input::placeholder { color: var(--ink-muted); }
.search input:hover { border-color: var(--border-strong); }
.search input:focus { background: var(--surface); border-color: var(--series-1); }

/* ---- Content ----------------------------------------------------------- */
.content {
  flex: 1 1 auto;
  padding: var(--space-6);
  display: flex; flex-direction: column; gap: var(--space-5);
  max-width: 1680px; width: 100%;
}

.pagehead { display: flex; align-items: flex-start; gap: var(--space-4); flex-wrap: wrap; }
.pagehead__text { flex: 1 1 320px; min-width: 0; }
.pagehead__eyebrow {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-2xs); font-weight: 600; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--ink-muted);
  margin-bottom: var(--space-1);
}
.pagehead__eyebrow b { color: var(--brand-navy); font-variant-numeric: tabular-nums; }
.pagehead h1 {
  font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.02em;
  text-wrap: balance;
}
.pagehead p {
  font-size: var(--text-sm); color: var(--ink-secondary);
  margin-top: var(--space-1); max-width: 68ch;
}
.pagehead__actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* ============================================================================
   CONTROLS
   ========================================================================= */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  min-height: 34px; padding: 0 var(--space-4);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font-size: var(--text-sm); font-weight: 500; white-space: nowrap;
  cursor: pointer; touch-action: manipulation;
  transition: background var(--dur-micro) var(--ease-out),
              border-color var(--dur-micro) var(--ease-out),
              box-shadow var(--dur-micro) var(--ease-out);
}
.btn:hover { background: var(--surface-hover); border-color: var(--brand-navy-300); }
.btn:active { background: var(--surface-sunken); }
.btn svg { width: 15px; height: 15px; flex: 0 0 auto; }

.btn--primary {
  background: var(--brand-navy); border-color: var(--brand-navy);
  color: var(--ink-on-dark); font-weight: 600;
}
.btn--primary:hover { background: var(--brand-navy-700); border-color: var(--brand-navy-700); }
.btn--primary:active { background: var(--brand-navy-600); }

.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-secondary); }
.btn--ghost:hover { background: var(--surface-hover); border-color: transparent; color: var(--ink); }

.btn--icon {
  width: 34px; padding: 0; flex: 0 0 auto;
  border-color: transparent; background: transparent; color: var(--ink-secondary);
  position: relative;
}
.btn--icon:hover { background: var(--surface-hover); border-color: var(--border); color: var(--ink); }
.btn--icon svg { width: 17px; height: 17px; }

.btn--sm { min-height: 28px; padding: 0 var(--space-3); font-size: var(--text-xs); }

.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }

/* Notification count on an icon button */
.btn--icon .dot {
  position: absolute; top: 5px; inset-inline-end: 5px;
  min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: var(--radius-pill);
  background: var(--status-critical); color: #fff;
  font-size: 9px; font-weight: 700; line-height: 15px; text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--surface);
}

/* Select */
.select { position: relative; display: inline-flex; align-items: center; }
.select select {
  appearance: none;
  min-height: 34px; padding-inline: var(--space-3) var(--space-8);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); font-size: var(--text-sm); font-weight: 500;
  cursor: pointer;
  transition: border-color var(--dur-micro) var(--ease-out);
}
.select select:hover { border-color: var(--brand-navy-300); }
.select::after {
  content: ""; position: absolute; inset-inline-end: 11px; top: 50%;
  width: 7px; height: 7px; translate: 0 -70%; rotate: 45deg;
  border-right: 1.5px solid var(--ink-muted); border-bottom: 1.5px solid var(--ink-muted);
  pointer-events: none;
}

/* Segmented control */
.segmented {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--surface-sunken); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.segmented button {
  min-height: 28px; padding: 0 var(--space-3);
  border: 0; border-radius: var(--radius-sm); background: transparent;
  font-size: var(--text-xs); font-weight: 500; color: var(--ink-secondary);
  cursor: pointer; white-space: nowrap;
  transition: background var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out);
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] {
  background: var(--surface); color: var(--ink); font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* Tabs */
.tabs {
  display: flex; gap: var(--space-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  position: relative; border: 0; background: none; cursor: pointer;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm); font-weight: 500; color: var(--ink-secondary);
  white-space: nowrap;
  transition: color var(--dur-micro) var(--ease-out);
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--brand-navy); font-weight: 600; }
.tabs button[aria-selected="true"]::after {
  content: ""; position: absolute; inset-inline: var(--space-3); bottom: -1px;
  height: 2px; background: var(--brand-navy); border-radius: 2px 2px 0 0;
}

/* Read-only field */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field__label { font-size: var(--text-xs); font-weight: 600; color: var(--ink-secondary); }
.field__value {
  min-height: 34px; display: flex; align-items: center;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-sunken); color: var(--ink);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}
.field__help { font-size: var(--text-2xs); color: var(--ink-muted); }

/* ============================================================================
   CARDS
   ========================================================================= */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  display: flex; flex-direction: column;
}
.card__head {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.card__titles { flex: 1 1 auto; min-width: 0; }
.card__title { font-size: var(--text-base); font-weight: 600; letter-spacing: -0.01em; }
.card__sub { font-size: var(--text-xs); color: var(--ink-muted); margin-top: 2px; }
.card__tools { display: flex; align-items: center; gap: var(--space-2); flex: 0 0 auto; }
.card__body { padding: var(--space-5); flex: 1 1 auto; min-width: 0; }
.card__body--flush { padding: 0; }
/* Inline flow, not flex: a footer is usually an icon followed by a sentence,
   and flex makes the icon and the text separate items that wrap apart. */
.card__foot {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs); color: var(--ink-muted);
  line-height: 1.6;
}
.card__foot > svg { vertical-align: -3px; margin-inline-end: 2px; }
.card__foot > .btn { margin-inline-end: var(--space-2); vertical-align: middle; }
.card__foot > .btn:last-child { margin-inline-end: 0; }

/* ---- Grid ------------------------------------------------------------- */
.grid { display: grid; gap: var(--space-4); }
.grid--kpi  { grid-template-columns: repeat(auto-fit, minmax(206px, 1fr)); }
.grid--2    { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--3    { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: start; }
/* Cards size to their content — a stretched card leaves a void under a
   chart, which reads as a mistake rather than as breathing room. */
.grid--wide { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.grid--side { grid-template-columns: minmax(0, 1fr) minmax(0, 1.9fr); align-items: start; }
@media (max-width: 1180px) {
  .grid--wide, .grid--side { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Stat tile --------------------------------------------------------- */
.stat { padding: var(--space-4) var(--space-5); gap: var(--space-3); }
.stat__label {
  font-size: var(--text-xs); font-weight: 500; color: var(--ink-secondary);
  display: flex; align-items: center; gap: 6px;
}
.stat__row { display: flex; align-items: flex-end; gap: var(--space-3); }
.stat__value {
  font-size: var(--text-2xl); font-weight: 600; letter-spacing: -0.03em;
  line-height: 1.1; /* proportional figures — never tabular at display size */
}
.stat__unit { font-size: var(--text-sm); font-weight: 500; color: var(--ink-muted); }
.stat__spark { margin-inline-start: auto; flex: 0 0 auto; }
.stat__delta {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--text-xs); font-weight: 600;
}
.stat__delta svg { width: 12px; height: 12px; }
.stat__delta--up   { color: var(--success-text); }
.stat__delta--down { color: var(--status-critical); }
.stat__delta--flat { color: var(--ink-muted); }
.stat__note { font-size: var(--text-2xs); color: var(--ink-muted); }

/* Hero figure — exactly one per view */
.hero-figure {
  font-size: var(--text-3xl); font-weight: 700; letter-spacing: -0.035em;
  line-height: 1.05; color: var(--brand-navy);
}

/* ============================================================================
   PILLS, BADGES, AVATARS
   ========================================================================= */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px var(--space-2); min-height: 21px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs); font-weight: 600; white-space: nowrap;
  background: var(--status-neutral-bg); color: var(--ink-secondary);
}
.pill svg { width: 12px; height: 12px; flex: 0 0 auto; }
.pill::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex: 0 0 auto;
}
.pill--icon::before { display: none; }
.pill--good     { background: var(--status-good-bg);     color: #056b05; }
.pill--warning  { background: var(--status-warning-bg);  color: #8a5c00; }
.pill--serious  { background: var(--status-serious-bg);  color: #a24218; }
.pill--critical { background: var(--status-critical-bg); color: #a32626; }
.pill--info     { background: var(--status-info-bg);     color: #1c4a94; }
.pill--brand    { background: rgba(254,205,8,0.2);       color: #7a5f00; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 6px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  font-size: var(--text-2xs); font-weight: 600; color: var(--ink-secondary);
  background: var(--surface); white-space: nowrap;
}

.avatar {
  width: 32px; height: 32px; flex: 0 0 auto;
  border-radius: 50%; display: grid; place-items: center;
  background: var(--status-info-bg); color: #1c4a94;
  font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.01em;
}
.avatar--lg { width: 52px; height: 52px; font-size: var(--text-md); }
.avatar--sm { width: 26px; height: 26px; font-size: var(--text-2xs); }

.person { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.person__name { display: block; font-weight: 600; font-size: var(--text-sm); }
.person__meta {
  font-size: var(--text-2xs); color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* ============================================================================
   TABLES
   ========================================================================= */

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: var(--text-sm);
}
table.data th, table.data td {
  padding: var(--space-3) var(--space-4);
  text-align: start; vertical-align: middle;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-sunken);
  font-size: var(--text-2xs); font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted);
  border-bottom: 1px solid var(--border);
}
table.data tbody tr { transition: background var(--dur-micro) var(--ease-out); }
table.data tbody tr:hover { background: var(--surface-hover); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num {
  text-align: end; font-variant-numeric: tabular-nums;
}
table.data td.wrap { white-space: normal; min-width: 220px; }
table.data .muted { color: var(--ink-muted); }

tr.row-link { cursor: pointer; }
tr.row-link:focus-visible { outline: 2px solid var(--series-1); outline-offset: -2px; }

/* Sortable header */
th.sortable { padding: 0; }
th.sortable button {
  width: 100%; min-height: 38px;
  display: flex; align-items: center; gap: 5px;
  padding: var(--space-3) var(--space-4);
  border: 0; background: none; cursor: pointer;
  font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit;
  transition: color var(--dur-micro) var(--ease-out);
}
th.sortable.num button { justify-content: flex-end; }
th.sortable button:hover { color: var(--ink); }
th.sortable button .caret {
  width: 11px; height: 11px; opacity: 0; flex: 0 0 auto;
  transition: opacity var(--dur-micro) var(--ease-out), rotate var(--dur-quick) var(--ease-out);
}
th.sortable button:hover .caret { opacity: 0.45; }
th[aria-sort] button { color: var(--brand-navy); }
th[aria-sort] button .caret { opacity: 1; }
th[aria-sort="descending"] button .caret { rotate: 180deg; }

table.data .cellcheck { width: 40px; }
input[type="checkbox"].box {
  width: 15px; height: 15px; accent-color: var(--brand-navy); cursor: pointer;
}

.tabletools {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tabletools .search { flex: 1 1 220px; max-width: 320px; }

.pager { display: flex; align-items: center; gap: var(--space-2); margin-inline-start: auto; }
.pager__label {
  font-size: var(--text-xs); color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* ============================================================================
   LISTS & TIMELINES
   ========================================================================= */

.list > li {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.list > li:last-child { border-bottom: 0; }
.list__body { flex: 1 1 auto; min-width: 0; }
/* block, so a title and its meta never run together on one line */
.list__title { display: block; font-size: var(--text-sm); font-weight: 600; }
.list__meta {
  display: block;
  font-size: var(--text-xs); color: var(--ink-muted); margin-top: 1px;
  overflow-wrap: anywhere;
}
.list__aside {
  flex: 0 0 auto; font-size: var(--text-2xs); color: var(--ink-muted);
  font-variant-numeric: tabular-nums; text-align: end;
}

.timeline { position: relative; padding-inline-start: var(--space-5); }
.timeline::before {
  content: ""; position: absolute; inset-inline-start: 6px; top: 6px; bottom: 6px;
  width: 1px; background: var(--border);
}
.timeline > li { position: relative; padding-bottom: var(--space-5); }
.timeline > li:last-child { padding-bottom: 0; }
.timeline > li::before {
  content: ""; position: absolute;
  inset-inline-start: calc(-1 * var(--space-5) + 3px); top: 5px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand-navy-300); box-shadow: 0 0 0 3px var(--surface);
}
.timeline > li[data-tone="good"]::before     { background: var(--status-good); }
.timeline > li[data-tone="critical"]::before { background: var(--status-critical); }
.timeline > li[data-tone="warning"]::before  { background: var(--status-warning); }

/* Stage / funnel bars */
.stages { display: flex; flex-direction: column; gap: var(--space-3); }
.stage__top {
  display: flex; align-items: baseline; gap: var(--space-2);
  font-size: var(--text-sm); margin-bottom: 5px;
}
.stage__name { font-weight: 500; }
.stage__count { margin-inline-start: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.stage__pct { font-size: var(--text-xs); color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.track {
  height: 8px; border-radius: var(--radius-pill);
  background: var(--seq-100); overflow: hidden;
}
.track__fill {
  height: 100%; border-radius: var(--radius-pill);
  background: var(--seq-500);
  transition: width var(--dur-panel) var(--ease-out);
}
.track--good, .track--warn, .track--crit { background: var(--status-neutral-bg); }
.track--good .track__fill { background: var(--status-good); }
.track--warn .track__fill { background: var(--status-warning); }
.track--crit .track__fill { background: var(--status-critical); }

/* Meta rows */
.meta-list { display: flex; flex-direction: column; gap: var(--space-3); }
.meta-row { display: flex; align-items: center; gap: var(--space-3); font-size: var(--text-sm); }
.meta-row dt { color: var(--ink-secondary); flex: 0 0 auto; }
.meta-row dd {
  margin: 0; margin-inline-start: auto; font-weight: 600; text-align: end;
  font-variant-numeric: tabular-nums;
}

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-4); }

/* ============================================================================
   NOTICES & EMPTY STATES
   ========================================================================= */

.notice {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface-sunken);
  font-size: var(--text-sm);
}
.notice svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; }
.notice strong { font-weight: 600; }
.notice p { color: var(--ink-secondary); margin-top: 2px; font-size: var(--text-xs); }
.notice--brand    { background: rgba(254,205,8,0.11); border-color: rgba(254,205,8,0.4); }
.notice--brand svg { color: var(--brand-gold-ink); }  /* 5.2:1 on the tint */
.notice--info     { background: var(--status-info-bg); border-color: #c3d6f5; }
.notice--info svg { color: var(--series-1); }
.notice--critical { background: var(--status-critical-bg); border-color: #f0c9c9; }
.notice--critical svg { color: var(--status-critical); }

.empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  padding: var(--space-10) var(--space-5); text-align: center;
}
.empty svg { width: 30px; height: 30px; color: var(--ink-muted); }
.empty h3 { font-size: var(--text-base); font-weight: 600; }
.empty p { font-size: var(--text-sm); color: var(--ink-muted); max-width: 40ch; }

/* ============================================================================
   OVERLAYS — drawer, modal, menu, toast
   ========================================================================= */

.scrim {
  position: fixed; inset: 0; z-index: var(--z-drawer);
  background: rgba(12, 24, 42, 0.42);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-panel) var(--ease-out);
}
.scrim[data-open="true"] { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; inset-block: 0; inset-inline-end: 0;
  z-index: calc(var(--z-drawer) + 1);
  width: min(560px, 100vw);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  translate: 100% 0;
  transition: translate var(--dur-panel) var(--ease-out);
}
[dir="rtl"] .drawer { translate: -100% 0; }
.drawer[data-open="true"] { translate: 0 0; }
.drawer__head {
  flex: 0 0 auto; display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-5); border-bottom: 1px solid var(--border);
}
.drawer__body { flex: 1 1 auto; overflow-y: auto; }
.drawer__foot {
  flex: 0 0 auto; padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--space-2);
  background: var(--surface-sunken);
}

.modal {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: grid; place-items: center; padding: var(--space-5);
  pointer-events: none;
}
.modal[data-open="true"] { pointer-events: auto; }
.modal__panel {
  width: min(520px, 100%); max-height: 86dvh; overflow-y: auto;
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0; scale: 0.97;
  transition: opacity var(--dur-panel) var(--ease-out), scale var(--dur-panel) var(--ease-out);
}
.modal[data-open="true"] .modal__panel { opacity: 1; scale: 1; }

.menu {
  position: absolute; z-index: var(--z-modal);
  min-width: 200px; padding: var(--space-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.menu button, .menu a {
  display: flex; align-items: center; gap: var(--space-3);
  width: 100%; min-height: 34px; padding: 0 var(--space-3);
  border: 0; background: none; border-radius: var(--radius-sm);
  font-size: var(--text-sm); text-align: start; cursor: pointer;
  transition: background var(--dur-micro) var(--ease-out);
}
.menu button:hover, .menu a:hover { background: var(--surface-hover); }
.menu button svg, .menu a svg { width: 15px; height: 15px; color: var(--ink-muted); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-2) 0; }
.menu__label {
  padding: var(--space-2) var(--space-3) var(--space-1);
  font-size: var(--text-2xs); font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--ink-muted);
}
.menu button[aria-checked="true"] { font-weight: 600; }
.menu button[aria-checked="true"]::after {
  content: ""; margin-inline-start: auto;
  width: 6px; height: 10px; rotate: 45deg;
  border-right: 2px solid var(--brand-navy); border-bottom: 2px solid var(--brand-navy);
}

.toaster {
  position: fixed; z-index: var(--z-toast);
  inset-block-end: var(--space-6); inset-inline-end: var(--space-6);
  display: flex; flex-direction: column; gap: var(--space-2);
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--space-3);
  min-width: 260px; max-width: 380px;
  padding: var(--space-3) var(--space-4);
  background: var(--brand-navy); color: var(--ink-on-dark);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  animation: toast-in var(--dur-panel) var(--ease-out);
}
.toast svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--brand-yellow); margin-top: 1px; }
.toast[data-leaving="true"] { animation: toast-out 160ms var(--ease-in-out) forwards; }
@keyframes toast-in  { from { opacity: 0; translate: 0 10px; } to { opacity: 1; translate: 0 0; } }
@keyframes toast-out { to { opacity: 0; translate: 0 6px; } }

/* ============================================================================
   PAGE ENTRANCE — one motion token, respects reduced-motion
   ========================================================================= */

.view-enter > * { animation: rise var(--dur-panel) var(--ease-out) backwards; }
.view-enter > *:nth-child(2) { animation-delay: 40ms; }
.view-enter > *:nth-child(3) { animation-delay: 80ms; }
.view-enter > *:nth-child(4) { animation-delay: 110ms; }
.view-enter > *:nth-child(n+5) { animation-delay: 140ms; }
@keyframes rise { from { opacity: 0; translate: 0 8px; } to { opacity: 1; translate: 0 0; } }

@media (prefers-reduced-motion: reduce) {
  .view-enter > * { animation: none; }
  .toast { animation: none; }
}

/* ============================================================================
   RESPONSIVE — sidebar becomes an off-canvas drawer below 1024px
   ========================================================================= */

@media (max-width: 1023px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0;
    width: var(--sidebar-w);
    translate: -100% 0;
    transition: translate var(--dur-panel) var(--ease-out);
    box-shadow: var(--shadow-lg);
    /* above the scrim, which shares the base --z-drawer layer */
    z-index: calc(var(--z-drawer) + 1);
  }
  [dir="rtl"] .sidebar { translate: 100% 0; }
  .sidebar[data-open="true"] { translate: 0 0; }
  .main { grid-column: 1; }
  .topbar__menu { display: inline-flex; }
  .content { padding: var(--space-4); gap: var(--space-4); }
}

@media (max-width: 719px) {
  .topbar { padding: 0 var(--space-4); gap: var(--space-2); }
  .search { flex-basis: 0; }
  .hide-sm { display: none !important; }
  .pagehead h1 { font-size: var(--text-lg); }
  .stat__value { font-size: var(--text-xl); }
  .toaster { inset-inline: var(--space-4); inset-block-end: var(--space-4); }
  .toast { max-width: none; }
}

/* ---- Print ------------------------------------------------------------- */
@media print {
  .sidebar, .topbar, .toaster, .card__tools { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .card { box-shadow: none; break-inside: avoid; }
}
