/**
 * ctOS style system — TASK_9.
 *
 * Design contract (do not drift):
 *   Base       #05070A → #0B0F14 blue-tinted near-black ramp
 *   Primary    #00E5FF cyan — the ONLY high-chroma accent. Everything that is
 *              "system chrome" is cyan or a dim derivative of it.
 *   Alerts     amber #FFB300 (warning) / red #FF2E3C (alarm) — states only,
 *              never decoration.
 *   Geometry   clip-path notched corners everywhere. border-radius is BANNED.
 *   Glow       thin 1px hairlines + faint text-shadow. No heavy drop shadows.
 *   Type       Chakra Petch (display) / Share Tech Mono (data) / Noto Sans TC (CJK names).
 *   Language   Chrome is English (TASK_12); Chinese appears ONLY in local
 *              identifiers: district, intersection and asset display names.
 *   Readability floor: body data text >= 12px, contrast >= 4.5:1 on panels.
 */

:root {
  --bg-0: #05070a;
  --bg-1: #0b0f14;
  --bg-2: #101820;
  --panel-bg: rgba(8, 13, 18, 0.86);
  --panel-bg-solid: #0a1016;
  --line-dim: rgba(0, 229, 255, 0.14);
  --line: rgba(0, 229, 255, 0.32);
  --line-hot: rgba(0, 229, 255, 0.75);

  --cyan: #00e5ff;
  --cyan-soft: #6fd3e0;      /* readable body-text tint of the accent */
  --cyan-dim: #14606e;
  --amber: #ffb300;
  --red: #ff2e3c;

  --text: #cfdde3;           /* blue-tinted off-white, never pure white */
  --text-dim: #64808d;
  --text-faint: #3a4f5a;

  --font-display: "Chakra Petch", "Noto Sans TC", sans-serif;
  --font-mono: "Share Tech Mono", "Chakra Petch", monospace;
  --font-cjk: "Noto Sans TC", sans-serif;

  --notch: 12px;
  --clip-panel: polygon(
    0 0,
    calc(100% - var(--notch)) 0,
    100% var(--notch),
    100% 100%,
    var(--notch) 100%,
    0 calc(100% - var(--notch))
  );
  --clip-btn: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  --clip-chip: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);

  --glow-text: 0 0 6px rgba(0, 229, 255, 0.45);
  --glow-amber: 0 0 6px rgba(255, 179, 0, 0.5);
  --glow-red: 0 0 7px rgba(255, 46, 60, 0.55);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-cjk);
  font-size: 14px;
  overflow: hidden;
}

::selection { background: rgba(0, 229, 255, 0.35); color: #eafcff; }

*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--cyan-dim); }
*::-webkit-scrollbar-thumb:hover { background: var(--line-hot); }

/* ---------------------------------------------------------------- layout */

#app { position: fixed; inset: 0; }

#scene { position: absolute; inset: 0; }
#scene .cesium-viewer-bottom { display: none; } /* logo moved to credits in README */
#scene .cesium-widget-credits { display: none !important; }

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 300px 1fr 384px;
  grid-template-areas:
    "top    top    top"
    "left   .      right"
    "bottom bottom bottom";
  gap: 10px;
  padding: 10px;
  z-index: 10;
}

#hud > * { min-height: 0; min-width: 0; }
.panel, .btn-ctos, .hud-actions { pointer-events: auto; }

/* --------------------------------------------------------------- panels */

.panel {
  clip-path: var(--clip-panel);
  background: linear-gradient(135deg, var(--line) 0%, var(--line-dim) 55%, var(--line) 100%);
  padding: 1px;
  position: relative;
}

.panel > .panel-body {
  clip-path: var(--clip-panel);
  background: var(--panel-bg);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.24em;
  color: var(--cyan);
  text-shadow: var(--glow-text);
  padding: 8px 12px 7px;
  border-bottom: 1px solid var(--line-dim);
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  text-transform: uppercase;
}

.panel-title::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--cyan);
  clip-path: polygon(0 0, 100% 0, 100% 100%); /* angular tick, not a dot */
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.6);
}

.panel-title .title-tag {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  text-shadow: none;
}

