/* ============================================================
   RUBICON ADMIN CONSOLE — Halo design tokens + layout
   Light mode, warm neutrals, one coral accent. Foundry-dense,
   Halo-clean. Tokens mirrored from build/design_system/halo.
   ============================================================ */

:root {
  /* ---- PALETTE · warm neutrals ---- */
  --gray-0:   #ffffff;
  --gray-25:  #fbfaf8;
  --gray-50:  #f6f5f2;
  --gray-100: #efede9;
  --gray-150: #e7e4df;
  --gray-200: #ddd9d2;
  --gray-300: #cbc6bd;
  --gray-400: #a8a299;
  --gray-500: #847e74;
  --gray-600: #6a645b;
  --gray-700: #4d4842;
  --gray-800: #2f2b26;
  --gray-900: #211e1a;

  /* ---- PALETTE · coral accent ---- */
  --coral-50:  #fcf0ec;
  --coral-100: #f9ded4;
  --coral-200: #f3bca8;
  --coral-300: #ec9981;
  --coral-400: #e56f55;
  --coral-500: #e0533d;
  --coral-600: #c8412c;
  --coral-700: #a33324;

  /* ---- PALETTE · status ---- */
  --green-50:  #ecf6ef;
  --green-500: #2f8f5b;
  --green-600: #257a4c;
  --amber-50:  #fbf2e3;
  --amber-500: #b9762a;
  --amber-600: #9c6120;
  --red-50:    #fbeeec;
  --red-500:   #cc3a2c;
  --red-600:   #ad2e22;
  --blue-50:   #ecf1fb;
  --blue-500:  #3d6fd0;
  --blue-600:  #305bb0;

  /* ---- SEMANTIC ---- */
  --surface-app:     var(--gray-25);
  --surface:         var(--gray-0);
  --surface-subtle:  var(--gray-50);
  --surface-sunken:  var(--gray-100);
  --surface-inverse: var(--gray-900);

  --text:            var(--gray-900);
  --text-secondary:  var(--gray-700);
  --text-muted:      var(--gray-600);
  --text-placeholder:var(--gray-500);
  --text-disabled:   var(--gray-400);
  --text-inverse:    var(--gray-0);
  --text-link:       var(--coral-700);

  --border:          var(--gray-200);
  --border-strong:   var(--gray-300);
  --border-focus:    var(--coral-500);

  --accent:          var(--coral-500);
  --accent-hover:    var(--coral-600);
  --accent-active:   var(--coral-700);
  --accent-surface:  var(--coral-50);
  --accent-surface-hover: var(--coral-100);
  --accent-border:   var(--coral-200);
  --accent-text:     var(--coral-700);
  --on-accent:       var(--gray-0);

  --focus-ring: 0 0 0 3px color-mix(in oklch, var(--coral-500) 32%, transparent);

  --success:         var(--green-600);
  --success-surface: var(--green-50);
  --warning:         var(--amber-600);
  --warning-surface: var(--amber-50);
  --danger:          var(--red-600);
  --danger-surface:  var(--red-50);
  --info:            var(--blue-600);
  --info-surface:    var(--blue-50);
  --selection-bg:    var(--coral-100);

  /* ---- TYPE ---- */
  --font-sans: "Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;

  --text-2xs:  0.6875rem;
  --text-xs:   0.75rem;
  --text-sm:   0.8125rem;
  --text-base: 0.9375rem;
  --text-md:   1.0625rem;
  --text-lg:   1.3125rem;
  --text-xl:   1.625rem;
  --text-2xl:  2rem;

  --weight-regular:  400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  --leading-tight:   1.15;
  --leading-snug:    1.3;
  --leading-normal:  1.55;

  --tracking-tight:  -0.02em;
  --tracking-snug:   -0.01em;
  --tracking-wide:   0.04em;

  /* ---- SPACING / RADIUS ---- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 2.5rem;
  --space-8: 3rem;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  --control-sm: 32px;
  --control-md: 40px;

  /* ---- ELEVATION / MOTION ---- */
  --shadow-xs: 0 1px 2px rgba(33,30,26,.05);
  --shadow-sm: 0 1px 2px rgba(33,30,26,.06), 0 1px 3px rgba(33,30,26,.05);
  --shadow-md: 0 2px 4px rgba(33,30,26,.05), 0 4px 12px rgba(33,30,26,.07);
  --shadow-lg: 0 4px 8px rgba(33,30,26,.06), 0 12px 28px rgba(33,30,26,.10);
  --shadow-xl: 0 8px 16px rgba(33,30,26,.08), 0 24px 48px rgba(33,30,26,.14);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --duration-fast: 120ms;
  --duration-base: 180ms;

  --nav-w: 232px;
  --topbar-h: 56px;
}

