/* Firma Authority — Control Room design system.
   Shared across every Askama template via <link href="/assets/app.css">.
   Ported from the `design_handoff_control_room` mock: dark-first, no shadows,
   separation carried by 1px borders and surface value alone. Both themes are
   defined here; the shell writes `data-theme` on <html> and persists the
   choice, so a page renders in the operator's theme before first paint. */

/* ─── FONTS ───────────────────────────────────────────────────────── */
/* Self-hosted Latin variable fonts (OFL-1.1, see ../licenses/): the CSP only
   allows 'self', so the families named in --sans, --display and --mono must be
   served from /assets. Each weight range matches the file's `wght` axis. */
@font-face {
  font-family: "Instrument Sans";
  src: url("/assets/instrument-sans.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Archivo;
  src: url("/assets/archivo.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

/* ─── TOKENS ──────────────────────────────────────────────────────── */
/* Dark is the default theme: `:root` carries it, `[data-theme=light]`
   overrides. Legacy aliases (--surface, --green, --r …) are kept at the end of
   each block so the page-level rules written against the previous design
   system inherit the new palette without being rewritten rule by rule. */
:root {
  color-scheme: dark;

  --bg:          #131217;
  --head:        rgba(19,18,23,.9);
  --rail:        #151419;
  --panel:       #191820;
  --panel2:      #1a1920;
  --line:        #262430;
  --line2:       #221f2b;
  --lineStrong:  #322f3d;
  --text:        #eceaef;
  --text2:       #9b95ab;
  --text3:       #6b6580;
  --text4:       #5d5870;
  --chip:        #c9c4d6;
  --accent:      #f2703a;
  --accentFg:    #1a0d07;
  --accentText:  #ffb08c;
  --accentSoft:  rgba(242,112,58,.14);
  --accentLine:  rgba(242,112,58,.34);
  --amber:       #e8b04b;
  --amberText:   #e8b04b;
  --amberSoft:   rgba(232,176,75,.12);
  --amberLine:   rgba(232,176,75,.30);
  --live:        #3fcf7f;
  --liveText:    #7ee7ad;
  --red:         #d94f4f;
  --redText:     #e88b8b;
  --redSoft:     rgba(217,79,79,.08);
  --redLine:     #4a2b2b;
  --dead:        #2c2937;
  --deadLine:    #3a3748;
  --deadFg:      #8a8299;
  --grid:        rgba(255,255,255,.035);
  --barNeutral:  #4f4a5e;
  --barTrack:    #221f2b;
  --foot:        #101015;
  --focusBg:     linear-gradient(180deg,#221a19 0%,#191820 55%);
  --focusLine:   #3a2a24;
  --blue:        #7aa2f7;
  --blueText:    #7aa2f7;
  --blueSoft:    rgba(122,162,247,.12);
  --blueLine:    rgba(122,162,247,.30);
  --muted:       #8a8299;
  --activeBar:   rgba(242,112,58,.9);
  --denyBar:     rgba(217,79,79,.85);
  --denyBarFg:   #2a0f0f;
  /* Neutral wash over the page surface, for zebra rows and inset fills. */
  --tint:        rgba(255,255,255,.03);
  --tint2:       rgba(255,255,255,.055);
  --auditHead:   rgba(25,24,32,.94);
  --scrim:       rgba(0,0,0,.62);

  --mono: "JetBrains Mono","SFMono-Regular",Consolas,"Liberation Mono",Menlo,monospace;
  --sans: "Instrument Sans",ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  --display: Archivo,"Instrument Sans",ui-sans-serif,system-ui,-apple-system,sans-serif;
  --r:    14px;
  --r-sm: 7px;

  /* Legacy aliases — previous design system names, repointed. */
  --surface:   var(--panel);
  --surface-2: var(--panel2);
  --line-soft: var(--line2);
  --text-2:    var(--text2);
  --text-3:    var(--text3);
  --green:     var(--accent);
  --green-2:   var(--accentText);
  --green-dim: var(--accentSoft);
  --red-dim:   var(--redSoft);
  --amber-dim: var(--amberSoft);
  --blue-dim:  var(--blueSoft);
  --sh:    none;
  --sh-lg: none;
}

[data-theme="light"] {
  color-scheme: light;

  --bg:          #f4f2ec;
  --head:        rgba(244,242,236,.9);
  --rail:        #faf8f3;
  --panel:       #ffffff;
  --panel2:      #faf8f3;
  --line:        #e4dfd4;
  --line2:       #eee9df;
  --lineStrong:  #d4cec0;
  --text:        #1a1820;
  --text2:       #5c5768;
  --text3:       #8a8496;
  --text4:       #a49eab;
  --chip:        #3a3646;
  --accent:      #cf5326;
  --accentFg:    #fff5f0;
  --accentText:  #a13d18;
  --accentSoft:  rgba(207,83,38,.10);
  --accentLine:  rgba(207,83,38,.30);
  --amber:       #a9761a;
  --amberText:   #a9761a;
  --amberSoft:   rgba(169,118,26,.10);
  --amberLine:   rgba(169,118,26,.28);
  --live:        #168a4a;
  --liveText:    #167a43;
  --red:         #bd382e;
  --redText:     #9c2b23;
  --redSoft:     rgba(189,56,46,.07);
  --redLine:     #e5c6c1;
  --dead:        #eae5da;
  --deadLine:    #d8d2c5;
  --deadFg:      #6f6a7a;
  --grid:        rgba(26,24,32,.05);
  --barNeutral:  #b6afbe;
  --barTrack:    #ece7dd;
  --foot:        #efece5;
  --focusBg:     linear-gradient(180deg,#fff4ee 0%,#ffffff 60%);
  --focusLine:   #e8cec2;
  --blue:        #3d5a80;
  --blueText:    #3d5a80;
  --blueSoft:    rgba(61,90,128,.10);
  --blueLine:    rgba(61,90,128,.28);
  --muted:       #6f6a7a;
  --activeBar:   #cf5326;
  --denyBar:     #bd382e;
  --denyBarFg:   #fff1ef;
  --tint:        rgba(26,24,32,.028);
  --tint2:       rgba(26,24,32,.05);
  --auditHead:   rgba(255,255,255,.92);
  --scrim:       rgba(26,24,32,.38);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  min-height: 100%; height: auto;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body {
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accentText); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -.03em; }

/* The live indicator's heartbeat, shared by the timeline dot and the footer. */
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ─── SHELL ───────────────────────────────────────────────────────── */
/* Header on top, rail + main side by side, status bar pinned to the bottom —
   the mock's three-band chrome. The previous 252px sidebar is gone: navigation
   lives in the 56px rail, labels reachable as tooltips. */
firma-shell, #page-frame, firma-hitl-page { display: contents; }
.app { min-height: 100vh; display: flex; flex-direction: column; }
.shell { display: flex; flex: 1; min-width: 0; }
main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { flex: 1; min-width: 0; padding: 26px 26px 34px; }

/* ─── HEADER ──────────────────────────────────────────────────────── */
.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 22px;
  height: 56px; padding: 0 22px;
  background: var(--head);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 4px;
  background: var(--accent); color: var(--accentFg);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 700; font-size: 13px;
}
.brand-name {
  font-family: var(--display); font-weight: 700; font-size: 14px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--text);
}

/* Workspace switcher chip */
.ws-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px;
  border: 1px solid var(--lineStrong); border-radius: 6px;
  background: transparent; cursor: pointer;
  font-family: var(--mono); font-size: 11.5px; color: var(--text);
}
.ws-chip .caret { color: var(--text4); pointer-events: none; }
.ws-chip:hover { border-color: var(--text3); }
.ws-chip.static { cursor: default; }

/* Command bar — a client-side filter over the current view, not a search API. */
.cmdbar-wrap { flex: 1; display: flex; justify-content: center; min-width: 0; }
firma-shell:has([data-hide-view-filter]) .cmdbar-wrap { display: none; }
.cmdbar {
  display: flex; align-items: center; gap: 10px;
  width: 100%; max-width: 420px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--panel2);
}
.cmdbar .glyph { font-size: 12px; color: var(--text4); }
.cmdbar input {
  flex: 1; min-width: 0;
  border: 0; background: transparent; outline: none;
  font-family: var(--sans); font-size: 12.5px; color: var(--text);
}
.cmdbar input::placeholder { color: var(--text3); }
.kbd {
  font-family: var(--mono); font-size: 10.5px; color: var(--text4);
  border: 1px solid var(--lineStrong); border-radius: 4px; padding: 1px 5px;
}

/* Role switcher — limited to the roles the operator actually holds. */
.role-switcher { display: flex; align-items: center; gap: 8px; }
.role-switcher form { display: inline-flex; }
.role-chip {
  border: 1px solid var(--line); background: transparent;
  border-radius: 6px; padding: 5px 11px;
  font-family: var(--mono); font-size: 11.5px; color: var(--text3);
  cursor: pointer; text-decoration: none; line-height: 1.35;
  transition: color 100ms ease-out, border-color 100ms ease-out, background 100ms ease-out;
}
.role-chip:hover { color: var(--text); border-color: var(--lineStrong); }
.role-chip.active {
  border-color: var(--accent); background: var(--accentSoft);
  color: var(--accentText); font-weight: 600;
}
.icon-btn {
  width: 30px; height: 28px; flex-shrink: 0;
  border: 1px solid var(--line); border-radius: 6px;
  background: transparent; color: var(--text2);
  font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 100ms ease-out, border-color 100ms ease-out;
}
.icon-btn:hover { border-color: var(--lineStrong); color: var(--text); }

/* ─── RAIL ────────────────────────────────────────────────────────── */
.rail {
  width: 56px; flex: 0 0 56px;
  position: sticky; top: 56px; align-self: flex-start;
  height: calc(100vh - 56px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--rail); border-right: 1px solid var(--line);
  padding: 14px 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.rail-item {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 8px; border: 0; background: transparent;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 14px; color: var(--text4);
  cursor: pointer; text-decoration: none;
  transition: background 100ms ease-out, color 100ms ease-out;
}
.rail-item:hover { background: var(--panel2); color: var(--text); }
.rail-item.active { background: var(--accentSoft); color: var(--accent); }
.rail-item.disabled { opacity: .38; cursor: default; }
.rail-item.disabled:hover { background: transparent; color: var(--text4); }
/* The link label stays in the DOM for assistive tech (and for the shell's
   role-gating tests, which assert on `>Label<`); the rail shows the glyph. */
.rail-label {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.rail-sep { width: 22px; height: 1px; background: var(--line); margin: 8px 0; flex-shrink: 0; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 4px; }
/* Pending-approval count, polled by htmx; empty when zero. */
.rail-item { position: relative; }
.nav-pill {
  position: absolute; top: 2px; right: 2px;
  min-width: 15px; padding: 0 4px;
  border-radius: 20px; border: 1px solid var(--accentLine);
  background: var(--accentSoft); color: var(--accentText);
  font-family: var(--mono); font-size: 9.5px; font-weight: 600;
  line-height: 14px; text-align: center;
}
.nav-pill:empty { display: none; }

/* ─── STATUS BAR ──────────────────────────────────────────────────── */
.statusbar {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: 26px;
  height: 38px; padding: 0 22px; flex-wrap: wrap;
  background: var(--foot); border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 10.5px; color: var(--text3);
}
.statusbar .online { display: inline-flex; align-items: center; gap: 7px; color: var(--text2); }
.statusbar .push { margin-left: auto; }

.live-dot {
  width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
}

/* ─── PAGE HEADING ────────────────────────────────────────────────── */
.eyebrow {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .2em; text-transform: uppercase; color: var(--accent);
}
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 33px; line-height: 1.05; margin-top: 10px; color: var(--text); }
.page-head .sub {
  margin-top: 9px; font-size: 13.5px; line-height: 1.6;
  color: var(--text2); max-width: 620px; text-wrap: pretty;
}
.head-stats { display: flex; gap: 34px; padding-bottom: 4px; }
.head-stat-value { font-family: var(--display); font-weight: 600; font-size: 30px; letter-spacing: -.03em; line-height: 1; color: var(--text); }
.head-stat-label { font-family: var(--mono); font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--text3); margin-top: 7px; }

/* ─── CONTROL ROOM: TIMELINE ──────────────────────────────────────── */
.cr-card { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 20px 22px; }
.cr-card.timeline { padding-bottom: 16px; }
.cr-label { font-family: var(--mono); font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--text3); }
.cr-card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.cr-live { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 10.5px; color: var(--accent); }
.cr-legend { display: flex; gap: 16px; font-family: var(--mono); font-size: 10px; color: var(--text3); }
.cr-legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 6px; border-radius: 2px; flex-shrink: 0; }
.swatch.active  { background: var(--accent); }
.swatch.expired { background: var(--deadLine); }
.swatch.pending { border: 1px solid var(--amber); }
.swatch.denied  { background: var(--red); }