.panel-content { padding: 10px 12px; overflow-y: auto; flex: 1; min-height: 0; }

/* ---------------------------------------------------------------- top bar */

#hud-top {
  grid-area: top;
  display: flex;
  align-items: stretch;
  gap: 10px;
  pointer-events: none;
}

#brand {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 18px 8px 14px;
  clip-path: var(--clip-panel);
  background: var(--panel-bg);
  border-top: 1px solid var(--line);
}

#brand .brand-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.14em;
  color: var(--cyan);
  text-shadow: var(--glow-text);
  white-space: nowrap;
}

#brand .brand-sub {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.32em;
  color: var(--text-dim);
  border-left: 1px solid var(--line-dim);
  padding-left: 12px;
  white-space: nowrap;
}

#alarm-banner {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.4em;
  color: var(--red);
  text-shadow: var(--glow-red);
  visibility: hidden;
}

html[data-alert="alarm"] #alarm-banner {
  visibility: visible;
  animation: alarm-blink 0.9s steps(2, jump-none) infinite;
}

@keyframes alarm-blink { 50% { opacity: 0.25; } }

#hud-status {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  clip-path: var(--clip-panel);
  background: var(--panel-bg);
  border-top: 1px solid var(--line);
}

#hud-clock {
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--text);
  letter-spacing: 0.08em;
  text-shadow: var(--glow-text);
  min-width: 118px;
  text-align: right;
}

#hud-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  border-right: 1px solid var(--line-dim);
  padding-right: 12px;
  margin-right: 4px;
  text-align: right;
  line-height: 1.5;
}

.chip {
  clip-path: var(--clip-chip);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  padding: 4px 10px;
  background: rgba(0, 229, 255, 0.08);
  color: var(--cyan-soft);
  border: 0;
  white-space: nowrap;
}

.chip[data-state="ok"] { color: var(--cyan); background: rgba(0, 229, 255, 0.1); }
.chip[data-state="warn"] { color: var(--amber); background: rgba(255, 179, 0, 0.12); text-shadow: var(--glow-amber); }
.chip[data-state="alarm"] { color: var(--red); background: rgba(255, 46, 60, 0.14); text-shadow: var(--glow-red); }

/* --------------------------------------------------------------- left rail */

#hud-left {
  grid-area: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 320px;
}

#panel-layers { flex: none; }
#panel-assets { flex: 1; min-height: 0; }

.layer-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display); /* layer titles are Latin since TASK_12 */
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--text);
  padding: 5px 2px;
  cursor: pointer;
  user-select: none;
}

.layer-toggle input { position: absolute; opacity: 0; }

.layer-toggle .box {
  width: 13px;
  height: 13px;
  flex: none;
  clip-path: polygon(3px 0, 100% 0, 100% calc(100% - 3px), calc(100% - 3px) 100%, 0 100%, 0 3px);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
  position: relative;
  transition: background 0.15s ease-out;
}

.layer-toggle input:checked + .box { background: var(--cyan); box-shadow: 0 0 7px rgba(0, 229, 255, 0.55); }
.layer-toggle:hover .box { box-shadow: inset 0 0 0 1px var(--line-hot); }
.layer-toggle input:checked:hover + .box { box-shadow: 0 0 7px rgba(0, 229, 255, 0.8); }
.layer-toggle .t-id {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.08em;
}

.asset-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  margin: 0 -4px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.12s ease-out, border-color 0.12s ease-out;
}

.asset-row:hover { background: rgba(0, 229, 255, 0.07); border-left-color: var(--cyan); }
.asset-row.selected { background: rgba(0, 229, 255, 0.1); border-left-color: var(--cyan); }

.asset-dot {
  width: 8px;
  height: 8px;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); /* diamond */
  background: var(--cyan);
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.7);
}

.asset-row[data-status="warning"] .asset-dot { background: var(--amber); box-shadow: 0 0 6px rgba(255, 179, 0, 0.8); }
.asset-row[data-status="alarm"] .asset-dot {
  background: var(--red);
  box-shadow: 0 0 7px rgba(255, 46, 60, 0.9);
  animation: dot-pulse 0.6s ease-in-out infinite alternate;
}
@keyframes dot-pulse { to { opacity: 0.35; } }