@media (prefers-reduced-motion: reduce) {
  :root { --duration-fast: 0ms; --duration-base: 0ms; }
}

/* ---- RESET ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text);
  background: var(--surface-app);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--selection-bg); }
h1, h2, h3, h4, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-disabled); }
.nowrap { white-space: nowrap; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0 0 0 0); border:0; }

/* ============================================================
   APP SHELL
   ============================================================ */
#app { min-height: 100vh; }
.shell { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }

/* ---- LEFT NAV ---- */
.nav {
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: var(--space-5) var(--space-3);
}
.nav-brand { display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-3) var(--space-4); text-decoration: none; color: inherit; }
.nav-brand:hover { text-decoration: none; }
.nav-brand:hover .nav-brand-txt strong { color: var(--accent-text); }
.nav-back {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); margin: 0 0 var(--space-2);
  border-radius: var(--radius-md); color: var(--text-muted);
  font-size: var(--text-sm); font-weight: var(--weight-medium); text-decoration: none;
  border: 1px solid var(--border); background: var(--surface-subtle);
  transition: var(--duration-fast) var(--ease-out);
}
.nav-back:hover { color: var(--text); border-color: var(--border-strong); text-decoration: none; }
.nav-mark {
  width: 30px; height: 30px; border-radius: var(--radius-md);
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; font-weight: var(--weight-bold);
  font-size: var(--text-md); flex: none;
}
.nav-brand-txt { line-height: 1.1; }
.nav-brand-txt strong { font-size: var(--text-base); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-snug); }
.nav-brand-txt span { display: block; font-size: var(--text-2xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: var(--tracking-wide); }

.nav-section-label {
  font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-wide);
  color: var(--text-muted); font-weight: var(--weight-semibold);
  padding: var(--space-4) var(--space-3) var(--space-2);
}
.nav a.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); margin-bottom: 2px;
  border-radius: var(--radius-md); color: var(--text-secondary);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  text-decoration: none; transition: var(--duration-fast) var(--ease-out);
  border: 1px solid transparent;
}
.nav a.nav-item:hover { background: var(--surface-subtle); color: var(--text); text-decoration: none; }
.nav a.nav-item.active { background: var(--accent-surface); color: var(--accent-text); border-color: var(--accent-border); }
.nav-item .ni-icon, .nav-back .ni-icon { width: 16px; height: 16px; flex: none; display: inline-flex; align-items: center; justify-content: center; opacity: .9; }
.nav-item .ni-icon svg, .nav-back .ni-icon svg { width: 16px; height: 16px; display: block; }
.nav-item.active .ni-icon { opacity: 1; }
.nav-item .ni-count {
  margin-left: auto; font-size: var(--text-2xs); font-family: var(--font-mono);
  background: var(--surface-sunken); color: var(--text-muted);
  padding: 1px 6px; border-radius: var(--radius-full);
}
.nav-item.active .ni-count { background: var(--accent-border); color: var(--accent-text); }
.nav-spacer { flex: 1 1 auto; }
.nav-foot { padding: var(--space-4) var(--space-3) 0; border-top: 1px solid var(--border); margin-top: var(--space-4); }
.nav-foot .nf-id { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.nav-foot .nf-mail { font-size: var(--text-2xs); color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-foot .nf-meta { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); flex-wrap: wrap; }
.nav-foot .nf-meta .api-v { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }

/* ---- MAIN ---- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--space-4);
  padding: 0 var(--space-6);
  background: color-mix(in oklch, var(--surface-app) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: var(--text-md); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-snug); }
.topbar .crumb { color: var(--text-muted); font-weight: var(--weight-regular); }
.topbar .grow { flex: 1; }
.topbar .win-pick { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); color: var(--text-muted); }

.view { padding: var(--space-6); max-width: var(--measure-wide, 1320px); width: 100%; }
.view-head { margin-bottom: var(--space-5); }
.view-head h2 { font-size: var(--text-xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-snug); }
.view-head .sub { color: var(--text-muted); font-size: var(--text-sm); margin-top: var(--space-1); max-width: 68ch; }
.section { margin-top: var(--space-7); }
.section-head { display: flex; align-items: baseline; gap: var(--space-3); margin-bottom: var(--space-3); }
.section-head h3 { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.section-head .sh-note { font-size: var(--text-xs); color: var(--text-muted); }
.section-head .grow { flex: 1; }

/* ============================================================
   PRIMITIVES
   ============================================================ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
.card-pad { padding: var(--space-5); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-sm); padding: 0 var(--space-4);
  border-radius: var(--radius-md); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  transition: var(--duration-fast) var(--ease-out); white-space: nowrap;
}
.btn:hover { background: var(--surface-subtle); border-color: var(--gray-400); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: var(--gray-300); }
.btn-danger:hover { background: var(--danger-surface); border-color: var(--red-500); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-subtle); }
.btn-sm { height: 28px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn-icon { width: 28px; padding: 0; }

.input, .select {
  height: var(--control-sm); padding: 0 var(--space-3);
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text); font-size: var(--text-sm);
  transition: var(--duration-fast) var(--ease-out); width: 100%;
}
.input:focus, .select:focus { border-color: var(--border-focus); box-shadow: var(--focus-ring); outline: none; }
/* Dropdowns: kill the browser-default arrow/bevel and render the mockup's control —
   bordered, rounded, medium-weight label, a quiet chevron on the right. */
.select {
  cursor: pointer; appearance: none; -webkit-appearance: none; -moz-appearance: none;
  font-weight: var(--weight-medium); color: var(--text-secondary); line-height: 1;
  padding-right: calc(var(--space-3) + 18px);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23847e74' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--space-3) center;
  text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
}
.select:hover { border-color: var(--gray-400); background-color: var(--surface-subtle); }
.select:disabled { opacity: .55; cursor: not-allowed; background-color: var(--surface-subtle); color: var(--text-disabled); }
.select option { font-weight: var(--weight-regular); color: var(--text); background: var(--surface); }
textarea.input { height: auto; min-height: 64px; padding: var(--space-2) var(--space-3); line-height: var(--leading-normal); resize: vertical; }

/* chips / badges */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: var(--radius-full);
  font-size: var(--text-2xs); font-weight: var(--weight-medium); line-height: 1.5;
  border: 1px solid var(--border); background: var(--surface-subtle); color: var(--text-secondary);
  white-space: nowrap;
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gray-400); flex: none; }
.chip-neutral { background: var(--surface-subtle); color: var(--text-secondary); border-color: var(--border); }
.chip-accent  { background: var(--accent-surface); color: var(--accent-text); border-color: var(--accent-border); }
.chip-accent .dot { background: var(--accent); }
.chip-success { background: var(--success-surface); color: var(--success); border-color: color-mix(in oklch, var(--green-500) 28%, transparent); }
.chip-success .dot { background: var(--green-500); }
.chip-warn    { background: var(--warning-surface); color: var(--warning); border-color: color-mix(in oklch, var(--amber-500) 30%, transparent); }
.chip-warn .dot { background: var(--amber-500); }
.chip-danger  { background: var(--danger-surface); color: var(--danger); border-color: color-mix(in oklch, var(--red-500) 30%, transparent); }
.chip-danger .dot { background: var(--red-500); }
.chip-preview { background: var(--info-surface); color: var(--info); border-color: color-mix(in oklch, var(--blue-500) 30%, transparent); }
.chip-preview .dot { background: var(--blue-500); }
.tl-item.is-candidate .tl-head .v { color: var(--info); }
.chip-info    { background: var(--info-surface); color: var(--info); border-color: color-mix(in oklch, var(--blue-500) 26%, transparent); }
.chip-info .dot { background: var(--blue-500); }
.chip-code { font-family: var(--font-mono); font-size: var(--text-2xs); background: var(--surface-sunken); color: var(--text-secondary); border-color: var(--border); }

