/* ═══════════════════════════════════════════════════════════════════
   CONTROL ROOM — staff portal design system (2026-11 revamp)
   Scoped to body[data-portal="staff"]; the client portal never sees a
   single rule here. Strategy: re-declare the shared --color-* tokens with
   the Control Room palette (components inherit automatically), then restyle
   the shell, rail, bands, panels, tables, and ops controls.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Palette: light staff ─────────────────────────────────────────── */
body[data-portal="staff"] {
  --color-bg: #EDF1F7;
  --color-bg-alt: #E4EAF3;
  --color-surface: #FFFFFF;
  --color-surface-hover: #EAF1FA;
  --color-surface-subtle: #F3F7FC;
  --color-border: #CBD8E8;
  --color-text: #0A1626;
  --color-text-muted: #3F5470;
  --color-text-subtle: #5B7089;
  --color-accent: #0072CE;
  --color-success: #00875A;
  --color-danger: #C81E32;
  --color-warning: #9A6700;
  --cr-rail-bg: #0A1626;
  --cr-rail-line: #1C2C42;
  --cr-rail-text: #C7D6E8;
  --cr-rail-faint: #94AAC4;
  --cr-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

/* ── Palette: dark staff — deep ops console ──────────────────────── */
:root[data-theme="dark"] body[data-portal="staff"] {
  --color-bg: #05080D;
  --color-bg-alt: #0A0F17;
  --color-surface: #0D1420;
  --color-surface-hover: #14202F;
  --color-surface-subtle: #101A28;
  --color-border: #1E2C42;
  --color-text: #E8F0FB;
  --color-text-muted: #B6C6DB;
  --color-text-subtle: #90A8C4;
  --color-accent: #4CC2FF;
  --color-primary: #4CC2FF;
  --color-primary-light: #7DD6FF;
  --color-success: #2FE08A;
  --color-danger: #FF5D6C;
  --color-warning: #FFC74D;
  --cr-rail-bg: #070C13;
  --cr-rail-line: #16233A;
}
:root[data-theme="dark"] body[data-portal="staff"] .btn-primary { color: #031320; }

/* ═══ Shell: rail + full-bleed column ═══════════════════════════════ */
body[data-portal="staff"] .app-frame {
  display: grid;
  grid-template-columns: 15.5rem minmax(0, 1fr);
  align-items: start;
  width: 100%;
  max-width: none;
}
body[data-portal="staff"] .site-header { display: none; }
body[data-portal="staff"] .app-main {
  max-width: none;
  margin: 0;
  width: 100%;
  min-width: 0;
  padding: 1.4rem 1.75rem 2.6rem;
}
body[data-portal="staff"] .site-footer {
  border-top: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-subtle);
  font-size: 0.74rem;
}

/* ═══ Rail ═══════════════════════════════════════════════════════════ */
.cr-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--cr-rail-bg);
  border-right: 1px solid var(--cr-rail-line);
  color: var(--cr-rail-text);
  scrollbar-width: thin;
}
.cr-rail-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.05rem 1.1rem 0.8rem;
}
.cr-rail-mark { width: 1.9rem; height: 1.9rem; border-radius: 0.55rem; }
.cr-rail-name { font-weight: 700; letter-spacing: -0.01em; color: #F2F7FF; font-size: 1.02rem; }
.cr-rail-env {
  margin-left: auto;
  font: 700 0.58rem/1 inherit;
  letter-spacing: 0.14em;
  color: var(--color-accent);
  border: 1px solid color-mix(in srgb, var(--color-accent) 40%, transparent);
  background: color-mix(in srgb, var(--color-accent) 10%, transparent);
  padding: 0.3rem 0.42rem;
  border-radius: 0.3rem;
}
.cr-rail-caption {
  padding: 0 1.1rem 0.85rem;
  font-size: 0.66rem;
  color: var(--cr-rail-faint);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.cr-rail-nav { display: flex; flex-direction: column; }
.cr-rail-sec {
  padding: 1.05rem 1.1rem 0.35rem;
  color: #9FB3CB;
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  color: var(--cr-rail-faint);
  text-transform: uppercase;
  font-weight: 800;
}
.cr-nav-a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1.1rem;
  color: #A9BCD3;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  border-left: 2px solid transparent;
}
.cr-nav-a:hover { background: color-mix(in srgb, var(--color-accent) 8%, transparent); color: #FFFFFF; text-decoration: none; }
.cr-nav-a.on {
  background: linear-gradient(90deg, color-mix(in srgb, var(--color-accent) 14%, transparent), transparent);
  color: #FFFFFF;
  border-left-color: var(--color-accent);
}
.cr-ico { width: 1.05rem; height: 1.05rem; flex: none; opacity: 0.85; }
.cr-rail-fleet {
  margin-top: auto;
  padding: 0.95rem 1.1rem 0.8rem;
  border-top: 1px solid var(--cr-rail-line);
}
.cr-rail-fleet h3 {
  color: #9FB3CB;
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  color: var(--cr-rail-faint);
  text-transform: uppercase;
  margin-bottom: 0.55rem;
}
.cr-srv {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.4rem 0;
  font-size: 0.78rem;
  color: #B8C9DD;
}
.cr-srv-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--color-success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-success) 18%, transparent);
}
.cr-srv-dot.w { background: var(--color-warning); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-warning) 18%, transparent); }
.cr-srv-dot.b { background: var(--color-danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-danger) 18%, transparent); }
.cr-srv-load { font-family: var(--cr-mono); font-size: 0.68rem; color: var(--cr-rail-faint); }
.cr-srv-load.hot { color: var(--color-warning); }
.cr-rail-fleet-idle { font-size: 0.72rem; color: var(--cr-rail-faint); }
.cr-rail-foot {
  padding: 0.7rem 1.1rem;
  border-top: 1px solid var(--cr-rail-line);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.78rem;
  color: #8FA4BF;
  min-width: 0;
}
.cr-avatar {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: #23405E;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #CFE3F8;
  flex: none;
}
.cr-rail-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-rail-theme {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--cr-rail-line);
  color: #8FA4BF;
  border-radius: 0.4rem;
  width: 1.9rem;
  height: 1.9rem;
  cursor: pointer;
  flex: none;
}
.cr-rail-theme:hover { color: #FFFFFF; border-color: #3A5170; }
.cr-rail-signout { padding: 0 1.1rem 1rem; }
.cr-rail-signout button {
  width: 100%;
  background: transparent;
  border: 1px solid var(--cr-rail-line);
  color: var(--cr-rail-faint);
  border-radius: 0.45rem;
  padding: 0.42rem 0.6rem;
  font: 600 0.74rem inherit;
  cursor: pointer;
}
.cr-rail-signout button:hover { color: #FFD9DD; border-color: color-mix(in srgb, var(--color-danger) 50%, var(--cr-rail-line)); }

/* ═══ Page header → console strip ═══════════════════════════════════ */
body[data-portal="staff"] .page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 0.9rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-border);
}
body[data-portal="staff"] .page-header .eyebrow {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--color-text-subtle);
}
body[data-portal="staff"] .page-header h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.025em; }
body[data-portal="staff"] .page-header .text-muted { font-size: 0.84rem; }