.asset-name { font-size: 12.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-id { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); letter-spacing: 0.06em; }
.asset-metric { font-family: var(--font-mono); font-size: 11px; color: var(--cyan-soft); text-align: right; white-space: nowrap; }
.asset-row[data-status="warning"] .asset-metric { color: var(--amber); }
.asset-row[data-status="alarm"] .asset-metric { color: var(--red); }

/* ---------------------------------------------------------------- sidebar */

#sidebar-panel { grid-area: right; pointer-events: auto; }

#sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 10px 12px;
  overflow-y: auto;
  flex: 1;
}

#sidebar .feed-empty {
  flex: 1;
  min-height: 150px; /* keeps presence now that the region panel sits below */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 12.5px;
  letter-spacing: 0.15em;
  padding: 24px;
  text-align: center;
}

#sidebar .feed-empty .scan-icon {
  width: 46px;
  height: 46px;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  box-shadow: inset 0 0 0 1px var(--line);
  position: relative;
  animation: icon-spin 6s linear infinite;
}
@keyframes icon-spin { to { transform: rotate(360deg); } }

#sidebar video {
  width: 100%;
  display: block;
  background: #000;
  border: 1px solid var(--line-dim);
  outline: 0;
}

#sidebar .feed-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 2px 0 6px;
}

#sidebar [data-role="camera-name"] {
  font-family: var(--font-cjk);
  font-weight: 700;
  font-size: 14px;
  margin: 0;
  color: var(--text);
}

#sidebar [data-role="camera-id"] {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--cyan);
  letter-spacing: 0.1em;
  text-shadow: var(--glow-text);
}

#sidebar [data-role="camera-meta"] {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  margin: 6px 0 0;
  letter-spacing: 0.06em;
  line-height: 1.6;
}

#sidebar [data-role="status"] {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--amber);
  margin: 6px 0 0;
  min-height: 15px;
}

#sidebar .live-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--red);
  margin-left: auto;
  animation: alarm-blink 1.4s steps(2, jump-none) infinite;
}

/* fatal stream loss → ctOS offline state on the feed tile (TASK_11) */
#sidebar [data-role="feed"][data-offline="1"] video {
  opacity: 0.28;
  filter: grayscale(1);
}
#sidebar [data-role="feed"][data-offline="1"] .live-tag {
  color: var(--text-faint);
  animation: none;
}
#sidebar [data-role="feed"][data-offline="1"] [data-role="status"] {
  color: var(--red);
  text-shadow: var(--glow-red);
  letter-spacing: 0.12em;
}

/* --------------------------------------------------------------- bottom bar */

#hud-bottom {
  grid-area: bottom;
  display: flex;
  gap: 10px;
  align-items: stretch;
  height: 128px;
  pointer-events: none;
}

#panel-log { flex: 1; min-width: 0; }

#event-log {
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.7;
  letter-spacing: 0.04em;
  overflow-y: auto;
  padding: 6px 12px;
  flex: 1;
}

#event-log .log-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#event-log .log-time { color: var(--text-faint); margin-right: 10px; }
#event-log .log-line[data-sev="info"] { color: var(--text-dim); }
#event-log .log-line[data-sev="ok"] { color: var(--cyan-soft); }
#event-log .log-line[data-sev="warning"] { color: var(--amber); }
#event-log .log-line[data-sev="alarm"] { color: var(--red); text-shadow: var(--glow-red); }

.hud-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: flex-end;
}

.btn-ctos {
  clip-path: var(--clip-btn);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.2em;
  color: var(--cyan);
  background: rgba(0, 229, 255, 0.07);
  border: 0;
  box-shadow: inset 0 0 0 1px var(--line);
  padding: 10px 22px;
  cursor: pointer;
  transition: background 0.12s ease-out, color 0.12s ease-out;
  white-space: nowrap;
}