/* status dots (versions) */
.sdot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.sdot-prod { background: var(--green-500); }
.sdot-beta { background: var(--amber-500); }
.sdot-dev  { background: var(--blue-500); }
.sdot-failed { background: var(--red-500); }
.sdot-muted { background: var(--gray-300); }

/* ============================================================
   KPI STAT CARDS
   ============================================================ */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: var(--space-3); }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-1);
  min-width: 0; transition: var(--duration-fast) var(--ease-out);
}
.kpi .k-label { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-wide); color: var(--text-muted); font-weight: var(--weight-semibold); }
.kpi .k-val { font-family: var(--font-mono); font-size: var(--text-xl); font-weight: var(--weight-semibold); line-height: 1.1; letter-spacing: var(--tracking-snug); font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: var(--text-xs); color: var(--text-muted); }
.kpi.k-accent .k-val { color: var(--accent-text); }
.kpi.k-warn { border-color: color-mix(in oklch, var(--amber-500) 34%, transparent); background: var(--warning-surface); }
.kpi.k-warn .k-val { color: var(--warning); }

/* ============================================================
   TABLES
   ============================================================ */
.tbl-wrap { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.tbl-scroll { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
table.tbl thead th {
  position: sticky; top: 0;
  text-align: left; font-weight: var(--weight-semibold); font-size: var(--text-2xs);
  text-transform: uppercase; letter-spacing: var(--tracking-wide); color: var(--text-muted);
  background: var(--surface-subtle); padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none;
}
table.tbl thead th.sortable { cursor: pointer; }
table.tbl thead th.sortable:hover { color: var(--text); background: var(--surface-sunken); }
table.tbl thead th.num, table.tbl td.num { text-align: right; }
table.tbl thead th .sort-arr { font-size: 9px; margin-left: 3px; color: var(--accent); }
table.tbl tbody td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr.clickable { cursor: pointer; transition: background var(--duration-fast) var(--ease-out); }
table.tbl tbody tr.clickable:hover { background: var(--surface-subtle); }
/* The '(internal & tests)' rollup row: present for honest totals, visually recessive. */
table.tbl tbody tr.row-muted td { color: var(--text-muted); font-style: italic; }
table.tbl td.num, table.tbl td .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
table.tbl td.strong { font-weight: var(--weight-medium); color: var(--text); }
table.tbl td .cell-sub { display: block; font-size: var(--text-xs); color: var(--text-muted); }
.op-display { display: flex; align-items: center; gap: var(--space-3); min-width: 340px; }
.op-logos { display: flex; align-items: center; min-width: 40px; }
.op-logo {
  width: 30px; height: 30px; object-fit: contain; background: var(--surface);
  border: 1px solid var(--border); border-radius: 9px; padding: 4px;
  box-shadow: 0 1px 3px rgba(39, 34, 26, .08);
}
.op-logo + .op-logo { margin-left: -7px; }
.op-copy { min-width: 0; }
.op-label { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text); }
.op-copy .cell-sub.mono { margin-top: 2px; font-size: 10px; }
.op-copy .cell-sub:not(.mono) { margin-top: 3px; max-width: 560px; line-height: 1.35; }
.zero { color: var(--text-disabled); }

/* ============================================================
   SKELETON LOADING
   ============================================================ */
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
.skel {
  background: var(--surface-subtle);
  background-image: linear-gradient(90deg, transparent, rgba(255,255,255,.6), transparent);
  background-size: 400px 100%; background-repeat: no-repeat;
  animation: shimmer 1.25s var(--ease-out) infinite;
  border-radius: var(--radius-sm); height: 12px;
}
.skel-row td { padding: var(--space-3) var(--space-4) !important; }
.skel-line { height: 12px; border-radius: var(--radius-sm); }
.skel-circle { width: 124px; height: 124px; border-radius: 50%; }

/* ============================================================
   BANNERS / ERRORS
   ============================================================ */
.banner {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  font-size: var(--text-sm); border: 1px solid var(--border);
  background: var(--surface-subtle); margin-bottom: var(--space-4);
}
.banner-err { background: var(--danger-surface); border-color: color-mix(in oklch, var(--red-500) 30%, transparent); color: var(--danger); }
.banner-warn { background: var(--warning-surface); border-color: color-mix(in oklch, var(--amber-500) 30%, transparent); color: var(--warning); }
.banner .b-ep { font-family: var(--font-mono); font-size: var(--text-xs); }
.banner .b-retry { margin-left: auto; }

.empty-state {
  text-align: center; padding: var(--space-8) var(--space-5);
  color: var(--text-muted); border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg); background: var(--surface-subtle);
}
.empty-state .es-title { font-size: var(--text-base); color: var(--text); font-weight: var(--weight-medium); margin-bottom: var(--space-2); }
.empty-state .es-sub { font-size: var(--text-sm); max-width: 46ch; margin: 0 auto; }