.lanes { display: flex; flex-direction: column; gap: 3px; }
.lane { display: grid; grid-template-columns: 168px 1fr; gap: 14px; align-items: center; }
.lanes .lane + .lane { border-top: 1px solid var(--line2); }
.lane-name { font-family: var(--mono); font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane-meta { font-size: 10.5px; color: var(--text3); margin-top: 2px; }
.track { position: relative; min-height: 42px; border-left: 1px solid var(--line); }
.track::before {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px 16.666%);
}
.bar {
  position: absolute; height: 26px;
  border-radius: 5px; padding: 0 8px;
  display: flex; align-items: center; overflow: hidden;
  font-family: var(--mono); font-size: 10.5px; white-space: nowrap;
  border: 1px solid transparent;
}
.bar span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.bar.active  { background: var(--activeBar); border-color: var(--activeBar); color: var(--accentFg); }
.bar.expired { background: var(--dead); border-color: var(--deadLine); color: var(--deadFg); }
.bar.pending { background: transparent; border-color: var(--amber); color: var(--amber); }
.bar.denied  { background: var(--denyBar); border-color: var(--denyBar); color: var(--denyBarFg); }
.axis { display: grid; grid-template-columns: 168px 1fr; gap: 14px; margin-top: 8px; }
.axis-ticks {
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 10px; color: var(--text4);
  border-top: 1px solid var(--line); padding-top: 8px;
}
/* Timeline window picker (30 / 60 / 240 min). */
.win-picker { display: inline-flex; gap: 6px; }
.win-picker a {
  font-family: var(--mono); font-size: 10px; color: var(--text3);
  border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px;
}
.win-picker a.active { border-color: var(--accent); color: var(--accentText); background: var(--accentSoft); }

/* ─── CONTROL ROOM: DECISION QUEUE ────────────────────────────────── */
.cr-grid { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(0,1fr); gap: 22px; align-items: start; margin-top: 22px; }
.cr-col { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.cr-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.cr-section-note { font-family: var(--mono); font-size: 11px; color: var(--text2); }

.focus-card { border: 1px solid var(--focusLine); border-radius: var(--r); background: var(--focusBg); padding: 24px; }
.focus-top { display: flex; justify-content: space-between; gap: 22px; align-items: flex-start; flex-wrap: wrap; }
.focus-caption { font-family: var(--mono); font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--text3); }
.focus-action { font-family: var(--display); font-weight: 600; font-size: 27px; letter-spacing: -.02em; margin-top: 9px; color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--lineStrong); border-radius: 20px; padding: 5px 11px;
  font-family: var(--mono); font-size: 11px; color: var(--chip);
}
.chip .k { color: var(--text3); }
.focus-ttl { text-align: right; }
.focus-ttl .value { font-family: var(--display); font-weight: 600; font-size: 34px; letter-spacing: -.03em; line-height: 1; color: var(--accent); }
.focus-ttl .label { font-family: var(--mono); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--text3); margin-top: 7px; }
.ttl-track { height: 4px; border-radius: 3px; background: var(--barTrack); margin-top: 20px; overflow: hidden; }
.ttl-fill { height: 100%; border-radius: 3px; background: var(--accent); }
.focus-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; align-items: center; }
.focus-actions .btn { padding: 11px 18px; font-size: 13px; border-radius: 8px; gap: 9px; }
.focus-actions .btn.primary .kbd { border: 0; background: rgba(0,0,0,.16); color: inherit; }
/* Approve / deny stay disabled until the shared approval service lands. */
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn:disabled:hover, .btn[disabled]:hover { opacity: .5; }
.focus-actions .meta { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--text3); }

