:root {
  color-scheme: dark;
  --bg-deep: #02070b;
  --bg: #06131b;
  --panel: rgba(11, 30, 40, 0.86);
  --panel-strong: rgba(14, 39, 50, 0.94);
  --edge: rgba(113, 208, 227, 0.2);
  --edge-bright: rgba(113, 208, 227, 0.54);
  --text: #eef8fa;
  --muted: #829ca5;
  --cyan: #70d5e7;
  --cyan-soft: rgba(112, 213, 231, 0.12);
  --orange: #ff6a1a;
  --orange-soft: rgba(255, 106, 26, 0.12);
  --alert: #ff6f61;
  --safe-x: 4vw;
  font-family: Inter, Aptos, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg-deep);
}

body { color: var(--text); }

.display-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-width: 960px;
  min-height: 540px;
  overflow: hidden;
  background:
    radial-gradient(circle at 84% 8%, rgba(21, 107, 122, 0.2), transparent 32%),
    radial-gradient(circle at 8% 96%, rgba(255, 106, 26, 0.07), transparent 30%),
    linear-gradient(135deg, var(--bg-deep), var(--bg) 54%, #071923);
}

.ambient-field {
  position: absolute;
  inset: 0;
  opacity: 0.52;
  background-image:
    linear-gradient(rgba(112, 213, 231, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(112, 213, 231, 0.025) 1px, transparent 1px),
    linear-gradient(112deg, transparent 45%, rgba(112, 213, 231, 0.045) 50%, transparent 55%);
  background-size: 4vw 4vw, 4vw 4vw, 180% 100%;
  animation: ambient-drift 22s linear infinite;
}

.masthead,
.display-footer {
  position: absolute;
  z-index: 10;
  right: var(--safe-x);
  left: var(--safe-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.masthead {
  top: 2.2vh;
  height: 8.4vh;
  border-bottom: 1px solid var(--edge);
}

.brand-lockup,
.system-state,
.footer-title { display: flex; align-items: center; }

.brand-lockup { gap: 0.8vw; }

.anchor-mark {
  width: 2.15vw;
  min-width: 28px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(255, 106, 26, 0.26));
}

.brand-copy { display: flex; align-items: center; gap: 1.1vw; }
.brand-context { min-width: 7.9vw; }
.brand-name,
.brand-system,
.board-title { display: block; }
.brand-name { font-size: 0.88vw; font-weight: 760; letter-spacing: 0.19em; }
.brand-system { margin-top: 0.35vh; color: var(--muted); font-size: 0.46vw; font-weight: 650; letter-spacing: 0.16em; }
.board-title {
  padding-left: 1.05vw;
  border-left: 1px solid var(--edge);
  font-size: 1.55vw;
  font-weight: 480;
  letter-spacing: -0.025em;
}

.system-state {
  gap: 0.62vw;
  color: var(--muted);
  font-size: 0.6vw;
  font-weight: 650;
  letter-spacing: 0.12em;
}
.source-summary { display: flex; align-items: center; gap: 0.55vw; }

.source-badge { color: var(--cyan); font-weight: 800; letter-spacing: 0.16em; }
.source-badge.state-stale,
.source-badge.state-error,
.source-badge.state-unknown { color: var(--orange); }
.source-time { margin-right: 1.2vw; letter-spacing: 0.04em; }

.system-state time {
  min-width: 4.7vw;
  margin-left: 1vw;
  color: var(--text);
  font-size: 1.05vw;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-align: right;
}

.connection-dot {
  width: 0.42vw;
  height: 0.42vw;
  min-width: 6px;
  min-height: 6px;
  border-radius: 50%;
  background: var(--muted);
}

.connection-dot.is-live {
  background: var(--cyan);
  animation: pulse 2.4s ease-out infinite;
}

.dashboard {
  position: absolute;
  z-index: 3;
  top: 12.2vh;
  right: var(--safe-x);
  bottom: 7.4vh;
  left: var(--safe-x);
}

.eyebrow {
  margin: 0 0 0.6vh;
  color: var(--cyan);
  font-size: 0.58vw;
  font-weight: 750;
  letter-spacing: 0.22em;
}

h1 {
  margin: 0;
  font-size: 3vw;
  font-weight: 420;
  letter-spacing: -0.035em;
  line-height: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 38fr) minmax(0, 62fr);
  grid-template-rows: 48vh 28.5vh;
  gap: 1.15vw;
}

.metric-cluster {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: 28.8vh 18vh;
  gap: 1.2vh 0.7vw;
}

.metric-card,
.crew-panel,
.tickets-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--edge);
  background: linear-gradient(145deg, var(--panel-strong), var(--panel));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.016), 0 1.2vh 3vh rgba(0, 0, 0, 0.12);
}

