/* Dispatch Assistant — phone first, read in a truck, in sunlight, in a hurry.
 *
 * Two rules drive the palette:
 *   - State is never carried by colour alone. Every coloured state also has a
 *     word. Colour through a windscreen at 0500 is not reliable.
 *   - Nothing neutral. There is no styling that says "fine" by omission; a
 *     panel with no data still renders a state (prime directive 4).
 */

:root {
  --bg: #11141a;
  --bg-raised: #191e27;
  --bg-sunk: #0c0f14;
  --line: #2b3340;
  --text: #e8edf4;
  --text-dim: #97a3b4;
  --text-faint: #6b7686;

  --ok: #3fb27f;
  --failed: #ff5b5b;
  --stale: #f0b429;
  --empty: #7d8ca3;
  --pending: #5f6b7d;
  --strong: #ff5b5b;
  --caution: #f0b429;
  --notice: #6fa8dc;
  --confirmation: #3fb27f;

  --tap: 3rem;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* `hidden` must actually hide.
 *
 * The browser's own [hidden] rule is `display: none`, at the very bottom of the
 * cascade, so any class that sets `display` silently defeats it. That is what
 * put a spinner reading "Reading the form…" on the capture screen before a photo
 * existed: the markup said `hidden`, but `.capture__working` said `display:flex`
 * and won. The stalled box next to it has no `display` rule and was therefore
 * immune, which is why the bug looked like it could not be there.
 *
 * A spinner that is showing when nothing is happening is prime directive 4
 * upside down — working must not look like working when it isn't. !important
 * because the whole point is to outrank whatever a class does. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 ui-sans-serif, -apple-system, "SF Pro Text", system-ui, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

code, pre { font-family: ui-monospace, "SF Mono", Menlo, monospace; }

main { max-width: 46rem; margin: 0 auto; padding: 1rem 1rem 3rem; }

h1 { font-size: 1.35rem; margin: 0 0 .25rem; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; }

/* ---- chrome ------------------------------------------------------------ */

.topbar {
  display: flex; flex-direction: column; gap: .1rem;
  padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem;
  background: var(--bg-sunk);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--text); font-weight: 600; text-decoration: none; letter-spacing: .02em; }
/* Prime directive 5: every screen states its own scope. */
.scopeline { color: var(--text-faint); font-size: .72rem; }

.footer {
  display: flex; justify-content: space-between; gap: 1rem;
  max-width: 46rem; margin: 0 auto; padding: 1rem;
  color: var(--text-faint); font-size: .72rem;
  border-top: 1px solid var(--line);
}
.footer a { color: var(--text-faint); }

.note { color: var(--text-dim); font-size: .82rem; }
.muted { color: var(--text-faint); }

/* ---- buttons ----------------------------------------------------------- */