.queue-stack { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.queue-row {
  display: flex; align-items: center; gap: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
  padding: 13px 16px; cursor: pointer; text-decoration: none;
  transition: border-color 100ms ease-out;
}
.queue-row:hover { border-color: var(--lineStrong); }
.queue-row.focused { border-color: var(--accentLine); background: var(--accentSoft); }
.queue-row .action { font-family: var(--mono); font-size: 12.5px; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-row .agent { font-size: 11.5px; color: var(--text3); }
.queue-row .ttl { font-family: var(--mono); font-size: 11.5px; color: var(--text3); }
.queue-row .ttl.low { color: var(--amber); }

/* ─── CONTROL ROOM: EXPOSURE ──────────────────────────────────────── */
.cr-card-sub { font-size: 11.5px; color: var(--text3); margin-top: 6px; margin-bottom: 18px; }
.exposure { display: flex; flex-direction: column; gap: 14px; }
.exposure-head { display: flex; justify-content: space-between; gap: 12px; font-family: var(--mono); font-size: 11.5px; margin-bottom: 7px; }
.exposure-head .name { color: var(--chip); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exposure-head .note { color: var(--text3); flex-shrink: 0; }
.exposure-bar { display: flex; height: 7px; border-radius: 4px; overflow: hidden; background: var(--barTrack); }
.exposure-bar .allow { background: var(--barNeutral); }
.exposure-bar .deny  { background: var(--red); }

/* ─── CONTROL ROOM: EVENT STREAM ──────────────────────────────────── */
.stream { display: flex; flex-direction: column; }
.stream-row { display: grid; grid-template-columns: 64px 1fr 76px; gap: 12px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line2); }
.stream-row .t { font-family: var(--mono); font-size: 10.5px; color: var(--text4); }
.stream-row .body { min-width: 0; }
.stream-row .action { font-family: var(--mono); font-size: 11.5px; color: var(--chip); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stream-row .detail { font-size: 10.5px; color: var(--text3); }
.stream-row .decision { font-family: var(--mono); font-size: 10.5px; text-align: right; }
.decision.deny, .decision.revoke { color: var(--red); }
.decision.grant  { color: var(--accent); }
.decision.allow  { color: var(--text2); }
.decision.hold   { color: var(--amber); }
.decision.sync   { color: var(--blue); }
.decision.stale  { color: var(--muted); }

/* An empty panel states what is missing rather than rendering a blank box. */
.cr-empty { font-size: 12.5px; color: var(--text3); padding: 18px 0; line-height: 1.6; }
/* Marks a panel whose numbers are partial because the backend cannot supply
   the full series yet (see the deny-by-action-class gap). */
.cr-caveat { font-family: var(--mono); font-size: 10px; color: var(--text4); margin-top: 14px; line-height: 1.5; }
/* ─── PAGE CHROME ─────────────────────────────────────────────────── */
/* Each page is its own server route, so no show/hide routing here. A page
   may wrap its body in `.page` purely for the mount fade-in. */
.page { animation: fadeUp .15s ease-out; }
@keyframes fadeUp { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }

.page-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 20px; margin-bottom: 26px;
}
.page-head h1 {
  font-size: 27px; font-weight: 700;
  letter-spacing: -.05em; line-height: 1.1;
}
.page-head .sub {
  margin-top: 7px; color: var(--text-2);
  font-size: 13.5px; line-height: 1.55; max-width: 580px;
}
.head-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }

/* ─── BUTTONS ─────────────────────────────────────────────────────── */
.btn {
  border-radius: var(--r-sm); padding: 7px 14px;
  font-size: 13px; font-weight: 650;
  cursor: pointer; border: 1px solid transparent;
  font-family: var(--sans); line-height: 1;
  transition: opacity 90ms, transform 80ms, box-shadow 90ms;
  display: inline-flex; align-items: center; gap: 5px;
}
.btn:active { transform: scale(.98); }
.btn.primary   { background: var(--green); color: var(--panel); border-color: var(--accentLine); }
.btn.secondary { background: var(--panel); color: var(--text); border-color: var(--line); }
.btn.approve   { background: var(--green-dim); color: var(--green-2); border-color: var(--accentLine); font-weight: 700; }
.btn.deny      { background: var(--red-dim); color: var(--redText); border-color: var(--redLine); }
.btn.sm        { padding: 5px 11px; font-size: 12px; border-radius: 6px; }
.btn:hover { opacity: .86; }

/* ─── CARDS ───────────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r);
  padding: 18px;
}
.card-title { font-size: 14.5px; font-weight: 650; letter-spacing: -.02em; margin-bottom: 3px; }
.card-sub    { font-size: 12.5px; color: var(--text-3); line-height: 1.5; margin-bottom: 14px; }

/* ─── STAT CARDS ──────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 26px; }
.stat {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r);
  padding: 16px 18px;
  cursor: pointer; transition: box-shadow 120ms, transform 80ms;
}
.stat:hover { transform: translateY(-1px); }
.stat-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-3); margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.stat-num {
  font-size: 38px; font-weight: 700;
  letter-spacing: -.065em; line-height: 1;
  margin-bottom: 5px;
}
.stat-note { font-size: 11.5px; color: var(--text-3); }

/* ─── BADGES ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid; border-radius: 5px;
  padding: 2px 7px;
  font-size: 11px; font-weight: 700; line-height: 1.4;
  white-space: nowrap;
}
.badge.active   { color: var(--accentText); border-color: var(--accentLine); background: var(--accentSoft); }
.badge.idle     { color: var(--text-3); border-color: var(--line); background: var(--tint); }
.badge.warn     { color: var(--amberText); border-color: var(--amberLine); background: var(--amberSoft); }
.badge.error    { color: var(--redText); border-color: var(--redLine); background: var(--redSoft); }
.badge.allow    { color: var(--accentText); border-color: var(--accentLine); background: var(--accentSoft); }
.badge.deny     { color: var(--redText); border-color: var(--redLine); background: var(--redSoft); }
.badge.pending  { color: var(--amberText); border-color: var(--amberLine); background: var(--amberSoft); }
.badge.info     { color: var(--blueText); border-color: var(--blueLine); background: var(--blueSoft); }
.badge.expired  { color: var(--text-3); border-color: var(--line); background: var(--tint); }

/* ─── TABLES ──────────────────────────────────────────────────────── */
.table-wrap { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 9px 13px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-3); background: var(--tint);
  font-size: 10.5px; letter-spacing: .10em;
  text-transform: uppercase; font-weight: 700;
}
td {
  padding: 10px 13px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text); vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; transition: background 70ms; }
tbody tr:hover { background: var(--accentSoft); }
.mono { font-family: var(--mono); font-size: 12px; }
.dim  { color: var(--text-3); }
.accent { color: var(--green-2); }

/* ─── SECTION HEADER ─────────────────────────────────────────────── */
.section-h {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.section-h .title { font-size: 14.5px; font-weight: 650; letter-spacing: -.02em; }
.section-h .count { font-family: var(--mono); font-size: 12px; color: var(--text-3); }

/* ─── KV ROWS ────────────────────────────────────────────────────── */
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv-k { color: var(--text-3); }
.kv-v { font-weight: 600; text-align: right; }

/* ═══════════════════════════════════════════════════════════════════
   PAGE: AGENTS
═══════════════════════════════════════════════════════════════════ */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}
.agent-card {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r);
  padding: 18px;
  cursor: pointer;
  transition: box-shadow 110ms, transform 80ms, border-color 110ms;
}
.agent-card:hover { transform: translateY(-1px); border-color: var(--accentLine); }
.agent-card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.agent-name-wrap .name { font-family: var(--mono); font-size: 14px; font-weight: 700; letter-spacing: -.02em; }
.agent-name-wrap .id   { font-family: var(--mono); font-size: 11px; color: var(--text-3); margin-top: 3px; }
.agent-divider { border: none; border-top: 1px solid var(--line-soft); margin: 0 0 12px; }
.agent-rows { display: grid; gap: 8px; }
.agent-row { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; }
.agent-row-label { color: var(--text-3); }
.agent-row-val { font-weight: 600; display: flex; align-items: center; gap: 5px; }
.conn-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.conn-dot.ok  { background: var(--green); }
.conn-dot.off { background: var(--deadLine); }
.conn-dot.err { background: var(--red); }
.channel-tag {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--line); background: var(--tint);
  border-radius: 5px; padding: 2px 8px;
  font-size: 12px; font-weight: 600; color: var(--text-2);
}


/* ─── WORKSPACE MANAGEMENT PAGE ──────────────────────────────── */
.ws-mgmt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width:900px){ .ws-mgmt-grid { grid-template-columns: 1fr; } }
.suspend-state-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }
.suspend-state-label { font-size: 13px; font-weight: 600; color: var(--text); }
.suspend-warn-box { font-size: 12px; color: var(--amberText); margin-top: 10px; padding: 9px 12px; background: var(--amber-dim); border-radius: 6px; border: 1px solid var(--amberLine); }
.key-id-mono { font-family: var(--mono); font-size: 12px; color: var(--text-2); background: var(--tint); padding: 3px 8px; border-radius: 4px; }
.sidecar-table { min-width: 480px; }
.psk-mono { font-family: var(--mono); font-size: 11px; background: var(--tint); padding: 2px 6px; border-radius: 3px; letter-spacing: .04em; color: var(--text-2); }
.scope-note { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; border-radius: 4px; padding: 1px 7px; }
.scope-note.org { background: var(--blueSoft); color: var(--blueText); border: 1px solid var(--blueLine); }
.scope-note.ws  { background: var(--tint); color: var(--text2); border: 1px solid var(--line); }

/* ─── BEHAVIOR BADGES (capability policy) ────────────────────── */
.bhv { display:inline-flex; align-items:center; gap:5px; border-radius:5px; padding:2px 9px; font-size:11.5px; font-weight:700; letter-spacing:.02em; white-space:nowrap; }
.bhv.allow { background: var(--accentSoft); color:var(--accentText); border:1px solid var(--accentLine); }
.bhv.deny  { background: var(--redSoft);  color:var(--redText); border:1px solid var(--redLine); }
.bhv.hitl  { background: var(--amberSoft); color:var(--amberText); border:1px solid var(--amberLine); }

/* segmented Allow / HITL / Deny control */
.seg { display:inline-flex; border:1px solid var(--line); border-radius:7px; overflow:hidden; background:var(--surface); flex-shrink:0; }
.seg button { border:none; background:transparent; padding:5px 12px; font-size:12px; font-weight:650; cursor:pointer; color:var(--text-3); font-family:var(--sans); border-right:1px solid var(--line); transition:background 90ms,color 90ms; }
.seg button:last-child { border-right:none; }
.seg button.on-allow { background: var(--green); color:var(--panel); }
.seg button.on-deny  { background: var(--red);   color:var(--panel); }
.seg button.on-hitl  { background: var(--amber); color:var(--panel); }
.seg.readonly button, .seg button:disabled { cursor: default; opacity: 1; }