.metric-card::before,
.crew-panel::before,
.tickets-panel::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: 0;
  left: -35%;
  width: 28%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  animation: edge-travel 9s ease-in-out infinite;
}

.metric-card {
  padding: 1.45vh 1.05vw;
  transition: border-color 500ms ease, background 500ms ease;
}

.metric-label {
  display: block;
  color: #bad0d6;
  font-size: 0.72vw;
  font-weight: 720;
  letter-spacing: 0.08em;
}

.metric-value {
  display: block;
  color: var(--text);
  font-size: 3.6vw;
  font-weight: 430;
  letter-spacing: -0.055em;
  line-height: 1;
}

.metric-time::after {
  content: "m";
  margin-left: 0.15em;
  color: #bdd2d7;
  font-size: 0.38em;
  font-weight: 620;
  letter-spacing: 0;
}
.metric-time.is-unknown::after { content: ""; }

.gauge-card .metric-copy {
  position: absolute;
  z-index: 3;
  inset: 0;
}

.gauge-card .metric-label { position: absolute; top: 1.45vh; left: 1.05vw; }
.gauge-card .metric-value {
  position: absolute;
  top: 19.7vh;
  left: 0;
  width: 100%;
  font-size: 2.2vw;
  text-align: center;
}

.gauge {
  position: absolute;
  top: 4.6vh;
  left: 50%;
  width: 77%;
  height: 15.2vh;
  overflow: visible;
  transform: translateX(-50%);
}

.gauge-track,
.gauge-value {
  fill: none;
  stroke-linecap: butt;
  stroke-width: 17;
}
.gauge-track { stroke: rgba(112, 213, 231, 0.14); }
.gauge-value {
  stroke: var(--cyan);
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  filter: drop-shadow(0 0 5px rgba(112, 213, 231, 0.35));
  transition: stroke-dashoffset 1.5s cubic-bezier(0.22, 0.78, 0.18, 1);
}
.gauge-hub { fill: var(--text); filter: drop-shadow(0 0 5px rgba(238, 248, 250, 0.3)); }
.gauge-scale { position: absolute; top: 18vh; color: var(--muted); font-size: 0.58vw; }
.gauge-min { left: 11%; }
.gauge-max { right: 11%; }

.metric-detail {
  position: absolute;
  right: 1.05vw;
  bottom: 1.15vh;
  left: 1.05vw;
  color: var(--muted);
  font-size: 0.58vw;
  line-height: 1.25;
}
.gauge-card .metric-detail { bottom: 0.9vh; text-align: center; }

.count-card .metric-value { margin-top: 1.45vh; }
.metric-alert {
  border-color: rgba(255, 111, 97, 0.42);
  background: linear-gradient(145deg, rgba(68, 37, 48, 0.83), rgba(25, 28, 38, 0.9));
}
.metric-alert::before { background: linear-gradient(90deg, transparent, var(--alert), transparent); }
.metric-alert.is-clear {
  border-color: var(--edge);
  background: linear-gradient(145deg, var(--panel-strong), var(--panel));
}

.panel-heading {
  position: relative;
  z-index: 3;
  display: flex;
  height: 4.6vh;
  padding: 0 1.1vw;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(112, 213, 231, 0.12);
  color: #bad0d6;
  font-size: 0.58vw;
  font-weight: 750;
  letter-spacing: 0.16em;
}
.panel-heading span:last-child { color: var(--muted); font-weight: 600; }