.btn-ctos:hover { background: rgba(0, 229, 255, 0.9); color: #041014; text-shadow: none; }
.btn-ctos:active { background: var(--cyan); }
.btn-ctos[disabled] { opacity: 0.35; cursor: default; pointer-events: none; }
.btn-ctos.danger { color: var(--red); box-shadow: inset 0 0 0 1px rgba(255, 46, 60, 0.4); background: rgba(255, 46, 60, 0.08); }
.btn-ctos.danger:hover { background: rgba(255, 46, 60, 0.85); color: #14060a; }

/* --------------------------------------------------------- profiler cards */

#profiler-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
}

#profiler-overlay svg { position: absolute; inset: 0; width: 100%; height: 100%; }

.profiler-card {
  position: absolute;
  min-width: 148px;
  max-width: 210px;
  clip-path: var(--clip-panel);
  --notch: 9px;
  background: var(--panel-bg);
  box-shadow: inset 0 0 0 1px var(--line);
  padding: 7px 10px 8px;
  pointer-events: auto;
  cursor: pointer;
  transform: translate(-50%, -100%);
  will-change: left, top;
  transition: opacity 0.2s ease-out;
}

.profiler-card .pc-id {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--cyan);
  text-shadow: var(--glow-text);
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.profiler-card .pc-status { margin-left: auto; font-size: 10px; letter-spacing: 0.14em; }
.profiler-card .pc-name { font-size: 11.5px; font-weight: 500; color: var(--text); margin-top: 3px; line-height: 1.35; }
.profiler-card .pc-metrics {
  display: flex;
  gap: 12px;
  margin-top: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--cyan-soft);
}
.profiler-card .pc-metrics b { font-weight: 400; color: var(--text-dim); margin-right: 4px; }

.profiler-card[data-status="online"] .pc-status { color: var(--cyan); }
.profiler-card[data-status="warning"] { box-shadow: inset 0 0 0 1px rgba(255, 179, 0, 0.55); }
.profiler-card[data-status="warning"] .pc-id, .profiler-card[data-status="warning"] .pc-status { color: var(--amber); text-shadow: var(--glow-amber); }
.profiler-card[data-status="alarm"] { box-shadow: inset 0 0 0 1px rgba(255, 46, 60, 0.7); animation: card-flicker 2.2s steps(3, jump-none) infinite; }
.profiler-card[data-status="alarm"] .pc-id, .profiler-card[data-status="alarm"] .pc-status { color: var(--red); text-shadow: var(--glow-red); }
.profiler-card[data-status="alarm"] .pc-metrics { color: var(--red); }

@keyframes card-flicker { 0%, 92% { opacity: 1; } 94% { opacity: 0.55; } 96% { opacity: 1; } 98% { opacity: 0.7; } }

.leader-line { stroke: var(--line-hot); stroke-width: 1; fill: none; }
.leader-line[data-status="warning"] { stroke: rgba(255, 179, 0, 0.8); }
.leader-line[data-status="alarm"] { stroke: rgba(255, 46, 60, 0.85); }
.leader-dot { fill: var(--cyan); }
.leader-dot[data-status="warning"] { fill: var(--amber); }
.leader-dot[data-status="alarm"] { fill: var(--red); }

/* ------------------------------------------------------------ boot overlay */

#boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  background:
    radial-gradient(ellipse 120% 90% at 50% 20%, rgba(0, 229, 255, 0.05), transparent 60%),
    var(--bg-0);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease-out;
}

#boot.boot-done { opacity: 0; pointer-events: none; }

#boot::before {
  /* slow scan sweep across the whole boot screen */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 0%, rgba(0, 229, 255, 0.06) 50%, transparent 100%);
  background-size: 100% 240px;
  background-repeat: no-repeat;
  animation: boot-sweep 2.8s linear infinite;
  pointer-events: none;
}

@keyframes boot-sweep {
  from { background-position: 0 -240px; }
  to { background-position: 0 110vh; }
}

#boot-inner { width: min(680px, 84vw); }

#boot-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(26px, 3.4vw, 40px);
  letter-spacing: 0.18em;
  color: var(--cyan);
  text-shadow: 0 0 14px rgba(0, 229, 255, 0.5);
  margin-bottom: 4px;
}

#boot-brand-sub {
  font-family: var(--font-cjk);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.5em;
  color: var(--text-dim);
  margin-bottom: 34px;
  border-bottom: 1px solid var(--line-dim);
  padding-bottom: 16px;
}

#boot-lines {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 2.05;
  letter-spacing: 0.05em;
  min-height: 210px;
}