.gate {
  display: grid; place-items: center; min-height: 60vh; padding: var(--space-6);
}
.gate-card { max-width: 420px; text-align: center; }
.gate-card .g-mark { width: 48px; height: 48px; margin: 0 auto var(--space-4); border-radius: var(--radius-lg); background: var(--accent-surface); color: var(--accent-text); display: grid; place-items: center; font-size: var(--text-lg); border: 1px solid var(--accent-border); }
.gate-card h2 { font-size: var(--text-lg); margin-bottom: var(--space-2); }
.gate-card p { color: var(--text-muted); font-size: var(--text-sm); }

/* ============================================================
   DRAWER / DETAIL PANEL
   ============================================================ */
.detail-head {
  display: flex; align-items: flex-start; gap: var(--space-4);
  padding-bottom: var(--space-5); border-bottom: 1px solid var(--border); margin-bottom: var(--space-5);
}
.detail-head .dh-main { min-width: 0; flex: 1; }
.detail-head h2 { font-size: var(--text-xl); letter-spacing: var(--tracking-snug); display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.detail-head .dh-meta { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin-top: var(--space-2); font-size: var(--text-xs); color: var(--text-muted); }
.detail-head .dh-meta .m { display: inline-flex; gap: 5px; align-items: center; }
.detail-head .dh-meta .m b { color: var(--text-secondary); font-weight: var(--weight-medium); }
.back-link { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-muted); margin-bottom: var(--space-4); }
.back-link:hover { color: var(--text); text-decoration: none; }

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

