/* Esplora Control Room. Visual language from the Esplora app
   (esplora/lib/core/theme/esplora_design.dart): pure black, white at fixed
   opacities, 1px hairlines instead of fills, near-square corners, Figtree for
   content and JetBrains Mono for labels, times and ids. Colour is reserved for
   meaning: red = alarm / breach, amber = unverified / warn, green = connected.
   Fonts are self-hosted: the CSP is self-only and no third party should learn
   who opens this console. */

@font-face { font-family: 'Figtree'; font-weight: 400; font-display: swap;
  src: url('fonts/Figtree-Regular.ttf') format('truetype'); }
@font-face { font-family: 'Figtree'; font-weight: 500; font-display: swap;
  src: url('fonts/Figtree-Medium.ttf') format('truetype'); }
@font-face { font-family: 'Figtree'; font-weight: 600; font-display: swap;
  src: url('fonts/Figtree-SemiBold.ttf') format('truetype'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 400; font-display: swap;
  src: url('fonts/JetBrainsMono-Regular.ttf') format('truetype'); }

:root {
  --bg: #000;
  --media: #0a0a0a;                       /* behind media before a frame arrives */
  --raise: rgba(255, 255, 255, .04);
  --raise-2: rgba(255, 255, 255, .08);
  --w92: rgba(255, 255, 255, .92);
  --w75: rgba(255, 255, 255, .75);
  --w60: rgba(255, 255, 255, .60);
  --w50: rgba(255, 255, 255, .50);        /* lowest opacity used for real text (5.3:1) */
  --w40: rgba(255, 255, 255, .40);        /* decoration only */
  --rule: rgba(255, 255, 255, .12);
  --rule-weak: rgba(255, 255, 255, .09);
  --rule-strong: rgba(255, 255, 255, .35);

  --alarm: #ff453a;                       /* text/borders on black */
  --alarm-fill: #c62828;                  /* fills behind white text (5.6:1) */
  --alarm-bg: rgba(255, 69, 58, .12);
  --warn: #ffb340;
  --warn-bg: rgba(255, 179, 64, .10);
  --ok: #30d158;                          /* Esplora green */

  --sans: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --radius: 2px;
  --header: 48px;
  --queue-w: 380px;
  --rail-w: 320px;
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--w92);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.spacer { flex: 1; }
.mono, .timer, .meta, .section, .clock, .who, .pill, .badge, .caption {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
.meta { font-size: 11px; color: var(--w50); letter-spacing: .04em; }
.section { font-size: 10px; letter-spacing: .16em; color: var(--w60); }
.error { color: var(--alarm); font-size: 13px; }
.error:empty { display: none; }
.pad { padding: 8px 16px; }
:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ── controls ─────────────────────────────────────────────────────── */

button {
  font: 500 14px/1.1 var(--sans); color: var(--w92);
  background: transparent; border: 1px solid var(--rule-strong);
  border-radius: var(--radius); padding: 10px 14px; cursor: pointer;
}
button:hover:not(:disabled) { background: var(--raise-2); border-color: var(--w75); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.busy { cursor: progress; opacity: .6; }
button.primary { background: #fff; color: #000; border-color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--w75); border-color: transparent; }
button.danger { background: var(--alarm-fill); border-color: var(--alarm-fill); color: #fff; font-weight: 600; }
button.danger:hover:not(:disabled) { background: #b71c1c; border-color: #ff8a80; }
button.danger.armed { outline: 2px solid #fff; outline-offset: 2px; }
button.ghost { border-color: transparent; color: var(--w60); }
button.ghost:hover:not(:disabled) { color: #fff; }
button.small { padding: 6px 10px; font-size: 12px; }
button.warn-outline { color: var(--warn); border-color: var(--warn); }
button.link {
  border: 0; padding: 0; background: none; color: #fff;
  font: 12px var(--mono); text-decoration: underline; text-underline-offset: 3px;
}
button.link:hover:not(:disabled) { background: none; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font: 10px var(--mono); letter-spacing: .18em; color: var(--w50); }
input, textarea {
  width: 100%; color: #fff; background: transparent;
  font: 15px/1.4 var(--sans); border-radius: 0;
}
input { border: 0; border-bottom: 1px solid var(--rule-strong); padding: 8px 0; }
textarea { border: 1px solid var(--rule-strong); padding: 8px 10px; font-size: 14px; resize: vertical; min-height: 64px; }
input:focus, textarea:focus { outline: none; border-color: #fff; }
textarea:disabled { opacity: .7; }
::placeholder { color: var(--w40); }

.logo { width: 22px; height: 22px; display: block; }

/* ── login ────────────────────────────────────────────────────────── */

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
  width: 340px; max-width: 100%; display: flex; flex-direction: column; gap: 18px;
  border: 1px solid var(--rule); padding: 32px 28px 28px;
}
.lockup { display: flex; align-items: center; gap: 10px; font: 12px var(--mono); letter-spacing: .14em; color: var(--w75); }
.login-card h1 { font-size: 30px; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; }
.caption { font-size: 11px; letter-spacing: .14em; color: var(--w50); margin-top: -12px; }
.login-card button { margin-top: 6px; padding: 13px 14px; font-size: 15px; }

/* ── app shell ────────────────────────────────────────────────────── */

#app-view { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  flex: 0 0 var(--header); height: var(--header);
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
  border-bottom: 1px solid var(--rule);
}
.brand { font-weight: 600; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.brand-sub { color: var(--w60); font-weight: 500; }
.clock { font-size: 12px; color: var(--w75); white-space: nowrap; }
.who { font-size: 12px; color: var(--w60); white-space: nowrap; }

.pill {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  padding: 5px 9px; border: 1px solid currentColor; border-radius: var(--radius);
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); }
.pill.warn { color: var(--warn); }
.pill.alarm { color: var(--alarm); }

.bar { padding: 9px 16px; font-size: 13px; font-weight: 500; }
.bar-alarm { background: var(--alarm-fill); color: #fff; }

#desk { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--queue-w) minmax(0, 1fr); }

/* ── queue ────────────────────────────────────────────────────────── */

#queue-pane { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--rule); }
.pane-head {
  flex: 0 0 auto; display: flex; align-items: baseline; justify-content: space-between;
  padding: 12px 16px 10px; border-bottom: 1px solid var(--rule);
}
#updated.stale { color: var(--warn); }
#queue-list { flex: 1; overflow-y: auto; min-height: 0; }

.group-head, .group-head-wrap { margin: 0; }
.group-head {
  position: sticky; top: 0; z-index: 1; width: 100%;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--bg); border: 0; border-bottom: 1px solid var(--rule);
  border-radius: 0; font: 10px/1.2 var(--mono); letter-spacing: .16em;
  text-transform: uppercase; color: var(--w60); text-align: left;
}
.group-head-wrap { position: sticky; top: 0; z-index: 1; }
.group-head.toggle { cursor: pointer; }
.group-head.toggle:hover:not(:disabled) { background: var(--raise); border-color: var(--rule); }
.group-head .count { color: #fff; }
#g-waiting .group-head .count.hot { color: var(--alarm); }
.chev { display: inline-block; transition: transform .15s; }
.group:not(.collapsed) .chev { transform: rotate(90deg); }
.group.collapsed .group-body, .group.collapsed .group-empty { display: none; }
.group-empty { padding: 14px 16px; font: 12px var(--mono); color: var(--w50); }
.group-empty:empty { display: none; }
.group-body:not(:empty) + .group-empty { display: none; }

.card {
  display: flex; gap: 12px; padding: 10px 14px 10px 13px; cursor: pointer;
  border-left: 3px solid transparent; border-bottom: 1px solid var(--rule-weak);
}
.card:hover { background: var(--raise); }
.card.sel { background: var(--raise-2); }
.card:focus-visible { outline-offset: -2px; }
.card.lane-grave { border-left-color: var(--alarm); }
.card.lane-triage { border-left-color: var(--warn); }
.card.st-parked { background: var(--alarm-bg); }
.card.st-resolved, .card.st-withdrawn { border-left-color: var(--rule); }
.card.st-resolved .cam, .card.st-withdrawn .cam { color: var(--w60); font-weight: 500; }
.thumb-box { flex: 0 0 96px; height: 54px; background: var(--media); overflow: hidden; }
.thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb:not([src]) { visibility: hidden; }
.card-body { flex: 1; min-width: 0; }
.card-line { display: flex; align-items: baseline; gap: 8px; }
.cam {
  flex: 1; min-width: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rule { color: var(--w60); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.card-actions { display: flex; gap: 8px; margin-top: 8px; }

.badge {
  display: inline-block; font-size: 11px; line-height: 1; letter-spacing: .08em;
  text-transform: uppercase; padding: 4px 6px; white-space: nowrap;
  border: 1px solid var(--rule-strong); border-radius: var(--radius); color: var(--w75);
}
.badge.alarm { background: var(--alarm-fill); border-color: var(--alarm-fill); color: #fff; }
.badge.unverified { color: var(--warn); border-color: var(--warn); }
.badge.needs { background: var(--alarm-fill); border-color: var(--alarm-fill); color: #fff; }
.badge.mine { background: #fff; border-color: #fff; color: #000; }
.badge.ok { color: var(--ok); border-color: var(--ok); }

.timer { font-size: 12px; color: var(--w75); white-space: nowrap; }
.t-warn { color: var(--warn); }
.t-breach { color: #fff; background: var(--alarm-fill); padding: 1px 5px; border-radius: var(--radius); }

/* ── detail ───────────────────────────────────────────────────────── */

#detail-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.detail-empty { margin: auto; max-width: 360px; padding: 24px; text-align: center; display: flex; flex-direction: column; gap: 10px; }
#detail { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.attention {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px;
  padding: 8px 20px; border-bottom: 1px solid var(--rule);
  font: 12px var(--mono); letter-spacing: .04em; color: var(--w75);
}
.attention.hot { background: var(--alarm-bg); color: #fff; }

.detail-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) var(--rail-w); }
.stage-col { min-width: 0; overflow-y: auto; padding: 16px 20px 20px; }

.detail-head { margin-bottom: 12px; }
.detail-head h2 { font-size: 22px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; overflow-wrap: anywhere; }
.detail-head .rule { font-size: 14px; white-space: normal; margin-top: 2px; }
.detail-head .badges { margin-top: 8px; }
.detail-head .timers { margin-top: 8px; font: 12px var(--mono); color: var(--w60); }
.notice {
  margin-top: 10px; padding: 8px 10px; font-size: 13px;
  border: 1px solid var(--warn); color: var(--warn); background: var(--warn-bg);
}

.stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: calc(100vh - 290px);
  min-height: 200px; background: var(--media); border: 1px solid var(--rule-weak); overflow: hidden;
}
.stage img, .stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--media); }
.stage img { cursor: zoom-in; }
.stage-msg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 24px; text-align: center; font: 12px var(--mono); color: var(--w50); letter-spacing: .04em;
}
.stage-msg:empty { display: none; }
.live-badge {
  position: absolute; top: 10px; left: 10px; display: flex; align-items: center; gap: 7px;
  font: 11px var(--mono); letter-spacing: .14em; color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .8); padding: 4px 7px; background: rgba(0, 0, 0, .45);
}
.live-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.live-badge.on::before { background: var(--ok); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.live-failed {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px;
  align-items: center; justify-content: center; background: rgba(0, 0, 0, .78); text-align: center; padding: 20px;
}
.live-failed p { color: var(--alarm); font-weight: 600; }

.strip { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; padding-bottom: 4px; }
.tile {
  flex: 0 0 auto; width: 112px; padding: 0; cursor: pointer; text-align: left;
  border: 1px solid var(--rule-weak); border-radius: 0; background: transparent; font: inherit; color: inherit;
}
.tile:hover:not(:disabled) { border-color: var(--w60); background: transparent; }
.tile.sel { border-color: #fff; }
.tile .tile-img { width: 100%; height: 63px; background: var(--media); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile img:not([src]) { visibility: hidden; }
.tile .cap { display: block; padding: 4px 6px; font: 11px var(--mono); color: var(--w75); white-space: nowrap; }
.tile.live-tile .tile-img { font: 11px var(--mono); letter-spacing: .14em; color: var(--w60); }
.tile.live-tile.lt-live .tile-img { color: var(--ok); }
.tile.live-tile.lt-failed .tile-img { color: var(--alarm); }
.tile.skeleton { cursor: default; border-style: dashed; }
.tile.skeleton .tile-img { animation: pulse 1.6s ease-in-out infinite; background: var(--raise-2); }
.tile.skeleton .cap { color: var(--w50); }
#strip-msg { margin-top: 6px; }
#strip-msg:empty { display: none; }

.rail { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--rule); }
.rail-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.facts { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 8px 12px; font-size: 13px; }
.facts dt { font: 10px/1.9 var(--mono); letter-spacing: .14em; color: var(--w50); text-transform: uppercase; }
.facts dd { overflow-wrap: anywhere; }
.facts .utc { color: var(--w50); }
.facts .unv { color: var(--warn); }
.facts .quote { white-space: pre-wrap; color: var(--w75); }
.rail-actions {
  flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px;
  padding: 12px 16px 14px; border-top: 1px solid var(--rule); background: var(--bg);
}
.resolve { display: flex; flex-direction: column; gap: 8px; }
.disp { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.disp button { padding: 9px 8px; font-size: 13px; }
#escalate-hint:empty { display: none; }
#talk-msg:empty { display: none; }
#btn-talk { touch-action: none; user-select: none; }
#btn-talk.on { background: var(--alarm-fill); border-color: var(--alarm); color: #fff; }

.lightbox {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .94); cursor: zoom-out; padding: 16px;
}
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* Below the desk width: one pane at a time (queue, or the open incident). */
@media (max-width: 1279px) {
  #desk { grid-template-columns: minmax(0, 1fr); }
  #queue-pane { border-right: 0; }
  body.detail-open #queue-pane { display: none; }
  body:not(.detail-open) #detail-pane { display: none; }
  .detail-grid { display: block; overflow-y: auto; }
  .stage-col { overflow: visible; padding: 16px; }
  .stage { max-height: 60vh; }
  .rail { border-left: 0; border-top: 1px solid var(--rule); }
  .rail-scroll { overflow: visible; }
  .rail-actions { position: sticky; bottom: 0; }
  .attention { padding: 8px 16px; }
}
@media (max-width: 640px) {
  .clock, .brand-sub { display: none; }
  .topbar { gap: 10px; }
}