/* ═══ KPI band: single bordered strip, mono values ═════════════════ */
body[data-portal="staff"] .stats-grid.dashboard-stats,
body[data-portal="staff"] .stats-grid.ops-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  border: 1px solid var(--color-border);
  border-radius: 0.65rem;
  background: var(--color-surface);
  overflow: hidden;
  gap: 0;
  margin-bottom: 1.15rem;
}
body[data-portal="staff"] .stats-grid.dashboard-stats .stat-card,
body[data-portal="staff"] .stats-grid.ops-stats .stat-card {
  border: 0;
  border-right: 1px solid color-mix(in srgb, var(--color-border) 55%, transparent);
  background: transparent;
  border-radius: 0;
  padding: 0.85rem 1rem;
  min-width: 0;
}
body[data-portal="staff"] .stats-grid.dashboard-stats .stat-card:last-child,
body[data-portal="staff"] .stats-grid.ops-stats .stat-card:last-child { border-right: 0; }
body[data-portal="staff"] .stat-label { font-size: 0.62rem; letter-spacing: 0.14em; font-weight: 800; color: var(--color-text-subtle); }
body[data-portal="staff"] .stat-value {
  font: 600 1.55rem var(--cr-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
body[data-portal="staff"] .stat-icon { opacity: 0.55; }

/* ═══ Panels ════════════════════════════════════════════════════════ */
body[data-portal="staff"] .card {
  border: 1px solid var(--color-border);
  border-radius: 0.65rem;
  background: var(--color-surface);
  box-shadow: none;
}
body[data-portal="staff"] .card-heading { margin-bottom: 0.85rem; }
body[data-portal="staff"] .card-heading h2,
body[data-portal="staff"] .card-heading h3 { font-size: 0.92rem; font-weight: 700; letter-spacing: -0.01em; }
body[data-portal="staff"] .card-heading .text-muted { font-size: 0.76rem; }

/* Attention rows: severity-ranked lines instead of chip grid */
body[data-portal="staff"] .attention-list { display: grid; gap: 0; border: 1px solid color-mix(in srgb, var(--color-border) 60%, transparent); border-radius: 0.5rem; overflow: hidden; }
body[data-portal="staff"] .attention-list .attn {
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  gap: 0.8rem;
  align-items: center;
  padding: 0.6rem 0.9rem;
  min-height: 3.1rem;
  border-bottom: 1px solid color-mix(in srgb, var(--color-border) 55%, transparent);
  border-left: 3px solid transparent;
  background: var(--color-surface-subtle);
  text-decoration: none;
  color: var(--color-text);
}
body[data-portal="staff"] .attention-list .attn:last-child { border-bottom: 0; }
body[data-portal="staff"] .attention-list .attn strong { font: 600 1.05rem var(--cr-mono); font-variant-numeric: tabular-nums; }
body[data-portal="staff"] .attention-list .attn span { font-size: 0.82rem; color: var(--color-text-muted); }
body[data-portal="staff"] .attention-list .attn:hover { text-decoration: none; background: var(--color-surface-hover); }
body[data-portal="staff"] .attention-list .attn-danger { border-left-color: var(--color-danger); }
body[data-portal="staff"] .attention-list .attn-danger strong { color: var(--color-danger); }
body[data-portal="staff"] .attention-list .attn-warn { border-left-color: var(--color-warning); }
body[data-portal="staff"] .attention-list .attn-warn strong { color: var(--color-warning); }
body[data-portal="staff"] .attention-list .attn-ok strong { color: var(--color-success); }

body[data-portal="staff"] .burn-rate-bar { max-width: 88%; }
body[data-portal="staff"] .burn-rate-label { font-size: 0.68rem; }

/* ═══ Tables: dense console data ════════════════════════════════════ */
body[data-portal="staff"] .data-table th {
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  font-weight: 800;
  color: var(--color-text-subtle);
}
body[data-portal="staff"] .data-table td { font-variant-numeric: tabular-nums; }
body[data-portal="staff"] .data-table td.mono,
body[data-portal="staff"] .data-table td .mono { font-family: var(--cr-mono); font-size: 0.76rem; }

/* ═══ Time-range / segmented controls ═══════════════════════════════ */
body[data-portal="staff"] .time-range-control {
  display: inline-flex;
  gap: 0.1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 0.15rem;
  width: auto;
  margin: 0 0 1.15rem;
}
body[data-portal="staff"] .time-range-btn {
  border: 0;
  background: transparent;
  color: var(--color-text-muted);
  font: 600 0.74rem inherit;
  padding: 0.35rem 0.7rem;
  border-radius: 0.38rem;
  min-height: 0;
}
body[data-portal="staff"] .time-range-btn:hover { color: var(--color-text); }
body[data-portal="staff"] .time-range-btn.active { background: var(--color-accent); color: #FFFFFF; }
:root[data-theme="dark"] body[data-portal="staff"] .time-range-btn.active { color: #031320; }

/* ═══ Model bars: track contrast + mono figures ═════════════════════ */
body[data-portal="staff"] .model-bar-track { fill: color-mix(in srgb, var(--color-text) 10%, transparent); }
body[data-portal="staff"] .model-bar-fill { fill: var(--color-accent); }
body[data-portal="staff"] .model-bar-label span { font-family: var(--cr-mono); font-variant-numeric: tabular-nums; }

/* ═══ Ops page: server controls as board cells ══════════════════════ */
body[data-portal="staff"] .ops-group {
  border: 1px solid color-mix(in srgb, var(--color-border) 70%, transparent);
  border-radius: 0.55rem;
  background: var(--color-surface-subtle);
  padding: 0.7rem 0.85rem;
}
body[data-portal="staff"] .ops-group + .ops-group { margin-top: 0.6rem; }
body[data-portal="staff"] .ops-group-title { font-size: 0.8rem; font-weight: 700; }
body[data-portal="staff"] .ops-group[open] .ops-group-title { color: var(--color-accent); }
body[data-portal="staff"] .ops-hero { position: relative; }
body[data-portal="staff"] .ops-view-switch {
  display: inline-flex;
  gap: 0.12rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 0.14rem;
  background: var(--color-surface);
}
body[data-portal="staff"] .ops-view-btn { border: 0; background: transparent; color: var(--color-text-muted); font-weight: 600; font-size: 0.74rem; border-radius: 0.38rem; padding: 0.34rem 0.7rem; min-height: 0; }
body[data-portal="staff"] .ops-view-btn.active, body[data-portal="staff"] .ops-view-btn[aria-pressed="true"] { background: var(--color-accent); color: #FFFFFF; }
:root[data-theme="dark"] body[data-portal="staff"] .ops-view-btn.active,
:root[data-theme="dark"] body[data-portal="staff"] .ops-view-btn[aria-pressed="true"] { color: #031320; }

/* ═══ Numeric emphasis everywhere ═══════════════════════════════════ */
body[data-portal="staff"] time.local-time,
body[data-portal="staff"] td.nowrap { font-family: var(--cr-mono); font-size: 0.76rem; color: var(--color-text-muted); }
body[data-portal="staff"] .eyebrow { font-weight: 800; letter-spacing: 0.16em; }

/* ═══ Fleet picker cards ════════════════════════════════════════════ */
body[data-portal="staff"] .fleet-picker-item { border-radius: 0.55rem; }
body[data-portal="staff"] .cr-unbilled { color: var(--color-warning); font-weight: 600; }

/* ═══ Responsive: rail is a desktop surface; mobile keeps topbar+drawer
   (never a collapsed hamburger-rail hybrid) ════════════════════════ */
@media (max-width: 900px) {
  body[data-portal="staff"] .app-frame { display: block; }
  body[data-portal="staff"] .cr-rail { display: none; }
  body[data-portal="staff"] .site-header { display: block; }
  body[data-portal="staff"] .app-main { padding: 1rem 1rem 2rem; }
}

/* Respect reduced motion on the rail gradient accents. */
@media (prefers-reduced-motion: reduce) {
  .cr-rail * { transition: none !important; }
}

/* Soft navigation: indeterminate progress rail (staff only, see softnav.js). */
body[data-portal="staff"] .softnav-progress{position:fixed;inset:0 0 auto 0;height:2px;z-index:60;background:transparent;overflow:hidden}
body[data-portal="staff"] .softnav-progress::after{content:"";position:absolute;top:0;bottom:0;width:35%;background:var(--color-accent);animation:softnav-slide 0.9s linear infinite}
@keyframes softnav-slide{from{transform:translateX(-100%)}to{transform:translateX(340%)}}