.controls-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }

/* ---- ACCESS EDITOR ---- */
.access-card { border-color: var(--accent-border); }
.access-card.is-open { border-color: var(--border); }
.access-head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.access-head h3 { font-size: var(--text-md); font-weight: var(--weight-semibold); flex: 1; }
.seg {
  display: inline-flex; padding: 3px; background: var(--surface-sunken);
  border-radius: var(--radius-md); border: 1px solid var(--border); gap: 3px;
}
.seg button {
  height: 30px; padding: 0 var(--space-3); border: none; background: transparent;
  border-radius: var(--radius-sm); font-size: var(--text-sm); font-weight: var(--weight-medium);
  color: var(--text-muted); transition: var(--duration-fast) var(--ease-out);
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.seg button.on.danger-on { color: var(--accent-text); background: var(--accent-surface); }

.principals { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-3) 0; min-height: 32px; align-items: center; }
.p-chip {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 4px 6px 4px 10px; border-radius: var(--radius-full);
  background: var(--surface-subtle); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: var(--text-xs);
}
.p-chip.locked { background: var(--accent-surface); border-color: var(--accent-border); color: var(--accent-text); }
.p-chip .x { display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: transparent; border: none; color: var(--text-muted); font-size: 13px; line-height: 1; }
.p-chip .x:hover { background: var(--gray-200); color: var(--text); }
.p-chip .lock { font-size: 10px; opacity: .7; }
.p-add { display: flex; gap: var(--space-2); margin-top: var(--space-2); }
.p-add .input { flex: 1; }
.helper { font-size: var(--text-xs); color: var(--text-muted); display: flex; align-items: center; gap: 6px; margin-top: var(--space-2); }
.helper .shield { color: var(--accent); }
.access-foot { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.access-foot .who-when { font-size: var(--text-xs); color: var(--text-muted); flex: 1; }

/* ---- TIMELINE ---- */
.timeline { position: relative; padding-left: var(--space-5); }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 var(--space-4) 0; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { position: absolute; left: calc(-1 * var(--space-5) + 1px); top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--gray-400); }
.tl-item.is-prod .tl-dot { border-color: var(--green-500); }
.tl-item.is-beta .tl-dot { border-color: var(--amber-500); }
.tl-item.is-dev .tl-dot  { border-color: var(--blue-500); }
.tl-item.is-failed .tl-dot { border-color: var(--red-500); background: var(--red-50); }
.tl-head { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
.tl-head .v { font-family: var(--font-mono); font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.tl-head .t { font-size: var(--text-xs); color: var(--text-muted); margin-left: auto; }
.tl-summary { font-size: var(--text-sm); color: var(--text-secondary); margin-top: 3px; }
.tl-summary.ai { color: var(--text); }
.tl-meta { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-2); display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }
.tl-meta .author { font-family: var(--font-mono); }
.diffstat { font-family: var(--font-mono); font-size: var(--text-2xs); }
.diffstat .add { color: var(--green-600); }
.diffstat .del { color: var(--red-600); }

/* ---- CSS BAR CHARTS ---- */
.bars { display: flex; flex-direction: column; gap: var(--space-2); }
.bar-row { display: grid; grid-template-columns: 120px 1fr auto; gap: var(--space-3); align-items: center; font-size: var(--text-sm); }
.bar-row .bl { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: var(--text-xs); }
.bar-track { height: 10px; background: var(--surface-sunken); border-radius: var(--radius-full); overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: var(--radius-full); min-width: 2px; transition: width var(--duration-base) var(--ease-out); }
.bar-fill.alt { background: var(--gray-400); }
.bar-row .bv { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--text-xs); color: var(--text-muted); text-align: right; min-width: 44px; }

