:root {
  color-scheme: dark;
  --bg: #061014;
  --panel: #0d1c23;
  --line: #304852;
  --txt: #f1f7f8;
  --dim: #b3c5cc;
  --accent: #35d1c6;
  --bad: #ff8393;
  --warn: #f4cf68;
  --good: #78e1b1;
  font-family:
    Inter,
    system-ui,
    -apple-system,
    sans-serif;
  font-size: 16px;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
}
::selection {
  background: var(--accent);
  color: var(--bg);
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
header,
main,
footer {
  padding: 20px 28px;
}
header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
h1 {
  font-size: clamp(28px, 3vw, 48px);
  line-height: 1.1;
  margin: 0;
  font-weight: 800;
}
h2 {
  font-size: 26px;
  margin: 0;
}
p {
  color: var(--dim);
  margin: 8px 0 16px;
  line-height: 1.5;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
#clock {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}
a {
  color: var(--accent);
  text-underline-offset: 4px;
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  min-height: 46px;
  padding: 10px 16px;
  background: #152d36;
  color: var(--txt);
  border: 1px solid #45616d;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 650;
}
button:hover {
  background: #25424d;
}
button:disabled {
  opacity: 0.55;
  cursor: wait;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #041718;
}
button.primary:hover {
  background: #7be5dd;
}
button[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}
.door {
  max-width: 420px;
  margin: 6vh auto;
}
.door input {
  display: block;
  width: 100%;
  margin: 8px 0 18px;
}
.door button {
  width: 100%;
}
label {
  display: block;
  font-weight: 650;
  margin-bottom: 8px;
}
input,
select,
textarea {
  background: #09161c;
  border: 1px solid #58717c;
  border-radius: 7px;
  padding: 12px;
  color: var(--txt);
  width: 100%;
  min-height: 48px;
  caret-color: var(--accent);
}
input::placeholder,
textarea::placeholder {
  color: #a9bbc4;
}
textarea {
  resize: vertical;
  min-height: 90px;
}
.connection {
  background: #12372f;
  color: #b8f1d9;
  padding: 12px 16px;
  border-radius: 6px;
  font-weight: 650;
}
.connection.stale {
  background: #4b241e;
  color: #ffe1cd;
}
.toolbar,
.actions,
.view-switch {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar {
  justify-content: space-between;
  margin: 18px 0 28px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin: 20px 0 12px;
}
.section-head p {
  margin: 6px 0;
}
.paging {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.board-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.board-table th {
  text-align: left;
  color: var(--dim);
  font-size: 14px;
  padding: 12px 16px;
  border-bottom: 2px solid var(--line);
  font-weight: 650;
}
.board-table td {
  vertical-align: top;
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.board-table tbody tr:nth-child(odd) {
  background: var(--panel);
}
.location {
  font-size: 25px;
  font-weight: 780;
  line-height: 1.2;
  display: block;
  margin-bottom: 8px;
}
.line {
  display: block;
  font-size: 18px;
  margin: 8px 0;
}
.badge {
  display: inline-block;
  font-weight: 750;
  font-size: 14px;
  border: 1px solid currentColor;
  padding: 5px 8px;
  border-radius: 5px;
  margin: 3px 0;
}
.bad {
  color: var(--bad);
}
.warn {
  color: var(--warn);
}
.good {
  color: var(--good);
}
.muted {
  color: var(--dim);
}
.train {
  margin-bottom: 14px;
}
.train strong {
  font-size: 24px;
  display: block;
}
.timer {
  font-variant-numeric: tabular-nums;
  font-size: 23px;
  font-weight: 750;
  display: block;
  margin-top: 5px;
}
.eta-detail {
  font-size: 15px;
  color: var(--dim);
  display: block;
  margin-top: 6px;
}
.row-note {
  margin: 10px 0 0;
  font-size: 15px;
  white-space: pre-wrap;
  line-height: 1.45;
}
.row-meta {
  font-size: 13px;
  color: var(--dim);
  margin-top: 12px;
}
.edit-button {
  margin-top: 12px;
}
.empty {
  padding: 28px;
  background: var(--panel);
  border: 1px dashed var(--line);
  color: var(--dim);
  line-height: 1.5;
}
.team-section {
  margin-top: 32px;
}
#history {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  padding: 20px 0;
}
summary {
  cursor: pointer;
  font-weight: 650;
  padding: 12px 0;
}
footer {
  font-size: 13px;
  color: var(--dim);
  border-top: 1px solid var(--line);
  line-height: 1.5;
}
#editor {
  max-width: 760px;
  margin: 0 auto 30px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.field {
  margin-bottom: 20px;
}
.full {
  grid-column: 1/-1;
}
.help {
  font-size: 14px;
  margin: 7px 0;
  color: var(--dim);
}
fieldset {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 16px;
  margin: 0 0 20px;
}
legend {
  font-size: 18px;
  font-weight: 750;
  padding: 0 8px;
}
.train-editor {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  margin-bottom: 14px;
}
.form-actions {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  align-items: center;
}
#saveError,
#pinError {
  color: #ffb4bf;
  white-space: pre-wrap;
}
* {
  scrollbar-color: #58717c var(--bg);
  scrollbar-width: thin;
}
@media (min-width: 1700px) {
  .board-table td {
    padding: 24px;
  }
  .location {
    font-size: 32px;
  }
  .board-table {
    font-size: 20px;
  }
}
@media (max-width: 760px) {
  header,
  main,
  footer {
    padding: 16px;
  }
  header {
    align-items: flex-start;
  }
  .header-actions {
    gap: 6px;
    justify-content: flex-end;
    font-size: 13px;
  }
  #clock {
    font-size: 16px;
  }
  header p {
    font-size: 13px;
    margin-bottom: 0;
  }
  .toolbar {
    gap: 16px;
  }
  .actions {
    width: 100%;
  }
  .actions #addIncident,
  .actions #addTeam {
    flex: 1;
  }
  .actions #fullScreen {
    display: none;
  }
  .section-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  h2 {
    font-size: 23px;
  }
  .board-table,
  .board-table tbody,
  .board-table tr,
  .board-table td {
    display: block;
    width: 100% !important;
  }
  .board-table thead {
    display: none;
  }
  .board-table tbody tr {
    padding: 14px;
    margin-bottom: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
  }
  .board-table td,
  .wall-mode .board-table td {
    padding: 8px 0;
    border: 0;
  }
  .board-table td[data-label]:before {
    content: attr(data-label);
    display: block;
    color: var(--dim);
    font-size: 13px;
    font-weight: 650;
    margin-bottom: 8px;
  }
  .location {
    font-size: 25px;
  }
  .train {
    display: inline-block;
    vertical-align: top;
    margin: 0 20px 10px 0;
  }
  .fields {
    display: block;
  }
  #editor {
    padding: 16px;
  }
  .form-actions {
    position: sticky;
    bottom: 0;
    background: var(--panel);
    padding: 12px 0;
  }
  .form-actions button {
    flex: 1;
  }
  .door {
    margin-top: 4vh;
  }
  .wall-mode .board-table {
    font-size: 16px;
  }
}
@media (prefers-reduced-motion: no-preference) {
  button {
    transition: background 0.12s ease-out;
  }
}