.crew-map { position: absolute; inset: 4.6vh 0 0; }
.crew-lines { position: absolute; inset: 0; width: 100%; height: 100%; }
.crew-lines path {
  fill: none;
  stroke: rgba(112, 213, 231, 0.5);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 900;
  stroke-dashoffset: 900;
  animation: draw-lines 1.7s 250ms ease-out forwards;
}

.crew-card {
  position: absolute;
  z-index: 2;
  display: flex;
  width: 17.4%;
  min-height: 7.4vh;
  padding: 0.75vh 0.45vw;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.45vh;
  border: 1px solid rgba(112, 213, 231, 0.58);
  border-radius: 0.3vw;
  background: rgba(14, 34, 46, 0.96);
  text-align: center;
  opacity: 0;
  transform: translateY(0.7vh);
  animation: crew-arrive 650ms ease-out forwards;
}
.crew-card strong {
  max-width: 100%;
  font-size: 0.66vw;
  font-weight: 660;
  line-height: 1.22;
  white-space: nowrap;
}
.crew-card span { color: var(--cyan); font-size: 0.43vw; font-weight: 760; letter-spacing: 0.1em; }
.crew-thomas { top: 2%; left: 23.55%; animation-delay: 100ms; }
.crew-mike { top: 2%; left: 77.55%; animation-delay: 160ms; }
.crew-luke { top: 36%; left: 5.55%; animation-delay: 260ms; }
.crew-scott { top: 36%; left: 41.55%; animation-delay: 320ms; }
.crew-stephen { top: 36%; left: 77.55%; animation-delay: 380ms; }
.crew-lewis-pryce,
.crew-sam,
.crew-jono,
.crew-henry,
.crew-michael,
.crew-lewis-callow { top: 72%; width: 13.5%; min-height: 8vh; }
.crew-lewis-pryce { left: 0.5%; animation-delay: 460ms; }
.crew-sam { left: 14.5%; animation-delay: 510ms; }
.crew-jono { left: 36.5%; animation-delay: 560ms; }
.crew-henry { left: 50.5%; animation-delay: 610ms; }
.crew-michael { left: 72.5%; animation-delay: 660ms; }
.crew-lewis-callow { left: 86%; animation-delay: 710ms; }
.crew-lewis-pryce strong,
.crew-sam strong,
.crew-jono strong,
.crew-henry strong,
.crew-michael strong,
.crew-lewis-callow strong { font-size: 0.56vw; white-space: normal; }

.officer-card > strong,
.officer-card > span { position: relative; z-index: 2; }
.officer-flash {
  position: absolute;
  z-index: 4;
  right: -0.72vw;
  bottom: -1.2vh;
  width: 1.6vw;
  height: 1.6vw;
  object-fit: contain;
  opacity: 0.88;
  transform: scale(1);
  transform-origin: center;
  filter: drop-shadow(0 0 0.24vw rgba(255, 224, 0, 0.5));
  animation: flash-pop 6s linear infinite;
  will-change: opacity, transform;
}
.crew-scott .officer-flash { animation-delay: 650ms; }
.crew-stephen .officer-flash { animation-delay: 1300ms; }
.crew-card .start-date {
  position: absolute;
  right: 7%;
  bottom: -2.25vh;
  left: 7%;
  z-index: 5;
  padding: 0.36vh 0.2vw;
  border-radius: 999px;
  background: var(--cyan);
  color: #05202a;
  font-size: 0.39vw;
  font-weight: 850;
  letter-spacing: 0.06em;
  white-space: nowrap;
  box-shadow: 0 0 0.7vw rgba(112, 213, 231, 0.16);
}