.boot-line { display: flex; color: var(--text-dim); opacity: 0; }
.boot-line.on { opacity: 1; }
.boot-line .bl-text { color: var(--text); }
.boot-line .bl-prefix { color: var(--cyan-dim); margin-right: 10px; }
.boot-line .bl-dots { flex: 1; overflow: hidden; color: var(--text-faint); margin: 0 8px; }
.boot-line .bl-state { color: var(--text-faint); min-width: 46px; text-align: right; }
.boot-line.ok .bl-state { color: var(--cyan); text-shadow: var(--glow-text); }
.boot-line.fail .bl-state { color: var(--red); text-shadow: var(--glow-red); }

#boot-online {
  margin-top: 26px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(20px, 2.6vw, 30px);
  letter-spacing: 0.5em;
  color: var(--cyan);
  text-shadow: 0 0 16px rgba(0, 229, 255, 0.65);
  opacity: 0;
}

#boot-online.on { animation: online-in 0.7s steps(6, jump-none) forwards; }

@keyframes online-in {
  0% { opacity: 0; transform: translateX(-6px); }
  30% { opacity: 1; transform: none; }
  45% { opacity: 0.2; }
  60% { opacity: 1; }
  80% { opacity: 0.5; }
  100% { opacity: 1; }
}

#boot-skip {
  position: absolute;
  bottom: 26px;
  right: 30px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--text-faint);
}

/* HUD stagger-in after boot */
#hud > * { opacity: 0; }
#hud.hud-in > * { animation: hud-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
#hud.hud-in > :nth-child(1) { animation-delay: 0.05s; }
#hud.hud-in > :nth-child(2) { animation-delay: 0.18s; }
#hud.hud-in > :nth-child(3) { animation-delay: 0.28s; }
#hud.hud-in > :nth-child(4) { animation-delay: 0.38s; }

@keyframes hud-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------- alarm mode */

html[data-alert="alarm"] #hud::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 140px rgba(255, 46, 60, 0.18);
  animation: alarm-breathe 1.6s ease-in-out infinite alternate;
}

@keyframes alarm-breathe { to { box-shadow: inset 0 0 200px rgba(255, 46, 60, 0.3); } }

/* --------------------------------------------------- region data panel */

.rp { display: flex; flex-direction: column; padding-top: 10px; }

.rp-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 2px 2px;
  border-top: 1px solid var(--line-dim);
  margin-top: 8px;
}

.rp-scope-label { font-family: var(--font-cjk); font-weight: 700; font-size: 13px; color: var(--text); }
.rp-scope-id {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: var(--cyan);
  text-shadow: var(--glow-text);
  white-space: nowrap;
}

.rp-sec {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: 0.22em;
  color: var(--cyan-soft);
  display: flex;
  align-items: baseline;
  border-bottom: 1px solid var(--line-dim);
  padding-bottom: 4px;
  margin: 14px 0 8px;
}

.rp-sec span {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--text-faint);
}

.rp-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.rp-tiles-2 { grid-template-columns: repeat(2, 1fr); }
.rp-tile-wide { grid-column: 1 / -1; }

.rp-tile {
  clip-path: var(--clip-chip);
  background: rgba(0, 229, 255, 0.05);
  padding: 7px 9px 6px;
  min-width: 0;
}

.rp-k {
  font-family: var(--font-display); /* Latin metric labels since TASK_12 */
  font-weight: 600;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.09em;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden; /* long unit tags truncate instead of breaking the notch */
}

.rp-v {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 19px;
  line-height: 1.2;
  color: var(--text);
  margin-top: 2px;
}

.rp-v-lg { font-size: 25px; text-shadow: 0 0 8px rgba(0, 229, 255, 0.25); }

