/* Parcel Command Center — executive monitor
   ────────────────────────────────────────────────────────────────
   The identity comes straight from the logo, which is exactly two colours,
   sampled from parcelLogo.png rather than guessed:

     navy   #09273D   the wordmark    — structure, body text, primary actions
     amber  #FED12C   the parcel box  — the single highlight

   Light mode makes navy the accent, because amber on white is unreadable.
   Dark mode inverts it: the ground becomes the navy family and amber becomes
   the accent — which is the logo's own pairing.

   Semantic colours are kept deliberately clear of brand amber: warning is a
   desaturated orange-brown, so a status pill can never read as a brand mark.
   ──────────────────────────────────────────────────────────────── */

:root {
  --brand-navy: #09273D;
  --brand-amber: #FED12C;

  --paper: #EFF2F6;
  --card: #FFFFFF;
  --sunk: #F4F7FA;
  --ink: #09273D;
  --muted: #55677A;
  --faint: #8695A5;
  --line: #DCE3EA;
  --line-strong: #BFCAD6;
  --accent: #09273D;
  --accent-soft: #E2EAF2;
  --on-accent: #FFFFFF;

  --good: #12694A;
  --good-bg: #DFEFE7;
  --warn: #8A5510;
  --warn-bg: #F7EAD6;
  --bad: #A62A20;
  --bad-bg: #F8E4E1;

  --shadow: 0 1px 2px rgba(9, 39, 61, .06), 0 1px 3px rgba(9, 39, 61, .07);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #061722;
    --card: #0B2436;
    --sunk: #102C40;
    --ink: #E3EBF3;
    --muted: #90A4B6;
    --faint: #5E7186;
    --line: #163348;
    --line-strong: #24455A;
    --accent: #FED12C;
    --accent-soft: #16324A;
    --on-accent: #09273D;

    --good: #4FBE8C;
    --good-bg: #0E3122;
    --warn: #D89A5C;
    --warn-bg: #33220F;
    --bad: #EF7E74;
    --bad-bg: #37191A;

    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .3);
  }
}

:root[data-theme="dark"] {
  --paper: #061722;
  --card: #0B2436;
  --sunk: #102C40;
  --ink: #E3EBF3;
  --muted: #90A4B6;
  --faint: #5E7186;
  --line: #163348;
  --line-strong: #24455A;
  --accent: #FED12C;
  --accent-soft: #16324A;
  --on-accent: #09273D;
  --good: #4FBE8C;
  --good-bg: #0E3122;
  --warn: #D89A5C;
  --warn-bg: #33220F;
  --bad: #EF7E74;
  --bad-bg: #37191A;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }

/* Author rules like `.backdrop { display: flex }` outrank the browser's own
   `[hidden] { display: none }`, so anything hidden via the attribute stayed on
   screen — the Settings dialog could not be closed. This puts the attribute
   back in charge, for every element. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

.mono, .num {
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

/* ── top bar ─────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 13px 24px;
  background: var(--card);
  /* The amber hairline is the logo's second colour, used once, at the top. */
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 3px 0 var(--brand-amber);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }

/* The wordmark ships in two versions: the original navy artwork, and a pale
   recolour for dark grounds with the amber box left intact. */
.logo { height: 26px; width: auto; display: block; flex: none; }
.logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: block; }
}
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }

.brand-rule { width: 1px; align-self: stretch; background: var(--line); flex: none; }