/* capability policy rule rows */
.cap-rule-row { display:flex; align-items:center; gap:10px; padding:9px 0; border-bottom:1px solid var(--line-soft); }
.cap-rule-row:last-child { border-bottom:none; }
.cap-ac-select { flex:1; min-width:180px; height:34px; font-family:var(--mono); font-size:12px; }
.cap-rule-remove { border:none; background:transparent; color:var(--text-3); cursor:pointer; font-size:18px; line-height:1; padding:2px 7px; border-radius:5px; }
.cap-rule-remove:hover { background: var(--red-dim); color: var(--red); }
.cap-policy-grid { display:grid; grid-template-columns: 1fr 1fr; gap:16px; align-items:start; }
@media (max-width:980px){ .cap-policy-grid { grid-template-columns:1fr; } }
.cap-count-row { display:flex; gap:14px; flex-wrap:wrap; margin-top:4px; }
.cap-count-row span { font-size:11.5px; font-weight:600; color:var(--text-2); }
.cap-ac-read {
  flex: 1; min-width: 180px; font-family: var(--mono); font-size: 12px;
  color: var(--text); background: var(--tint);
  border: 1px solid var(--line-soft); border-radius: 7px; padding: 8px 10px;
}

/* ═══════════════════════════════════════════════════════════════════
   PAGE: HITL
═══════════════════════════════════════════════════════════════════ */
.hitl-layout { display: grid; grid-template-columns: 1fr 310px; gap: 18px; align-items: start; }

.approval-card {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color 110ms;
}
.approval-card:hover { border-color: var(--accentLine); }

.appr-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.appr-left .action  { font-family: var(--mono); font-size: 15px; font-weight: 700; margin-bottom: 7px; }
.appr-right { display: flex; flex-direction: column; gap: 5px; align-items: flex-end; flex-shrink: 0; }

.ttl-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 12.5px; font-weight: 700;
  padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--amberLine);
  background: var(--amberSoft); color: var(--amberText);
}
.ttl-badge.urgent { border-color: var(--redLine); background: var(--red-dim); color: var(--redText); }
.ttl-cap { font-size: 11px; color: var(--text-3); }

.appr-meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; }
.appr-meta span { font-size: 12px; color: var(--text-3); }
.appr-meta strong { color: var(--text-2); font-weight: 600; }

.appr-caption {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .09em; color: var(--text-3); margin-bottom: 4px;
}
.aai-lbl { display: inline-block; min-width: 62px; color: var(--text-3); font-weight: 600; }
.appr-fields { display: flex; flex-wrap: wrap; gap: 14px 30px; margin-top: 10px; }
.appr-field-lbl { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); margin-bottom: 4px; }
.appr-field-val { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); }

.appr-actions { display: flex; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft); flex-wrap: wrap; }
.budget-action-box {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 28px; padding: 5px 10px;
  border: 1px solid var(--accentLine); border-radius: 6px;
  background: var(--green-dim); color: var(--green-2);
  font-size: 12px; font-weight: 700; line-height: 1;
}
.budget-action-box .lbl { white-space: nowrap; }
.budget-input {
  width: 48px; border: 1px solid var(--accentLine); border-radius: 5px;
  padding: 3px 5px; font-size: 12px; font-family: var(--mono); font-weight: 800;
  color: var(--green-2); background: var(--panel); outline: none;
}
.budget-input:focus { border-color: var(--accentLine); }
.budget-unit { font-size: 11px; color: var(--green-2); font-weight: 700; white-space: nowrap; }


.time-picker-row {
  display: none; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 10px; padding: 10px 12px;
  border: 1px solid var(--accentLine); border-radius: 8px;
  background: var(--accentSoft);
}
.time-picker-row.open { display: flex; }
.tp-input {
  width: 72px; border: 1px solid var(--line); border-radius: 7px;
  padding: 5px 9px; font-size: 13px; font-family: var(--mono);
  color: var(--text); background: var(--panel); outline: none;
  transition: border-color 90ms;
}
.tp-input:focus { border-color: var(--accentLine); }
.tp-unit { font-size: 12.5px; color: var(--text-3); font-weight: 600; }

/* Side panel */
.side-panel { display: flex; flex-direction: column; gap: 14px; }

.active-appr-item {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 9px; padding: 12px;
  margin-bottom: 10px;
}
.active-appr-item:last-child { margin-bottom: 0; }
.aai-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.aai-action { font-family: var(--mono); font-size: 12.5px; font-weight: 700; }
.aai-meta   { font-size: 11.5px; color: var(--text-3); margin-top: 2px; line-height: 1.45; }
.aai-status { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; flex-shrink: 0; }
.revoke-btn { padding: 4px 9px; font-size: 11.5px; }

.bar-wrap { }
.bar-track { height: 3px; background: var(--tint); border-radius: 2px; overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 2px; transition: width 1s linear; }
.bar-fill.ok   { background: var(--green); }
.bar-fill.warn { background: var(--amber); }
.bar-fill.urg  { background: var(--red); }
.bar-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-top: 3px; }

/* ═══════════════════════════════════════════════════════════════════
   PAGE: AUDIT
═══════════════════════════════════════════════════════════════════ */
.filter-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel);
}
.filter-lbl { font-size: 12px; font-weight: 700; color: var(--text-3); }
.filter-sep { width: 1px; height: 20px; background: var(--line); }
.filter-add { margin-left: auto; }
select.fsel,
input.fsel,
textarea.fsel {
  border: 1px solid var(--line); background: var(--panel);
  color: var(--text); border-radius: 6px;
  padding: 5px 10px; font-size: 12.5px;
  font-family: var(--sans); outline: none;
}
select.fsel { cursor: pointer; }
select.fsel:focus,
input.fsel:focus,
textarea.fsel:focus { border-color: var(--accentLine); }
.audit-resource { width: 240px; max-width: 100%; }
.audit-resource-controls { display: flex; gap: 6px; min-width: 0; }
.audit-resource-controls select { height: 32px; flex: 1 0 90px; min-width: 0; }
.audit-resource-controls textarea { box-sizing: border-box; width: 140px; min-width: 0; height: 32px; line-height: 20px; resize: vertical; }
.audit-resource-error { margin: 0; font-size: 12px; color: var(--redText); overflow-wrap: anywhere; }
.audit-resource-controls [aria-invalid="true"] { border-color: var(--redLine); }

.audit-time-controls { display: flex; flex-wrap: wrap; gap: 6px; }
.audit-time-controls select { height: 32px; }
#audit-filters > [data-reset-filters] {
  align-self: flex-end; display: inline-flex; align-items: center;
  box-sizing: border-box; height: 32px;
}
.dialog.audit-time-dialog h3 { letter-spacing: 0; }
.audit-time-dialog input { min-width: 0; width: 100%; box-sizing: border-box; font-family: var(--mono); }
.audit-time-dialog input[aria-invalid="true"] { border-color: var(--redLine); }
.dialog.audit-details-dialog { max-height: 85vh; max-height: 85dvh; overflow: hidden; }
.dialog.audit-details-dialog .modal-body { box-sizing: border-box; max-height: 85vh; max-height: 85dvh; padding: 0; gap: 0; }
.audit-details-header { flex-shrink: 0; padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.audit-details-header .icon-btn { flex-shrink: 0; }
.audit-details-controls { display: flex; flex-shrink: 0; gap: 6px; }
.audit-details-controls [aria-disabled="true"] { opacity: .45; cursor: default; }
.audit-details-content { min-height: 0; padding: 16px 22px; overflow: auto; overscroll-behavior: contain; scrollbar-color: var(--barNeutral) var(--panel2); }
.audit-details-content:focus-visible { outline: 2px solid var(--accentLine); outline-offset: -3px; }
.audit-details-status { box-sizing: content-box; flex-shrink: 0; min-height: 18px; margin: 0; padding: 8px 22px 0; font-size: 12px; line-height: 18px; color: var(--text-2); overflow-wrap: anywhere; }
.audit-details-dialog [data-details-actions] { flex-shrink: 0; padding: 14px 22px; border-top: 1px solid var(--line); }
.audit-details-dialog [data-details-actions][hidden] { display: none; }
.audit-details-dialog [data-details-retry][aria-disabled="true"] { opacity: .55; cursor: default; }
.dialog.audit-details-dialog h3 { letter-spacing: 0; }
.audit-details-dialog dl { margin: 0; min-width: 0; }
.audit-details-dialog dt { color: var(--text-2); font-size: 12px; margin-top: 12px; }
.audit-details-dialog dt:first-child { margin-top: 0; }
.audit-details-dialog dd { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }
.audit-details-dialog dd:empty { min-height: 1em; }
@media (max-height: 360px) {
  .audit-details-header { padding: 10px 16px; }
  .audit-details-status { padding: 4px 16px 0; }
  .audit-details-content { padding: 8px 16px; }
  .audit-details-dialog [data-details-actions] { padding: 8px 16px; }
}
.audit-time-error { margin: 0; font-size: 12px; color: var(--redText); overflow-wrap: anywhere; }
firma-checkbox-menu { display: inline-block; min-width: 0; }
.audit-filter-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
firma-checkbox-menu details { position: relative; width: 180px; max-width: 100%; }
firma-checkbox-menu summary {
  box-sizing: border-box; cursor: pointer; height: 32px;
  border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 10px; color: var(--text); background: var(--panel);
  font: 12.5px var(--sans);
}
firma-checkbox-menu summary:focus-visible { outline: 2px solid var(--accentLine); outline-offset: 2px; }
firma-checkbox-menu [data-checkbox-label] {
  display: inline-block; max-width: calc(100% - 18px); vertical-align: middle;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
firma-checkbox-menu fieldset {
  position: absolute; z-index: 30; top: 100%; left: 0;
  box-sizing: border-box; width: 100%; max-height: 260px; overflow-y: auto;
  margin: 4px 0 0; padding: 8px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--panel); color: var(--text);
}
firma-checkbox-menu legend {
  position: absolute; width: 1px; height: 1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
firma-checkbox-menu label { display: flex; gap: 8px; padding: 5px 0; font-size: 12.5px; }
firma-checkbox-menu [data-option-label] { min-width: 0; overflow-wrap: anywhere; }
firma-checkbox-menu input { flex-shrink: 0; accent-color: var(--accent); }
firma-checkbox-menu label:has(input:disabled) { opacity: .55; }
.audit-option-footer { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding-top: 6px; }
.audit-option-status { margin: 0; color: var(--text-3); font-size: 12px; overflow-wrap: anywhere; }
.audit-option-footer button[aria-disabled="true"] { opacity: .55; cursor: default; }
.live-badge {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--green-2);
}
.live-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: blink 2s infinite; }
.deny-rsn { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); }
.type-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 800; letter-spacing: .02em;
  border-radius: 999px; border: 1px solid; padding: 3px 9px;
  text-transform: uppercase; white-space: nowrap;
}
.type-chip.session { color: var(--accentText); border-color: var(--accentLine); background: var(--accentSoft); }
.type-chip.call { color: var(--blueText); border-color: var(--blueLine); background: var(--blueSoft); }


