:root {
  --green: #0f5132;
  --green-2: #146c43;
  --mint: #eaf6ef;
  --ink: #111827;
  --body: #475569;
  --line: #d9e2ec;
  --warn-bg: #fffbeb;
  --warn: #92400e;
}

* { box-sizing: border-box; }
.hidden { display: none !important; }
.login-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, .72);
  padding: 18px;
}
.login-box {
  width: min(440px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  display: grid;
  gap: 12px;
}
body {
  margin: 0;
  font-family: Inter, "IBM Plex Sans", Arial, sans-serif;
  color: var(--ink);
  background: #f8fafc;
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
body.login-page {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
}
body.login-page main {
  width: min(520px, 100%);
}
body.night, html[data-theme="night"] body {
  --ink: #e5e7eb;
  --body: #cbd5e1;
  --line: #334155;
  --mint: #123326;
  background: #0b1220;
}
body.night aside, body.night header, body.night .band, body.night article, body.night .split > div { background: #111827; }
body.night .site-card,
body.night .item,
body.night .responder-card,
body.night .evidence-card,
body.night .timeline-row,
body.night .legend-item,
body.night .login-box,
body.night select,
body.night input,
body.night textarea {
  background: #0f172a;
  color: var(--ink);
  border-color: var(--line);
}
aside {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  min-width: 0;
}
.brand {
  color: var(--green);
  font-weight: 800;
  font-size: 22px;
  margin-bottom: 24px;
}
nav { display: grid; gap: 5px; }
nav a {
  color: var(--body);
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 6px;
}
nav a:hover { background: var(--mint); color: var(--green); }
nav a.active { background: var(--mint); color: var(--green); font-weight: 800; }
main { padding: 28px; display: grid; gap: 22px; min-width: 0; }
.route-hidden { display: none !important; }
header, .band, article, .split > div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}
header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}
.site-switcher {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--body);
  font-weight: 700;
}
select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: #111827;
}
.eyebrow {
  color: var(--green-2);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
  margin: 0 0 6px;
}
h1, h2 { margin: 0 0 14px; letter-spacing: 0; }
h1 { font-size: 30px; }
h2 { font-size: 18px; }
.status-strip, .controls, .metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.status-strip span, .chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: #fff;
  color: var(--body);
  font-size: 13px;
}
button, .chip, .item, nav a {
  overflow-wrap: anywhere;
}
.chip.ok { color: var(--green); background: var(--mint); border-color: #bfe6cf; }
.chip.warn { color: var(--warn); background: var(--warn-bg); border-color: #fde68a; }
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 18px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
#cross-site {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.site-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}
.site-card.selected { border-color: #0f5132; background: var(--mint); }
.mission-complete-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.map {
  min-height: 380px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(90deg, rgba(15,81,50,.08) 1px, transparent 1px),
    linear-gradient(rgba(15,81,50,.08) 1px, transparent 1px),
    #edf7f0;
  background-size: 40px 40px;
  position: relative;
  overflow: hidden;
}
.real-map { background: #dbeafe; }
.maplibregl-map { font: inherit; }
.gis-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
  gap: 16px;
}
.teach-layout {
  display: grid;
  grid-template-columns: minmax(280px, .9fr) minmax(0, 1.1fr);
  gap: 16px;
  align-items: start;
}
.teach-layout pre {
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--body);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  background: #fff;
  font-size: 12px;
}
.legend-item i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
}
.responder-grid, .evidence-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.responder-card, .evidence-card, .timeline-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  color: inherit;
  text-decoration: none;
}
.responder-card svg { width: 22px; height: 22px; color: var(--green); }
.evidence-card {
  min-height: 150px;
  display: grid;
  align-content: end;
  background: linear-gradient(135deg, #eaf6ef, #dbeafe);
}
.evidence-card span {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  color: var(--green);
}
.timeline-playhead {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.timeline-playhead input { flex: 1; }
.timeline-list { display: grid; gap: 8px; }
.timeline-row {
  display: grid;
  grid-template-columns: 160px 190px 1fr 120px;
  gap: 10px;
  align-items: center;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  max-width: min(900px, 94vw);
}
.map .marker {
  position: absolute;
  transform: translate(-50%, -50%);
  background: var(--green);
  color: white;
  padding: 5px 7px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}
.map .route {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
}
.empty-map {
  display: grid;
  place-items: center;
  height: 380px;
  color: var(--warn);
  text-align: center;
  font-weight: 800;
}
.video {
  min-height: 380px;
  border-radius: 6px;
  background: #111827;
  color: white;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}
.video::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(135deg, rgba(255,255,255,.08), rgba(255,255,255,.08) 12px, transparent 12px, transparent 24px);
}
.video-label {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 6px 8px;
  border-radius: 5px;
  background: var(--warn-bg);
  color: var(--warn);
  font-weight: 700;
}
#scenario-title { position: relative; font-size: 28px; font-weight: 800; }
.chat-form { display: flex; gap: 10px; }
.contact-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.contact-form label {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--body);
  font-weight: 700;
}
.contact-form input[type="checkbox"] { flex: 0 0 auto; }
.stack-form {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.stack-form label { display: grid; gap: 5px; color: var(--body); font-weight: 700; }
input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  font-size: 15px;
}
button {
  border: 0;
  border-radius: 6px;
  padding: 10px 13px;
  background: var(--green);
  color: white;
  font-weight: 700;
  cursor: pointer;
}
button:hover { background: var(--green-2); }
button:disabled {
  background: #e2e8f0;
  color: #64748b;
  cursor: not-allowed;
}
pre {
  overflow: auto;
  background: #0b1220;
  color: #e5e7eb;
  padding: 14px;
  border-radius: 6px;
  min-height: 84px;
}
.item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;
}
.item strong { display: block; margin-bottom: 5px; }
.muted { color: var(--body); font-size: 13px; }
.report { display: block; padding: 32px; background: white; }
.capability-groups {
  display: grid;
  gap: 16px;
}
.capability-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 9px;
}
.capability-card {
  align-items: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 76px;
  text-align: left;
}
body.night .capability-card { background: #111827; }
.capability-card strong {
  font-size: 12px;
  text-transform: uppercase;
}
.state-passed { border-color: #16a34a; }
.state-test_ready { border-color: #2563eb; }
.state-blocked,
.state-failed { border-color: #dc2626; }
.state-locked,
.state-disabled,
.state-not_implemented { opacity: .72; }
.capability-detail { margin-top: 16px; }
.flight-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 14px;
}
.flight-layout textarea {
  margin-top: 6px;
  min-height: 92px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}
.readiness-pass { border-left: 4px solid #16a34a; }
.readiness-fail { border-left: 4px solid #dc2626; }
.readiness-record { border-left: 4px solid #64748b; }
body.operator-mode .admin-only,
body.admin-mode .operator-only {
  display: none !important;
}
body.operator-mode #system {
  display: none;
}
body.operator-mode pre {
  white-space: pre-wrap;
}
.phone-field {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: auto auto 1fr;
  margin: 10px 0;
}
.phone-field span {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--soft);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.phone-field input {
  margin: 0;
}
.cross-sweep-svg {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1;
  display: block;
  border-radius: 8px;
  background: var(--soft);
}
.cross-sweep-svg rect {
  fill: rgba(15, 81, 50, .04);
  stroke: var(--line);
}
.cross-sweep-svg line {
  stroke: rgba(100, 116, 139, .35);
  stroke-width: .5;
}
.cross-sweep-svg polyline {
  fill: none;
  stroke: #16a34a;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cross-sweep-svg circle {
  fill: #f59e0b;
  stroke: var(--panel);
  stroke-width: 1;
}
.cross-sweep-svg circle.centre {
  fill: #0f5132;
}
body.night .cross-sweep-svg rect {
  fill: rgba(22, 163, 74, .08);
}
@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  aside, main {
    width: 100%;
    max-width: 100vw;
  }
  aside { position: static; height: auto; }
  .split, .grid, .gis-layout, .teach-layout, .responder-grid, .evidence-grid { grid-template-columns: 1fr; }
  #cross-site, .mission-complete-grid { grid-template-columns: 1fr; }
  .contact-form { grid-template-columns: 1fr; }
  header { display: grid; }
  main { padding: 16px; }
  .timeline-row { grid-template-columns: 1fr; }
}
