/* IB Ops v2 -- IB Brand Redesign palette
   Sora + Open Sans + JetBrains Mono · #0d1117 / #3fb950 · sharp corners */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700;800&family=Open+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #0A141E;
  --bg-deep: #050E17;
  --surface: #14293C;
  --card: #14293C;
  --card-h: #1A3146;
  --border: #1E3450;
  --border-b: #2A4058;

  --green: #5EFF0D;
  --green-d: #3ccc00;
  --green-dim: #1A3A0A;
  --green-line: rgba(94, 255, 13, 0.30);
  --green-soft: rgba(94, 255, 13, 0.10);
  --green-strong: rgba(94, 255, 13, 0.18);
  --green-glow: rgba(94, 255, 13, 0.06);

  --teal: #58a6ff;
  /* Canonical secondary-data / "info" blue. --blue and --sage are aliases kept
     for existing selectors; retune the role in one place here. --teal is a
     distinct, brighter link/badge blue, not the same token. */
  --info: #79c0ff;
  --blue: var(--info);
  --brand-secondary: #0050FF;
  --purple: #d2a8ff;
  --warn: #e3b341;
  --warn-soft: rgba(227, 179, 65, 0.12);
  --danger: #f85149;
  --danger-soft: rgba(248, 81, 73, 0.12);
  --teal-soft: rgba(88, 166, 255, 0.12);
  --purple-soft: rgba(210, 168, 255, 0.12);

  --muted: #A3B8CC;
  --dim: #30363d;
  --text: #e6edf3;
  --text-s: #A3B8CC;
  --text-faint: #8A9CAE;

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --r-xl: 12px;

  --t-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base: 220ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  /* Elevation -- refined shadow ramp with subtle color casts */
  --sh-1: 0 1px 2px rgba(1, 4, 9, 0.40);
  --sh-2: 0 6px 18px rgba(1, 4, 9, 0.45);
  --sh-3: 0 14px 36px rgba(1, 4, 9, 0.60);
  --sh-glow: 0 0 20px rgba(63, 185, 80, 0.08);

  --rail-w: 240px;
  --rail-w-min: 64px;
  --appbar-h: 56px;

  /* Semantic z-index scale. Ordered low→high by stacking intent so layers never
     collide on arbitrary literals: in-flow raised → sticky chrome → sidebar →
     popovers/tooltips (must clear sticky chrome) → drawer scrim → mobile drawer
     → skip link (always reachable). */
  --z-base: 1;
  --z-raised: 2;
  --z-sticky: 50;
  --z-sidebar: 60;
  --z-popover: 70;
  --z-scrim: 90;
  --z-drawer: 100;
  --z-skip: 200;

  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --sans: 'Open Sans', system-ui, sans-serif;
  --title: 'Sora', system-ui, sans-serif;

  --accent: var(--green);
  --accent-soft: var(--green-soft);
  --accent-strong: var(--green-strong);
  --accent-line: var(--green-line);
  --sage: var(--info);
  --sage-soft: rgba(121, 192, 255, 0.12);
  --amber: var(--warn);
  --amber-soft: var(--warn-soft);
  --red: var(--danger);
  --red-soft: var(--danger-soft);
  --violet: var(--purple);
  --violet-soft: var(--purple-soft);

  --surface-2: var(--card);
  --surface-3: var(--card-h);
  --border-strong: var(--border-b);
  --border-bright: #4a5360;
  --text-muted: var(--muted);
  --text-dim: #939DA9;
}

* { box-sizing: border-box; }
*::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Horizontal-overflow guard. Use clip (not hidden) so it never establishes a
   scroll container -- keeps position:sticky working -- and apply it to <html> too:
   body{overflow-x:hidden} alone is defeated when the viewport scroll propagates
   to <html>, which is what let absolutely-positioned popovers widen the page.
   Genuinely-wide content (tables, heatmaps) gets a local .xscroll / .table-wrap
   scroller instead of relying on this clip to hide it. */
html, body { overflow-x: clip; }
body { min-height: 100vh; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---- Global interaction baseline (one consistent focus ring / cursor / disabled) ----
   :where() keeps these at zero specificity so any component's own focus rule still
   wins; this only fills the gaps. No border-radius here -- the brand is sharp-cornered,
   so the outline simply follows each element's existing shape. */
:where(a[href], button, input, select, textarea, summary,
  [tabindex]:not([tabindex="-1"]), [role="button"], [role="tab"], [role="link"]):focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
summary, label[for], [role="button"], [role="tab"] { cursor: pointer; }
:where(button, .btn, .input, .select, input, select, textarea):disabled,
[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Type -- display headings use Sora */
h1, h2, h3, h4, .title { font-family: var(--title); letter-spacing: -0.01em; }

/* ========== APP SHELL ========== */

.skip-link {
  position: fixed;
  top: 10px; left: 10px;
  z-index: var(--z-skip);
  background: var(--green);
  color: var(--bg);
  font-family: var(--title);
  font-weight: 700;
  font-size: 12px;
  padding: 10px 16px;
  border-radius: var(--r-sm);
  transform: translateY(-160%);
  transition: transform var(--t-fast);
}
.skip-link:focus,
.skip-link:focus-visible { transform: translateY(0); outline: 2px solid var(--text); outline-offset: 2px; }

/* Desktop default: content sits to the right of the fixed sidebar. */
body { padding-left: var(--rail-w); }

/* ---- Sidebar ---- */
.app-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--rail-w);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
  border-right: 1px solid var(--border);
  z-index: var(--z-sidebar);
  overflow: hidden;
  padding-left: env(safe-area-inset-left);
  transition: transform var(--t-base), box-shadow var(--t-base);
}
.app-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: var(--appbar-h);
  flex-shrink: 0;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}
.app-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.app-brand-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--title);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text);
  white-space: nowrap;
  transition: opacity var(--t-fast);
}
.app-brand-ver {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--green);
  padding: 2px 6px;
  background: var(--green-dim);
  border: 1px solid var(--green-d);
  border-radius: var(--r-sm);
  letter-spacing: 0;
  text-transform: none;
}
.brand-mark {
  width: 22px; height: 22px;
  border-radius: 3px;
  flex-shrink: 0;
  object-fit: contain;
}

.app-nav { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: 10px 0; }
.app-nav::-webkit-scrollbar { width: 8px; }
.app-nav::-webkit-scrollbar-thumb { background: var(--border-b); border-radius: 4px; }
.nav-group { padding: 6px 0; }
.nav-caption {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-faint);
  padding: 6px 20px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--t-fast);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 20px;
  color: var(--text-s);
  font-family: var(--title);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.2px;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-item:hover { background: var(--green-soft); color: var(--text); }
.nav-item.active {
  color: var(--green);
  background: var(--green-dim);
}
.nav-item:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
.nav-ic { flex-shrink: 0; width: 18px; height: 18px; }
.nav-label { overflow: hidden; transition: opacity var(--t-fast); }

.app-nav-foot {
  flex-shrink: 0;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  transition: opacity var(--t-fast);
}

/* Pulsing "live" dot -- shared by header + sidebar. */
.live-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2s ease-in-out infinite;
  margin-right: 7px;
  vertical-align: middle;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* Close button -- only shown inside the mobile drawer. */
.drawer-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  background: transparent;
  border: 1px solid var(--border-b);
  border-radius: var(--r-sm);
  color: var(--text);
  transition: border-color var(--t-fast), color var(--t-fast);
}
.drawer-close:hover { border-color: var(--green); color: var(--green); }
.drawer-close:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---- Utility header ---- */
.appbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.appbar-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--appbar-h);
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 24px;
}
.appbar-title {
  flex: 1 1 auto;
  min-width: 0;             /* allow the flex item to shrink so ellipsis works */
  font-family: var(--title);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appbar-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
  flex-shrink: 0;          /* utility controls keep their size; title yields */
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}
.live-tag { display: inline-flex; align-items: center; white-space: nowrap; }
.live-compact { display: none; }

.menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px; height: 34px;
  background: transparent;
  border: 1px solid var(--border-b);
  border-radius: var(--r-sm);
  color: var(--text);
  flex-shrink: 0;
  transition: border-color var(--t-fast), color var(--t-fast);
}
.menu-btn:hover { border-color: var(--green); color: var(--green); }
.menu-btn:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---- Scrim (mobile drawer backdrop) ---- */
.app-scrim {
  position: fixed;
  inset: 0;
  background: rgba(1, 4, 9, 0.55);
  z-index: var(--z-scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}
body.menu-open .app-scrim { opacity: 1; pointer-events: auto; }
/* Lock background scroll while the drawer is open (drawer is phone-only). */
body.menu-open { overflow: hidden; }

/* ---- Timezone select (header) ---- */
.tz-select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--muted);
  padding: 3px 20px 3px 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='5'><path d='M0 0l4 5 4-5z' fill='%238b949e'/></svg>");
  background-repeat: no-repeat;
  background-position: right 6px center;
  cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast);
}
.tz-select:hover, .tz-select:focus { border-color: var(--green-line); color: var(--text); }
.tz-select:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }

/* ========== LAYOUT ========== */
.page {
  max-width: 1480px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}
.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.page-title {
  font-family: var(--title);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.1;
  color: var(--text);
}
.page-subtitle {
  font-family: var(--sans);
  color: var(--text-dim);
  margin: 10px 0 0;
  font-size: 13.5px;
  max-width: 680px;
  line-height: 1.7;
}
.page-eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 8px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.page-eyebrow::before {
  content: '';
  width: 16px;
  height: 1.5px;
  background: var(--green);
  border-radius: 1px;
}

/* ========== KPI GRID ========== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-5);
  position: relative;
  box-shadow: var(--sh-1);
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
  overflow: hidden;
}
.kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--green);
  opacity: 0;
  transition: opacity var(--t-fast);
}
.kpi:hover {
  border-color: var(--green-line);
  background: var(--card-h);
  box-shadow: var(--sh-2), var(--sh-glow);
}
.kpi:hover::before { opacity: 0.55; }
.kpi-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 14px;
}
.kpi-value {
  font-family: var(--title);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--green);
  line-height: 1;
}
.kpi-value .unit {
  font-size: 14px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 4px;
}
.kpi-sub {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.kpi.accent .kpi-value { color: var(--green); }
.kpi.sage  .kpi-value { color: var(--blue); }
.kpi.amber .kpi-value { color: var(--warn); }
.kpi.red   .kpi-value { color: var(--danger); }

/* ========== CARDS / SECTIONS ========== */
.section { margin-bottom: 40px; }
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
  gap: var(--sp-4);
}
.section-title {
  font-family: var(--title);
  font-size: 0.85rem;
  font-weight: 700;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text);
}
.section-meta {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-5);
  box-shadow: var(--sh-1);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.card:hover { border-color: var(--green-line); box-shadow: var(--sh-2), var(--sh-glow); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}
.card-title {
  font-family: var(--title);
  font-size: 0.78rem;
  font-weight: 700;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text);
}
.card-meta {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; }
@media (max-width: 1100px) {
  .grid-2, .grid-3, .grid-4, .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
}

/* ========== TABLE ========== */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--sh-1);
}
.table-wrap.scroll { max-height: 70vh; overflow-y: auto; }
table.t {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  font-family: var(--sans);
}
table.t thead th {
  position: sticky;
  top: 0;
  z-index: var(--z-base);
  background: var(--card-h);
  font-family: var(--title);
  font-size: 0.67rem;
  font-weight: 700;
  color: var(--muted);
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  white-space: nowrap;
  user-select: none;
}
table.t thead th.sortable { cursor: pointer; user-select: none; transition: color var(--t-fast); }
table.t thead th.sortable:hover { color: var(--green); }
/* Active sort direction (supports both the JS data-dir API and aria-sort). */
table.t thead th.sortable[data-dir="asc"]::after,
table.t thead th.sortable[aria-sort="ascending"]::after { content: ' ↑'; color: var(--green); }
table.t thead th.sortable[data-dir="desc"]::after,
table.t thead th.sortable[aria-sort="descending"]::after { content: ' ↓'; color: var(--green); }
/* Neutral, always-visible affordance so a sortable column reads as sortable. */
table.t thead th.sortable:not([data-dir]):not([aria-sort])::after,
table.t thead th.sortable[aria-sort="none"]::after { content: ' ⇅'; color: var(--text-faint); font-size: 0.85em; }
table.t tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(33, 38, 45, 0.5);
  color: var(--text);
  vertical-align: middle;
}
table.t tbody tr:last-child td { border-bottom: none; }
table.t tbody tr { transition: background var(--t-fast), transform var(--t-fast); }
table.t tbody tr:hover { background: var(--green-glow); }
table.t tbody tr.tr-link { cursor: pointer; }
table.t tbody tr.tr-link:hover { background: var(--green-soft); }
table.t td.mono, table.t th.mono {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text);
}
table.t td.dim { color: var(--muted); }
table.t td.right, table.t th.right { text-align: right; }
table.t td.center, table.t th.center { text-align: center; }

/* ========== BADGES ========== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-sm);
  font-size: 10px;
  font-weight: 600;
  font-family: var(--mono);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.badge-sage   { background: var(--teal-soft); color: var(--blue); border-color: rgba(121,192,255,0.25); }
.badge-amber  { background: var(--warn-soft); color: var(--warn); border-color: rgba(227,179,65,0.30); }
.badge-red    { background: var(--danger-soft); color: var(--danger); border-color: rgba(248,81,73,0.30); }
.badge-accent { background: var(--green-dim); color: var(--green); border-color: var(--green-d); }
.badge-blue   { background: var(--teal-soft); color: var(--teal); border-color: rgba(88,166,255,0.30); }
.badge-violet { background: var(--purple-soft); color: var(--purple); border-color: rgba(210,168,255,0.30); }
.badge-sage:hover   { background: rgba(121,192,255,0.22); }
.badge-amber:hover  { background: rgba(227,179,65,0.22); }
.badge-red:hover    { background: rgba(248,81,73,0.22); }
.badge-accent:hover { background: var(--green-strong); }
.badge-violet:hover { background: rgba(210,168,255,0.22); }

/* ========== INPUTS / SEARCH ========== */
.input {
  background: var(--bg);
  border: 1px solid var(--border-b);
  border-radius: var(--r-md);
  color: var(--text);
  padding: 8px 12px;
  font-family: var(--sans);
  font-size: 12.5px;
  outline: none;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
  width: 100%;
}
.input:focus {
  border-color: var(--green);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--green-soft);
}
.input::placeholder { color: var(--text-faint); }
.search-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.search-bar .input { flex: 1; min-width: 220px; }
.select {
  background: var(--bg);
  border: 1px solid var(--border-b);
  border-radius: var(--r-md);
  color: var(--text);
  padding: 8px 28px 8px 12px;
  font-family: var(--sans);
  font-size: 12.5px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0l5 6 5-6z' fill='%238b949e'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-s);
  padding: 8px 16px;
  font-family: var(--title);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  transition: all var(--t-fast);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--green);
  color: var(--green);
  box-shadow: var(--sh-glow);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }
.btn-accent {
  background: var(--green-dim);
  border-color: var(--green-d);
  color: var(--green);
}
.btn-accent:hover { background: var(--green); border-color: var(--green); color: var(--bg); box-shadow: 0 0 20px rgba(63, 185, 80, 0.2); transform: translateY(-1px); }
.btn-ghost { background: transparent; }