/* Security Admin */
.table-wrap.scroll { overflow-x: auto; }
.security-table { min-width: 1320px; }
.security-table th { vertical-align: bottom; }
.filter-row th { padding: 6px 8px; background: var(--panel); }
.col-filter {
  width: 100%; min-width: 82px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); color: var(--text);
  padding: 5px 7px; font-size: 11.5px;
  font-family: var(--sans); outline: none;
  text-transform: none; letter-spacing: 0; font-weight: 500;
}
.col-filter:focus { border-color: var(--accentLine); }
.sec-dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); gap: 18px; align-items: stretch; }
/* equal-height columns: the box (table / card) fills so both column bottoms align */
.sec-dashboard-grid > div { display: flex; flex-direction: column; }
.sec-dashboard-grid > div > .table-wrap,
.sec-dashboard-grid > div > .card { flex: 1; }
.issue-list { display: grid; gap: 10px; }
.issue-item {
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); padding: 12px;
}
.issue-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.issue-title { font-size: 13px; font-weight: 650; }
.issue-desc { font-size: 12px; color: var(--text-3); line-height: 1.45; }
.sec-role-grid { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(320px,.65fr); gap: 18px; align-items: start; }
.role-table { min-width: 980px; }
.mini-select {
  border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 7px; font-size: 12px; font-family: var(--sans);
  color: var(--text); background: var(--panel); outline: none;
}
.control-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sec-empty { padding: 28px 14px; text-align: center; color: var(--text-3); font-size: 12.5px; }

/* ─── WORKSPACE POPUP ────────────────────────────────────────────── */
.ws-summary-row { cursor: pointer; }
.ws-summary-row:hover { background: var(--accentSoft) !important; }
.ws-tenant-cell { display: inline-flex; align-items: center; gap: 8px; }
.ws-click-icon {
  width: 20px; height: 20px; border-radius: 5px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accentSoft); border: 1px solid var(--accentLine);
  color: var(--green-2); font-size: 10px; transition: background 120ms;
}
.ws-summary-row:hover .ws-click-icon { background: var(--accentLine); }

/* Popup overlay — lighter than the full modal */
.ws-popup-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: var(--scrim); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; padding: 24px;
}
.ws-popup-overlay.open { display: flex; animation: fadeIn .13s ease; }
.ws-popup {
  width: min(820px, 96vw); max-height: min(86vh, 680px);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px;
  display: flex; flex-direction: column; overflow: hidden;
  animation: popIn .17s ease;
}
.ws-popup-head {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px; border-bottom: 1px solid var(--line-soft); flex-shrink: 0;
}
.ws-popup-icon {
  width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--green-dim); border: 1px solid var(--accentLine); font-size: 16px;
}
.ws-popup-title { font-size: 16px; font-weight: 700; letter-spacing: -.03em; }
.ws-popup-sub   { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.ws-popup-close {
  margin-left: auto; width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text-2);
  cursor: pointer; font-size: 15px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 90ms;
}
.ws-popup-close:hover { background: var(--tint); }
.ws-popup-body { overflow-y: auto; padding: 20px; }
.ws-agent-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ws-agent-table th {
  text-align: left; padding: 8px 12px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-3); background: var(--tint);
  border-bottom: 1px solid var(--line-soft);
}
.ws-agent-table td {
  padding: 11px 12px; border-bottom: 1px solid var(--line-soft);
  color: var(--text); vertical-align: middle;
}
.ws-agent-table tr:last-child td { border-bottom: none; }
.ws-agent-table tbody tr:hover { background: var(--accentSoft); }
.ws-status-dot {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0;
}
.ws-status-dot.ok       { background: var(--green); }
.ws-status-dot.warning  { background: var(--amber); }
.ws-status-dot.critical { background: var(--red); }
.pf-chip {
  display: inline-flex; align-items: center;
  font-family: var(--mono); font-size: 11px; color: var(--green-2);
  border: 1px solid var(--accentLine); background: var(--accentSoft);
  border-radius: 5px; padding: 2px 7px; margin: 2px 3px 2px 0; white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════════
   PAGE: CONFIGURATION
═══════════════════════════════════════════════════════════════════ */
.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: stretch; }
@media (max-width: 900px) { .config-grid { grid-template-columns: 1fr; } }
/* equal-height columns: last card fills so both column bottoms align */
.config-grid > div { display: flex; flex-direction: column; }
.config-grid > div > .card { margin-bottom: 0; }
.config-grid > div > .card + .card { margin-top: 18px; }
.config-grid > div > .card:last-child { flex: 1; }

.cfg-section { margin-bottom: 18px; }
.cfg-section-title { font-size: 15px; font-weight: 650; letter-spacing: -.02em; margin-bottom: 3px; }
.cfg-section-desc  { font-size: 12.5px; color: var(--text-3); margin-bottom: 16px; line-height: 1.5; }

.cfg-field { margin-bottom: 14px; }
.cfg-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--text-2); margin-bottom: 6px; }
.cfg-input {
  width: 100%; max-width: 340px;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--text); border-radius: 8px;
  padding: 8px 12px; font-size: 13.5px; font-family: var(--mono);
  outline: none; transition: border-color 90ms, box-shadow 90ms;
}
.cfg-input:focus { border-color: var(--accentLine); }
.cfg-hint { font-size: 11.5px; color: var(--text-3); margin-top: 5px; line-height: 1.45; }

/* ─── HITL CHANNEL BLOCKS ────────────────────────────────────────── */
.channel-block {
  padding: 14px 0; border-bottom: 1px solid var(--line-soft);
}
.channel-block-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.channel-block-info { display: flex; align-items: flex-start; gap: 10px; flex: 1; }
.channel-block-icon { font-size: 18px; margin-top: 1px; flex-shrink: 0; }
.channel-block-name { font-size: 13.5px; font-weight: 650; margin-bottom: 2px; }
.channel-block-desc { font-size: 12px; color: var(--text-3); line-height: 1.45; }
.channel-block-fields { margin-top: 10px; padding-left: 28px; }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--line-soft);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-info .toggle-title { font-size: 13.5px; font-weight: 600; }
.toggle-info .toggle-desc  { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.toggle-sw { position: relative; width: 38px; height: 22px; flex-shrink: 0; }
.toggle-sw input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--line); border-radius: 22px;
  cursor: pointer; transition: background 200ms;
}
.toggle-track::before {
  content: ''; position: absolute;
  width: 16px; height: 16px; left: 3px; top: 3px;
  background: var(--panel); border-radius: 50%;
  transition: transform 200ms;
}
.toggle-sw input:checked + .toggle-track { background: var(--green); }
.toggle-sw input:checked + .toggle-track::before { transform: translateX(16px); }

/* ═══════════════════════════════════════════════════════════════════
   POLICY ADMIN PAGES
═══════════════════════════════════════════════════════════════════ */
/* ─── TENANT SWITCHER ────────────────────────────────────────────── */
.tenant-switcher { position: relative; }
.tenant-btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 8px; padding: 0 12px; height: 34px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: var(--sans);
  transition: border-color 90ms, box-shadow 90ms;
}
.tenant-btn:hover { border-color: var(--accentLine); }
.tenant-lbl { color: var(--text-3); font-weight: 600; font-size: 12px; }
.tenant-cur { letter-spacing: -.01em; }
.tenant-caret { color: var(--text-3); font-size: 10px; }
.ws-box {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 8px; padding: 0 12px; height: 34px;
}
.ws-lbl { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
.ws-id-val { font-family: var(--mono); font-size: 12.5px; color: var(--text); font-weight: 600; }
/* Uniform height for all header-bar controls so the boxes align */
.head-actions .btn { height: 34px; }
.tenant-menu {
  display: none; position: absolute; top: calc(100% + 6px); right: 0; z-index: 50;
  min-width: 250px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 5px;
}
.tenant-menu.open { display: block; }
.tenant-menu-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: var(--text-3); padding: 6px 9px 5px;
}
.tenant-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 9px; border-radius: 7px; cursor: pointer;
}
.tenant-item:hover { background: var(--accentSoft); }
.tenant-item .ti-name { font-size: 13px; font-weight: 600; color: var(--text); }
.tenant-item .ti-sub  { font-size: 11px; color: var(--text-3); font-family: var(--mono); margin-top: 1px; }
.tenant-item .ti-check { color: var(--green-2); font-weight: 700; visibility: hidden; flex-shrink: 0; }
.tenant-item.current .ti-check { visibility: visible; }
.tenant-item.current { background: var(--accentSoft); }