.bigbutton {
  display: flex; align-items: center; justify-content: center;
  min-height: var(--tap); width: 100%;
  padding: .75rem 1rem; margin: .5rem 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-raised); color: var(--text);
  font-size: 1rem; font-weight: 600; text-decoration: none;
  cursor: pointer;
}
.bigbutton input[type=file] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.bigbutton:disabled { opacity: .4; }
.bigbutton--go { background: #16624a; border-color: #1e8a68; }
.bigbutton--select { background: #1d3f66; border-color: #2d629d; }
.bigbutton--override { background: #6a3a12; border-color: #a2591d; }

.linkbutton {
  background: none; border: none; color: var(--text-dim);
  text-decoration: underline; font-size: .9rem; padding: .75rem 0; cursor: pointer;
}
.cancel { display: inline-block; padding: .75rem 1rem; color: var(--text-dim); }

/* ---- capture ----------------------------------------------------------- */

.login { max-width: 22rem; }
.login__form { margin-top: 1rem; }
.login__label { display: block; font-size: .82rem; color: var(--text-dim); margin-bottom: .25rem; }
.login__input {
  width: 100%; min-height: var(--tap); padding: .6rem .75rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-sunk); color: var(--text); font-size: 1rem;
}
.login__input:focus { outline: 2px solid var(--notice); outline-offset: 1px; }

.modebanner {
  padding: .7rem .8rem; margin: 0 0 1rem;
  border: 1px solid var(--stale); border-left-width: 4px;
  border-radius: var(--radius); background: #23200f; font-size: .85rem;
}
.modebanner code { font-size: .8rem; }

.capture__working {
  display: flex; align-items: center; gap: .6rem;
  min-height: var(--tap); padding: .75rem 1rem; margin: .5rem 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-raised); font-weight: 600;
}
.spinner {
  width: 1.1rem; height: 1.1rem; flex: none;
  border: 2px solid var(--line); border-top-color: var(--notice);
  border-radius: 50%; animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.capture__stalled {
  padding: .8rem .9rem; margin: .5rem 0;
  border: 1px solid var(--failed); border-left-width: 4px;
  border-radius: var(--radius); background: #241618;
}
.capture__stalled p { margin: 0 0 .35rem; }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

.recent__list { list-style: none; padding: 0; margin: 0; }
.recent__list a {
  display: flex; justify-content: space-between; gap: 1rem; align-items: center;
  min-height: var(--tap); padding: .6rem .75rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: .4rem; color: var(--text); text-decoration: none;
  background: var(--bg-raised);
}
.recent__status { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); }
.status--confirmed { color: var(--confirmation); }
.status--extraction_failed { color: var(--failed); }
.status--awaiting_confirmation { color: var(--stale); }

/* ---- panels (§7) ------------------------------------------------------- */

.panel {
  border: 1px solid var(--line); border-left: 4px solid var(--line);
  border-radius: var(--radius); background: var(--bg-raised);
  padding: .8rem .9rem; margin: 1rem 0;
}
.panel--ok      { border-left-color: var(--ok); }
.panel--failed  { border-left-color: var(--failed); background: #241618; }
.panel--stale   { border-left-color: var(--stale); background: #23200f; }
.panel--empty   { border-left-color: var(--empty); }
.panel--pending { border-left-color: var(--pending); background: var(--bg-sunk); }

.panel__title { font-size: .98rem; margin: 0; }
/* §7: line two is always visible, never a tooltip. */
.panel__scope { color: var(--text-dim); font-size: .78rem; margin: .2rem 0 0; }
.panel__prov  { color: var(--text-faint); font-size: .72rem; margin: .15rem 0 0; }
.panel__state { margin: .6rem 0 0; }
.panel__action { margin: .35rem 0 0; font-size: .85rem; }
.panel--failed .panel__action { color: #ffc9c9; }
.panel__summary { margin: .5rem 0 0; }
.panel__body { margin-top: .75rem; }

.badge {
  display: inline-block; padding: .1rem .45rem; border-radius: 4px;
  font-size: .68rem; font-weight: 700; letter-spacing: .08em;
}
.badge--failed  { background: var(--failed); color: #2a0000; }
.badge--stale   { background: var(--stale); color: #2a1e00; }
.badge--empty   { background: var(--empty); color: #10151c; }
.badge--pending { background: var(--pending); color: #10151c; }

.devpanels__row {
  display: grid; gap: .5rem; margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--line); padding-bottom: 1rem;
}

/* ---- confirm gate (§5) ------------------------------------------------- */

.gate__lede { color: var(--text-dim); margin: 0 0 1rem; }

.crop { margin: 0 0 1.25rem; }
.crop img { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; }
.crop__caption { color: var(--text-faint); font-size: .75rem; margin: .3rem 0 0; }
.crop__missing {
  padding: .75rem; border: 1px dashed var(--stale); border-radius: var(--radius);
  color: #ffe6b0; font-size: .88rem;
}
.crop__full summary { color: var(--text-dim); font-size: .82rem; padding: .5rem 0; cursor: pointer; }

.forced {
  border: 1px solid var(--notice); border-radius: var(--radius);
  background: #10202e; padding: .7rem .8rem; font-size: .88rem; margin-bottom: 1rem;
}

.cand {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-raised); padding: .85rem; margin: 0 0 1rem;
}
.cand--transposition { border-style: dashed; }
.cand--blocked { opacity: .72; background: #1b1416; border-color: #4a2429; }
.cand--acknowledging { border-color: var(--caution); box-shadow: 0 0 0 1px var(--caution) inset; }

.cand__dd { font-family: ui-monospace, Menlo, monospace; font-size: 1.22rem; font-weight: 600; }
.cand__dms { font-family: ui-monospace, Menlo, monospace; font-size: .85rem; color: var(--text-dim); }
.cand__how { font-size: .76rem; color: var(--text-faint); margin-top: .25rem; }

.tag {
  display: inline-block; margin-left: .35rem; padding: .05rem .35rem;
  border: 1px solid var(--line); border-radius: 4px; font-size: .68rem;
}
.tag--warn { border-color: var(--caution); color: var(--caution); }

.cand__derivation, .cand__context {
  display: grid; grid-template-columns: 5.5rem 1fr; gap: .15rem .6rem;
  margin: .7rem 0 0; font-size: .8rem;
}
.cand__derivation dt, .cand__context dt { color: var(--text-faint); }
.cand__derivation dd, .cand__context dd { margin: 0; color: var(--text-dim); }
.cand__derivation code { color: var(--text); }

.flag {
  margin: .5rem 0 0; padding: .5rem .6rem; font-size: .84rem;
  border-left: 3px solid var(--line); border-radius: 0 6px 6px 0; background: var(--bg-sunk);
}
.flag--confirmation { border-left-color: var(--confirmation); }
.flag--notice       { border-left-color: var(--notice); }
.flag--caution      { border-left-color: var(--caution); }
.flag--strong       { border-left-color: var(--strong); }
.flag--hard         { border-left-color: var(--failed); background: #2a1315; }

.cand__blocked-note { font-size: .8rem; color: #ffb4b4; margin: .5rem 0 0; }
.cand__ack { margin-top: .75rem; border-top: 1px solid var(--caution); padding-top: .6rem; }
.cand__ack-text { font-size: .86rem; margin: 0 0 .3rem; }
.cand__ack-list { margin: 0 0 .5rem; padding-left: 1.2rem; font-size: .84rem; color: var(--caution); }

.hardfail {
  border: 1px solid var(--failed); background: #241618; border-radius: var(--radius);
  padding: .8rem; margin-bottom: 1rem;
}

.review { margin: 1rem 0; }
.review summary { color: var(--text-dim); font-size: .85rem; padding: .6rem 0; cursor: pointer; }
.review__note { font-size: .8rem; color: var(--text-faint); }
.review ul { font-size: .82rem; color: var(--text-dim); padding-left: 1.1rem; }
.review pre {
  white-space: pre-wrap; word-break: break-word; font-size: .74rem;
  background: var(--bg-sunk); padding: .6rem; border-radius: 6px; color: var(--text-dim);
}

.reject { margin-top: 1.5rem; text-align: center; }

/* ---- brief / handoff (§6) ---------------------------------------------- */

.brief__lede { color: var(--text-dim); margin: 0 0 1rem; font-size: .88rem; }
.brief__section { margin-top: 2rem; }
.brief__back { margin-top: 2rem; text-align: center; }
.brief__back a { color: var(--text-dim); }

.interstitial {
  border: 1px solid var(--caution); background: #23200f;
  border-radius: var(--radius); padding: .9rem; margin-bottom: 1.25rem;
}
.interstitial h2 { margin-top: 0; }
.interstitial__path {
  font-family: ui-monospace, Menlo, monospace; font-size: .88rem;
  background: var(--bg-sunk); padding: .5rem .6rem; border-radius: 6px;
}

.formatpick { display: grid; gap: .4rem; }
.formatpick .bigbutton { flex-direction: column; gap: .15rem; padding: .7rem 1rem; }
.formatpick__label { font-family: ui-monospace, Menlo, monospace; font-size: 1.05rem; }
.formatpick__desc { font-size: .75rem; font-weight: 400; color: var(--text-dim); }
.handoff__format { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; }
.handoff__format .linkbutton { padding: 0; font-size: .78rem; }
.handoff__format--ask {
  display: block; margin-top: .6rem; padding: .6rem .7rem;
  border: 1px solid var(--caution); border-radius: var(--radius); background: #23200f;
}
.formatpick--inline { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; }
.formatpick--inline .bigbutton { margin: 0; padding: .5rem .3rem; min-height: 2.6rem; }
.formatpick--inline .formatpick__label { font-size: .84rem; }

.handoff__row { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; }
.handoff__label { color: var(--text-faint); font-size: .78rem; }
.handoff__value { font-family: ui-monospace, Menlo, monospace; font-size: .88rem; }
.handoff__value--big { font-size: 1.05rem; font-weight: 600; }
.handoff__readback {
  margin: .75rem 0; padding: .7rem;
  border: 1px solid var(--notice); border-radius: var(--radius); background: #10202e;
}
.handoff__note { font-size: .78rem; color: var(--text-dim); margin: .35rem 0 0; }
.handoff__gated { font-size: .85rem; color: var(--caution); }
.handoff__url summary { color: var(--text-dim); font-size: .8rem; padding: .5rem 0; cursor: pointer; }
.handoff__url code { font-size: .72rem; word-break: break-all; color: var(--text-dim); }
.handoff__csv { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .75rem; }

@media (min-width: 40rem) {
  .devpanels__row { grid-template-columns: repeat(2, 1fr); }
}

/* Present position (BACKLOG 4). A compact row, not a §7 panel: it is device
 * context rather than a check that ran, and giving it panel chrome would imply
 * a provenance and a scope line it does not have. */
.fromhere {
  display: flex; flex-direction: column; gap: .15rem;
  padding: .6rem .75rem; margin: .5rem 0;
  border: 1px solid var(--line); border-left-width: 4px;
  border-radius: var(--radius); background: var(--bg-raised);
}
.fromhere--ok { border-left-color: var(--notice); }
/* Absent is styled as absent, not as neutral. Prime directive 4: there is no
 * appearance in this app that means "fine" by omission. */
.fromhere--absent { border-left-color: var(--empty); }
.fromhere__label {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint);
}
.fromhere__value { font-size: 1.15rem; }
.fromhere--absent .fromhere__value { font-size: 1rem; color: var(--text-dim); }
.fromhere__meta { font-size: .75rem; color: var(--text-faint); }
.fromhere__caveat { margin: .4rem 0 0; }
.fromhere__scope { margin: .3rem 0 0; font-size: .72rem; color: var(--text-faint); }
.fromhere .linkbutton { align-self: flex-start; margin-top: .2rem; }

/* Tanker bases. The marker letter repeats what the source overlay puts on the
 * map pin, so the two read the same — and the letter carries the category, not
 * the colour, because colour alone fails in sunlight (see the palette note). */
.bases__aircraft { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.bases__aircraft form { display: contents; }
.bases__ask { font-size: .78rem; color: var(--text-faint); margin-right: .1rem; }
.bases__count { margin: .45rem 0 .6rem; font-size: .74rem; color: var(--text-dim); }
.chip {
  padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 999px;
  background: none; color: var(--text-dim); text-decoration: none;
  font-size: .78rem; font-weight: 600; cursor: pointer;
}
.chip--on { background: var(--bg-sunk); color: var(--text); border-color: var(--notice); }

.bases__list { list-style: none; margin: 0; padding: 0; }
.baserow {
  display: flex; align-items: center; gap: .6rem;
  padding: .45rem 0; border-bottom: 1px solid var(--line);
}
.baserow:last-child { border-bottom: none; }
.baserow__marker {
  flex: none; width: 1.4rem; height: 1.4rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; color: #0c0f14;
}
.baserow__marker--vlat { background: #ff5b5b; }
.baserow__marker--lat  { background: #7bbf7b; }
.baserow__marker--seat { background: #5b9bd5; }
.baserow__ident { font-family: ui-monospace, Menlo, monospace; font-size: 1rem; font-weight: 600; }
.baserow__offset { margin-left: auto; color: var(--text-dim); font-size: .85rem; }
.bases__scope { margin: .6rem 0 0; font-size: .72rem; color: var(--text-faint); }

/* Aircraft declaration on the capture screen. Below the shutter, quiet, and
 * never between the operator and the photo. */
.flying { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin-top: 1.25rem; }
.flying form { display: contents; }
.flying__label {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); margin-right: .15rem;
}
.flying__clear { border-style: dashed; }
.flying__note { margin: .4rem 0 0; font-size: .75rem; }

/* §8.2 weather indicators on the base rows. Category is carried by the word as
 * well as the colour — the palette rule, and doubly so here, where the four
 * categories are exactly the kind of thing a colour-only scheme renders
 * unreadable through a windscreen. */
.baserow { flex-direction: column; align-items: stretch; gap: .25rem; }
.baserow__head { display: flex; align-items: center; gap: .6rem; }
.wx { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; padding-left: 2rem; }
.wx__cat {
  font-size: .7rem; font-weight: 700; letter-spacing: .04em;
  padding: .1rem .4rem; border-radius: 4px; background: var(--bg-sunk);
}
.wx__cat--vfr  { color: #3fb27f; }
.wx__cat--mvfr { color: #6fa8dc; }
.wx__cat--ifr  { color: #f0b429; }
.wx__cat--lifr { color: #ff5b5b; }
/* Absence is styled as absence, never as neutral or as fine. */
.wx__cat--none { color: var(--text-faint); font-weight: 600; font-style: italic; }
.wx__detail, .wx__outlook { font-size: .72rem; color: var(--text-faint); }
.wx__short { color: var(--stale); }
.wx__wind {
  font-size: .72rem; font-weight: 700; color: #2a1e00;
  background: var(--stale); padding: .1rem .4rem; border-radius: 4px;
}
