/* Ampirical CloudOps — app-centric design (from the TurboStation CloudOps
   mockup): navy 56px header with env pills, white application sidebar,
   gold-underline section tabs, light slate content with white cards.
   Typefaces: Public Sans (UI) + IBM Plex Mono (data), vendored (OFL).

   Theming: LIGHT is the design's native palette; dark keeps the earlier navy
   family. System preference applies unless data-theme (persisted by the user
   menu) forces one. Header is brand navy in both. */

:root {
  --gold: #f5a800;
  --navy: #071c33;
  --on-gold: #071c33;
  --gold-ink: #f5a800;
  --link: #2fbdf2;
  --cyan-ink: #2fbdf2;
  --good-ink: #4cbf85;
  --good-bg: rgba(76, 191, 133, 0.12);
  --good-border: rgba(76, 191, 133, 0.35);
  --warn-ink: #e0a83f;
  --warn-bg: rgba(224, 168, 63, 0.12);
  --warn-border: rgba(224, 168, 63, 0.35);
  --bad-ink: #ef6b66;
  --bg: #01152e;
  --bg-raised: #071c33;
  --bg-inset: #000d1f;
  --border: #14335c;
  --border-subtle: #0c2747;
  --text: #e9eef5;
  --muted: #8fa3bf;
  --kicker: #64809f;
  --bar-track: #0c2747;
  --bar-fill: #2fbdf2;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --gold-ink: #8f6200;
    --link: #0d6ea8;
    --cyan-ink: #0d6ea8;
    --good-ink: #12703f;
    --good-bg: #e7f4ec;
    --good-border: #c3e4d0;
    --warn-ink: #9a5b00;
    --warn-bg: #fdf3e2;
    --warn-border: #f0dcb8;
    --bad-ink: #c0491f;
    --bg: #eef2f7;
    --bg-raised: #ffffff;
    --bg-inset: #f5f8fb;
    --border: #dde5ee;
    --border-subtle: #eef2f7;
    --text: #0f172a;
    --muted: #64748b;
    --kicker: #94a3b8;
    --bar-track: #eef2f7;
    --bar-fill: #0d6ea8;
  }
  :root:not([data-theme="dark"]) .only-dark { display: none; }
  :root:not([data-theme="dark"]) .only-light { display: initial; }
}

:root[data-theme="light"] {
  --gold-ink: #8f6200;
  --link: #0d6ea8;
  --cyan-ink: #0d6ea8;
  --good-ink: #12703f;
  --good-bg: #e7f4ec;
  --good-border: #c3e4d0;
  --warn-ink: #9a5b00;
  --warn-bg: #fdf3e2;
  --warn-border: #f0dcb8;
  --bad-ink: #c0491f;
  --bg: #eef2f7;
  --bg-raised: #ffffff;
  --bg-inset: #f5f8fb;
  --border: #dde5ee;
  --border-subtle: #eef2f7;
  --text: #0f172a;
  --muted: #64748b;
  --kicker: #94a3b8;
  --bar-track: #eef2f7;
  --bar-fill: #0d6ea8;
}
:root[data-theme="light"] .only-dark { display: none; }
:root[data-theme="light"] .only-light { display: initial; }
:root[data-theme="dark"] .only-dark { display: initial; }
:root[data-theme="dark"] .only-light { display: none; }
.only-light { display: none; }