/* + button on Policy Library */
.icon-add {
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--accentLine);
  background: var(--green); color: var(--panel);
  font-size: 21px; font-weight: 400; line-height: 1;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: opacity 90ms, transform 80ms;
}
.icon-add:hover { opacity: .9; }
.icon-add:active { transform: scale(.95); }

.desc-cell { color: var(--text-2); font-size: 12.5px; }

/* ─── ACTIVE / DRAFT SEGMENTED TOGGLE (policy library rows) ─────── */
.status-toggle {
  display: inline-flex; border: 1px solid var(--line);
  border-radius: 7px; overflow: hidden; background: var(--panel);
}
.status-toggle button {
  border: none; background: transparent;
  padding: 4px 12px; font-size: 11.5px; font-weight: 700;
  letter-spacing: .02em; color: var(--text-3);
  cursor: pointer; font-family: var(--sans);
  transition: background 90ms, color 90ms;
}
.status-toggle button + button { border-left: 1px solid var(--line); }
.status-toggle button:hover:not(.on) { background: var(--tint); color: var(--text-2); }
.status-toggle button.on.active-on { color: var(--green-2); background: var(--accentSoft); }
.status-toggle button.on.draft-on  { color: var(--amberText);        background: var(--amberSoft); }

/* ─── EDITOR MODAL (Notion-style) ─────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: var(--scrim); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; padding: 26px;
}
.modal-overlay.open { display: flex; animation: fadeIn .14s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(1160px, 96vw); height: min(88vh, 880px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px;
  display: flex; flex-direction: column; overflow: hidden;
  animation: popIn .16s ease;
}
@keyframes popIn { from { opacity: 0; transform: scale(.985) translateY(6px); } to { opacity: 1; transform: none; } }

.modal-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 20px; border-bottom: 1px solid var(--line-soft); flex-shrink: 0;
}
.modal-crumb { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); }
.modal-close {
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text-2);
  cursor: pointer; font-size: 15px; line-height: 1;
}
.modal-close:hover { background: var(--tint); }

.modal-body { flex: 1; display: grid; grid-template-columns: 1fr 380px; min-height: 0; }
.modal.read-only .modal-body { grid-template-columns: 1fr; }
.modal.read-only .chat-pane,
.modal.read-only .editor-modes,
.modal.read-only .template-picker,
.modal.read-only .modal-foot .deny,
.modal.read-only .modal-foot .primary { display: none; }
.modal.read-only .editor-pane { border-right: none; }

/* Editor (left) */
.editor-pane {
  display: flex; flex-direction: column; min-width: 0;
  padding: 24px 28px; overflow-y: auto; border-right: 1px solid var(--line-soft);
}
.editor-title {
  border: none; outline: none; background: transparent; width: 100%; padding: 0;
  font-family: var(--sans); font-size: 28px; font-weight: 700;
  letter-spacing: -.045em; color: var(--text);
}
.editor-title::placeholder { color: var(--text-3); opacity: .5; }
.editor-desc {
  border: none; outline: none; resize: none; background: transparent; width: 100%;
  margin-top: 8px; font-family: var(--sans); font-size: 14px; color: var(--text-2);
  line-height: 1.5; min-height: 24px;
}
.editor-desc::placeholder { color: var(--text-3); opacity: .7; }
.editor-title[readonly],
.editor-desc[readonly],
.editor-code[readonly] { cursor: default; }

.editor-modes { display: flex; gap: 8px; margin-top: 18px; }
.mode-btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--text-2);
  border-radius: var(--r-sm); padding: 7px 13px; font-size: 12.5px; font-weight: 650;
  cursor: pointer; font-family: var(--sans); transition: background 90ms, color 90ms, border-color 90ms;
}
.mode-btn.active { background: var(--panel); color: var(--green-2); border-color: var(--accentLine); }

.template-picker {
  display: none; margin-top: 12px;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel);
}
.template-picker.open { display: block; }
.tp-search {
  width: 100%; border: none; border-bottom: 1px solid var(--line-soft);
  padding: 9px 12px; font-size: 13px; outline: none; font-family: var(--sans); color: var(--text);
}
.tp-list { max-height: 246px; overflow-y: auto; }
.tp-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line-soft);
}
.tp-item:last-child { border-bottom: none; }
.tp-item:hover { background: var(--accentSoft); }
.tp-item .nm { font-family: var(--mono); font-size: 12.5px; color: var(--text); }
.tp-item .ds { font-size: 11px; color: var(--text-3); }
.tp-empty { padding: 14px; text-align: center; font-size: 12.5px; color: var(--text-3); }

.editor-code-label {
  margin: 18px 0 7px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .09em; color: var(--text-3);
}
.editor-code {
  flex: 1; min-height: 230px; width: 100%;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel2); color: var(--text);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.65;
  padding: 14px 16px; outline: none; resize: none; tab-size: 2;
}
.editor-code:focus { border-color: var(--accentLine); }

/* Chat (right) */
.chat-pane { display: flex; flex-direction: column; min-height: 0; background: var(--surface-2); }
.chat-head {
  padding: 14px 18px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; flex-shrink: 0;
}
.chat-head .spark { color: var(--green-2); font-size: 14px; }
.chat-head .sub { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--text-3); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 11px; }
.chat-msg { font-size: 13px; line-height: 1.5; max-width: 92%; }
.chat-msg.user {
  align-self: flex-end; background: var(--green); color: var(--panel);
  padding: 9px 12px; border-radius: 13px 13px 4px 13px;
}
.chat-msg.bot {
  align-self: flex-start; background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 9px 12px; border-radius: 13px 13px 13px 4px;
}
.chat-msg.bot code {
  display: block; margin-top: 7px; background: var(--panel2); border: 1px solid var(--line-soft);
  border-radius: 7px; padding: 8px 10px; font-family: var(--mono); font-size: 11.5px;
  color: var(--text); white-space: pre-wrap; line-height: 1.55;
}
.chat-input-row { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line-soft); flex-shrink: 0; }
.chat-input {
  flex: 1; border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 12px; font-size: 13px; font-family: var(--sans); color: var(--text);
  outline: none; resize: none; max-height: 90px; line-height: 1.4;
}
.chat-input:focus { border-color: var(--accentLine); }
.chat-send {
  border: none; background: var(--green); color: var(--panel); border-radius: 9px;
  padding: 0 14px; font-size: 13px; font-weight: 700; cursor: pointer; flex-shrink: 0;
}
.chat-send:hover { opacity: .9; }

/* Footer */
.modal-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 20px; border-top: 1px solid var(--line-soft); flex-shrink: 0;
}

/* ─── ACTION CLASS PAGE ───────────────────────────────────────────── */
.ac-layout { display: grid; grid-template-columns: 1fr 360px; gap: 18px; align-items: start; }
.ac-detail { position: sticky; top: 78px; }
.ac-empty {
  border: 1.5px dashed var(--line); border-radius: var(--r);
  padding: 44px 20px; text-align: center; color: var(--text-3);
}
.ac-empty .icon { font-size: 24px; margin-bottom: 10px; opacity: .6; }
.ac-empty .label { font-size: 13.5px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.ac-empty .desc { font-size: 12.5px; max-width: 240px; margin: 0 auto; line-height: 1.5; }
.alias-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.alias-chip {
  font-family: var(--mono); font-size: 11.5px; color: var(--text-2);
  border: 1px solid var(--line); background: var(--tint);
  border-radius: 5px; padding: 2px 7px;
}
.policy-file-chip {
  display: inline-flex; align-items: center;
  font-family: var(--mono); font-size: 11.5px; color: var(--green-2);
  border: 1px solid var(--accentLine); background: var(--accentSoft);
  border-radius: 5px; padding: 2px 7px;
  cursor: pointer;
}
.policy-file-chip:hover { border-color: var(--accentLine); background: var(--accentSoft); }
.policy-ref-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--mono); font-size: 11px; font-weight: 650;
  color: var(--green-2); border: 1px solid var(--accentLine);
  background: var(--accentSoft); border-radius: 5px; padding: 2px 7px;
  cursor: pointer; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.policy-ref-chip:hover { background: var(--accentSoft); border-color: var(--accentLine); }
.policy-ref-list { display: flex; flex-wrap: wrap; gap: 6px; min-width: 210px; }
tbody tr.selected { background: var(--accentSoft); }

/* ─── ALIAS CHIPS (action class editor) ──────────────────────────── */
.alias-edit-list { display: flex; flex-wrap: wrap; gap: 6px; min-height: 26px; margin-bottom: 8px; }
.alias-edit-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 11.5px;
  border: 1px solid var(--line); background: var(--tint);
  border-radius: 6px; padding: 3px 9px; color: var(--text-2);
}
.alias-edit-chip .rmx { cursor: pointer; color: var(--text-3); font-size: 14px; line-height: 1; margin-left: 2px; }
.alias-edit-chip .rmx:hover { color: var(--red); }
.alias-add-row { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }

/* ─── TOAST ───────────────────────────────────────────────────────── */
#toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 90;
  display: flex; flex-direction: column; gap: 9px;
  width: min(320px, calc(100vw - 36px)); pointer-events: none;
}
.toast {
  border-radius: 12px; padding: 11px 14px;
  font-size: 13px; font-weight: 600; line-height: 1.4;
  background: var(--panel);
  border: 1px solid var(--line);
  opacity: 0; transform: translateY(6px);
  transition: opacity .14s, transform .14s;
}
.toast.in { opacity: 1; transform: translateY(0); }
.toast.approve-t { border-color: var(--accentLine); }
.toast.deny-t    { border-color: var(--redLine); }

/* ─── RESPONSIVE ─────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .stats-row { grid-template-columns: repeat(2,1fr); }
  .hitl-layout { grid-template-columns: 1fr; }
  .sec-dashboard-grid,
  .sec-role-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  aside { display: none; }
}
@media (max-width: 620px) {
  .topbar { padding: 0 12px; gap: 10px; }
  .appbar {
    position: static; height: auto; padding: 10px 12px; gap: 8px;
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  }
  .appbar .brand { grid-area: 1 / 1; }
  .appbar .ws-chip { grid-area: 2 / 1; min-width: 0; overflow-wrap: anywhere; }
  .appbar .role-switcher { grid-area: 1 / 2; justify-content: flex-end; min-width: 0; }
  .appbar .role-chip { min-width: 0; overflow-wrap: anywhere; }
  .appbar .cmdbar-wrap { grid-area: 2 / 2; }
  .appbar .cmdbar { min-width: 0; }
  .rail { top: 0; }
  .role-label { display: none; }
  .role-toggle button { padding: 5px 8px; font-size: 11.5px; }
  .content { padding: 22px 14px 56px; }
  .page-head, .page-header { flex-direction: column; }
  .head-actions, .header-actions { flex-wrap: wrap; max-width: 100%; }
}

/* ═══════════════════════════════════════════════════════════════════
   APP EXTRAS — components not present in the mock
   ═══════════════════════════════════════════════════════════════════ */

/* Warning banner (default-credential notice, pending-feature callouts) */
.banner-warn {
  border: 1px solid var(--amberLine); background: var(--amber-dim);
  border-radius: 10px; padding: 12px 14px; margin: 0 0 20px;
  color: var(--amberText); font-size: 13px; line-height: 1.5;
}
.banner-warn .pending-tag {
  display: inline-block; border-radius: 999px; padding: 2px 9px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  background: var(--amberLine); color: var(--amberText); margin-right: 8px;
}

/* Role chip list (dashboard "Your roles") */
.role-list { list-style: none; padding: 0; margin: 8px 0 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.role-list li {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 13px; font-size: 13px; font-weight: 600;
}

/* Live "connected" pill used in the audit filter bar */
.footnote { color: var(--text-3); font-size: 12.5px; margin-top: 16px; line-height: 1.5; }
.empty-note { color: var(--text-3); font-size: 13px; margin: 4px 0 0; }

/* ═══════════════════════════════════════════════════════════════════
   APP COMPONENTS
   Styles for the class names the Askama templates + htmx partials already
   use. Kept under their existing names (JS and htmx selectors depend on
   them) but restyled to the design-system tokens above. Templates carry no
   inline <style> — this is the single source.
   ═══════════════════════════════════════════════════════════════════ */

/* Page header + shared shell aliases */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 26px; }
.page-header h1 { margin: 0 0 4px; font-size: 27px; font-weight: 700; letter-spacing: -.05em; line-height: 1.1; }
.subtitle { margin: 0; color: var(--text-2); font-size: 13.5px; line-height: 1.55; max-width: 620px; }
.header-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
.btn-primary { background: var(--green); color: var(--panel); border: 1px solid var(--accentLine); border-radius: var(--r-sm); padding: 8px 15px; font-size: 13px; font-weight: 650; cursor: pointer; white-space: nowrap; font-family: var(--sans); transition: opacity 90ms; }
.btn-primary:hover { opacity: .88; }
.btn-ghost { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 15px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; font-family: var(--sans); transition: background 90ms, border-color 90ms; }
.btn-ghost:hover { border-color: var(--accentLine); }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 6px; }
button[disabled], .btn-primary[disabled], .btn-ghost[disabled] { opacity: .55; cursor: not-allowed; }

.agents-section { margin-top: 28px; }
.agents-section h2 { font-size: 14.5px; font-weight: 650; letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; margin: 0 0 14px; }
.section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.section-head h2 { font-size: 14.5px; font-weight: 650; letter-spacing: -.02em; margin: 0; }
.section-note { color: var(--text-3); font-size: 13px; margin: 6px 0 16px; line-height: 1.5; }
.count-badge { font-family: var(--mono); background: var(--tint); border: 1px solid var(--line); border-radius: 999px; padding: 1px 10px; font-size: 12px; color: var(--text-3); }

/* Badge variants used by the partials (base .badge comes from the mock) */
.badge.ok      { color: var(--accentText); border-color: var(--accentLine); background: var(--accentSoft); }
.badge.deny    { color: var(--redText); border-color: var(--redLine);  background: var(--redSoft); }
.badge.pending { color: var(--amberText); border-color: var(--amberLine); background: var(--amberSoft); }
.badge.muted   { color: var(--text-3); border-color: var(--line); background: var(--tint); }
.badge.plan    { color: var(--blueText); border-color: var(--blueLine); background: var(--blueSoft); }

/* ── AGENTS: grid + card ─────────────────────────────────────────── */
.agent-grid-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.agent-card .card-head { display: flex; justify-content: space-between; align-items: center; }
.agent-name { font-family: var(--mono); font-weight: 700; font-size: 14px; letter-spacing: -.02em; }
.agent-id { display: block; font-family: var(--mono); color: var(--text-3); font-size: 11px; margin: 3px 0 12px; }
.card-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-top: 1px solid var(--line-soft); font-size: 12.5px; }
.agent-policy-set-error { margin: 6px 0 0; font-size: 12px; color: var(--redText); }
/* Policy sets list */
.policy-set-enabled { display: flex; align-items: center; gap: 8px; }
.toggle-sw input:disabled + .toggle-track { opacity: .45; cursor: not-allowed; }
.policy-set-hint { font-size: 12px; color: var(--text-3); }
.policy-set-alert { margin: 6px 0 0; font-size: 12px; color: var(--redText); }
.policy-set-alert p { margin: 0; }
.policy-set-alert ul { margin: 4px 0 0; padding-left: 18px; }
.row-label { color: var(--text-3); }
.mini-select { border: 1px solid var(--line); border-radius: 7px; padding: 5px 9px; background: var(--panel); color: var(--text); font-size: 12.5px; font-family: var(--sans); outline: none; cursor: pointer; }
.agent-status { font-size: 11px; font-weight: 700; border-radius: 5px; padding: 2px 8px; border: 1px solid var(--line); background: var(--tint); color: var(--text-3); }
.agent-status[data-status="active"] { background: var(--accentSoft); color: var(--accentText); border-color: var(--accentLine); }
.agent-status .last-seen, .agent-status .bundle-version { display: none; }
.pending { color: var(--text-3); font-size: 12.5px; }
.pending-some { color: var(--green-2); font-weight: 650; text-decoration: none; }
.pending-some:hover { text-decoration: underline; }