/* vertical daily columns */
.cols { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: var(--space-2); }
.col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; min-width: 0; height: 100%; }
.col .stack { display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; flex: 1; }
.col .seg1 { background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; transition: height var(--duration-base) var(--ease-out); }
.col .seg2 { background: var(--coral-200); border-radius: 0 0 3px 3px; min-height: 0; }
.col .cx { font-size: 9px; color: var(--text-disabled); text-align: center; font-family: var(--font-mono); white-space: nowrap; overflow: hidden; }
.col:hover .seg1 { background: var(--accent-hover); }
.cols-legend { display: flex; gap: var(--space-4); margin-top: var(--space-3); font-size: var(--text-xs); color: var(--text-muted); }
.cols-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.cols-legend .sw { width: 10px; height: 10px; border-radius: 3px; }

/* ---- MODAL ---- */
.modal-scrim { position: fixed; inset: 0; z-index: 400; background: rgba(33,30,26,.32); display: grid; place-items: center; padding: var(--space-5); animation: fade var(--duration-base) var(--ease-out); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl); width: 100%; max-width: 440px; padding: var(--space-6);
  animation: pop var(--duration-base) var(--ease-out);
}
@keyframes pop { from { transform: translateY(6px) scale(.99); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h3 { font-size: var(--text-lg); margin-bottom: var(--space-3); }
.modal p { color: var(--text-secondary); font-size: var(--text-sm); margin-bottom: var(--space-4); }
.modal .m-warn { background: var(--danger-surface); border: 1px solid color-mix(in oklch, var(--red-500) 26%, transparent); color: var(--danger); border-radius: var(--radius-md); padding: var(--space-3); font-size: var(--text-xs); margin-bottom: var(--space-4); }
.modal .m-actions { display: flex; justify-content: flex-end; gap: var(--space-3); }
.modal .m-field { margin-bottom: var(--space-4); }
.modal .m-field label { display: block; font-size: var(--text-xs); color: var(--text-muted); margin-bottom: var(--space-2); font-weight: var(--weight-medium); }

/* ---- TOAST ---- */
.toasts { position: fixed; bottom: var(--space-5); right: var(--space-5); z-index: 500; display: flex; flex-direction: column; gap: var(--space-2); }
.toast {
  background: var(--surface-inverse); color: var(--text-inverse);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  font-size: var(--text-sm); box-shadow: var(--shadow-lg); max-width: 360px;
  animation: pop var(--duration-base) var(--ease-out); display: flex; align-items: center; gap: var(--space-3);
}
.toast.err { background: var(--red-600); }
.toast.ok .t-ic { color: var(--green-500); }

/* misc */
.pin-ctl { display: inline-flex; align-items: center; gap: var(--space-2); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: var(--space-2) var(--space-4); font-size: var(--text-sm); }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; font-family: var(--font-mono); font-size: var(--text-xs); }
.spark { display: inline-flex; align-items: flex-end; gap: 1px; height: 18px; }
.spark i { width: 3px; background: var(--accent-border); border-radius: 1px; min-height: 1px; }
.outcome-ok { color: var(--success); }
.outcome-err { color: var(--danger); }
.split-bar { display: flex; height: 14px; border-radius: var(--radius-full); overflow: hidden; border: 1px solid var(--border); }
.split-bar .s-ai { background: var(--accent); }
.split-bar .s-human { background: var(--gray-400); }
.split-legend { display: flex; gap: var(--space-4); margin-top: var(--space-3); font-size: var(--text-sm); }

/* ============================================================
   REDESIGN — Section 7 layouts (Halo tokens, no new palette).
   All data-backed; elements without a data source are omitted.
   ============================================================ */

/* ---- 7a Overview: 3-hero + 4-compact KPI hierarchy ---- */
.kpi-hero-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: var(--space-4); }
.kpi-hero {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5); box-shadow: var(--shadow-xs);
}
.kpi-hero .kh-label { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-wide); color: var(--text-muted); font-weight: var(--weight-semibold); }
.kpi-hero .kh-val { font-family: var(--font-mono); font-size: var(--text-2xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); line-height: 1.05; margin-top: var(--space-2); }
.kpi-hero.k-accent .kh-val { color: var(--accent-text); }
.kpi-hero .kh-sub { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-2); }
.kpi-hero.k-warn { background: var(--warning-surface); border-color: color-mix(in oklch, var(--amber-500) 34%, transparent); }
.kpi-hero.k-warn .kh-label, .kpi-hero.k-warn .kh-val, .kpi-hero.k-warn .kh-sub { color: var(--warning); }
.kpi-compact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); }
.kpi-compact { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); font-size: var(--text-xs); color: var(--text-muted); }
.kpi-compact.k-warn { background: var(--warning-surface); border-color: color-mix(in oklch, var(--amber-500) 34%, transparent); }
.kpi-compact.k-warn b { color: var(--warning); }
.kpi-compact.k-danger { background: var(--danger-surface); border-color: color-mix(in oklch, var(--red-500) 30%, transparent); }
.kpi-compact.k-danger b { color: var(--danger); }
a.kpi-link { text-decoration: none; display: block; transition: border-color .15s ease; }
a.kpi-link:hover { border-color: var(--accent); }
.ai-pies { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--space-4); margin-top: var(--space-4); }
.ai-pie { display: flex; flex-direction: column; align-items: flex-start; }
.ai-pie-title { font-size: var(--text-sm); font-weight: var(--weight-semibold); margin-bottom: 6px; }
.ai-legend { display: flex; flex-direction: column; gap: 3px; font-size: var(--text-xs); color: var(--text-muted); margin-top: 8px; }
.ai-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.ai-legend .sw, .cols-legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.ai-line { margin-top: var(--space-2); }
/* Halo hover states for the AI charts: focused element lifts, siblings recede. */
.ai-pie-svg svg .pie-seg { transition: filter .15s ease, stroke-width .15s ease, opacity .15s ease; cursor: pointer; }
.ai-pie-svg svg:hover .pie-seg { opacity: .45; }
.ai-pie-svg svg .pie-seg:hover { opacity: 1; filter: brightness(1.08) saturate(1.15); stroke-width: 19; }
/* Pie-slice selection (click-to-filter the trend): chosen slice stays lit. */
.ai-pie-svg svg .pie-seg.sel { opacity: 1 !important; stroke-width: 18.5; filter: saturate(1.15); }
.ai-pie-svg svg .pie-seg.dim { opacity: .3; }
.ai-legend .lg.lg-click { cursor: pointer; }
.ai-legend .lg.lg-click:hover { color: var(--text); }
.ai-legend .lg.sel { color: var(--text); font-weight: var(--weight-semibold); }
.ai-filterbar { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2); }
.ai-line svg .pt { transition: r .12s ease, filter .12s ease, stroke-width .12s ease; cursor: pointer; }
.ai-line svg .pt:hover { r: 4.5; filter: brightness(1.12); stroke-width: 2; }
/* Halo tooltip for the AI charts (data-tip driven; one per card). */
.ai-tip {
  position: absolute; z-index: 40; display: none; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: 0 6px 18px rgba(0, 0, 0, .14);
  padding: 6px 10px; font-size: var(--text-xs); color: var(--text);
  white-space: pre-line; line-height: 1.45; max-width: 260px;
}
/* Smooth 7d/30d switch: the card greys IN PLACE (true proportions) with a
   shimmer sweep while fresh data loads — a live skeleton, not an empty box. */