@font-face {
  font-family: "Public Sans";
  src: url("/fonts/public-sans.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/plex-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

:root { --mono: "IBM Plex Mono", ui-monospace, monospace; }

body {
  margin: 0;
  font: 14px/1.45 "Public Sans", system-ui, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--link); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }

/* ---- header (brand navy in both themes) --------------------------------- */
header {
  --bg-raised: #071c33;
  --bg-inset: #041526;
  --border: #14335c;
  --text: #e6edf5;
  --muted: #9fb3c8;
  height: 56px;
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: #071c33;
  border-bottom: 2px solid var(--gold);
  color: var(--text);
}
header .logo { height: 26px; }
header h1 { font-size: 16px; font-weight: 700; margin: 0; white-space: nowrap; color: #ffffff; }
#home-link { display: flex; align-items: center; gap: 12px; cursor: pointer; color: inherit; text-decoration: none; }
.accent { color: var(--gold); }
/* The segmented env switcher carries its own frame; a divider line between it
   and the logo is visual noise. */
.header-divider { display: none; }
#header-app { flex: 1; display: flex; align-items: center; gap: 14px; min-width: 0; }
.spacer { flex: 1; }
#signin-theme-select { font-size: 12.5px; padding: 4px 6px; margin-left: auto; }

/* env pills */
#env-tabs {
  display: flex; gap: 2px; align-items: center;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px; border-radius: 10px;
}
#env-tabs button {
  padding: 6px 16px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  border: 0; border-radius: 7px; letter-spacing: 0.01em;
  background: transparent; color: #7f95ad; font-family: inherit;
}
#env-tabs button.active {
  background: #ffffff; color: #071c33;
  box-shadow: 0 1px 2px rgba(7, 28, 51, 0.35);
}

