/* Northbound Air (fictional): petrol slate #16323f, teal #2a9d8f, Inter */
:root {
  --brand: #16323f;
  --brand-2: #2a9d8f;
  --print-ink: #12355b;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f6f8f9;
  --ink: #1c2529;
  --heading: #16323f;
  --muted: #56636b;
  --line: #d9e0e4;
  --accent: #16323f;
  --accent-hover: #22495b;
  --accent-ink: #ffffff;
  --ok: #1a7445;
  --ok-bg: #e2f3e9;
  --warn: #8a5300;
  --warn-bg: #fff3d1;
  --err: #b4231b;
  --err-bg: #fde8e6;
  --zone: #edf2f4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(22, 50, 63, .06), 0 2px 8px rgba(22, 50, 63, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1418; --surface: #121e24; --surface-2: #18272e; --ink: #e6edf0; --heading: #ffffff; --muted: #9fb0b8;
    --line: #263a43; --accent: #5cc8b9; --accent-hover: #7fd6ca; --accent-ink: #0c1418; --ok: #5fd08f; --ok-bg: #11301f;
    --warn: #ffbf4d; --warn-bg: #33270f; --err: #ff8076; --err-bg: #3c1715; --zone: #16242b; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1418; --surface: #121e24; --surface-2: #18272e; --ink: #e6edf0; --heading: #ffffff; --muted: #9fb0b8;
  --line: #263a43; --accent: #5cc8b9; --accent-hover: #7fd6ca; --accent-ink: #0c1418; --ok: #5fd08f; --ok-bg: #11301f;
  --warn: #ffbf4d; --warn-bg: #33270f; --err: #ff8076; --err-bg: #3c1715; --zone: #16242b; --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
.topbar {
  position: sticky; top: 0; z-index: 10; background: var(--brand); color: #fff;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 20px;
}
/* teal rule under the top bar */
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 4px; background: var(--brand-2); }
.brand { display: flex; align-items: center; gap: 12px; white-space: nowrap; color: #fff; }
.brand .logo { width: 132px; height: auto; display: block; }
.brand .divider { width: 1px; height: 28px; background: rgba(255, 255, 255, .28); }
.brand .app { font-weight: 700; font-size: 16px; letter-spacing: .01em; }
.poc { font-size: 11px; font-weight: 600; color: #a6ebe1; background: rgba(42, 157, 143, .18); border: 1px solid rgba(42, 157, 143, .5); border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.topbar select, .topbar input[type="date"] { min-width: 0; max-width: 280px; min-height: 36px; width: auto; background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .28); color: #fff; border-radius: 999px; padding: 4px 14px; }
.topbar select option { color: #1c2529; background: #fff; }
.topbar select:focus, .topbar .btn:focus-visible { outline-color: var(--brand-2); }
.btn {
  min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; white-space: nowrap; font-weight: 600; font-size: 14px; color: var(--heading);
}
.btn:hover { border-color: var(--accent); background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn.icon { min-width: 36px; padding: 0 8px; }
.btn.danger { color: var(--err); }
.topbar .btn { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .3); }
.topbar .btn:hover { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .6); }
.topbar .btn.danger { color: #ffb3ad; }
.topbar .btn.primary { background: var(--brand-2); color: #0c1f26; border-color: var(--brand-2); }
.topbar .btn.primary:hover { background: #3cb3a4; }
main { padding: 24px 16px; max-width: 1180px; margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h2 { font-size: 17px; font-weight: 700; margin: 0 0 12px; color: var(--heading); letter-spacing: -.005em; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card h3 { font-size: 12px; margin: 20px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 12px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=date], input[type=time], select, textarea {
  min-height: 40px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); width: 100%;
}
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
code { font-size: 13px; background: var(--zone); padding: 1px 5px; border-radius: 4px; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 20px; align-items: center; }
.check { display: flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; }
.check input { width: 20px; height: 20px; }
.radio-group { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; border-left: 2px solid var(--line); padding-left: 16px; }
.radio-group > span { font-size: 13px; color: var(--muted); font-weight: 600; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { border-collapse: collapse; width: 100%; }
table.t th, table.t td { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: right; white-space: nowrap; }
table.t th { font-size: 12px; color: var(--muted); font-weight: 600; vertical-align: bottom; padding-bottom: 8px; }
table.t th.l, table.t td.l { text-align: left; }
table.t td input[type=text] { min-height: 36px; text-align: right; width: 80px; padding: 4px 6px; }
table.t td input.dest { width: 104px; text-align: left; text-transform: uppercase; font-weight: 600; }
table.t td input.wide { width: 160px; text-align: left; }
table.t td input.narrow { width: 64px; }
table.t tfoot td { font-weight: 700; background: var(--zone); color: var(--heading); }
table.t .calc { background: var(--surface-2); font-weight: 600; }
table.t .sub { font-weight: 400; color: var(--muted); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.alerts { display: grid; gap: 6px; margin-bottom: 12px; }
.alert { border-radius: 10px; padding: 9px 14px; font-size: 14px; display: flex; gap: 10px; align-items: baseline; }
.alert.error { background: var(--err-bg); color: var(--err); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.info { background: var(--zone); color: var(--muted); }
.alert b { white-space: nowrap; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.err { background: var(--err-bg); color: var(--err); }
.pill.muted { background: var(--zone); color: var(--muted); font-weight: 600; }
.bad { color: var(--err); font-weight: 700; }
.warnc { color: var(--warn); font-weight: 700; }
.good { color: var(--ok); }
.preview-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 12px; border-radius: 8px; background: var(--zone); padding: 12px; }
.sheet { background: #fff; color: #000; box-shadow: 0 2px 12px rgba(22, 50, 63, .14); border-radius: 4px; padding: 18px; margin: 2px; }
.sheet.landscape { min-width: 920px; }
.sheet.portrait { min-width: 640px; max-width: 820px; }
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); max-width: 420px; padding: 24px; }
dialog::backdrop { background: rgba(12, 20, 24, .55); }
dialog h2 { margin: 0 0 8px; font-size: 17px; color: var(--heading); }
#limitDialog h2 { color: var(--err); }
#limitDialog ul { margin: 8px 0 4px; padding-left: 20px; color: var(--err); font-weight: 600; }
#print-root { display: none; }
/* manifest cells holding a sum: corner tick, and the breakdown pop-up */
table.t td.has-calc { position: relative; }
table.t td.has-calc::after { content: ""; position: absolute; top: 5px; right: 7px; border: 5px solid transparent; border-top-color: var(--brand-2); border-right-color: var(--brand-2); border-top-right-radius: 3px; pointer-events: none; }
.calc-pop { position: fixed; z-index: 20; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 20px rgba(12, 20, 24, .18); padding: 8px 12px; font-size: 13px; min-width: 120px; }
.calc-pop[hidden] { display: none; }
.calc-pop .h { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.calc-pop table { border-collapse: collapse; width: 100%; }
.calc-pop td { padding: 1px 0; text-align: right; }
.calc-pop td.op { text-align: left; color: var(--muted); padding-right: 10px; }
.calc-pop tr.tot td { border-top: 1px solid var(--line); padding-top: 4px; font-weight: 700; color: var(--heading); }
/* dragging the destination tags on the form preview */
.sheet .chip { cursor: grab; touch-action: none; }
.sheet .chip.dragging { opacity: .35; }
.sheet .ghost { pointer-events: none; opacity: .9; cursor: grabbing; }
.sheet .drop, .sheet .area { pointer-events: none; }
.sheet .area.over { fill: rgba(42, 157, 143, .2); stroke: #2a9d8f; stroke-width: 3; stroke-dasharray: 10 6; }


/* ---------- printable forms (always black on white) ---------- */
.page { color: #000; background: #fff; font: 12px/1.25 Calibri, "Segoe UI", Arial, sans-serif; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.page .foot { margin-top: 8px; font-size: 9px; color: #555; display: flex; justify-content: space-between; gap: 12px; }
.page .val { font-family: "Courier New", ui-monospace, monospace; font-weight: 700; color: #0b3a8a; }

/* drawn forms with the data overlay */
.page .drawn svg { display: block; width: 100%; height: auto; }
.page .drawn .v { font-family: "Courier New", ui-monospace, monospace; font-weight: 700; fill: var(--print-ink); paint-order: stroke; stroke: #fff; stroke-width: 4px; stroke-linejoin: round; }
.page .drawn .note { font-family: "Segoe UI", Arial, sans-serif; fill: var(--print-ink); paint-order: stroke; stroke: #fff; stroke-width: 4px; stroke-linejoin: round; }
.page .drawn g .v { stroke: none; }

/* one-page layout: flight details + manifest above the form */
.one-top { display: grid; grid-template-columns: minmax(200px, auto) minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 8px; }
.one-top h1 { font-size: 16px; }
.one-top .meta { grid-template-columns: auto 1fr; border-bottom: 0; margin: 0; padding: 0; font-size: 12px; }
.one-top table { font-size: 12px; }
.one-top th, .one-top td { padding: 2px 6px; }
.one-top .box { min-height: 0; margin-top: 4px; font-size: 11px; }

/* manifest page */
.mf h1 { font-size: 18px; margin: 0 0 6px; }
.mf .meta { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 3px 14px; font-size: 13px; border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 10px; }
.mf table { border-collapse: collapse; width: 100%; font-size: 13px; }
.mf th, .mf td { border: 1px solid #000; padding: 5px 7px; text-align: right; }
.mf th { background: #eee; }
.mf .l { text-align: left; }
.mf tfoot td { font-weight: 700; background: #f2f2f2; }
.mf .box { border: 1px solid #000; min-height: 60px; padding: 6px; white-space: pre-wrap; margin-top: 4px; }

.page .plogo { width: 120px; color: var(--print-ink); height: auto; flex: none; display: block; }
.mf .mf-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.mf h1 { color: var(--print-ink); }
.one-h { display: flex; align-items: center; gap: 10px; }
.one-h .plogo { width: 96px; }
.one-h h1 { margin: 0; }
.page .val { color: var(--print-ink); }
.page .foot { border-top: 2px solid var(--brand-2); padding-top: 3px; }
@page { size: letter portrait; margin: 0.4in; }
@page land { size: letter landscape; margin: 0.3in; }
@media print {
  body { background: #fff; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  #print-root .page { break-after: page; }
  #print-root .page:last-child { break-after: auto; }
  #print-root .page.landscape { page: land; }
}
/* signed out: only the sign-in card and the theme button */
body.signed-out .needs-auth, body.signed-out #view { display: none; }
.signin { max-width: 380px; margin: 48px auto; }
.save-status { font-size: 12px; color: #c9d6df; white-space: nowrap; }
.save-status.error { color: #ffb4a8; font-weight: 600; cursor: pointer; text-decoration: underline; }
/* closed flight: read-only */
.locked { border: 0; padding: 0; margin: 0; min-width: 0; }
.closed-banner { background: var(--brand-2); color: #fff; border-radius: 8px; padding: 8px 14px; margin: 0 0 12px; font-weight: 600; }
.topbar input[type="date"] { color-scheme: dark; }

/* Reports page */
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.reports { max-width: 900px; margin: 0 auto; }
.report-form { display: grid; gap: 10px; max-width: 420px; }
.report-status { min-height: 1.4em; margin: 0; color: var(--muted); }
.report-status.error, .report-error { color: var(--err); }
.report-body h3 { font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--heading); margin: 22px 0 6px; }
.report-body h3:first-child { margin-top: 0; }
.report-body ul { margin: 0; padding-left: 20px; }
.report-body li { margin: 4px 0; line-height: 1.5; }
.report-meta { margin: 20px 0 0; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.report-calls { margin-top: 8px; color: var(--muted); font-size: 13px; }
.pill { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.err { color: var(--err); background: var(--err-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.report-labels { margin-top: 12px; }
.report-labels table { font-size: 13px; }
.table-wrap { overflow-x: auto; }
table.history { width: 100%; border-collapse: collapse; font-size: 14px; }
table.history th, table.history td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