.kbd {
  font-family: var(--mono);
  font-size: 10px;
  background: var(--card);
  border: 1px solid var(--border-b);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  padding: 1px 6px;
  color: var(--muted);
}

/* ========== BARS / PROGRESS ========== */
.bar-row {
  display: grid;
  /* Label column floored at 0 (not 120px) so a bar row inside a narrow card
     (e.g. the 3-up categories grid at tablet/desktop widths, ~213px cards)
     shrinks and ellipsizes its label instead of forcing a 284px min-width that
     overflows the card. On wide cards 1fr already far exceeds 120px, so this is
     a no-op there. .lbl already has overflow:hidden + text-overflow:ellipsis. */
  grid-template-columns: minmax(0, 1fr) 80px 60px;
  gap: 12px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.bar-row:last-child { border-bottom: none; }
.bar-row .lbl { font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .lbl .sub { display: block; font-size: 10.5px; color: var(--muted); font-family: var(--mono); }
.bar-track {
  background: var(--bg);
  height: 6px;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}
.bar-fill {
  position: absolute; inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--green), var(--green-d));
  transition: width 600ms cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 0 2px 2px 0;
}
.bar-fill.sage   { background: linear-gradient(90deg, var(--blue), #5a8fcf); }
.bar-fill.blue   { background: linear-gradient(90deg, var(--teal), #3d8fd4); }
.bar-fill.amber  { background: linear-gradient(90deg, var(--warn), #c4952e); }
.bar-fill.violet { background: linear-gradient(90deg, var(--purple), #b07ad6); }
.bar-fill.secondary { background: linear-gradient(90deg, var(--brand-secondary), #0033cc); }
.bar-row .val {
  font-family: var(--mono);
  font-size: 11.5px;
  text-align: right;
  color: var(--text);
}
.bar-row .val .pct { display: block; font-size: 10px; color: var(--muted); }

/* ========== STAFF AVATAR ========== */
.av {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: var(--card);
  border: 1px solid var(--border-b);
  flex-shrink: 0;
}
.av-row { display: flex; align-items: center; gap: 10px; }
.av-row .name { font-weight: 600; font-size: 13px; }
.av-row .role { font-size: 10.5px; color: var(--muted); font-family: var(--mono); }

/* ========== STAT TILES ========== */
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--tile-rad, var(--r-sm));
  overflow: hidden;
}
.stat-tile {
  background: var(--card);
  padding: 14px 16px;
  transition: background var(--t-fast);
}
.stat-tile:hover { background: var(--card-h); }
.stat-tile-label {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
.stat-tile-value {
  font-family: var(--title);
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 6px;
  line-height: 1;
}
.stat-tile-value.accent { color: var(--green); }
.stat-tile-value.sage   { color: var(--blue); }
.stat-tile-value.red    { color: var(--danger); }

/* ========== CHARTS ========== */
.chart-host { width: 100%; height: 240px; position: relative; }
.chart-host.tall  { height: 320px; }
.chart-host.short { height: 160px; }
.chart-host svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-grid line { stroke: var(--border); stroke-width: 1; }
/* The class is set on the <text> elements directly (text.chart-axis), not a
   parent group, so the old `.chart-axis text` selector never matched and labels
   fell back to SVG-default black (invisible on the dark background). */
.chart-axis,
.chart-axis text {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}
.chart-bar { fill: var(--green); }
.chart-bar:hover { fill: var(--green-d); }
.chart-line { stroke: var(--green); stroke-width: 2; fill: none; }
.chart-area { fill: var(--green-soft); }
.chart-tooltip {
  position: absolute;
  background: var(--bg-deep);
  border: 1px solid var(--green-line);
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text);
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms cubic-bezier(0.16,1,0.3,1), transform 200ms cubic-bezier(0.16,1,0.3,1);
  white-space: nowrap;
  z-index: var(--z-popover);
  box-shadow: var(--sh-3), 0 0 30px rgba(1,4,9,0.8);
  transform: translateY(3px);
  line-height: 1.4;
}
.chart-tooltip.visible { opacity: 1; transform: translateY(0); }

/* ========== HEATMAP ========== */
.heatmap {
  display: grid;
  grid-template-columns: 36px repeat(24, 1fr);
  gap: 2px;
  font-family: var(--mono);
  font-size: 10px;
}
.hm-cell {
  aspect-ratio: 1.4;
  background: var(--card);
  border-radius: 2px;
  cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.hm-cell:hover {
  transform: scale(1.5);
  z-index: var(--z-raised);
  box-shadow: 0 0 0 2px var(--green);
}

/* ========== UTIL ========== */
.muted { color: var(--muted); }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--mono); }
.flex { display: flex; }
.flex-c { display: flex; align-items: center; gap: 8px; }
.flex-b { display: flex; align-items: center; justify-content: space-between; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-12 { margin-bottom: 12px; }
.right { text-align: right; }
.tabular { font-variant-numeric: tabular-nums; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ========== DESIGN-SYSTEM POLISH ==========
   Cross-cutting refinements layered on the existing component classes so every
   page (incl. the new FCR / after-hours / backlog / recurring-issues /
   data-quality / comm-deep-review / chat-presence / staff-tab sections, which
   all reuse .kpi/.card/.section/table.t/.stat-tile) reads as one product.
   Additive only -- no new markup, no palette or font change. */

/* Tabular figures: digits align in columns / KPIs / stat values so numbers
   scan cleanly and don't jitter when they update. */
.kpi-value, .stat-tile-value, .sev-dist-n, .mood-tile-value, .esc-stat-val,
.perf-row-sat, .analysis-row-sat, .improv-pct, .sev-col-lbl,
.bar-row .val, .sr-val, .wait-val, .badge,
table.t td.mono, table.t td.right, table.t th.right {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Sticky table header reads as a crisp edge while the body scrolls under it. */
table.t thead th { box-shadow: inset 0 -1px 0 var(--border-b); }

/* Keyboard focus ring on text inputs / selects, whose resting outline is none. */
.input:focus-visible,
.select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 1px;
}

/* Deep-linked tabs / sections land below the sticky utility header instead of
   being hidden behind it. */
[id] { scroll-margin-top: calc(var(--appbar-h) + 12px); }

/* Loader + skeleton */
.loader {
  display: flex; align-items: center; justify-content: center;
  padding: 80px 0;
  color: var(--muted);
  font-size: 13px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}
.loader::before {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid var(--border-b);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton-page { padding: 40px 24px; max-width: 1480px; margin: 0 auto; }
.sk-row { display: flex; gap: 12px; margin-bottom: 32px; }
.sk-card { flex: 1; height: 100px; background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md); padding: 20px; }
.sk-card-bar { height: 14px; background: var(--border); border-radius: 3px; margin-bottom: 10px; animation: sk-shimmer 1.5s ease-in-out infinite; }
.sk-card-bar:nth-child(2) { width: 60%; }
.sk-card-bar:nth-child(3) { width: 40%; }
.sk-chart { height: 240px; background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 24px; padding: 20px; }
.sk-chart-bar { height: 100%; width: 30px; background: var(--border); border-radius: 3px 3px 0 0; animation: sk-shimmer 1.5s ease-in-out infinite; display: inline-block; margin-right: 8px; vertical-align: bottom; }
@keyframes sk-shimmer {
  0% { opacity: 0.4; }
  50% { opacity: 0.8; }
  100% { opacity: 0.4; }
}

.reveal {
  opacity: 0;
  transform: translateY(8px);
  animation: reveal 500ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.reveal-1 { animation-delay: 60ms; }
.reveal-2 { animation-delay: 120ms; }
.reveal-3 { animation-delay: 180ms; }
.reveal-4 { animation-delay: 240ms; }
@keyframes reveal { to { opacity: 1; transform: translateY(0); } }

/* Pagination */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
}
.pager-actions { display: flex; gap: 6px; }
.pager-btn {
  background: var(--bg);
  border: 1px solid var(--border-b);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 4px 10px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10.5px;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.pager-btn:hover:not(:disabled) { border-color: var(--green); color: var(--green); }
.pager-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* Trajectory pills */
.traj-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.traj-pill::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted);
}
.traj-pill.resolved_satisfied::before    { background: var(--green); }
.traj-pill.unresolved_frustrated::before { background: var(--danger); }
.traj-pill.no_response::before           { background: var(--warn); }
.traj-pill.stable::before                { background: var(--blue); }
.traj-pill.improving::before             { background: var(--green); }
.traj-pill.worsening::before             { background: var(--warn); }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.donut-wrap { display: flex; gap: 24px; align-items: center; }
.donut-wrap svg { flex-shrink: 0; }
.donut-legend { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.donut-legend .li {
  display: grid; grid-template-columns: 14px 1fr auto auto; gap: 8px; align-items: center;
  font-size: 12px;
}
.donut-legend .sw { width: 10px; height: 10px; border-radius: 2px; }
.donut-legend .v { font-family: var(--mono); color: var(--text); font-size: 11px; }
.donut-legend .p { font-family: var(--mono); color: var(--muted); font-size: 10.5px; }

/* ========== STAFF DEEP-DIVE ========== */
.card.clickable {
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
.card.clickable:hover {
  border-color: var(--green);
  background: var(--card-h);
  transform: translateY(-1px);
  box-shadow: var(--sh-2);
}
.card.clickable:active { transform: translateY(0); }

.staff-header { align-items: center; }

.staff-headline {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 18px;
  margin-bottom: 24px;
  background: var(--green-soft);
  border: 1px solid var(--green-line);
  border-top: 2px solid var(--green);
  border-radius: var(--r-md);
}
.staff-headline-tag {
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--green);
  font-weight: 600;
  white-space: nowrap;
  padding-top: 3px;
}
.staff-headline-text {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  line-height: 1.55;
}

.fact-list {
  margin: 0; padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
}
.fact-list li {
  font-size: 13px;
  color: var(--text);
  padding-left: 18px;
  position: relative;
  line-height: 1.55;
}
.fact-list li::before {
  content: '◆';
  position: absolute;
  left: 0; top: 0;
  color: var(--green);
  font-size: 9px;
  line-height: 1.8;
}

.perf-panel { border-top: 2px solid transparent; }
.perf-panel.sage   { border-top-color: var(--blue); }
.perf-panel.red    { border-top-color: var(--danger); }
.perf-panel.amber  { border-top-color: var(--warn); }
.perf-panel.accent { border-top-color: var(--green); }

.perf-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.perf-row:last-child { border-bottom: none; }
.perf-row-l { min-width: 0; }
.perf-row-game { font-size: 13px; font-weight: 600; color: var(--text); }
.perf-row-meta { font-size: 10.5px; margin-top: 3px; }
.perf-row-r { text-align: right; flex-shrink: 0; }
.perf-row-sat {
  font-family: var(--title);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.perf-row-delta {
  font-family: var(--mono);
  font-size: 10.5px;
  margin-top: 2px;
}
.perf-row-delta.sage { color: var(--blue); }
.perf-row-delta.red  { color: var(--danger); }
.perf-row-delta.dim  { color: var(--muted); }

.routing-row {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.routing-row:last-child { border-bottom: none; }
.routing-rank {
  font-size: 11px;
  font-weight: 700;
  color: var(--green);
  min-width: 28px;
  padding-top: 2px;
}
.routing-row-body { flex: 1; min-width: 0; }
.routing-game { font-size: 13.5px; font-weight: 600; color: var(--text); }
.routing-meta { font-size: 10.5px; }

.improv-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.improv-row:last-child { border-bottom: none; }
.improv-label { font-size: 13px; font-weight: 600; color: var(--text); }
.improv-kind {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-top: 3px;
}
.improv-stat { text-align: right; }
.improv-pct {
  font-family: var(--title);
  font-size: 1rem;
  font-weight: 700;
  color: var(--warn);
}
.improv-pct.amber { color: var(--warn); }
.improv-pct.red   { color: var(--danger); }

.coverage-pattern {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  margin-bottom: 14px;
}
.coverage-pattern-tag {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 4px;
}
.coverage-pattern-text {
  font-size: 13px;
  color: var(--text);
}

.legend-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
}

a.card { display: block; color: inherit; text-decoration: none; }
.staff-card-cta {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  text-align: right;
  transition: color var(--t-fast);
}
a.card.clickable:hover .staff-card-cta { color: var(--green); }

.tenure-line {
  font-size: 11px;
  margin-top: 6px;
  letter-spacing: 0.4px;
  color: var(--blue);
}

.theme-only-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.theme-only-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.theme-only-label {
  font-family: var(--title);
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.theme-only-meta {
  font-size: 11px;
}

.specialty-ack {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--purple-soft);
  border: 1px solid rgba(210, 168, 255, 0.30);
  border-top: 2px solid var(--purple);
  border-radius: var(--r-sm);
}
.specialty-ack-head { margin-bottom: 10px; }
.specialty-ack-tag {
  display: block;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--purple);
  font-weight: 600;
  margin-bottom: 6px;
}
.specialty-ack-explain {
  font-size: 12px;
  color: var(--text-s);
  line-height: 1.55;
}
.specialty-ack-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 14px;
  align-items: baseline;
  padding: 6px 0;
  border-top: 1px solid rgba(210, 168, 255, 0.20);
  font-size: 12px;
}
.specialty-ack-game {
  font-family: var(--title);
  font-weight: 600;
  color: var(--text);
}
@media (max-width: 700px) {
  .specialty-ack-row { grid-template-columns: 1fr; gap: 4px; }
}

/* ========== Mood impact tiles ========== */
.mood-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  margin-bottom: 14px;
}
.mood-tile {
  background: var(--card);
  padding: 14px 16px;
}
.mood-tile-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin-bottom: 8px;
}
.mood-tile-value {
  font-family: var(--title);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
}
.mood-tile-delta {
  font-size: 11px;
  margin-top: 6px;
}
.mood-tile-delta.sage { color: var(--blue); }
.mood-tile-delta.red  { color: var(--danger); }
.mood-tile-delta.dim  { color: var(--muted); }
.mood-tile-arc {
  font-size: 10px;
  margin-top: 4px;
}
.mood-tile-sub {
  font-size: 10.5px;
  margin-top: 8px;
  line-height: 1.4;
}
.mood-footnote {
  font-size: 10.5px;
  line-height: 1.5;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin: 0;
}
@media (max-width: 800px) {
  .mood-grid { grid-template-columns: 1fr; }
}

/* ========== Distribution rates summary ========== */
.distribution-rates {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.distribution-rate {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
}
.distribution-rate-label { font-size: 10.5px; }
.distribution-rate-value { font-weight: 600; }

/* ========== STAFF DEEP-DIVE -- specialty panel ========== */
.specialties {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 28px;
}
.specialty-card {
  border-top: 2px solid var(--purple);
  background: linear-gradient(135deg, rgba(210, 168, 255, 0.06), rgba(210, 168, 255, 0.02));
}
.specialty-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.specialty-icon {
  font-size: 30px;
  width: 52px; height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--purple-soft);
  border: 1px solid rgba(210, 168, 255, 0.30);
  border-radius: var(--r-md);
  flex-shrink: 0;
}
.specialty-head-text { flex: 1; min-width: 0; }
.specialty-tag {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--purple);
  font-weight: 600;
}
.specialty-label {
  font-family: var(--title);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-top: 2px;
}
.specialty-scope {
  font-size: 11.5px;
  margin-top: 4px;
}

.specialty-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  margin-bottom: 16px;
}

.specialty-games {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.specialty-game-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 14px;
  align-items: center;
  background: var(--card);
  padding: 10px 14px;
}
.specialty-game-name {
  font-family: var(--title);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.specialty-game-stats {
  font-size: 12px;
  color: var(--text);
  line-height: 1.55;
}
.specialty-game-stats .dim { color: var(--muted); }
.specialty-note {
  font-size: 10.5px;
  color: var(--warn);
  margin-top: 4px;
}

@media (max-width: 700px) {
  .specialty-stats { grid-template-columns: 1fr; }
  .specialty-game-row { grid-template-columns: 1fr; gap: 4px; }
}

/* ========== STAFF DEEP-DIVE -- coaching cards ========== */
.coaching-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.coaching-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 2px solid var(--green);
  border-radius: var(--r-md);
  padding: 16px 18px;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.coaching-card:hover { background: var(--card-h); }
.coaching-card.sage   { border-top-color: var(--blue); }
.coaching-card.amber  { border-top-color: var(--warn); }
.coaching-card.red    { border-top-color: var(--danger); }

.coaching-card-tag {
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}
.coaching-card-title {
  font-family: var(--title);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}
.coaching-card-body {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-s);
}

/* ========== STAFF DEEP-DIVE -- analysis rows (strengths/weaknesses) ========== */
.analysis-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.analysis-row:last-child { border-bottom: none; }
.analysis-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.analysis-row-l { min-width: 0; flex: 1; }
.analysis-row-game {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.analysis-row-meta { font-size: 10.5px; margin-top: 3px; }
.analysis-row-r { text-align: right; flex-shrink: 0; }
.analysis-row-sat {
  font-family: var(--title);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}
.analysis-row-delta {
  font-family: var(--mono);
  font-size: 10.5px;
  margin-top: 2px;
}
.analysis-row-delta.sage { color: var(--blue); }
.analysis-row-delta.red  { color: var(--danger); }
.analysis-row-delta.dim  { color: var(--muted); }

.analysis-themes {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.analysis-themes-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 6px;
}
.analysis-themes-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pair-with-hint {
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--teal-soft);
  border: 1px solid rgba(88, 166, 255, 0.30);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--text);
}
.pair-with-tag {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--blue);
  font-weight: 600;
  margin-right: 6px;
}

.analysis-examples-toggle {
  margin-top: 10px;
  background: transparent;
  border: 1px dashed var(--border-b);
  border-radius: var(--r-sm);
  color: var(--muted);
  padding: 6px 12px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  width: 100%;
  text-align: left;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.analysis-examples-toggle:hover {
  color: var(--green);
  border-color: var(--green-line);
}
.analysis-examples {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

.ticket-example {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.ticket-example:last-child { border-bottom: none; }
.ticket-example-l { min-width: 0; flex: 1; }
.ticket-example-channel {
  font-size: 11.5px;
  color: var(--text);
  font-weight: 600;
  word-break: break-all;
}
.ticket-example-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

/* ========== STAFF DEEP-DIVE -- routing rows ========== */
.routing-reason {
  font-size: 12px;
  color: var(--text);
  margin-top: 6px;
  line-height: 1.5;
}
.routing-caveat {
  margin-top: 8px;
  padding: 6px 10px;
  background: var(--warn-soft);
  border: 1px solid rgba(227, 179, 65, 0.30);
  border-radius: var(--r-sm);
  font-size: 11.5px;
  color: var(--text);
  line-height: 1.5;
}
.routing-caveat-tag {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--warn);
  font-weight: 600;
}

/* ========== STAFF DEEP-DIVE -- severity / SLA ========== */
.severity-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 18px;
  margin-top: 14px;
}
.sla-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  margin-bottom: 14px;
}
.sla-vs-team {
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 11.5px;
}

/* Long unbreakable strings (Discord URLs, pasted IDs) must wrap instead of
   forcing their container -- and therefore the whole page -- wider than the
   viewport. No-op for normal prose; only bites unbreakable tokens. */
.wrap-anywhere { overflow-wrap: anywhere; word-break: break-word; }

/* ========== STAFF DEEP-DIVE -- working-pattern activity heatmap ========== */
/* Built from inline flex rows in page-staff-detail.js (dowHeatmap). Desktop is
   the original 28px label + 24 × 14px cells; the phone breakpoint (≤640px)
   shrinks the columns so all 24 hours fit instead of overflowing the card. */
.wp-heatmap { margin-top: 12px; }
.wp-heatmap-inner { min-width: 420px; }
.wp-hm-row { display: flex; align-items: center; gap: 1px; margin-bottom: 1px; }
.wp-hm-label {
  width: 28px;
  flex-shrink: 0;
  font-size: 9.5px;
  color: var(--text-s);
}
.wp-hm-tick {
  width: 14px;
  flex-shrink: 0;
  font-size: 8px;
  color: var(--text-faint);
  text-align: center;
}
.wp-hm-cell {
  width: 14px;
  height: 16px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ========== STAFF DEEP-DIVE -- full game/theme tables ========== */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.table-toolbar .input { width: auto; flex: 1; max-width: 320px; }

.lc-badge {
  font-size: 9.5px;
  color: var(--muted);
  font-weight: 500;
  margin-left: 4px;
}

.theme-ctx-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.section-meta.sage { color: var(--blue); }
.section-meta.red  { color: var(--danger); }

table.t td.dim   { color: var(--muted); }
table.t td .sage { color: var(--blue); }
table.t td .red  { color: var(--danger); }

/* ========== SUBTABS (in-page tab nav, used on Ops) ========== */
.subtab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.subtab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 10px 18px;
  font-family: var(--title);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  cursor: pointer;
  position: relative;
  transition: color var(--t-fast);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.subtab:hover { color: var(--text); }
.subtab.active {
  color: var(--green);
  border-bottom-color: var(--green);
}

/* ========== APP SHELL -- responsive (icon rail + off-canvas drawer) ========== */

/* Tablet (768-1023px): collapsed icon rail; hover or keyboard focus expands it
   as an overlay (content does not reflow -- body padding stays at the rail min). */
@media (max-width: 1023.98px) {
  body { padding-left: var(--rail-w-min); }
  .app-sidebar { width: var(--rail-w-min); }
  .app-sidebar .nav-label,
  .app-sidebar .app-brand-text,
  .app-sidebar .app-nav-foot { opacity: 0; pointer-events: none; }
  .app-sidebar .nav-caption { opacity: 0; height: 0; padding-top: 0; padding-bottom: 0; }

  .app-sidebar:hover,
  .app-sidebar:focus-within {
    width: var(--rail-w);
    box-shadow: 10px 0 28px rgba(0, 0, 0, 0.55);
  }
  .app-sidebar:hover .nav-label,
  .app-sidebar:hover .app-brand-text,
  .app-sidebar:hover .app-nav-foot,
  .app-sidebar:focus-within .nav-label,
  .app-sidebar:focus-within .app-brand-text,
  .app-sidebar:focus-within .app-nav-foot { opacity: 1; pointer-events: auto; }
  .app-sidebar:hover .nav-caption,
  .app-sidebar:focus-within .nav-caption { opacity: 1; height: auto; padding: 6px 20px; }
}

/* Phone (<768px): sidebar becomes an off-canvas drawer toggled by the hamburger. */
@media (max-width: 767.98px) {
  body { padding-left: 0; }
  .app-sidebar {
    width: var(--rail-w);
    max-width: 86vw;
    transform: translateX(-100%);
    z-index: var(--z-drawer);
    border-right: 1px solid var(--border-b);
    box-shadow: 10px 0 32px rgba(0, 0, 0, 0.6);
  }
  body.menu-open .app-sidebar { transform: translateX(0); }
  /* Drawer always shows full labels -- undo the rail collapse above. */
  .app-sidebar .nav-label,
  .app-sidebar .app-brand-text,
  .app-sidebar .app-nav-foot { opacity: 1; pointer-events: auto; }
  .app-sidebar .nav-caption { opacity: 1; height: auto; padding: 6px 20px; }

  .menu-btn { display: inline-flex; }
  .drawer-close { display: inline-flex; }
  .appbar-inner { padding: 0 16px; gap: 10px; }
  .appbar-title { font-size: 0.98rem; }
  .appbar-meta { gap: 12px; }
  .live-full { display: none; }
  .live-compact { display: inline-block; margin-left: 2px; color: var(--text); }
}

/* Honor reduced-motion: animations/transitions/scroll resolve effectively
   instantly across the whole product (standard universal reset), with the
   shell pieces and the pulsing live-dot called out explicitly. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .app-sidebar, .app-scrim, .skip-link,
  .nav-item, .nav-label, .nav-caption,
  .app-brand-text, .app-nav-foot { transition: none !important; }
  .live-dot { animation: none !important; }
}

/* ========== MOBILE BREAKPOINT -- content density ========== */
@media (max-width: 860px) {
  .tz-select { font-size: 10px; padding: 1px 18px 1px 5px; }

  .page { padding: 20px 14px 60px; }
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    margin-bottom: 22px;
    padding-bottom: 16px;
  }
  .page-title { font-size: 1.4rem; }
  .page-subtitle { font-size: 12.5px; }

  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 22px; }
  .kpi { padding: 14px 14px; }
  .kpi-value { font-size: 1.3rem; }
  .kpi-label { font-size: 9.5px; margin-bottom: 10px; }

  .grid-2, .grid-3, .grid-4, .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; gap: 12px; }

  .card { padding: var(--sp-4); }
  .stat-tiles { grid-template-columns: repeat(2, 1fr); }

  .donut-wrap { flex-direction: column; align-items: stretch; gap: 14px; }
  .donut-wrap > .chart-host { align-self: center; }

  .search-bar { gap: 6px; }
  .search-bar .input,
  .search-bar .select { min-width: 0; flex: 1 1 140px; max-width: none; }
  .search-bar .input[type="date"] { flex-basis: 130px; }

  /* Page-header control rows (staff "sort" select, users "tier" filter) are a
     plain .flex-c holding an .input with an inline min-width:220px plus a select.
     On a phone 220 + gap + select exceeds the viewport and .flex-c does not wrap,
     so the row pushes the page wider. Let the row wrap and the input shrink
     (the inline min-width needs !important to override). */
  .page-header .flex-c { flex-wrap: wrap; }
  .page-header .flex-c > .input { min-width: 0 !important; flex: 1 1 160px; }

  .table-wrap.scroll { max-height: 60vh; }
  table.t thead th, table.t tbody td { padding: 8px 10px; font-size: 11.5px; }
  table.t td.mono, table.t th.mono { font-size: 10.5px; }

  /* Real <table class="t"> wrappers: the base rule is overflow:hidden (so the
     sticky-header sits inside the rounded corners). On mobile a wide table
     would be clipped -- relax to horizontal scroll instead. */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap.scroll { overflow: auto; }

  /* Sub-tab navigation scrolls horizontally instead of wrapping into several
     rows. Two strips exist: the Ops in-page .subtab-bar and the inline-styled
     .sub-tab-strip built in app.js (width:fit-content → needs the override). */
  .subtab-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .subtab-bar::-webkit-scrollbar { display: none; }
  .subtab { flex: 0 0 auto; padding: 10px 14px; }

  .sub-tab-strip {
    width: auto !important;
    max-width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .sub-tab-strip::-webkit-scrollbar { display: none; }
  .sub-tab-strip > .sub-tab { flex: 0 0 auto; white-space: nowrap; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .stat-tiles { grid-template-columns: 1fr 1fr; }
}

/* ========== MOBILE: dense inline-grid "tables" + summary grids (≤640px) ==========
   The Ops sub-pages (severity-routing, playbook, coverage, people, playbook
   game-detail) don't use <table class="t"> -- they build tables out of nested
   <div style="display:grid; grid-template-columns: …px …fr">. Those inline
   templates mix fixed-px columns with fr columns, so at phone widths the fr
   columns collapse to ~0 and cells wrap into the next column (the reported
   "Suggested alt claimers" bug). The shared table.t media rules can't reach
   inline styles, so each such table is wrapped in `.xscroll` in its page JS.   */

/* Wrapper: scroll its (single) child horizontally. Unconditional overflow so a
   genuinely-wide table (hard-px columns whose sum already exceeds the viewport,
   e.g. the game×severity matrix) scrolls at any width. Inert on desktop -- a
   child narrower than the viewport never produces a scrollbar, and the
   min-width floor below only applies at phone widths. */
.xscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Categories grids (cat-grid-two / cat-grid-three) are inline-styled CSS grids
   whose cards hold wide content -- a 6-column handler table and nowrap bar
   labels. Without min-width:0 the grid items keep the default min-width:auto, so
   each track grows to its content's min-content size and the grid blows past the
   viewport at EVERY width (measured: 1310px content @ 1024 viewport). min-width:0
   lets the cards shrink so the table scrolls inside its own overflow-x:auto
   wrapper and the bar labels ellipsis. */
.cat-grid-two > *, .cat-grid-three > * { min-width: 0; }

/* The 3-up categories grid is too cramped for bar-row labels in the tablet band
   (≈641–900px each card is ~210px and labels ellipsize to a single glyph). Drop
   to 2-up there so labels stay readable; ≤640px collapses to 1-up below. */
@media (max-width: 900px) {
  .cat-grid-three { grid-template-columns: 1fr 1fr !important; }
}

@media (max-width: 640px) {
  /* Floor the wrapped table's width so its fr columns keep a readable size and
     the whole table scrolls as one aligned unit (header tracks with body).
     Pages override --xt for wider tables (matrix, heatmap, alt-claimers, …). */
  .xscroll > * { min-width: var(--xt, 640px); }

  /* Collapse inline multi-column *summary* grids (cards, not tables). They set
     grid-template-columns inline, so the class override needs !important. */
  .mcol1 { grid-template-columns: 1fr !important; }
  .mcol2 { grid-template-columns: 1fr 1fr !important; }
  /* Categories page two/three-up card rows (classed, but inline template). */
  .cat-grid-two, .cat-grid-three { grid-template-columns: 1fr !important; }

  /* Two-column text grids that read fine stacked on a phone. */
  .fact-list { grid-template-columns: 1fr; }
  .severity-legend { grid-template-columns: 1fr; }

  /* Shave oversized desktop padding/margins so content gets more width. */
  .section { margin-bottom: var(--sp-6); }
  .card { padding: var(--sp-4); }

  /* SLA / stat-tile grids on the staff deep-dive (working pattern, severity,
     de-escalation, comm style) are repeat(3,1fr); 3-up clips labels on a phone
     ("AVG ACTIVE HOURS/DAY" → "ACTIVE S/DAY"). Drop to 2-up so labels fit. */
  .sla-grid { grid-template-columns: 1fr 1fr; }

  /* Activity heatmap: fit all 24 hour-columns inside the viewport instead of
     the 420px desktop row. Neutralise the .xscroll 640px floor, drop the inner
     min-width, and let the ticks/cells flex to share the row width -- so the
     coloured cells stay visible rather than collapsing into an empty box. */
  .wp-heatmap.xscroll > * { min-width: 0; }
  .wp-heatmap-inner { min-width: 0; width: 100%; }
  .wp-hm-label { width: 20px; font-size: 8px; }
  .wp-hm-tick { font-size: 7px; }
  .wp-hm-tick,
  .wp-hm-cell { flex: 1 1 0; min-width: 0; width: auto; }
  .wp-hm-cell { height: 14px; }
}

/* ========== SEVERITY & COMPLEXITY HUB (Ops → Severity) ==========
   All components here are built by page-ops-severity-routing.js via safe DOM
   construction (no innerHTML). Wide tables ride .table-wrap / .xscroll; the
   stacked-column and heatmap blocks are wrapped in .xscroll (--xt) so they
   scroll as one unit on phones instead of squashing their fr columns to ~0. */

/* Distribution / aggregate cells -- auto-fit so they reflow without media queries. */
.sev-dist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.sev-dist-cell { background: var(--card); padding: 13px 15px; }
.sev-dist-k {
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}
.sev-dist-n {
  font-family: var(--title);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-top: 6px;
  line-height: 1;
}
.sev-dist-p { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Horizontal stacked severity bar (table cells, distribution, aggregates). */
.sev-stack {
  display: flex;
  height: 12px;
  min-width: 90px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
}
.sev-seg { height: 100%; min-width: 1px; }

/* Legend. */
.sev-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-dim);
  margin-top: 10px;
}
.sev-legend + .table-wrap { margin-top: 12px; }
.sev-leg-item { display: inline-flex; align-items: center; gap: 5px; }
.sev-sw { width: 9px; height: 9px; border-radius: 2px; display: inline-block; flex-shrink: 0; }

/* Vertical stacked columns (month / hour). */
.sev-cols { display: flex; align-items: flex-end; gap: 6px; }
.sev-col { flex: 1 1 0; min-width: 14px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.sev-col-track { width: 100%; height: var(--colh, 150px); display: flex; align-items: flex-end; }
.sev-col-stack {
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.sev-col-seg { width: 100%; }
.sev-col-lbl {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--text-dim);
  white-space: nowrap;
  min-height: 12px;
}

/* Single-metric rate rows (abandons, by-DOW). */
.sr-row {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.sr-row:last-child { border-bottom: none; }
.sr-label { font-family: var(--mono); font-size: 11.5px; font-weight: 600; }
.sr-track {
  position: relative;
  height: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.sr-fill { position: absolute; inset: 0 auto 0 0; border-radius: 0 3px 3px 0; transition: width 600ms cubic-bezier(0.16, 1, 0.3, 1); }
.sr-val { font-family: var(--mono); font-size: 11.5px; text-align: right; white-space: nowrap; }

/* Wait-by-severity rows -- p90 ghost + median fill + S4 baseline reference line. */
.wait-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 10.5px; align-items: center; margin-bottom: 12px; }
.wait-key { display: inline-block; width: 14px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.wait-key.med { background: var(--blue); }
.wait-key.p90 { background: var(--surface-3); }
.wait-key.ref { width: 2px; height: 12px; background: var(--text); border-radius: 0; }
.wait-row {
  display: grid;
  grid-template-columns: 150px 1fr 230px;
  gap: 14px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.wait-row:last-child { border-bottom: none; }
.wait-lbl { font-family: var(--mono); font-size: 11.5px; font-weight: 600; }
.wait-n { font-weight: 400; }
.wait-track {
  position: relative;
  height: 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: visible;
}
.wait-p90 { position: absolute; top: 0; bottom: 0; left: 0; background: var(--surface-3); border-radius: 3px; }
.wait-med { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 3px; }
.wait-ref { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: 0.6; }
.wait-val { font-family: var(--mono); font-size: 11px; text-align: right; white-space: nowrap; }
.wait-bad { color: var(--warn); font-weight: 700; }

/* Callout banners (wait inversion, abandon alarm). */
.sev-callout {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 18px;
  margin-bottom: 16px;
  border-radius: var(--r-md);
  background: var(--warn-soft);
  border: 1px solid rgba(227, 179, 65, 0.30);
  border-top: 2px solid var(--warn);
}
.sev-callout.red {
  background: var(--danger-soft);
  border-color: rgba(248, 81, 73, 0.30);
  border-top-color: var(--danger);
}
.sev-callout-tag {
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 700;
  white-space: nowrap;
  padding-top: 3px;
  color: var(--warn);
}
.sev-callout.red .sev-callout-tag { color: var(--danger); }
.sev-callout-text { font-size: 13.5px; line-height: 1.55; color: var(--text); }

/* Fires -- danger tables with linked ticket chips. */
.fire-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.fire-row:last-child { border-bottom: none; }
.fire-name { font-size: 13px; font-weight: 600; color: var(--text); }
.fire-r { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.fire-ex { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.fire-tix {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  background: var(--bg);
  border: 1px solid var(--border-b);
  color: var(--blue);
  transition: border-color var(--t-fast), color var(--t-fast);
}
.fire-tix:hover { border-color: var(--green); color: var(--green); }

/* Low-sample rows in the rank tables. */
.sev-lown td { opacity: 0.6; }

/* Severity × complexity heatmap. */
.cx-heat { display: grid; grid-template-columns: 64px repeat(3, 1fr); gap: 4px; }
.cx-head {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  text-align: center;
  padding: 4px 0;
}
.cx-rowlbl { font-family: var(--mono); font-size: 12px; font-weight: 600; display: flex; align-items: center; }
.cx-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
}
.sev-partial-note {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-s);
  background: var(--warn-soft);
  border: 1px solid rgba(227, 179, 65, 0.30);
  border-top: 2px solid var(--warn);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  margin-bottom: 14px;
}

@media (max-width: 640px) {
  /* Wait rows stack: label → track → values, full width each. */
  .wait-row { grid-template-columns: 1fr; gap: 5px; }
  .wait-val { text-align: left; }
  /* Single-metric rate rows keep their 3-col layout but tighten the label gutter. */
  .sr-row { grid-template-columns: 78px 1fr auto; gap: 10px; }
  /* Complexity heatmap: shrink the row-label gutter so the 3 value columns fit. */
  .cx-heat { grid-template-columns: 44px repeat(3, 1fr); }
}

/* ============================================================================
   ESCALATIONS PAGE (page-escalated.js)
   Dedicated deep-dive on every escalated ticket. All nodes are built via safe
   DOM construction (no innerHTML). The big enumeration table rides
   .table-wrap > .xscroll (--xt:1040px) so it scrolls as one unit on phones;
   summary grids collapse via .mcol1 / .mcol2; long snippets/ids use
   .wrap-anywhere. Reuses app.css vars + .card / .kpi / .badge / .traj-pill.
   ========================================================================== */

/* Signal-mix stat tiles */
.esc-stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 2px solid var(--tile, var(--accent));
  border-radius: var(--r-md);
  padding: 14px 16px;
}
.esc-stat-val { font-family: var(--mono); font-size: 1.6rem; font-weight: 600; line-height: 1; }
.esc-stat-label { font-size: 12px; font-weight: 600; margin-top: 8px; color: var(--text); }
.esc-stat-sub { font-size: 11px; margin-top: 3px; }

/* Escalation-rate trend host (custom decimal-faithful line chart) */
.esc-rate-host { width: 100%; height: 240px; position: relative; margin-top: 8px; }

/* Outcome trajectory mini stacked bar */
.esc-mstack {
  display: flex; width: 100%; height: 22px; border-radius: 5px;
  overflow: hidden; background: var(--surface); border: 1px solid var(--border);
}
.esc-mseg { height: 100%; }
.esc-mlegend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.esc-mleg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.esc-mleg .mono { font-size: 11px; }
.esc-msw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex-shrink: 0; }

/* ----- Deep-dive table ----- */
table.t.esc-table tbody td { padding: 9px 11px; vertical-align: middle; }
table.t.esc-table thead th { white-space: nowrap; }

.esc-row { cursor: pointer; transition: background var(--t-fast, 120ms); }
.esc-row:hover { background: var(--card-h); }
.esc-row.open { background: var(--accent-soft); }

.esc-caret {
  display: inline-block; width: 12px; color: var(--text-dim);
  font-size: 10px; transition: transform 140ms ease; margin-right: 6px;
}
.esc-caret.open { transform: rotate(90deg); color: var(--accent); }

.esc-link { color: var(--accent); text-decoration: none; font-weight: 500; }
.esc-link:hover { text-decoration: underline; }

/* Ticket cell: link with the escalation reason wrapped beneath it. */
.esc-tcell { display: inline-block; vertical-align: top; max-width: 240px; }
.esc-reason { display: block; font-size: 10px; line-height: 1.35; margin-top: 2px; white-space: normal; }

/* Severity pill -- colour driven by inline style var per row */
.esc-sev {
  display: inline-block; font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  padding: 2px 7px; border-radius: 4px; border: 1px solid; white-space: nowrap;
}
/* Escalation-signal chip */
.esc-sig {
  display: inline-block; font-family: var(--mono); font-size: 9.5px;
  padding: 1px 5px; border-radius: 3px; border: 1px solid; background: transparent;
}
.esc-outcome { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }

/* ----- Expanded detail row ----- */
/* Specificity (0,2,4) clears both `table.t tbody td` and `table.t.esc-table
   tbody td` without !important; the expanded detail row owns its own padding. */
table.t tbody tr.esc-xrow > td { padding: 0; background: var(--bg-deep); border-bottom: 1px solid var(--border); }
.esc-xpanel {
  padding: 14px 16px 16px;
  border-top: 2px solid var(--accent);
  background: var(--surface);
}
.esc-xhead {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
  padding-bottom: 10px; border-bottom: 1px dashed var(--border);
}
.esc-detail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px 18px;
}
.esc-dblock.wide { grid-column: 1 / -1; }
.esc-dlabel {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim); font-weight: 700; margin-bottom: 4px;
}
.esc-dval { font-size: 12.5px; line-height: 1.55; color: var(--text); }
.esc-snippet {
  display: block; font-style: italic; color: var(--text-s);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  line-height: 1.6;
  margin-top: 4px;
}

@media (max-width: 640px) {
  .esc-stat-val { font-size: 1.3rem; }
  .esc-stat { padding: 12px 12px; }
  .esc-rate-host { height: 210px; }
  /* esc-detail auto-fits already; keep blocks readable on narrow panels. */
  .esc-detail { grid-template-columns: 1fr 1fr; gap: 10px 12px; }
}

/* ========== INFO AFFORDANCE (i) ========== */
/* Replaces always-on explainer paragraphs. Hover / focus / tap reveals terse copy. */
.info-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 6px;
  cursor: help;
  outline: none;
}
.info-tip-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border: 1px solid var(--text-faint);
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  font-style: normal;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1;
  color: var(--text-dim);
  transition: color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.info-tip:hover .info-tip-ic,