/* header status + user chip */
#sys-status { display: flex; align-items: center; gap: 7px; color: #9fb3c8; font-size: 12.5px; white-space: nowrap; }
#sys-status .dot { width: 7px; height: 7px; border-radius: 50%; background: #4cbf85; }
#sys-status.bad .dot { background: #ef6b66; }
#user-menu summary {
  display: flex; align-items: center; gap: 8px; color: #e6edf5; font-size: 13px;
  font-weight: 500; padding: 5px 10px 5px 6px; border-radius: 8px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.12); list-style: none; background: none;
}
#user-menu summary::-webkit-details-marker { display: none; }
#user-menu summary:hover { background: rgba(255, 255, 255, 0.06); }
#user-menu summary::after { content: " \25BE"; color: #7f95ad; }
.avatar {
  width: 24px; height: 24px; border-radius: 6px; background: var(--gold);
  color: #071c33; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

/* menus (shared) */
details.menu { position: relative; }
.menu-items {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
  display: flex; flex-direction: column; min-width: 200px;
  background: #071c33; border: 1px solid #14335c;
  border-radius: 10px; padding: 5px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  color: #e6edf5;
}
.menu-items button {
  background: none; border: none; color: inherit; cursor: pointer;
  text-align: left; padding: 8px 10px; border-radius: 6px; font: inherit; font-size: 13px;
}
.menu-items button:hover { background: rgba(255, 255, 255, 0.07); }

/* Split button: primary action on the left, period chooser on the right. */
.split { display: inline-flex; }
.split .split-main { border-radius: 7px 0 0 7px; border-right: 0; }
.split .split-caret {
  border-radius: 0 7px 7px 0; padding: 6px 9px; font-size: 11px; line-height: 1.5;
  display: flex; align-items: center;
}
.split details { display: flex; }
.menu-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 7px 10px; font-size: 13px;
}
.menu-row select { font-size: 12.5px; padding: 3px 6px; background: #041526; color: #e6edf5; border: 1px solid #14335c; border-radius: 6px; }

/* ---- shell -------------------------------------------------------------- */
main { flex: 1; min-height: 0; display: flex; }
main > section { flex: 1; min-height: 0; }

#signin-view, #boot-view { display: flex; align-items: center; justify-content: center; }
.boot-box { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.card-panel {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: 12px; padding: 40px 48px; max-width: 420px; text-align: center;
}
.logo-large { width: 260px; margin-bottom: 12px; }

#app-shell { display: flex; align-items: stretch; }

#sidebar {
  width: var(--sidebar-w, 236px); flex: 0 0 var(--sidebar-w, 236px);
  position: relative;
  display: flex; flex-direction: column; gap: 18px;
  background: var(--bg-raised); border-right: 1px solid var(--border);
  padding: 16px 12px 12px;
}
/* Drag the right edge to resize; the width persists per browser. */
#sidebar-resize {
  position: absolute; top: 0; right: -3px; width: 6px; height: 100%;
  cursor: col-resize; z-index: 20;
}
#sidebar-resize:hover, #sidebar-resize.dragging { background: var(--gold); opacity: 0.4; }
.side-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--kicker); padding: 0 10px 4px;
}
.side-group { display: flex; flex-direction: column; gap: 4px; }
.side-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--muted);
}
.side-row .dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto; background: var(--border); }
.side-row:hover { background: var(--bg-inset); color: var(--text); }
/* The active app reads as a raised card, not just a tinted row. */
.side-row.active {
  background: var(--bg-inset); border-color: var(--border); color: var(--text);
  font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.side-row.active .dot { background: var(--gold); }
.side-row.disabled { cursor: default; opacity: 0.55; }
.side-row.disabled:hover { background: none; color: var(--muted); }
.side-foot {
  margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.side-foot-label { font-size: 11.5px; color: var(--kicker); line-height: 1.5; }
.side-collapse {
  flex: 0 0 auto; background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; cursor: pointer; font-size: 13px; line-height: 1;
  padding: 3px 8px; font-family: inherit;
}
.side-collapse:hover { color: var(--text); border-color: var(--muted); }

/* Miniature (collapsed) sidebar: an icon rail of initials. */
#app-shell.mini #sidebar { width: 62px; flex: 0 0 62px; padding: 16px 8px 12px; }
#app-shell.mini .side-label { display: none; }
#app-shell.mini .side-row { justify-content: center; gap: 0; padding: 9px 0; font-size: 0; }
#app-shell.mini .side-row .dot { display: none; }
#app-shell.mini .side-row::before {
  content: attr(data-initial); font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em;
}
#app-shell.mini .side-foot { justify-content: center; }
#app-shell.mini .side-foot-label { display: none; }
#app-shell.mini #sidebar-resize { display: none; }

#workarea { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#section-bar { background: var(--bg-raised); border-bottom: 1px solid var(--border); padding: 0 28px; flex: 0 0 auto; }
#section-tabs { max-width: 1560px; margin: 0 auto; display: flex; align-items: center; gap: 24px; }
#section-tabs button {
  padding: 11px 2px; font-size: 13px; font-weight: 500; color: var(--muted);
  background: none; border: 0; border-bottom: 2px solid transparent;
  cursor: pointer; margin-bottom: -1px; font-family: inherit;
}
#section-tabs button.active { font-weight: 600; color: var(--text); border-bottom-color: var(--gold); }

#content {
  flex: 1; min-height: 0; overflow-y: auto; width: 100%;
  padding: 22px 28px 48px;
}
#content > * { max-width: 1560px; margin-left: auto; margin-right: auto; }