#entryForm > details,
#entryForm fieldset > details {
  margin: 16px 0;
}
#entryForm summary {
  cursor: pointer;
  padding: 12px 0;
  font-weight: 650;
}
.line-state-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.line-state-row strong {
  display: block;
  margin-bottom: 10px;
}
.line-segments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.line-segments button {
  flex: 1;
  padding: 10px 8px;
  min-height: 44px;
}
.line-segments [aria-pressed="true"] {
  background: #31536a;
  border-color: #93bdd7;
}
.line-segments [data-state="block"][aria-pressed="true"] {
  background: #742c39;
  border-color: #ff8393;
}
.line-segments [data-state="normal"][aria-pressed="true"] {
  background: #20573f;
  border-color: #78e1b1;
}
.line-state-row .remove-line {
  margin-top: 8px;
}
.line-state-summary {
  display: block;
  font-weight: 700;
  margin-top: 8px;
}

.storm-editing .toolbar {
  display: none;
}
.storm-editing #editor {
  margin-top: 20px;
}
.line-segments {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.line-segments [aria-pressed="true"] {
  color: #fff;
}

#lineSuggestions button:disabled {
  cursor: default;
}

/* ---- 28 Oct 2026: sandbox banner, summary tiles, one-tap actions, toast, time fields ---- */
.world-banner {
  background: repeating-linear-gradient(135deg, #f4cf68 0 18px, #141414 18px 36px);
  color: #fff;
  text-shadow: 0 0 4px #000, 0 0 2px #000;
  font-weight: 800;
  text-align: center;
  padding: 8px 12px;
  letter-spacing: 0.02em;
}
.world-chip {
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 750;
  font-size: 14px;
}
.world-chip.sandbox {
  border-color: var(--warn);
  color: var(--warn);
}
.sandbox-mode header {
  border-bottom-color: var(--warn);
}
.ndm-badge {
  background: #742c39;
  border: 1px solid var(--bad);
  color: #ffd9de;
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 750;
  font-size: 15px;
  text-decoration: none;
}
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}
.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 5px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tile.bad { border-left-color: var(--bad); }
.tile.warn { border-left-color: var(--warn); }
.tile.good { border-left-color: var(--good); }
.tile-label {
  color: var(--dim);
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tile-value {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.tile.bad .tile-value { color: var(--bad); }
.tile.warn .tile-value { color: var(--warn); }
.tile-detail {
  font-size: 13px;
  color: var(--dim);
  overflow-wrap: anywhere;
}
.filters {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.filter-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.filter-buttons button {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 14px;
}
.filters input[type="search"] {
  min-height: 40px;
  width: 220px;
  padding: 6px 10px;
}
.wall-mode .filters { display: none; }
.place {
  color: var(--dim);
  font-size: 16px;
}
.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 4px 0;
}
.chip {
  display: inline-block;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 14px;
  font-weight: 700;
  margin: 2px 4px 2px 0;
}
.ndm-chip {
  display: inline-block;
  border: 1px solid currentColor;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 14px;
  font-weight: 700;
  margin: 6px 0 2px;
  text-decoration: none;
}
.ndm-chip.bad { background: #3a1a21; }
.ndm-chip.warn { background: #3a3215; }
.ndm-chip.good { background: #163a2b; }
.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.row-actions button,
.train-actions button,
.train-actions select,
.quick-train button,
.quick-note button,
.line-toggle button {
  min-height: 40px;
  padding: 6px 12px;
  font-size: 14px;
}
.train-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.train-actions select {
  width: auto;
  min-height: 40px;
  padding: 6px 10px;
}
.train-history,
.updates {
  margin-top: 6px;
  font-size: 13px;
  color: var(--dim);
}
.train-history summary,
.updates summary {
  padding: 4px 0;
  font-size: 13px;
}
.train-history div,
.updates div {
  padding: 2px 0;
  overflow-wrap: anywhere;
}
.quick-train,
.quick-note {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
}
.quick-train input[name="headcode"] {
  width: 120px;
  min-height: 40px;
  padding: 6px 10px;
  text-transform: uppercase;
}
.quick-note input {
  flex: 1;
  min-width: 160px;
  min-height: 40px;
  padding: 6px 10px;
}
label.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  margin: 0;
}
label.check input {
  width: 22px;
  height: 22px;
  min-height: 0;
  margin: 0;
}
.line-state-summary {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
}
.line-toggle {
  display: inline-flex;
  gap: 4px;
}
.line-toggle button {
  color: var(--txt);
}
.line-toggle [aria-pressed="true"] {
  border-color: currentColor;
  background: #31536a;
}
.line-toggle [data-state="block"][aria-pressed="true"] { background: #742c39; }
.line-toggle [data-state="normal"][aria-pressed="true"] { background: #20573f; }
.line-toggle [data-state="caution"][aria-pressed="true"] { background: #5a4a12; }
.closed-row .location { color: var(--dim); }
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: #12372f;
  color: #e8fff4;
  border: 1px solid var(--good);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  z-index: 30;
  max-width: min(92vw, 640px);
  box-shadow: 0 8px 30px #000a;
}
.toast.error {
  background: #4b241e;
  color: #ffe1cd;
  border-color: var(--bad);
}
.toast button {
  min-height: 36px;
  padding: 4px 12px;
}
/* time fields: 24-hour clock, date defaults to today, chips for the usual corrections */
.time-inputs {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 8px;
}
.time-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.time-chips button {
  min-height: 36px;
  padding: 4px 10px;
  font-size: 14px;
}
.time-note {
  display: block;
}
.field-error {
  display: block;
  color: #ffb4bf;
  font-size: 14px;
  margin-top: 6px;
  min-height: 0;
}
.field-error:empty { display: none; }
[aria-invalid="true"] {
  border-color: var(--bad);
  box-shadow: 0 0 0 2px #ff839355;
}
/* compact sticky save bar that never covers the last field */
#entryForm {
  padding-bottom: 8px;
}
@media (max-width: 760px) {
  .form-actions {
    padding: 8px 0;
    border-top: 1px solid var(--line);
    gap: 8px;
  }
  .form-actions button {
    min-height: 42px;
    padding: 6px 10px;
  }
  #entryForm > .field:last-of-type,
  #entryForm > select:last-of-type {
    margin-bottom: 8px;
  }
  #entryForm {
    padding-bottom: 72px;
  }
  /* a field scrolled or focused into view lands above the bar, never under it */
  #entryForm .field,
  #entryForm input,
  #entryForm select,
  #entryForm textarea,
  #entryForm details,
  #entryForm fieldset {
    scroll-margin-bottom: 84px;
  }
  .tile-value { font-size: 24px; }
  .tiles { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .tile { padding: 8px 10px; }
  .filters input[type="search"] { width: 100%; }
  .actions #fullScreen { display: inline-block; }
  .door button { margin-bottom: 10px; }
}

/* round 2: team links, stale lines, map on the overview */
.team-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; align-items: center; }
.team-chip {
  border: 1px solid currentColor; border-radius: 999px; padding: 4px 12px; font-size: 14px;
  font-weight: 700; background: transparent; min-height: 36px;
}
.team-chip.good { color: var(--good); }
.team-chip.warn { color: var(--warn); }
.line-state-row.stale-line strong { color: var(--warn); }
.stale-note { display: block; margin: 4px 0 8px; }
#mapDetails summary { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
#mapDetails summary h2 { display: inline; }
#mapDetails:not([open]) ~ #stormWallMap, #mapDetails:not([open]) ~ #mapStatus { display: none; }
.wall-mode #mapDetails summary { pointer-events: none; list-style: none; }
.wall-mode #mapDetails .map-help { display: none; }
.map-help { margin: 0 0 8px; }
.map-toggle-hint { color: var(--accent); font-size: 14px; font-weight: 650; }
.wall-mode .map-toggle-hint { display: none; }

/* round 8: stand a responding team down from the incident card */
.team-standdown { margin-left: 4px; padding: 3px 8px; font-size: 12px; border-radius: 999px; border: 1px solid #2b3d46; background: transparent; color: inherit; cursor: pointer; }
.team-standdown:hover { border-color: #e7a33e; }
#sandboxReset.armed { background: #5a1f1f; border-color: #ff8a8a; color: #fff; }
.place-note { margin: 4px 0 6px; font-size: 13px; color: #ffd98a; }

/* round 8: on a phone the long tile labels ("NDM forms outstanding") wrap instead of clipping */
@media (max-width: 760px) {
  .tile { min-width: 0; }
  .tile-label { font-size: 11.5px; letter-spacing: 0.02em; white-space: normal; overflow-wrap: anywhere; line-height: 1.2; }
}