.topbar h1 { font-size: 15.5px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.sub { margin: 0; font-size: 12px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.meta { font-family: "IBM Plex Mono", monospace; font-size: 11.5px; color: var(--faint); }
/* Brand amber on brand navy — the logo's own pairing, used for the one
   notice that should be impossible to miss. */
.badge {
  font-family: "IBM Plex Mono", monospace; font-size: 10.5px; font-weight: 600;
  letter-spacing: .08em; padding: 3px 10px; border-radius: 20px;
  background: var(--brand-amber); color: var(--brand-navy); border: none;
}
.btn {
  font-family: inherit; font-size: 13px;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 7px;
  padding: 6px 14px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: .55; cursor: default; }

/* ── layout ──────────────────────────────────────────────── */
.page { max-width: 1240px; margin: 0 auto; padding: 26px 24px 60px; }
.block { margin-bottom: 34px; }
.block-head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.block-head h2 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: .01em; }
.hint { font-size: 12.5px; color: var(--faint); }
.skeleton { color: var(--faint); font-size: 13px; padding: 20px 0; }

/* ── alerts ──────────────────────────────────────────────── */
.alerts { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.alert {
  background: var(--card); border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: 9px; padding: 14px 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
  cursor: pointer; text-align: left; font: inherit; color: inherit;
}
.alert:hover { border-color: var(--line-strong); }
.alert:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.alert.critical { border-left-color: var(--bad); }
.alert.warning { border-left-color: var(--warn); }
.alert.info { border-left-color: var(--accent); }
.alert-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sev {
  font-family: "IBM Plex Mono", monospace; font-size: 9.5px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 20px;
}
.sev.critical { background: var(--bad-bg); color: var(--bad); }
.sev.warning { background: var(--warn-bg); color: var(--warn); }
.sev.info { background: var(--accent-soft); color: var(--accent); }
.alert-val {
  font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums;
  font-size: 15px; font-weight: 600;
}
.alert.critical .alert-val { color: var(--bad); }
.alert.warning .alert-val { color: var(--warn); }
.alert h3 { font-size: 14px; margin: 0; font-weight: 600; }
.alert p { margin: 0; font-size: 12.5px; color: var(--muted); }
.alert .do {
  font-size: 12.5px; color: var(--accent); font-weight: 500;
  border-top: 1px solid var(--line); padding-top: 7px; margin-top: 2px;
}
.all-clear {
  background: var(--good-bg); border: 1px solid var(--good);
  color: var(--good); border-radius: 9px; padding: 16px 18px;
  font-size: 13.5px; grid-column: 1 / -1;
}

/* ── kpis ────────────────────────────────────────────────── */
.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden; box-shadow: var(--shadow);
}
.kpi { padding: 15px 18px; border-left: 1px solid var(--line); }
.kpi:first-child { border-left: none; }
.kpi small { display: block; font-size: 11.5px; color: var(--muted); }
.kpi b {
  display: block; margin-top: 3px;
  font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums;
  font-size: 21px; font-weight: 600;
}
.kpi.pos b { color: var(--good); }
.kpi.neg b { color: var(--bad); }
.kpi.accent b { color: var(--accent); }
.note { font-size: 12.5px; color: var(--muted); margin: 10px 2px 0; max-width: 74ch; }

/* ── tabs ────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 2px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); margin-bottom: 16px;
}
.tab {
  font: inherit; font-size: 13px;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 8px 14px; cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.panel-intro { font-size: 13px; color: var(--muted); margin: 0 0 12px; max-width: 78ch; }

.filters { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  font: inherit; font-size: 12.5px;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 6px;
  padding: 4px 12px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── tables ──────────────────────────────────────────────── */
.tablewrap {
  overflow-x: auto;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow);
}
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
table.grid th {
  text-align: left; padding: 10px 14px; white-space: nowrap;
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); background: var(--sunk);
  border-bottom: 1px solid var(--line-strong);
  position: sticky; top: 0;
}
table.grid th.n, table.grid td.n { text-align: right; }
table.grid th.sortable { user-select: none; padding: 0; }
/* The label is a real <button> for keyboard focus; keep it visually a header. */
table.grid th.sortable .th-sort {
  font: inherit; color: inherit; background: none; border: none;
  cursor: pointer; padding: 10px 14px; width: 100%; text-align: inherit;
  text-transform: inherit; letter-spacing: inherit;
}
table.grid th.n.sortable .th-sort { text-align: right; }
table.grid th.sortable .th-sort:hover { color: var(--accent); }
table.grid th.sortable .th-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
table.grid th.sortable .th-sort::after { content: " ⇅"; opacity: .3; font-size: 9px; }
table.grid th[data-dir="asc"] .th-sort::after { content: " ↑"; opacity: 1; color: var(--accent); }
table.grid th[data-dir="desc"] .th-sort::after { content: " ↓"; opacity: 1; color: var(--accent); }
table.grid td { padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover { background: var(--sunk); }
table.grid td.n { font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; }
.name { font-weight: 600; }
.sub-line { display: block; font-size: 11px; color: var(--faint); font-family: "IBM Plex Mono", monospace; }
.pos { color: var(--good); font-weight: 600; }
.neg { color: var(--bad); font-weight: 600; }
.pill {
  display: inline-block; font-size: 10.5px; padding: 1px 8px; border-radius: 4px;
  background: var(--warn-bg); color: var(--warn); white-space: nowrap;
}
.pill.age { background: var(--bad-bg); color: var(--bad); }
.pill.ok { background: var(--good-bg); color: var(--good); }
.empty { padding: 26px 16px; text-align: center; color: var(--faint); font-size: 13px; }

.bar { position: relative; height: 6px; border-radius: 3px; background: var(--line); min-width: 60px; }
.bar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.bar i.pos { background: var(--good); left: 50%; }
.bar i.neg { background: var(--bad); right: 50%; }
.bar::before { content: ""; position: absolute; top: -2px; bottom: -2px; left: 50%; width: 1px; background: var(--line-strong); }

/* ── notes ───────────────────────────────────────────────── */
.notes { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.notes li {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 11px 15px; font-size: 12.5px; color: var(--muted);
}

.foot {
  border-top: 1px solid var(--line); padding: 16px 24px;
  font-size: 12px; color: var(--faint); text-align: center;
}

/* ── settings dialog ─────────────────────────────────────── */
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); color: var(--on-accent); }

.backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(9, 13, 20, .55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto;
}
.modal {
  background: var(--card); border: 1px solid var(--line-strong);
  border-radius: 12px; width: 100%; max-width: 720px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .28);
  display: flex; flex-direction: column; max-height: calc(100vh - 80px);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 16px; margin: 0; font-weight: 700; }