#page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 18px; }
.kicker { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--kicker); }
.page-title-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.page-title-row h1 { margin: 2px 0 0; font-size: 20px; letter-spacing: -0.01em; }
.page-sub { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.ext-link { margin-left: 6px; font-size: 12.5px; text-decoration: none; }
.ext-link:hover { text-decoration: none; }
.page-actions { display: flex; align-items: center; gap: 10px; }

/* ---- shared primitives --------------------------------------------------- */
input, select, textarea {
  background: var(--bg-raised); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 9px;
  font: inherit; font-size: 13px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(245, 168, 0, 0.45); }
textarea { font-family: var(--mono); font-size: 12.5px; resize: vertical; }

button.primary {
  background: var(--gold); color: var(--on-gold); border: none; border-radius: 7px;
  padding: 7px 16px; font-weight: 600; cursor: pointer; font-family: inherit;
}
button.primary:hover { filter: brightness(1.06); }
/* Full-strength label: muted text on a pale surface read as disabled.
   Only the :disabled state should look inactive. */
/* summary.ghost too: the split-button caret and the log download menu are
   <summary> elements, which a button-only selector silently skipped. */
button.ghost, summary.ghost {
  background: var(--bg-raised); border: 1px solid var(--border); color: var(--text);
  border-radius: 7px; padding: 6px 12px; cursor: pointer; font-family: inherit; font-size: 13px;
  font-weight: 500; list-style: none;
}
summary.ghost::-webkit-details-marker { display: none; }
button.ghost:hover, summary.ghost:hover { border-color: var(--muted); background: var(--bg-inset); }
button:disabled { opacity: 0.45; cursor: default; }
button.ghost:disabled:hover { background: var(--bg-raised); border-color: var(--border); }
button.icon, .menu summary.icon { font-size: 15px; padding: 4px 10px; line-height: 1.3; }
.menu.disabled summary { opacity: 0.45; pointer-events: none; }

.muted { color: var(--muted); font-size: 13px; }
.spinner-wrap { display: flex; justify-content: center; padding: 28px; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--gold);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner.mini { width: 11px; height: 11px; border-width: 2px; display: inline-block; vertical-align: -2px; margin-right: 7px; }
.empty-note { color: var(--muted); text-align: center; padding: 28px 16px; margin: 0; }

.card {
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

/* pills */
.pill {
  font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  white-space: nowrap;
}
.pill.good { color: var(--good-ink); background: var(--good-bg); border: 1px solid var(--good-border); }
.pill.warn { color: var(--warn-ink); background: var(--warn-bg); border: 1px solid var(--warn-border); }

.section-divider {
  display: flex; align-items: center; gap: 12px; margin: 6px 0 16px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--kicker);
}
.section-divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-bottom: 18px; }
.tile { background: var(--bg-raised); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; display: flex; flex-direction: column; gap: 7px; }
.tile .label { font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.tile .big { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.tile .sub { font-size: 12px; color: var(--muted); }
.tile .sub.mono { font-family: var(--mono); }
.tile .ok { color: var(--good-ink); }
.tile .bad { color: var(--bad-ink); }
.tile .warn { color: var(--warn-ink); }

/* service cards (overview) */
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; margin-bottom: 18px; }
.svc-card { display: flex; flex-direction: column; }
.svc-card .head { padding: 14px 18px; border-bottom: 1px solid var(--border-subtle); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.svc-card .head h3 { margin: 0; font-size: 14.5px; display: flex; align-items: center; gap: 10px; }
.svc-card .imgrow { padding: 12px 18px; border-bottom: 1px solid var(--border-subtle); display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.svc-card .imgrow .mono {
  font-family: var(--mono); color: var(--text); font-size: 12px;
  background: var(--bg-inset); border: 1px solid var(--border-subtle);
  border-radius: 6px; padding: 2px 8px;
}
.svc-card .bars { padding: 16px 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.meter { display: flex; flex-direction: column; gap: 7px; }
.meter .row { display: flex; align-items: baseline; justify-content: space-between; font-size: 12px; color: var(--muted); }
.meter .row b { color: var(--text); font-size: 13px; }
.meter .track { height: 3px; border-radius: 2px; background: var(--bar-track); overflow: hidden; cursor: pointer; }
.meter .fill { min-width: 3px; height: 100%; border-radius: 2px; background: var(--bar-fill); }
.svc-card .foot { padding: 12px 18px; font-size: 12.5px; color: var(--muted); display: flex; gap: 14px; }
/* Inline control rows inside a panel (AutoCAD worker / Jobs queue). */
.svc-card .ctl {
  padding: 10px 18px; border-top: 1px solid var(--border-subtle);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.svc-card .ctl .lbl { color: var(--muted); font-size: 12.5px; min-width: 62px; }
.svc-card .ctl + .foot { border-top: 1px solid var(--border-subtle); }

.card-head {
  padding: 12px 18px; border-bottom: 1px solid var(--border-subtle);
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--kicker);
}
td.num { text-align: right; font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
th.num { text-align: right; white-space: nowrap; }
/* The cost trend is one series over the whole page width, not a grid cell. */
#cost-chart { grid-template-columns: 1fr; }
#cost-chart svg { height: 120px; }
/* Long AWS service names shouldn't stretch a stat tile to two lines. */
.tile .big.long { font-size: 15px; line-height: 1.25; }
.delta.up { color: var(--bad-ink); }
.delta.down { color: var(--good-ink); }

/* tables */
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--kicker); padding: 12px 18px 8px;
  border-bottom: 1px solid var(--border-subtle); position: sticky; top: 0; background: var(--bg-raised);
}
table.data td { padding: 10px 18px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.mono { font-family: var(--mono); font-size: 12.5px; }

/* charts */
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.chart-card { background: var(--bg-raised); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.chart-card .label { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.chart-card .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 2px; }
.chart-card .value {
  font-size: 20px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 6px;
  display: flex; align-items: baseline; gap: 8px;
}
.chart-card .value-note { color: var(--muted); font-size: 11px; font-weight: 500; }
.chart-card .value-toggle { margin-left: auto; font-size: 11px; padding: 2px 10px; border-radius: 999px; }
.chart-card .axis { display: flex; justify-content: space-between; color: var(--kicker); font-size: 11px; margin-top: 6px; }
.chip-note {
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 10px; white-space: nowrap;
}
.chip-note.info { color: var(--cyan-ink); background: rgba(13, 110, 168, 0.1); border-color: rgba(13, 110, 168, 0.28); }
.chip-note.warn { color: var(--warn-ink); background: var(--warn-bg); border-color: var(--warn-border); }
.chip-note.good { color: var(--good-ink); background: var(--good-bg); border-color: var(--good-border); }
.chip-note.bad { color: var(--bad-ink); background: rgba(239, 107, 102, 0.1); border-color: rgba(239, 107, 102, 0.3); }
.chart-card svg { width: 100%; height: 64px; display: block; }
.chart-card polyline { fill: none; stroke-width: 2; }
.chart-card polyline.partial { stroke-dasharray: 4 5; opacity: 0.55; }
.chart-card .hit { fill: transparent; }
.modal-chart svg { width: 100%; height: 240px; display: block; }
.modal-chart polyline { fill: none; stroke-width: 2; }
.modal-chart .hit { fill: transparent; }
.modal-chart .value { font-size: 18px; font-weight: 700; margin-bottom: 8px; }

/* ---- logs section (existing workspace, restyled) -------------------------- */
/* Logs is a full-bleed workspace: escapes the content padding (page-head is
   hidden for it) and pins to the remaining viewport below header+tabs. */
#sec-logs {
  display: flex; min-height: 0; gap: 0;
  max-width: none !important; margin: -22px -28px -48px !important;
  height: calc(100vh - 99px);
}
#group-pane {
  width: 320px; min-width: 240px; display: flex; flex-direction: column;
  border-right: 1px solid var(--border); background: var(--bg-raised);
}
.pane-head { padding: 10px; border-bottom: 1px solid var(--border-subtle); }
#group-filter { width: 100%; }
#group-list { list-style: none; margin: 0; padding: 4px; overflow-y: auto; flex: 1; }
#group-list li {
  padding: 6px 10px; border-radius: 6px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--mono); font-size: 12px;
}
#group-list li:hover { background: var(--bg-inset); }
#group-list li.selected { background: var(--gold); color: var(--on-gold); font-weight: 600; }
#group-list li .size { color: var(--muted); font-size: 11px; margin-left: 6px; }
#group-list li.selected .size { color: var(--on-gold); }
#group-list li .chev { margin-right: 4px; cursor: pointer; color: var(--muted); font-size: 10px; display: inline-block; width: 11px; }
#group-list li .chev.blank { cursor: default; }
#group-list li.child { padding-left: 44px; color: var(--cyan-ink); }
#group-list li.child.none { color: var(--muted); cursor: default; font-style: italic; }
#group-list li .pin { margin-right: 6px; cursor: pointer; color: var(--muted); }
#group-list li .pin.pinned { color: var(--gold-ink); }
#group-list li.selected .pin, #group-list li.selected .pin.pinned { color: var(--on-gold); }
#group-list li.pin-sep { border-bottom: 1px solid var(--border); margin: 4px 6px; padding: 0; height: 0; cursor: default; }

#detail-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
#mode-tabs { display: flex; gap: 2px; padding: 8px 12px 0; }
button.mode {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 6px 14px; cursor: pointer; font-size: 13px; font-family: inherit;
}
button.mode.active { color: var(--text); font-weight: 600; border-bottom-color: var(--gold); }

#events-pane, #insights-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px 12px; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.toolbar input[type="search"] { flex: 1; min-width: 160px; }
.toolbar input.narrow { flex: 0 1 200px; min-width: 130px; }
#custom-range input, #insights-custom input { font-size: 12px; padding: 4px 6px; }
.tail-toggle { color: var(--muted); display: flex; align-items: center; gap: 4px; font-size: 13px; }

#event-scroll, #insights-scroll { flex: 1; overflow: auto; background: var(--bg-raised); border: 1px solid var(--border); border-radius: 8px; }
table.logtable { border-collapse: collapse; width: 100%; font-family: var(--mono); font-size: 12px; }
table.logtable td, table.logtable th { padding: 3px 10px; vertical-align: top; text-align: left; }
table.logtable tr:hover td { background: rgba(245, 168, 0, 0.06); }
table.logtable th { position: sticky; top: 0; background: var(--bg-raised); color: var(--muted); font-weight: 600; }
td.ts { color: var(--gold-ink); white-space: nowrap; }
td.stream { color: var(--cyan-ink); white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
td.msg { white-space: pre-wrap; word-break: break-word; }

/* ---- key-value + task-def sections --------------------------------------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 16px; font-size: 13px; }
.kv .k { color: var(--muted); }
.kv .v { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.td-section { background: var(--bg-inset); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 12px; }
.td-section h3 { margin: 0 0 8px; font-size: 13.5px; color: var(--gold-ink); }
.badge {
  display: inline-block; font-size: 11px; font-weight: 600; margin-left: 8px;
  background: var(--gold); color: var(--on-gold); border-radius: 999px; padding: 1px 8px;
  vertical-align: 1px;
}
.td-section details { margin-top: 8px; }
.td-section summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
.td-section details table { margin-top: 6px; }
.json-pre {
  background: var(--bg-inset); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; font-size: 12px; white-space: pre-wrap; word-break: break-word; margin: 0;
  font-family: var(--mono);
}

/* ---- settings / access ---------------------------------------------------- */
/* Permission matrix: people down, groups across in labelled sections, one
   click per grant. Deliberately wide (per request); it scrolls horizontally
   on a narrow screen rather than wrapping. */
#admin-scroll { overflow-x: auto; }
table.matrix { border-collapse: collapse; width: 100%; font-size: 13px; }
table.matrix th, table.matrix td { padding: 8px 10px; }
table.matrix thead th {
  position: sticky; top: 0; z-index: 1; background: var(--bg-raised);
  font-weight: 700; color: var(--kicker); text-align: center; vertical-align: bottom;
}
table.matrix thead tr.sections th {
  font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase;
  padding-bottom: 10px; border-bottom: 1px solid var(--border-subtle);
}
table.matrix thead tr.cols th {
  font-family: var(--mono); font-weight: 500; font-size: 10.5px; color: var(--muted);
  white-space: normal; line-height: 1.25; border-bottom: 1px solid var(--border);
  min-width: 46px; max-width: 66px; word-break: break-word;
}
table.matrix th.who, table.matrix td.who { text-align: left; white-space: nowrap; min-width: 190px; }
table.matrix thead th.who {
  font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase; font-family: inherit;
}
table.matrix td.who { font-weight: 600; color: var(--text); }
table.matrix td.who .email { display: block; color: var(--muted); font-size: 11.5px; font-weight: 400; font-family: var(--mono); }
table.matrix td.cell { text-align: center; padding: 4px; }
table.matrix tbody tr { border-bottom: 1px solid var(--border-subtle); }
table.matrix tbody tr:last-child { border-bottom: 0; }
table.matrix tbody tr:hover { background: var(--bg-inset); }
table.matrix .sep { border-left: 1px solid var(--border-subtle); }
table.matrix tfoot th, table.matrix tfoot td {
  border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); text-align: center;
}
table.matrix tfoot th.who {
  font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--kicker);
}
table.matrix tfoot td.zero { color: var(--border); }
table.matrix tr.pending { opacity: 0.5; pointer-events: none; }
/* Grant marks: green for environment access, gold for elevated (admin/action). */
.cellmark {
  background: none; border: 0; cursor: pointer; font-size: 13.5px; line-height: 1;
  width: 28px; height: 24px; border-radius: 6px; font-family: inherit;
}
.cellmark:hover { background: var(--bg-inset); }
.cellmark.off { color: var(--border); }
.cellmark.on.env { color: var(--good-ink); }
.cellmark.on.elevated { color: var(--gold-ink); }
.cellmark:disabled { cursor: not-allowed; opacity: 0.6; }

