:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c2230;
  --line: #2a3240;
  --line-soft: #222a36;
  --ink: #e6edf3;
  --ink-dim: #9aa7b4;
  --ink-faint: #66707c;
  --accent: #3b82f6;
  --scheduled: #6b7280;
  --briefed: #d97706;
  --airborne: #10b981;
  --landed: #2563eb;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---- top bar ---- */
.topbar {
  display: grid; grid-template-columns: 1fr minmax(0, auto) 1fr; align-items: center;
  gap: 20px; padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-right { justify-self: end; }
.metarWrap {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 12px; max-width: 100%;
}
.metarCat {
  font-family: var(--mono); font-weight: 700; font-size: 15px;
  letter-spacing: 1px; padding: 4px 10px; border-radius: 6px;
  background: #2a3240; color: var(--ink-dim); flex: 0 0 auto;
}
.metarCat.cat-vfr  { background: #052e1a; color: #4ade80; }
.metarCat.cat-mvfr { background: #0b2a56; color: #60a5fa; }
.metarCat.cat-ifr  { background: #3f1010; color: #f87171; }
.metarCat.cat-lifr { background: #3a1042; color: #d8b4fe; }
.metarRaw {
  font-family: var(--mono); font-size: 12px; letter-spacing: .3px; line-height: 1.35;
  color: var(--ink); min-width: 0; max-width: 460px;
  white-space: normal; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.metarRaw.cat-vfr  { color: #4ade80; }
.metarRaw.cat-mvfr { color: #60a5fa; }
.metarRaw.cat-ifr  { color: #f87171; }
.metarRaw.cat-lifr { color: #d8b4fe; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand .crest {
  width: 34px; height: 34px; border-radius: 6px;
  background: #0f5132; color: #a7f3d0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.brand h1 { font-size: 15px; margin: 0; letter-spacing: 1px; font-weight: 600; }
.brand .sub { font-family: var(--mono); font-size: 11px; color: var(--ink-dim); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.clock { font-family: var(--mono); font-size: 15px; color: var(--airborne); letter-spacing: 1px; }
.adsb {
  display: inline-flex; align-items: center; gap: 7px; font-family: var(--mono);
  font-size: 11px; color: var(--ink-dim); padding: 5px 12px; height: 28px;
  border: 1px solid var(--line); border-radius: 999px;
  white-space: nowrap; flex: 0 0 auto;
}
.topbar-right { flex-wrap: nowrap; }
.adsb-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); }
.adsb.live .adsb-dot { background: var(--airborne); box-shadow: 0 0 0 3px rgba(16,185,129,.2); }
.adsb.polling .adsb-dot { background: var(--briefed); }
.adsb.err .adsb-dot { background: #ef4444; }

.live-tag {
  font-family: var(--mono); font-size: 17px; font-weight: 600; letter-spacing: .5px;
  color: var(--airborne); display: inline-flex; align-items: center; gap: 6px;
}
.live-tag .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--airborne); }
.times .actual { color: var(--airborne); }
.times .elapsed { color: var(--airborne); font-weight: 600; letter-spacing: .5px; }
.times .total { color: #93c5fd; font-weight: 600; }
.times .local { color: #f59e0b; }
.clock .loc { color: #f59e0b; }
.stepbtn {
  width: 42px; height: 40px; padding: 0; font-size: 24px; line-height: 1;
  background: var(--panel-2); color: var(--ink); border: 1px solid #3a4657;
  display: inline-flex; align-items: center; justify-content: center;
}
.stepbtn:first-child { border-radius: 6px 0 0 6px; }
.stepbtn:last-child { border-radius: 0 6px 6px 0; }
.stepbtn:hover { background: #2a3446; border-color: #4a5a70; }
#returnRadius::-webkit-outer-spin-button,
#returnRadius::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#returnRadius { -moz-appearance: textfield; }

/* ---- buttons ---- */
button {
  font-family: inherit; cursor: pointer; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  padding: 7px 13px; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, border-color .12s, transform .05s;
}
button:hover { background: #232b3a; border-color: #3a4657; }
button:active { transform: scale(.98); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #2f6fd6; }
button.ghost { background: transparent; }
button:disabled { opacity: .45; cursor: default; }
button svg { width: 15px; height: 15px; }

/* ---- board ---- */
.board { padding: 16px 20px 60px; max-width: none; }
.wx-panels {
  width: 100%; height: 130px; border: 0; margin-bottom: 12px;
  background: transparent; display: block;
}
.board-head {
  display: grid; grid-template-columns: 170px 1.6fr 260px 150px 150px;
  gap: 12px; padding: 6px 12px 6px 17px; font-family: var(--mono);
  font-size: 10.5px; letter-spacing: 1px; color: var(--ink-faint);
}
.board-head .r { text-align: left; }

.strip {
  display: grid; grid-template-columns: 170px 1.6fr 260px 150px 150px;
  gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line-soft);
  border-left-width: 5px; border-radius: 8px;
  padding: 8px 12px; margin-bottom: 8px;
}
/* uniform strip cells — every column is a fixed-height rounded chip */
.callsign, .times, .pill, .crew {
  height: 52px; box-sizing: border-box; border-radius: 8px;
  display: flex; align-items: center; font-family: var(--mono);
}
.callsign, .times {
  justify-content: center; background: #0c2a20; border: 1px solid #1f6f52;
  color: #4ade80; padding: 4px 12px; letter-spacing: .5px;
}
.strip.s-scheduled { border-left-color: var(--scheduled); }
.strip.s-briefed   { border-left-color: var(--briefed); }
.strip.s-airborne  { border-left-color: var(--airborne); }
.strip.s-landed    { border-left-color: var(--landed); background: #131c2e; }

.callsign { font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.times { font-size: 12px; line-height: 1.2; flex-direction: column; justify-content: center; gap: 2px; white-space: nowrap; align-items: stretch; }
.times-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.times-lbl { color: #6b8f7d; font-size: 10.5px; letter-spacing: .5px; text-transform: uppercase; }
.times-val { color: #4ade80; font-size: 13px; text-align: right; }
.crew { flex-direction: column; justify-content: center; align-items: flex-start; gap: 4px; padding: 0 4px; line-height: 1.2; }
.crew .n {
  font-size: 13px; font-family: var(--mono); color: #fbbf24;
  background: #2a1a04; border: 1px solid #7c5410;
  padding: 3px 10px; border-radius: 6px; letter-spacing: .3px;
  display: inline-block;
}
.crew .m { font-size: 12px; color: var(--ink-dim); }

.pill {
  width: 100%; justify-content: center; font-size: 13px; letter-spacing: .5px;
  gap: 6px; border: 1px solid transparent;
}
.pill.scheduled { background: #2a2f38; color: #cbd5e1; }
.pill.briefed   { background: #3a2a10; color: #fbbf24; }
.pill.airborne  { background: #0d2f24; color: #34d399; }
.pill.landed    { background: #10233f; color: #93c5fd; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.strip .actions { display: flex; justify-content: flex-start; align-items: center; gap: 6px; }
.strip .actions button { height: 40px; }
.strip .actions .del { width: 40px; padding: 0; color: var(--ink-faint); border-color: var(--line-soft); background: transparent; }
.strip .actions .del:hover { color: #fff; background: #7f1d1d; border-color: #991b1b; }
.strip .actions .del svg { width: 14px; height: 14px; }

.empty {
  text-align: center; color: var(--ink-faint); padding: 60px 20px;
  font-size: 14px; border: 1px dashed var(--line); border-radius: 10px;
}

/* ---- modal ---- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; z-index: 40; overflow-y: auto;
}
.overlay.hidden { display: none; }
.modal {
  width: 100%; max-width: 720px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.modal-body { padding: 16px 18px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.modal-foot {
  padding: 12px 18px; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field.wide { grid-column: 1 / -1; }
.field label { font-family: var(--mono); font-size: 10.5px; letter-spacing: .5px; color: var(--ink-dim); }
.field input, .field select, .field textarea {
  font-family: inherit; font-size: 14px; color: var(--ink);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 10px; height: 38px; width: 100%;
}
.field textarea { height: auto; min-height: 58px; resize: vertical; }
.field select, .field input[type="time"], .field input[type="date"] { font-family: var(--mono); }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59,130,246,.25);
}
.field.accent input, .field.accent select, .field.accent textarea { border-color: #2b4a7a; }
.hint { font-size: 11px; color: var(--ink-faint); }
#rosterText::placeholder { color: rgba(230, 237, 243, 0.15); }

/* ---- brief sheet overlay ---- */
.brief-overlay { position: fixed; inset: 0; background: #3a4150; z-index: 60; display: flex; flex-direction: column; }
.brief-overlay.hidden { display: none; }
.brief-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.bt-title { font-size: 14px; font-weight: 600; }
.brief-scroll { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; align-items: center; }

.brief-sheet {
  width: 8.5in; min-height: 11in; background: #fff; color: #000;
  padding: 0.4in 0.5in; margin-bottom: 24px; box-shadow: 0 4px 20px rgba(0,0,0,.4);
  font-family: Arial, Helvetica, sans-serif; font-size: 9.2px; line-height: 1.28;
}
.bs-head { display: grid; grid-template-columns: 46px 1fr; align-items: center; column-gap: 10px; margin-bottom: 6px; }
.bs-crest { grid-row: span 2; }
.bs-title { font-size: 14px; font-weight: 700; text-align: center; letter-spacing: .5px; }
.bs-note-red { grid-column: 2; color: #c00; font-size: 8px; text-align: center; }
.bs-row.bs-hdr { display: flex; gap: 18px; flex-wrap: wrap; border-top: 1px solid #000; border-bottom: 1px solid #000; padding: 3px 0; margin-bottom: 4px; }
.bs-item { margin-bottom: 3px; }
.bs-sub { margin-left: 16px; }
.bs-fill { color: #000; }
.bv { color: #c00; font-weight: 700; }
.bp { color: #0033cc; font-style: italic; }
.bs-blue { color: #0033cc; font-weight: 700; }
.bs-hl { background: #fff59d; display: inline-block; padding: 0 2px; }
.bs-sign { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 10px; padding-top: 8px; }
.bs-line { display: inline-block; width: 200px; border-bottom: 1px solid #000; height: 12px; }
.bs-line.wide { width: 80%; } .bs-line.short { width: 90px; }
.bs-officer { color: #c00; font-weight: 700; text-align: right; }
.bs-officer small { color: #000; font-weight: 400; }
.bs-foot { display: flex; justify-content: space-between; border-top: 1px solid #000; margin-top: 8px; padding-top: 3px; font-size: 8px; color: #333; }

.brief-sheet.rw .rw-contract { text-align: center; font-size: 9px; margin-bottom: 6px; }
.rw-hdr { display: flex; flex-wrap: wrap; gap: 14px; border-top: 1px solid #000; border-bottom: 1px solid #000; padding: 3px 0; margin-bottom: 6px; }
.rw-group { background: #d9d9d9; font-weight: 700; padding: 2px 4px; margin: 5px 0 3px; }
.rw-q { margin: 2px 0 2px 4px; }
.rw-n { font-weight: 700; }
.rw-ans { color: #444; margin-left: 6px; white-space: nowrap; }
.rw-final { margin: 4px 0; }
.rw-pick { border: 1px solid #000; padding: 1px 8px; margin: 0 3px; }
.rw-pick.on { background: #fff59d; font-weight: 700; }
.rw-note, .rw-remarks { font-size: 8.4px; margin: 6px 0; }
.rw-sign { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }

@media print {
  body * { visibility: hidden; }
  .brief-overlay, .brief-overlay * { visibility: visible; }
  .brief-overlay { position: static; background: #fff; }
  .brief-toolbar { display: none; }
  .brief-scroll { overflow: visible; padding: 0; }
  .brief-sheet { box-shadow: none; margin: 0; padding: 0.3in 0.4in; page-break-after: always; width: auto; min-height: auto; }
  @page { size: letter portrait; margin: 0.3in; }
}
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 10px 4px 0; font-family: var(--mono); font-size: 11px; color: var(--ink-dim); }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
