@font-face {
  font-family: "Manrope";
  font-weight: 400 800;
  font-display: swap;
  src: url("assets/manrope-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF;
}
@font-face {
  font-family: "Manrope";
  font-weight: 400 800;
  font-display: swap;
  src: url("assets/manrope-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1EFF, U+20A0-20AB, U+20AD-20C4;
}

:root {
  --ink: #102638;
  --muted: #66717f;
  --line: #d6dde5;
  --paper: #f4f7fa;
  --white: #fff;
  --blue: #1f6f95;
  --navy: #0a2a43;
  --gold: #b48745;
  --gold-soft: #d1af7a;
  --red: #b42318;
  --radius: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Manrope", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-size: 13.5px;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 6px 18px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.brand { white-space: nowrap; }
.brand small { display: block; color: var(--muted); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 6px 12px; border-radius: 7px; color: var(--muted); font-weight: 700; }
.tabs a.is-active { color: var(--navy); background: var(--paper); }
.badge { margin-left: 4px; padding: 1px 7px; color: var(--white); background: var(--blue); border-radius: 999px; font-size: 0.72rem; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }

.btn {
  min-height: 32px;
  padding: 0 13px;
  color: var(--white);
  background: var(--navy);
  border: 1px solid var(--navy);
  border-radius: 7px;
  font-weight: 750;
  cursor: pointer;
}
.btn.gold { color: #071522; background: var(--gold-soft); border-color: var(--gold-soft); }
.btn.ghost { color: var(--ink); background: var(--white); border-color: var(--line); }
.btn.small { min-height: 28px; padding: 0 10px; font-size: 0.82rem; }
.btn:hover { filter: brightness(1.05); }
.btn.file { display: inline-flex; align-items: center; }
.icon-btn { width: 26px; height: 26px; line-height: 1; border: 1px solid var(--line); border-radius: 7px; background: var(--white); color: var(--muted); font-size: 1.1rem; cursor: pointer; }
.icon-btn:hover { color: var(--red); border-color: var(--red); }

main { max-width: 1600px; margin: 0 auto; padding: 12px 16px; }
.calc-grid { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 12px; align-items: start; }
.calc-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: start; }
.calc-form .card.wide { grid-column: 1 / -1; }

.card { margin: 0; padding: 8px 12px 12px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
fieldset.card { min-width: 0; }
legend { display: flex; align-items: center; gap: 7px; padding: 0 5px; margin-left: -5px; font-weight: 800; font-size: 0.8rem; color: var(--navy); text-transform: uppercase; letter-spacing: 0.03em; }
legend span { display: grid; place-items: center; width: 18px; height: 18px; color: var(--white); background: var(--navy); border-radius: 50%; font-size: 0.68rem; letter-spacing: 0; }
h3.sub { margin: 18px 0 8px; font-size: 0.86rem; color: var(--muted); }

.grid { display: grid; gap: 6px 8px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.span-all { grid-column: 1 / -1; }
label, .field { display: grid; gap: 2px; color: var(--muted); font-size: 0.72rem; font-weight: 750; }
.field-label { color: var(--muted); font-size: 0.72rem; font-weight: 750; }
input, select, textarea {
  width: 100%;
  min-height: 30px;
  padding: 4px 8px;
  color: var(--ink);
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31, 111, 149, 0.25); border-color: var(--blue); background: var(--white); }
input[readonly] { color: var(--navy); font-weight: 800; background: var(--paper); }
.check { display: flex; align-items: center; gap: 6px; align-self: end; min-height: 30px; color: var(--ink); font-size: 0.84rem; white-space: nowrap; }
.check input { width: 15px; min-height: 15px; height: 15px; accent-color: var(--navy); }
.inline { display: flex; gap: 8px; }
.inline input { flex: 0 0 70px; }
.hint { margin: 0; color: var(--muted); font-size: 0.78rem; line-height: 1.4; align-self: center; }

.segmented { display: inline-flex; gap: 2px; margin-bottom: 8px; padding: 2px; background: var(--paper); border: 1px solid var(--line); border-radius: 9px; }
.segmented label { display: flex; align-items: center; gap: 6px; padding: 4px 10px; color: var(--ink); font-size: 0.82rem; border-radius: 6px; cursor: pointer; }
.segmented input { width: auto; min-height: 0; accent-color: var(--navy); }
.segmented label:has(input:checked) { background: var(--white); box-shadow: 0 1px 4px rgba(16, 38, 56, 0.1); }

/* stops */
.stops { display: grid; gap: 5px; margin-bottom: 6px; }
.stop { display: grid; grid-template-columns: 20px minmax(0, 1fr); grid-auto-flow: column; grid-auto-columns: auto; gap: 6px; align-items: center; }
.stop .icon-btn { width: 26px; }
.stop [data-zone-tag]:empty { display: none; }
.stop-n { display: grid; place-items: center; width: 20px; height: 20px; color: var(--navy); border: 1.5px solid var(--navy); border-radius: 50%; font-weight: 800; font-size: 0.7rem; }
.base-row { margin-top: 18px; padding-top: 16px; border-top: 1px solid #e8edf2; }
.airport-picker { position: relative; }
.suggestions { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: 4px; list-style: none; background: var(--white); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 30px rgba(16, 38, 56, 0.16); }
.suggestions li { padding: 5px 8px; border-radius: 6px; cursor: pointer; font-size: 0.9rem; }
.suggestions li span { display: block; color: var(--muted); font-size: 0.8rem; }
.suggestions li.is-active, .suggestions li:hover { background: var(--paper); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
th { padding: 4px 6px; color: var(--muted); font-size: 0.66rem; font-weight: 800; text-align: left; text-transform: uppercase; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 3px 6px; border-bottom: 1px solid #edf1f5; vertical-align: middle; }
td small { display: inline; margin-left: 6px; color: var(--muted); font-size: 0.74rem; }
.r { text-align: right; }
td input { min-height: 26px; max-width: 96px; padding: 2px 6px; margin-left: auto; text-align: right; }
tr.positioning td:first-child b { color: var(--blue); }
tr.positioning { background: #f8fbfd; }
td.empty { padding: 18px 10px; color: var(--muted); }
.extra { display: grid; grid-template-columns: minmax(0, 1fr) 110px 26px; gap: 6px; margin-bottom: 5px; align-items: center; }

/* summary */
.summary { position: sticky; top: 52px; }
.summary-card { padding: 14px 16px; color: var(--white); background: var(--navy); border-color: var(--navy); }
.eyebrow { margin: 0 0 6px; color: var(--gold-soft); font-size: 0.74rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.price { margin: 0; font-size: 1.9rem; font-weight: 800; letter-spacing: -0.01em; }
.price-sub { min-height: 1.2em; margin: 2px 0 8px; color: rgba(255, 255, 255, 0.7); font-size: 0.86rem; }
dl { margin: 0; }
dl div { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.08); font-size: 0.84rem; }
dt { color: rgba(255, 255, 255, 0.68); }
dd { margin: 0; font-weight: 700; text-align: right; }
.breakdown .total { margin-top: 4px; border-top: 1px solid rgba(255, 255, 255, 0.25); border-bottom: 0; }
.breakdown .total dt, .breakdown .total dd { color: var(--white); font-weight: 800; }
.breakdown .margin dd { color: var(--gold-soft); font-size: 0.84rem; }
.facts { margin-top: 8px; }
.facts div { font-size: 0.84rem; }
.warnings { margin: 14px 0 0; padding: 0; list-style: none; }
.warnings li { margin-top: 4px; padding: 5px 8px; color: #ffe4bf; background: rgba(209, 175, 122, 0.14); border-left: 3px solid var(--gold-soft); border-radius: 4px; font-size: 0.76rem; line-height: 1.35; }

/* saved */
.saved-head { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.saved-head input { max-width: 420px; }
.saved-actions { margin-left: auto; display: flex; gap: 8px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 50; padding: 12px 18px; color: var(--white); background: var(--navy); border-radius: 8px; transform: translate(-50%, 20px); opacity: 0; visibility: hidden; transition: transform 220ms ease, opacity 220ms ease, visibility 220ms; font-weight: 700; }
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
.fatal { margin: 0; padding: 14px 24px; color: var(--white); background: var(--red); }
.print-quote { display: none; }

@media (max-width: 1100px) {
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .topbar-actions { order: 3; width: 100%; margin-left: 0; }
  .user { margin-left: auto; }
  .calc-grid { grid-template-columns: 1fr; }
  .summary { position: static; order: -1; }
}
@media (max-width: 900px) {
  .calc-form { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .topbar-actions { width: 100%; margin: 0; }
  .topbar-actions .btn { flex: 1; padding: 0 8px; }
  main { padding: 10px; }
  .g3, .grid { grid-template-columns: 1fr 1fr; }
  .span2, .span3 { grid-column: 1 / -1; }
  .segmented { display: grid; }
}

/* aircraft reference line */
.aircraft-info { font-size: 0.74rem; }
.aircraft-info a { color: var(--blue); text-decoration: underline; }
.warn-inline { color: #9a6a1f; font-weight: 700; }

/* calibration panel */
.calibration { margin-top: 2px; padding: 5px 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; font-size: 0.86rem; }
.calibration summary { cursor: pointer; font-weight: 750; color: var(--navy); }
.calibration table { margin-top: 10px; font-size: 0.82rem; }
.cal-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; margin-top: 6px; }
.cal-form .btn { grid-column: span 4; justify-self: start; }
td input.wind { max-width: 72px; }
@media (max-width: 720px) { .cal-form { grid-template-columns: 1fr 1fr; } .cal-form .btn { grid-column: span 2; } }

/* compact route footer, flight plan, weather */
.route-foot { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 8px; align-items: center; margin-top: 4px; padding-top: 6px; border-top: 1px solid #e8edf2; }
.route-foot .check { align-self: center; }
.terms { margin-top: 6px; font-size: 0.8rem; }
.terms summary, .wx-box summary { cursor: pointer; color: var(--navy); font-weight: 750; font-size: 0.8rem; }
.terms label { margin-top: 5px; }
.fp-head { display: grid; grid-template-columns: repeat(4, minmax(90px, 130px)) minmax(0, 1fr) auto; gap: 8px; align-items: end; margin-bottom: 6px; }
.fp-head .btn { grid-column: -2; }
.fp-sources { grid-column: 1 / -1; order: 9; font-size: 0.72rem; }
table.fp td input { width: 62px; min-width: 56px; }
table.fp td input.alt { width: 62px; text-align: left; text-transform: uppercase; }
td .src { color: var(--muted); font-size: 0.7rem; margin-left: 4px; }
td.bad { color: var(--red); font-weight: 800; }
.wx-box { margin-top: 6px; }
.wx-box pre { margin: 4px 0; padding: 6px 8px; background: var(--paper); border-radius: 6px; white-space: pre-wrap; font: 0.76rem/1.4 ui-monospace, Menlo, monospace; }
@media (max-width: 720px) { .fp-head { grid-template-columns: 1fr 1fr 1fr; } .fp-head .btn, .fp-sources { grid-column: 1 / -1; } .route-foot { grid-template-columns: 1fr 1fr; } }

/* technical stops */
.techstops { margin: 6px 0; display: grid; gap: 5px; }
.techstop.is-block { background: #fdecec; border-color: #d08080; }
.airspace { margin: 6px 0; padding: 6px 10px; background: #fff7ea; border: 1px solid var(--gold-soft); border-left-width: 4px; border-radius: 6px; font-size: 0.82rem; }
.airspace:has(li.is-block) { background: #fdecec; border-color: #c24b4b; }
.airspace b { color: var(--navy); }
.airspace:has(li.is-block) > b { color: #a31f1f; }
.airspace ul { margin: 4px 0; padding-left: 18px; }
.airspace li { margin: 2px 0; }
.airspace li.is-block { color: #a31f1f; font-weight: 600; }
.airspace li.is-info { color: var(--navy); font-weight: 600; }
.airspace li small, .airspace > small { display: block; color: #7a7f8c; font-weight: 400; font-size: 0.72rem; }
.tag.tag-block { background: #c24b4b; color: #fff; }
.tag.tag-warn { background: #f3dcae; color: #6b4a12; }
.techstop { display: grid; gap: 5px; padding: 6px 10px; background: #fff7ea; border: 1px solid var(--gold-soft); border-radius: 6px; font-size: 0.82rem; }
.techstop b { color: var(--navy); }
.ts-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.ts-row:has(select) { grid-template-columns: auto minmax(0, 340px) auto; }
.tag { display: inline-block; margin-left: 6px; padding: 0 6px; color: #7a5a1f; background: #fbeed6; border-radius: 999px; font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; }
.stop .tag { margin: 0; }
@media (max-width: 720px) { .ts-row, .ts-row:has(select) { grid-template-columns: 1fr; } }

/* phase 2: sign-in, user, banner, conflict dialog */
.user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.86rem; font-weight: 700; }
.login { display: grid; place-items: center; min-height: 60vh; }
.login-card { width: min(100%, 460px); padding: 32px; text-align: center; }
.login-card h1 { margin: 0 0 8px; color: var(--navy); font-size: 1.4rem; }
.login-actions { display: grid; gap: 10px; margin-top: 20px; }
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 18px; padding: 12px 16px; background: #fff7ea; border: 1px solid var(--gold-soft); border-radius: var(--radius); }
.banner .btn { margin-left: auto; }
.team-defaults { margin-top: 6px; }
.conflict { max-width: 480px; padding: 0; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 24px 60px rgba(16, 38, 56, 0.25); }
.conflict::backdrop { background: rgba(10, 42, 67, 0.45); }
.conflict form { padding: 24px; }
.conflict h2 { margin: 0 0 8px; color: var(--navy); font-size: 1.15rem; }
.conflict p { margin: 0 0 10px; line-height: 1.5; }
.dialog-actions { display: grid; gap: 8px; margin-top: 16px; }

/* ---------- client quotation (print / Save as PDF) ---------- */
@page { size: A4; margin: 16mm 15mm; }
@media print {
  body { background: var(--white); font-size: 11pt; }
  .topbar, main, .toast, .conflict { display: none !important; }
  .print-quote { display: block; color: var(--ink); }
  .pq-head { display: grid; grid-template-columns: 54px 1fr auto; gap: 14px; align-items: start; padding-bottom: 14px; border-bottom: 2px solid var(--navy); }
  .pq-head strong { display: block; font-size: 15pt; color: var(--navy); }
  .pq-head span { display: block; color: var(--muted); font-size: 8.5pt; line-height: 1.5; }
  .pq-meta { text-align: right; }
  .pq-meta h1 { margin: 0 0 4px; color: var(--navy); font-size: 17pt; }
  .print-quote h2 { margin: 18px 0 6px; color: var(--gold); font-size: 8.5pt; letter-spacing: 0.06em; text-transform: uppercase; }
  .pq-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .pq-grid.two { grid-template-columns: 1fr 1fr; }
  .pq-grid p { margin: 0; line-height: 1.5; }
  .pq-table th { color: var(--muted); border-bottom: 1px solid var(--navy); }
  .pq-table td { border-bottom: 1px solid var(--line); }
  .pq-price { display: flex; align-items: baseline; gap: 14px; margin: 20px 0 4px; padding: 14px 18px; color: var(--white); background: var(--navy); border-radius: 6px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pq-price span { font-weight: 700; }
  .pq-price strong { margin-left: auto; font-size: 18pt; }
  .pq-price small { color: rgba(255, 255, 255, 0.7); }
  .print-quote ul { margin: 0; padding-left: 16px; line-height: 1.6; }
  .pq-foot { margin-top: 26px; padding-top: 10px; color: var(--muted); border-top: 1px solid var(--line); font-size: 8pt; line-height: 1.5; }
  /* flight plan */
  .ofp { font-size: 8.5pt; }
  .ofp-page { break-after: page; }
  .ofp-page:last-child { break-after: auto; }
  .ofp-head { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 6px; border-bottom: 2px solid var(--navy); }
  .ofp-head strong { display: block; color: var(--navy); font-size: 12pt; }
  .ofp-head span { display: block; color: var(--muted); font-size: 8pt; line-height: 1.4; }
  .ofp-warn { margin: 6px 0; padding: 5px 8px; border: 1px solid var(--gold); border-radius: 4px; font-size: 7.5pt; line-height: 1.4; }
  .ofp-zone.is-block { border: 2px solid #000; font-size: 8.5pt; }
  .ofp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .ofp table { font-size: 8pt; }
  .ofp td, .ofp th { padding: 2px 4px; }
  .ofp-t tr.sum td { font-weight: 800; border-top: 1px solid var(--navy); }
  .ofp h2 { margin: 10px 0 4px; }
  .ofp-fpl, .ofp pre { margin: 0 0 4px; padding: 5px 7px; background: #f4f7fa; border-radius: 4px; white-space: pre-wrap; font: 7.8pt/1.35 ui-monospace, Menlo, monospace; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ofp-log td, .ofp-log th { font-variant-numeric: tabular-nums; }
  .ofp-log tr { break-inside: avoid; }
}