.access-legend {
  margin-top: 12px; display: flex; align-items: center; flex-wrap: wrap; gap: 16px;
  font-size: 12px; color: var(--muted);
}
.access-legend .key { display: inline-flex; align-items: center; gap: 6px; }
.access-legend .mk { font-size: 13.5px; }
.access-legend .mk.elevated { color: var(--gold-ink); }
.access-legend .mk.env { color: var(--good-ink); }
.access-legend .mk.off { color: var(--border); }
.access-legend .note { flex: 1 1 320px; min-width: 260px; line-height: 1.5; }
.access-review {
  margin-top: 14px; display: flex; gap: 12px; align-items: flex-start;
  background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: 10px;
  padding: 12px 16px; font-size: 12.5px; line-height: 1.5; color: var(--text);
}
.access-review .badge {
  flex: 0 0 auto; font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  /* Outline chip: without this the generic .badge gold fill bleeds through
     and warn-ink text vanishes on it in dark mode. */
  background: transparent; margin-left: 0;
  color: var(--warn-ink); border: 1px solid var(--warn-border); border-radius: 5px;
  padding: 2px 7px; text-transform: uppercase; margin-top: 1px;
}
.access-review code { font-family: var(--mono); font-size: 11.5px; }
.access-review a { margin-left: auto; flex: 0 0 auto; }