.icon-btn {
  font: inherit; font-size: 15px; line-height: 1;
  background: none; border: 1px solid transparent; border-radius: 6px;
  color: var(--muted); padding: 5px 9px; cursor: pointer;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.modal-tabs { padding: 0 22px; margin-bottom: 0; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 22px; border-top: 1px solid var(--line);
  background: var(--sunk); border-radius: 0 0 12px 12px;
}
.grow { flex: 1; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; flex: 1; min-width: 0; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.field input {
  font: inherit; font-size: 13px;
  font-family: "IBM Plex Mono", Consolas, monospace;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 7px;
  padding: 8px 11px; width: 100%;
}
.field select {
  font: inherit; font-size: 13px;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 7px;
  padding: 8px 11px; width: 100%; cursor: pointer;
}
.field select:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.field input:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.field input.bad { border-color: var(--bad); }
.help { font-size: 11.5px; color: var(--muted); margin: 0; }
.err { font-size: 11.5px; color: var(--bad); margin: 0; font-weight: 500; }
.req {
  font-size: 9.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); background: var(--sunk); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 6px; margin-inline-start: 6px; vertical-align: 1px;
}

/* ── readiness checklist ─────────────────────────────────── */
.checklist-wrap {
  background: var(--sunk); border: 1px solid var(--line);
  border-radius: 9px; padding: 14px 16px; margin-bottom: 18px;
}
.mini-head {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 0 0 10px;
}
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; }
.checklist .tick {
  width: 16px; height: 16px; border-radius: 50%; flex: none; margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; line-height: 1;
}
.checklist li.ok .tick { background: var(--good-bg); color: var(--good); }
.checklist li.todo .tick { background: var(--bad-bg); color: var(--bad); }
.checklist li.opt .tick { background: var(--sunk); color: var(--faint); border: 1px solid var(--line-strong); }
.cl-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.checklist b { font-size: 12.5px; font-weight: 600; }
.cl-val {
  font-family: "IBM Plex Mono", monospace; font-size: 11px; color: var(--muted);
  background: var(--card); border: 1px solid var(--line);
  border-radius: 4px; padding: 0 6px; word-break: break-all;
}
.checklist li.todo .cl-val { color: var(--bad); }
.checklist small { display: block; font-size: 11px; color: var(--faint); line-height: 1.5; }
.help.block { margin-bottom: 16px; max-width: 62ch; line-height: 1.6; }
.help code { font-family: "IBM Plex Mono", monospace; font-size: 11px; }

.switch { display: flex; gap: 11px; align-items: flex-start; margin-bottom: 18px; cursor: pointer; }
.switch input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.switch b { display: block; font-size: 13.5px; }
.switch small { display: block; font-size: 12px; color: var(--muted); line-height: 1.55; }

.callout {
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: 8px; padding: 13px 16px; font-size: 12.5px;
  color: var(--ink); margin-bottom: 16px; line-height: 1.6;
}
.callout b { color: var(--accent); }
.snippet {
  font-family: "IBM Plex Mono", Consolas, monospace; font-size: 11.5px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 6px; padding: 10px 12px; margin: 10px 0 0;
  overflow-x: auto; line-height: 1.55; color: var(--ink);
}
.actions-inline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.fallback {
  margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px;
}
.fallback > summary {
  font-size: 12px; color: var(--faint); cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 6px;
}
.fallback > summary::before { content: "▸"; font-size: 9px; }
.fallback[open] > summary::before { content: "▾"; }
.fallback > summary:hover { color: var(--muted); }
.fallback > summary::-webkit-details-marker { display: none; }
.fallback .switch { margin: 12px 0 0; }

.checks { display: flex; flex-direction: column; gap: 9px; margin-top: 16px; }
.check {
  display: flex; gap: 11px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: 8px; padding: 11px 14px;
}
.check .dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none; margin-top: 6px;
}
.check.pass { border-left: 3px solid var(--good); }
.check.pass .dot { background: var(--good); }
.check.warn { border-left: 3px solid var(--warn); }
.check.warn .dot { background: var(--warn); }
.check.fail { border-left: 3px solid var(--bad); }
.check.fail .dot { background: var(--bad); }
.check b { display: block; font-size: 13px; }
.check p { margin: 3px 0 0; font-size: 12px; color: var(--muted); line-height: 1.55; }
.check .snippet { margin-top: 8px; }

.msg-ok { color: var(--good); }
.msg-bad { color: var(--bad); }
.msg-warn { color: var(--warn); }

@media (max-width: 560px) {
  .field-row { flex-direction: column; gap: 0; }
  .backdrop { padding: 0; }
  .modal { max-width: none; border-radius: 0; max-height: 100vh; border: none; }
  .modal-foot { border-radius: 0; }
}

@media (max-width: 640px) {
  .kpi { border-left: none; border-top: 1px solid var(--line); }
  .kpi:first-child { border-top: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .chip, .tab, .alert { transition: color .12s ease, background .12s ease, border-color .12s ease; }
}