.tickets-panel { grid-column: 1 / 3; }
.tickets-heading { height: 4.4vh; }
.ticket-table { padding: 0 1.05vw; }
.ticket-row {
  display: grid;
  grid-template-columns: 6.3% 46.7% 13% 21% 13%;
  min-height: 3.32vh;
  align-items: center;
  border-bottom: 1px solid rgba(112, 213, 231, 0.08);
  color: #d7e8ec;
  font-size: 0.68vw;
}
.ticket-row span {
  min-width: 0;
  padding-right: 0.75vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ticket-row span:first-child { color: var(--cyan); font-weight: 650; }
.ticket-header {
  min-height: 2.3vh;
  color: var(--muted);
  font-size: 0.5vw;
  font-weight: 680;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.ticket-header span:first-child { color: var(--muted); }
.ticket-rows .ticket-row {
  opacity: 0;
  transform: translateX(-0.55vw);
  animation: row-arrive 500ms ease-out forwards;
}
.ticket-empty { color: var(--muted); }

.display-footer {
  bottom: 2.3vh;
  height: 3.7vh;
  color: #69848d;
  font-size: 0.58vw;
  font-weight: 650;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.footer-title { gap: 0.55vw; color: #d4e4e8; font-size: 0.8vw; font-weight: 560; letter-spacing: 0.03em; text-transform: none; }
.footer-anchor { width: 1.35vw; min-width: 20px; }

.pairing-screen {
  position: absolute;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at center, rgba(18, 67, 81, 0.32), transparent 42%), rgba(3, 8, 13, 0.985);
  transition: opacity 600ms ease, visibility 0s linear 600ms;
}
.pairing-screen.is-linked { visibility: hidden; opacity: 0; }
.pairing-card {
  width: min(62vw, 900px);
  padding: 6vh 5vw;
  border: 1px solid var(--edge);
  background: linear-gradient(145deg, rgba(13, 38, 50, 0.96), rgba(5, 15, 23, 0.985));
  text-align: center;
  box-shadow: 0 3vh 10vh rgba(0, 0, 0, 0.38);
}
.pairing-anchor { width: 4vw; margin-bottom: 3vh; }
.pairing-card h1 { font-size: 3.2vw; }
.pairing-instruction { margin: 3vh 0 2vh; color: var(--muted); font-size: 0.95vw; }
.pairing-instruction strong { color: var(--cyan); }
.pairing-code { color: var(--text); font-size: 4.4vw; font-weight: 430; letter-spacing: 0.22em; text-indent: 0.22em; }
.pairing-status { margin: 2.5vh 0 0; color: var(--muted); font-size: 0.75vw; letter-spacing: 0.05em; }

.pair-admin-body { min-height: 100%; overflow: auto; background: var(--bg-deep); }
.pair-admin-shell { width: min(92vw, 680px); margin: 8vh auto; padding: 48px; border: 1px solid var(--edge); background: var(--panel); }
.pair-admin-anchor { width: 48px; margin-bottom: 28px; }
.pair-admin-shell h1 { font-size: 54px; }
.pair-admin-copy { color: var(--muted); font-size: 17px; line-height: 1.55; }
.pair-form { display: grid; gap: 22px; margin-top: 34px; }
.pair-form label { display: grid; gap: 8px; color: #aac3cc; font-size: 13px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.pair-form input { width: 100%; border: 1px solid var(--edge); border-radius: 0; padding: 15px 16px; background: #051018; color: var(--text); font: inherit; font-size: 18px; letter-spacing: normal; text-transform: none; outline: none; }
.pair-form input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-soft); }
.pair-form button { border: 0; padding: 17px 22px; background: var(--orange); color: #160904; font: inherit; font-size: 14px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer; }
.pair-result { min-height: 24px; margin-top: 24px; color: var(--cyan); line-height: 1.5; }

@keyframes ambient-drift { from { background-position: 0 0, 0 0, 100% 0; } to { background-position: 0 0, 0 0, -80% 0; } }
@keyframes edge-travel { 0%, 15% { left: -35%; opacity: 0; } 27% { opacity: 1; } 58%, 100% { left: 112%; opacity: 0; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(112, 213, 231, 0.38); } 75%, 100% { box-shadow: 0 0 0 0.55vw rgba(112, 213, 231, 0); } }
@keyframes draw-lines { to { stroke-dashoffset: 0; } }
@keyframes crew-arrive { to { opacity: 1; transform: translateY(0); } }
@keyframes row-arrive { to { opacity: 1; transform: translateX(0); } }
@keyframes flash-pop {
  0%, 68%, 100% { opacity: 0.88; transform: scale(1); }
  70% { opacity: 0.18; transform: scale(0.88); }
  72% { opacity: 1; transform: scale(1.28); }
  74% { opacity: 0.28; transform: scale(0.94); }
  76% { opacity: 1; transform: scale(1.2); }
  80% { opacity: 0.88; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