/* Audit log action chips: gold for mutating/elevated actions. */
.audit-action {
  font-family: var(--mono); font-size: 11.5px; padding: 2px 8px; border-radius: 999px;
  background: var(--bg-inset); border: 1px solid var(--border); color: var(--muted);
  white-space: nowrap;
}
.audit-action.elevated { color: var(--gold-ink); border-color: var(--gold); }

/* AWS Accounts: account/person cards of permission-set and people chips. */
.ps-chip {
  display: inline-block; margin: 2px 4px 2px 0; padding: 2px 10px;
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: 999px; font-size: 12px; white-space: nowrap; cursor: default;
}
.access-card .card-head {
  display: flex; align-items: baseline; gap: 10px;
  text-transform: none; letter-spacing: normal;
  font-size: 13.5px; color: var(--text);
}
.access-card .card-head .sub {
  font-family: var(--mono); font-size: 11.5px; color: var(--muted); font-weight: 400;
}
.access-rows { padding: 12px 18px; display: flex; flex-direction: column; gap: 8px; }
.perm-row { display: flex; gap: 12px; align-items: baseline; }
.perm-name { flex: 0 0 150px; font-size: 12.5px; color: var(--muted); }
.perm-chips { display: flex; flex-wrap: wrap; }

/* ---- modal ---------------------------------------------------------------- */
#modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4, 12, 24, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
#modal {
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  width: min(960px, 100%); max-height: 86vh; display: flex; flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
#modal-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
#modal-head h3 { margin: 0 auto 0 0; font-size: 14.5px; }
#modal-tools { display: flex; gap: 8px; align-items: center; }
#modal-body { padding: 14px 16px; overflow: auto; min-height: 120px; }
#modal-body table { background: var(--bg-raised); border: 1px solid var(--border); border-radius: 8px; }
/* Terminal dock: sessions outlive navigation and close only on request. */
#term-dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  height: 42vh; min-height: 160px;
  display: flex; flex-direction: column;
  background: #000d1f; border-top: 2px solid var(--gold);
  box-shadow: 0 -8px 26px rgba(0, 0, 0, 0.35);
}
#term-dock.minimized { height: auto !important; }
#term-dock.minimized #term-bodies, #term-dock.minimized #term-resize { display: none; }
#term-resize { height: 6px; cursor: ns-resize; background: transparent; flex: 0 0 auto; }
#term-resize:hover { background: rgba(245, 168, 0, 0.35); }
#term-dock-head {
  display: flex; align-items: center; gap: 8px; padding: 4px 10px;
  background: #071c33; border-bottom: 1px solid #14335c; flex: 0 0 auto;
}
#term-tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1; }
.term-tab {
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 5px 8px 5px 12px; border-radius: 7px 7px 0 0; cursor: pointer;
  font-size: 12.5px; color: #9fb3c8; border: 1px solid transparent;
}
.term-tab:hover { color: #e6edf5; }
.term-tab.active { background: #000d1f; color: #e6edf5; border-color: #14335c; border-bottom-color: transparent; }
.term-tab .dot { width: 6px; height: 6px; border-radius: 50%; background: #4cbf85; }
.term-tab.dead .dot { background: #ef6b66; }
.term-tab button { background: none; border: none; color: #7f95ad; cursor: pointer; font-size: 13px; padding: 0 2px; line-height: 1; }
.term-tab button:hover { color: #ef6b66; }
/* Red hover means destructive; the pop-out button isn't. */
.term-tab button.pop:hover { color: #e6edf5; }
#term-dock-status { color: #7f95ad; font-size: 12px; }
#term-dock-head button.ghost { background: none; border-color: #14335c; color: #9fb3c8; }
#term-bodies { flex: 1; min-height: 0; position: relative; }
/* Popped-out shell window: one full-viewport terminal. */
#shell-popout { position: fixed; inset: 0; z-index: 50; background: #000d1f; padding: 8px 0 0 8px; }
/* From the first paint, a popout is a dark window with no chrome: the header
   and boot spinner never flash in (index.html sets the flag pre-paint). The
   sign-in card stays available for a popout that lands unauthenticated. */
html[data-popout] header, html[data-popout] #boot-view { display: none !important; }
html[data-popout] body { background: #000d1f; }
#shell-popout .terminal, #shell-popout .xterm { height: 100%; }
.term-host {
  position: absolute; inset: 0; padding: 8px 10px; background: #000d1f;
}
/* Parked view while the session lives in its own window. The mirror behind
   it stays covered; reattaching is the way back to the session. */
.term-external {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; background: rgba(0, 13, 31, 0.97); color: #9fb3c8; font-size: 13px;
}
.term-external button.ghost { background: none; border: 1px solid #14335c; color: #9fb3c8; }
.term-external button.ghost:hover { color: #e6edf5; }