/* ── HITL page ───────────────────────────────────────────────────── */
.hitl-banner { border: 1px solid var(--amberLine); background: var(--amber-dim); border-radius: 10px; padding: 12px 14px; margin: 18px 0 4px; color: var(--amberText); font-size: 13px; line-height: 1.5; }
.hitl-banner .pending-tag { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 11px; font-weight: 700; background: var(--amberLine); color: var(--amberText); margin-right: 8px; }
.hitl-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; margin-top: 22px; align-items: start; }
@media (max-width: 900px) { .hitl-grid { grid-template-columns: 1fr; } }
.hitl-col { display: flex; flex-direction: column; gap: 14px; }
.appr-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; transition: border-color 110ms; }
.appr-card:hover { border-color: var(--accentLine); }
.appr-caption { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--text-3); margin-bottom: 4px; }
.appr-action { font-family: var(--mono); font-weight: 700; font-size: 15px; margin: 2px 0 12px; }
.appr-fields { margin: 0 0 12px; display: grid; gap: 6px; }
.appr-fields div { display: flex; justify-content: space-between; gap: 12px; }
.appr-fields dt { color: var(--text-3); font-size: 13px; margin: 0; }
.appr-fields dd { margin: 0; text-align: right; word-break: break-all; font-size: 13px; }
.appr-ttl { display: flex; justify-content: space-between; align-items: center; background: var(--amberSoft); border: 1px solid var(--amberLine); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; }
.ttl-label { color: var(--amberText); font-size: 12.5px; font-weight: 600; }
.ttl { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 700; color: var(--amberText); }
.ttl.urgent { color: var(--redText); }
.ttl.lapsed { color: var(--text-3); font-weight: 400; }
.appr-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--text-3); font-size: 12px; margin-bottom: 12px; }
.appr-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-deny { color: var(--redText); border-color: var(--redLine); background: var(--red-dim); }
.side-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.grant-card { border-top: 1px solid var(--line-soft); padding: 14px 0; }
.grant-card:first-of-type { border-top: 0; padding-top: 6px; }
.grant-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.grant-action { font-family: var(--mono); font-weight: 700; font-size: 14px; }
.grant-bar { position: relative; height: 4px; border-radius: 999px; background: var(--tint); overflow: hidden; margin: 10px 0; }
.grant-fill { position: absolute; right: 0; top: 0; bottom: 0; width: 100%; background: var(--green); }
.grant-foot { display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 12px; }
.grant-foot .ttl { margin-left: auto; font-size: 13px; }
.hint { color: var(--text-3); font-size: 12px; }
.decision-list { list-style: none; margin: 8px 0 0; padding: 0; }
.decision-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line-soft); }
.decision-row:first-child { border-top: 0; }
.decision-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.decision-agent { font-weight: 600; font-size: 13px; }
.decision-action { color: var(--text-3); font-size: 12.5px; }
.decision-time { color: var(--text-3); font-size: 12px; }
.decision-side { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.apr-id { color: var(--text-3); font-size: 12px; font-family: var(--mono); }

/* ── AUDIT page ──────────────────────────────────────────────────── */
/* Filter bar controls reuse the shared .filter-lbl / .fsel styles above. */
firma-audit-page { display: block; }
.audit-live-controls {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 32px; margin: -4px 0 8px;
}
.audit-live-status {
  display: inline-flex; align-items: center; gap: 10px; min-width: 0;
  color: var(--text-3); font-size: 12px;
}
.audit-live-status .live-badge { margin-left: 0; }
.audit-live-status[data-state="paused"] #audit-live-mode { color: var(--amberText); }
.audit-live-status[data-state="error"] #audit-live-updated,
.audit-live-status[data-state="error"] #audit-live-mode { color: var(--redText); }
.audit-jump-latest[hidden] { display: none; }
.audit-log-shell { position: relative; }
.audit-log-viewport {
  min-height: 280px;
  max-height: min(62vh, 760px);
  overflow: auto;
  scroll-behavior: auto;
  scrollbar-color: var(--barNeutral) var(--panel2);
  scrollbar-width: thin;
  overflow-anchor: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.audit-rows { min-width: 980px; overflow-anchor: none; }
.audit-log-viewport:has(> .audit-rows > .empty) { display: grid; place-items: center; }
.audit-rows:has(> .empty) { min-width: 0; width: 100%; }
.audit-rows > .empty { margin: 0; padding: 24px; text-align: center; }
.audit-log-viewport::-webkit-scrollbar { width: 10px; height: 10px; }
.audit-log-viewport::-webkit-scrollbar-track {
  background: var(--panel2);
  border-left: 1px solid var(--line);
}
.audit-log-viewport::-webkit-scrollbar-thumb {
  background: var(--barNeutral);
  border: 2px solid var(--panel2);
  border-radius: 999px;
}
.audit-log-viewport::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.audit-log-viewport::-webkit-scrollbar-corner { background: var(--panel2); }
.audit-table {
  min-width: 980px; width: 100%; border-collapse: collapse; overflow-anchor: none;
  background: var(--surface); font-size: 13px;
}
.audit-table caption {
  text-align: left; color: var(--text-3); font-size: 12.5px; padding: 10px 14px;
  caption-side: top;
}
.audit-table th,
.audit-table td {
  text-align: left; padding: 8px 12px; border-top: 1px solid var(--line-soft);
  vertical-align: top;
}
.audit-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--auditHead);
  color: var(--text-3); font-weight: 700; font-size: 10.5px; letter-spacing: .10em;
  text-transform: uppercase; border-top: 0; white-space: nowrap;
  box-shadow: 0 1px 0 var(--line), 0 8px 18px rgba(0,0,0,.16);
  backdrop-filter: blur(12px) saturate(1.08);
  -webkit-backdrop-filter: blur(12px) saturate(1.08);
}
.audit-table .ts,
.audit-table .scope { font-family: var(--mono); font-size: 12px; }
.audit-entry-trigger { appearance: none; border: 0; padding: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; user-select: text; }
.audit-entry-trigger:hover { text-decoration: underline; }
.audit-entry-trigger:focus-visible { outline: 2px solid var(--accentLine); outline-offset: 3px; }
.audit-table .scope { word-break: break-all; }
.audit-table .detail { color: var(--text-3); }
.audit-decision-table { table-layout: fixed; }
.audit-decision-table th:nth-child(1) { width: 20%; }
.audit-decision-table th:nth-child(2) { width: 18%; }
.audit-decision-table th:nth-child(3) { width: 17%; }
.audit-decision-table th:nth-child(4) { width: 18%; }
.audit-decision-table th:nth-child(5) { width: 17%; }
.audit-decision-table th:nth-child(6) { width: 10%; }
.audit-decision-table td { overflow-wrap: anywhere; }
.audit-table tbody tr.audit-row-sidecar-decision td:first-child { border-left: 3px solid var(--accentLine); }
.empty { color: var(--text-3); padding: 24px 2px; }

/* ── CONFIG page ─────────────────────────────────────────────────── */
.config-col { display: flex; flex-direction: column; gap: 20px; }
.config-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.config-card h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.02em; }
.config-card .card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-intro { color: var(--text-3); font-size: 13px; margin: 6px 0 16px; line-height: 1.5; }
.saved-flash { color: var(--green-2); font-size: 12.5px; font-weight: 650; }
.channel { border-top: 1px solid var(--line-soft); padding: 14px 0; }
.channel:last-child { padding-bottom: 0; }
.channel-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.channel-name { font-weight: 650; font-size: 13.5px; }
.channel-desc { color: var(--text-3); font-size: 12.5px; margin: 4px 0 12px; line-height: 1.45; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3); }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-2); font-weight: 600; margin-bottom: 12px; }
.field input { border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; font-size: 13.5px; background: var(--panel); color: var(--text); outline: none; font-family: var(--sans); }
.field input:focus { border-color: var(--accentLine); }
.field input:disabled { background: var(--tint); color: var(--text-3); }
.channel-actions { display: flex; justify-content: flex-end; }
.info-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); font-size: 13px; }
.info-row:first-of-type { border-top: 0; }
.info-label { color: var(--text-3); }
.info-value { font-weight: 600; text-align: right; word-break: break-all; }
.info-value.mono { font-family: var(--mono); font-weight: 400; font-size: 12px; }
.field-note { color: var(--text-3); font-size: 12.5px; margin: 4px 0 0; }

/* ── Native <dialog> (add-agent) ──────────────────────────────────── */
/* `margin: auto` restores the UA-centered modal position that the global
   `* { margin: 0 }` reset above would otherwise clobber (pins it top-left). */
dialog.dialog { border: 0; border-radius: 14px; padding: 0; margin: auto; width: min(440px, 92vw); background: var(--surface); color: var(--text); }
dialog.dialog.wide { width: min(680px, 94vw); }
dialog.dialog::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
dialog.dialog form, dialog.dialog .modal-body { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
dialog.dialog h3 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.dialog label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.dialog input[type=text] { border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; font-size: 13.5px; background: var(--panel); color: var(--text); outline: none; }
.dialog input[type=text]:focus { border-color: var(--accentLine); }
.dialog input[readonly] { background: var(--tint); color: var(--text-3); }
.dialog fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.dialog fieldset legend { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); padding: 0 4px; }
.dialog fieldset label { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.dialog footer, .dialog .modal-footer { display: flex; justify-content: flex-end; gap: 10px; }

/* ── AUTH pages (login, workspace select) ────────────────────────── */
body.auth { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; min-height: 100vh; }
body.auth main { flex: 0 1 auto; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-card.workspace-picker { width: min(540px, 100%); }
.native-login-form { display: flex; flex-direction: column; gap: 14px; }
.login-brand { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.03em; }
.login-brand .dot { color: var(--green); }
.login-sub { margin: 0 0 6px; color: var(--text-2); font-size: 13.5px; }
.login-error { margin: 0; background: var(--red-dim); color: var(--redText); border: 1px solid var(--redLine); border-radius: 8px; padding: 9px 12px; font-size: 13.5px; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.login-card input, .login-card select { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font-size: 14px; background: var(--panel); color: var(--text); outline: none; font-family: var(--sans); }
.login-card input:focus, .login-card select:focus { border-color: var(--accentLine); }
.login-submit { margin-top: 6px; background: var(--green); color: var(--panel); border: 0; border-radius: 8px; padding: 10px 14px; font-size: 14px; font-weight: 650; cursor: pointer; }
.login-submit:hover { opacity: .9; }
.external-login-divider { display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 12px; }
.external-login-divider::before, .external-login-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.external-login-button { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; background: var(--panel); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.external-login-button:hover { border-color: var(--accentLine); }
.login-link { display: block; text-align: center; }
.login-secondary { width: 100%; background: transparent; color: var(--text); border: 1px solid var(--line); }
.login-back { margin: 0; text-align: center; }
.login-linkbtn { background: none; border: 0; color: var(--text-3); font-size: 13px; cursor: pointer; text-decoration: underline; padding: 0; }
  