.ai-fade { transition: opacity .18s ease; position: relative; }
.ai-fade.is-loading { opacity: .55; pointer-events: none; }
.ai-fade.is-loading::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background-image: linear-gradient(90deg, transparent, rgba(255, 255, 255, .35), transparent);
  background-size: 400px 100%; background-repeat: no-repeat;
  animation: shimmer 1.25s var(--ease-out) infinite;
}
/* The 7d/30d window switch — a labeled segmented control, not two tiny chips. */
.seg-ctl {
  display: inline-flex; gap: 2px; padding: 2px;
  background: var(--surface-subtle); border: 1px solid var(--border);
  border-radius: 999px;
}
.seg-btn {
  border: none; background: transparent; cursor: pointer;
  padding: 5px 14px; border-radius: 999px;
  font-size: var(--text-sm); color: var(--text-muted); font-family: inherit;
  transition: background .15s ease, color .15s ease;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active {
  background: var(--accent-surface); color: var(--accent-text);
  font-weight: var(--weight-semibold);
  box-shadow: inset 0 0 0 1px var(--accent-border);
}
.kpi-compact b { font-family: var(--font-mono); font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--text); margin-right: 6px; }
@media (max-width: 900px) { .kpi-hero-grid { grid-template-columns: 1fr; } .kpi-compact-grid { grid-template-columns: 1fr 1fr; } }

.posture-list { display: flex; flex-direction: column; gap: 5px; }
.posture-op { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); }
.posture-op .po-name { font-family: var(--font-mono); font-size: var(--text-xs); }
.posture-op .po-count { margin-left: auto; }