.info-tip:focus .info-tip-ic,
.info-tip:focus-visible .info-tip-ic {
  color: var(--accent);
  border-color: var(--accent);
}
.info-tip:focus-visible .info-tip-ic {
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.info-tip-bubble {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: var(--z-popover);
  width: max-content;
  max-width: min(340px, 80vw);
  padding: 9px 11px;
  background: var(--surface);
  border: 1px solid var(--border-b);
  border-radius: var(--r-md);
  box-shadow: var(--sh-2);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 400;
  font-style: normal;
  line-height: 1.6;
  letter-spacing: 0;
  text-transform: none;
  text-align: left;
  white-space: normal;
  color: var(--text-dim);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity var(--t-fast), transform var(--t-fast);
  pointer-events: none;
}
.info-tip.tip-right .info-tip-bubble { left: auto; right: 0; }
.info-tip:hover .info-tip-bubble,
.info-tip:focus .info-tip-bubble,
.info-tip:focus-within .info-tip-bubble {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
  .info-tip-bubble { transition: none; transform: none; }
}

/* ========== OVERVIEW -- outcome resolution x sentiment heatmap ==========
   3x3 grid: rows = resolution (Resolved/Partial/Unresolved), columns = sentiment
   (Satisfied/Neutral/Frustrated), plus a trailing row of column-totals and a
   trailing column of row-totals (the marginal mix). Cell fill is keyed to an
   outcome-health score (.heat-s4..s0) so the green->red corner diagonal reads at
   a glance; fills are low-alpha so the tabular figures stay legible on dark. */
.outcome-heat {
  display: grid;
  grid-template-columns: minmax(56px, auto) repeat(3, minmax(0, 1fr)) minmax(46px, auto);
  gap: 4px;
  font-variant-numeric: tabular-nums;
}
.heat-corner { min-height: 18px; }
.heat-h, .heat-rh, .heat-foot-h {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  display: flex;
  align-items: center;
}
.heat-h { justify-content: center; text-align: center; padding-bottom: 2px; }
.heat-rh { justify-content: flex-start; padding-right: 6px; }
.heat-h.heat-mix-h, .heat-foot-h { color: var(--text-dim); justify-content: center; }

/* The 9 data cells. */
.heat-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  position: relative;
  min-height: 58px;
  padding: 10px 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  text-align: center;
}
.heat-cell .hc-n {
  font-family: var(--title);
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--text);
}
.heat-cell .hc-p {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

/* Score -> red/amber/green. Low-alpha rgba (literal, since the score steps need
   five distinct intensities the soft tokens don't cover) keeps text readable. */
.heat-s4 { background: rgba(63, 185, 80, 0.24); border-color: var(--green-line); }
.heat-s3 { background: rgba(63, 185, 80, 0.13); border-color: var(--green-line); }
.heat-s2 { background: rgba(227, 179, 65, 0.17); border-color: rgba(227, 179, 65, 0.32); }
.heat-s1 { background: rgba(248, 81, 73, 0.13); border-color: rgba(248, 81, 73, 0.30); }
.heat-s0 { background: rgba(248, 81, 73, 0.26); border-color: rgba(248, 81, 73, 0.46); }

/* Watch cell (Resolved x Frustrated) -- the false-resolution signal. */
.heat-watch { border: 1.5px dashed var(--warn); box-shadow: inset 0 0 0 1px var(--warn-soft); }
.heat-watch .hc-watch {
  position: absolute;
  top: 3px; right: 4px;
  display: inline-flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--warn);
}
.heat-watch .hc-watch .info-tip { margin-left: 3px; }
.heat-watch .hc-watch .info-tip-ic { width: 12px; height: 12px; font-size: 8px; }

/* Marginal totals (row + column) + grand total -- lighter, set apart from the 9. */
.heat-tot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px dashed var(--border-b);
}
.heat-tot .hc-n { font-family: var(--title); font-weight: 700; font-size: 14px; line-height: 1; color: var(--text-s); }
.heat-tot .hc-p { font-family: var(--mono); font-size: 9px; color: var(--text-dim); }
.heat-grand { background: var(--card-h); border-style: solid; }
.heat-grand .hc-n { color: var(--text); }

/* Phone: shrink fixed tracks, padding and figures so 3x3 + margins fit ~375px. */
@media (max-width: 560px) {
  .outcome-heat {
    gap: 3px;
    grid-template-columns: minmax(40px, auto) repeat(3, minmax(0, 1fr)) minmax(34px, auto);
  }
  .heat-cell { min-height: 48px; padding: 7px 3px; }
  .heat-cell .hc-n { font-size: 15px; }
  .heat-cell .hc-p { font-size: 9px; }
  .heat-h, .heat-rh, .heat-foot-h { font-size: 8px; letter-spacing: 0.3px; }
  .heat-tot { padding: 6px 2px; }
  .heat-tot .hc-n { font-size: 12px; }
}