.rp-u {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

/* LOS letter: A/B cyan, C/D amber, E/F red — state colours, not decoration */
.rp-los[data-los="A"], .rp-los[data-los="B"] { color: var(--cyan); text-shadow: var(--glow-text); }
.rp-los[data-los="C"], .rp-los[data-los="D"] { color: var(--amber); text-shadow: var(--glow-amber); }
.rp-los[data-los="E"], .rp-los[data-los="F"] { color: var(--red); text-shadow: var(--glow-red); }

/* environment tiles out of threshold */
.rp-tile[data-state="warn"] { background: rgba(255, 179, 0, 0.09); }
.rp-tile[data-state="warn"] .rp-v { color: var(--amber); text-shadow: var(--glow-amber); }
.rp-tile[data-state="alarm"] { background: rgba(255, 46, 60, 0.1); }
.rp-tile[data-state="alarm"] .rp-v { color: var(--red); text-shadow: var(--glow-red); }

.rp-spark { width: 100%; height: 28px; display: block; margin-top: 5px; }
.rp-spark-line { fill: none; stroke: var(--cyan); stroke-width: 1; }
.rp-spark-area { fill: rgba(0, 229, 255, 0.09); stroke: none; }

/* vehicle mix — single-hue lightness steps + neutral, legend carries names */
.rp-mixbar {
  display: flex;
  height: 14px;
  clip-path: var(--clip-chip);
  background: var(--bg-2);
  overflow: hidden;
}

.rp-mix-seg { transition: width 0.9s cubic-bezier(0.16, 1, 0.3, 1); min-width: 1px; }
.rp-mix-seg[data-mix="car"], .rp-mix-item[data-mix="car"] i { background: var(--cyan); }
.rp-mix-seg[data-mix="moto"], .rp-mix-item[data-mix="moto"] i { background: #0e8296; }
.rp-mix-seg[data-mix="heavy"], .rp-mix-item[data-mix="heavy"] i { background: #bfe9f2; }
.rp-mix-seg[data-mix="bike"], .rp-mix-item[data-mix="bike"] i { background: var(--text-faint); }

.rp-mix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 7px;
  font-size: 11px;
  color: var(--text-dim);
}

.rp-mix-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.rp-mix-item i {
  width: 8px;
  height: 8px;
  clip-path: polygon(2px 0, 100% 0, 100% calc(100% - 2px), calc(100% - 2px) 100%, 0 100%, 0 2px);
}
.rp-mix-item b {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 400;
  color: var(--text);
}

/* pole equipment status lights */
.rp-pole { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 2px 2px 4px; }
.rp-pole-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.07em;
  color: var(--text);
  white-space: nowrap;
}
.rp-pole-item[data-status="warning"] .asset-dot { background: var(--amber); box-shadow: 0 0 6px rgba(255, 179, 0, 0.8); }
.rp-pole-item[data-status="alarm"] .asset-dot {
  background: var(--red);
  box-shadow: 0 0 7px rgba(255, 46, 60, 0.9);
  animation: dot-pulse 0.6s ease-in-out infinite alternate;
}
.rp-pole-item[data-status="offline"] .asset-dot { background: var(--text-faint); box-shadow: none; }

/* recent events mini list */
.rp-events { display: flex; flex-direction: column; }
.rp-evt {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 11.5px;
  padding: 3px 2px;
  border-left: 2px solid transparent;
}
.rp-evt-time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  color: var(--text-faint);
  flex: none;
}
.rp-evt-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-evt[data-sev="info"] .rp-evt-title { color: var(--text-dim); }
.rp-evt[data-sev="ok"] .rp-evt-title { color: var(--cyan-soft); }
.rp-evt[data-sev="warning"] { border-left-color: var(--amber); }
.rp-evt[data-sev="warning"] .rp-evt-title { color: var(--amber); }
.rp-evt[data-sev="alarm"] { border-left-color: var(--red); }
.rp-evt[data-sev="alarm"] .rp-evt-title { color: var(--red); text-shadow: var(--glow-red); }
.rp-evt-empty { font-size: 11.5px; color: var(--text-faint); padding: 2px; }

/* ------------------------------------------------------------- responsive */

@media (max-width: 1500px) {
  #hud { grid-template-columns: 268px 1fr 340px; }
  #brand .brand-sub { display: none; }
}

@media (min-width: 2200px) {
  /* ultra-wide: rails stay edge-anchored; give panels a hair more room */
  #hud { grid-template-columns: 330px 1fr 420px; }
}

@media (max-height: 820px) {
  #hud-bottom { height: 104px; }
  #boot-lines { min-height: 170px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}