/* ---- 7b Apps: toolbar, identity cell, status dot+word ---- */
.tbl-toolbar { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.tbl-toolbar .t-search { width: 220px; }
.id-cell { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.app-av { width: 26px; height: 26px; border-radius: var(--radius-sm); background: var(--gray-900); color: #fff; font-size: 11px; font-weight: var(--weight-bold); display: inline-flex; align-items: center; justify-content: center; flex: none; text-transform: uppercase; }
.app-av.legacy { background: var(--gray-500); }
.app-av.lg { width: 44px; height: 44px; border-radius: var(--radius-lg); font-size: var(--text-md); }
.id-cell .id-txt { min-width: 0; }
.id-cell .id-name { font-weight: var(--weight-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.id-cell .id-sub { display: block; font-family: var(--font-mono); font-size: 10px; color: var(--text-disabled); }
.st { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.st .sdot { width: 7px; height: 7px; }
.st-production { color: var(--success); } .st-beta { color: var(--warning); }
.st-development { color: var(--info); } .st-deleted, .st-unknown { color: var(--text-muted); }

/* ---- 7c App detail: history left, governance rail right, isolated danger zone ---- */
.detail-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: var(--space-4); align-items: start; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }
.gov-rail { display: flex; flex-direction: column; gap: var(--space-4); }
.rail-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.rail-card .rc-head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--surface-sunken); font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.rail-card .rc-body { padding: var(--space-4); }
.rail-stats { display: flex; gap: var(--space-5); }
.rail-stats .rs { min-width: 0; }
.rail-stats .rs .rs-l { font-size: var(--text-2xs); font-weight: var(--weight-semibold); color: var(--text-muted); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.rail-stats .rs .rs-v { font-family: var(--font-mono); font-size: var(--text-md); font-weight: var(--weight-semibold); }
.danger-zone { border: 1px solid var(--accent-border); border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5); background: var(--surface); }
.danger-zone h3 { color: var(--accent-text); font-size: var(--text-md); font-weight: var(--weight-semibold); margin-bottom: var(--space-3); }
.danger-zone .dz-note { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-3); }
.dh-pin { display: inline-flex; align-items: center; gap: var(--space-2); flex: none; }
.dh-pin .k-label { font-size: var(--text-2xs); }

/* ---- 7e People: avatar cell + pending-row highlight ---- */
.person-av { width: 28px; height: 28px; border-radius: var(--radius-full); background: var(--gray-200); color: var(--gray-700); font-size: 10.5px; font-weight: var(--weight-bold); display: inline-flex; align-items: center; justify-content: center; flex: none; text-transform: uppercase; }
.person-av.self { background: var(--coral-200); color: var(--accent-text); }
table.tbl tbody tr.pending { background: var(--accent-surface); }
table.tbl tbody tr.pending:hover { background: var(--accent-surface-hover); }
.unsaved-note { font-size: var(--text-xs); color: var(--text-muted); }
.unsaved-note b { color: var(--text-secondary); font-weight: var(--weight-medium); }

/* ---- 7f Usage: proportional daily chart legend already covered by .cols-legend ---- */
td.billable, th.billable { color: var(--accent-text); }

@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; flex-direction: row; flex-wrap: wrap; overflow-x: auto; }
  .nav-spacer, .nav-foot { display: none; }
  .view { padding: var(--space-4); }
  .bar-row { grid-template-columns: 90px 1fr auto; }
  .kpi-hero-grid, .kpi-compact-grid, .detail-grid { grid-template-columns: 1fr; }
}

/* Admins data dictionary — a scannable glossary (overflow-safe two-column) */
.gloss { padding: 0; overflow: hidden; }
.gloss > summary { list-style: none; cursor: pointer; padding: var(--space-4) var(--space-5);
  font-weight: 600; display: flex; align-items: center; gap: var(--space-2); }
.gloss > summary::-webkit-details-marker { display: none; }
.gloss > summary::before { content: "▸"; color: var(--text-muted); font-size: 11px; transition: transform .15s; }
.gloss[open] > summary::before { transform: rotate(90deg); }
.gloss > summary .muted { font-weight: 400; color: var(--text-muted); font-size: var(--text-xs);
  border: 1px solid var(--border); border-radius: var(--radius-full); padding: 1px 8px; }
.gloss-body { border-top: 1px solid var(--border); }
.gloss-item { display: grid; grid-template-columns: 184px minmax(0, 1fr); gap: var(--space-4);
  align-items: start; padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border); }
.gloss-item:first-child { border-top: none; }
.gloss-term { min-width: 0; font-weight: 600; font-size: var(--text-sm); color: var(--text); overflow-wrap: anywhere; }
.gloss-def { min-width: 0; color: var(--text-secondary); font-size: var(--text-sm); line-height: 1.55; overflow-wrap: anywhere; }
.gloss-def code { font-size: var(--text-xs); background: var(--surface-subtle);
  border: 1px solid var(--border); padding: 0 5px; border-radius: var(--radius-sm); overflow-wrap: anywhere; }
@media (max-width: 760px) { .gloss-item { grid-template-columns: 1fr; gap: var(--space-2); } }
