:root {
  --bg: #F5F5F3; --surface: #FFFFFF; --surface-2: #FAFAF8; --line: #E3E3DF; --line-strong: #CFCFCA;
  --ink: #1C1D20; --ink-2: #45474C; --muted: #5F6167; --accent: #2A2C30; --bad: #A94C43; --ok: #2F6B4F;
  --paper-line: #2A2C30; --focus: #FFF7D6;
  --radius: 14px; --pad-x: 40px;
  --shadow: 0 1px 2px rgba(20, 22, 26, .04), 0 8px 24px rgba(20, 22, 26, .05);
}
@media (max-width: 720px) { :root { --pad-x: 16px; } }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 'IBM Plex Sans', system-ui, sans-serif; overflow-x: hidden; }
h1, h2, .brand { font-family: 'Space Grotesk', system-ui, sans-serif; }
.wrap { max-width: 1280px; margin: 0 auto; padding-left: var(--pad-x); padding-right: var(--pad-x); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.muted { color: #8A8C92; }

.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: rgba(245, 245, 243, .92); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; flex-wrap: wrap; }
.brand { white-space: nowrap; display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 18px; height: 18px; border: 2px solid var(--ink); border-radius: 3px; clip-path: polygon(0 0, 100% 0, 100% 100%, 28% 100%, 0 62%); }
.nav { display: flex; gap: 2px; overflow-x: auto; max-width: 100%; }
.nav a { color: var(--ink-2); text-decoration: none; font-size: 14px; padding: 6px 11px; border-radius: 999px; white-space: nowrap; }
.nav a:hover { background: #EAEAE6; }
.nav a[aria-current="page"] { background: var(--ink); color: #fff; }
@media (max-width: 560px) { .topbar-inner { padding-top: 8px; padding-bottom: 8px; } .nav a { font-size: 13px; padding: 5px 9px; } }

.hero { padding-top: 56px; padding-bottom: 22px; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 12px; color: var(--muted); margin: 0 0 14px; }
.hero h1 { font-size: clamp(32px, 5vw, 56px); line-height: 1.04; letter-spacing: -.03em; margin: 0; font-weight: 600; max-width: 20ch; }
.lede { font-size: 17px; color: var(--ink-2); max-width: 64ch; margin: 16px 0 0; }
@media (max-width: 720px) { .hero { padding-top: 36px; } .lede { font-size: 15.5px; } }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.toolbar .saved { font-size: 13px; color: var(--muted); margin-right: auto; }
.btn-primary { border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 10px; padding: 10px 18px; font: 600 14px 'IBM Plex Sans', sans-serif; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; min-height: 42px; }
.btn-primary:hover { background: #111214; }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-ghost { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 10px; padding: 9px 14px; font: 500 14px 'IBM Plex Sans', sans-serif; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; min-height: 42px; }
.btn-ghost:hover { background: var(--surface-2); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Work area: the AWB and the helper */
.work { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
@media (max-width: 1020px) { .work { grid-template-columns: 1fr; } }

/* The AWB "paper" */
.awb { background: #fff; border: 1.5px solid var(--paper-line); border-radius: 4px; box-shadow: var(--shadow); font-size: 12px; }
.awb .r { display: flex; }
.awb .r > * { flex: 1 1 0; min-width: 0; }
.awb .cols { display: grid; grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .awb .cols { grid-template-columns: 1fr; } .awb .r.wrap-sm { flex-wrap: wrap; } .awb .r.wrap-sm > * { flex-basis: 33.3%; } }
.box { display: flex; flex-direction: column; border-right: 1px solid var(--paper-line); border-bottom: 1px solid var(--paper-line); padding: 4px 6px 3px; background: #fff; cursor: text; min-height: 44px; position: relative; }
.box:last-child { border-right: 0; }
.col > .box, .col > .r > .box:last-child { border-right: 0; }
.cols > .col:first-child { border-right: 1px solid var(--paper-line); }
@media (max-width: 720px) { .cols > .col:first-child { border-right: 0; } }
.box .bl { font-size: 9.5px; line-height: 1.2; letter-spacing: .02em; color: #3A3C41; text-transform: none; }
.box input, .box textarea, .box select { border: 0; background: transparent; font: 500 13px/1.35 'IBM Plex Mono', monospace; color: var(--ink); padding: 3px 0 1px; width: 100%; resize: none; outline: none; }
.box textarea { overflow: hidden; }
.box select { cursor: pointer; appearance: none; -webkit-appearance: none; }
.box input::placeholder, .box textarea::placeholder { color: #B5B7BB; }
.box.up input, .box.up textarea { text-transform: uppercase; }
.box:focus-within { background: var(--focus); box-shadow: inset 0 0 0 2px var(--ink); z-index: 1; }
.box.calc { background: var(--surface-2); cursor: default; }
.box.calc .v { font: 600 13px 'IBM Plex Mono', monospace; padding-top: 3px; }
.box.bad { box-shadow: inset 0 0 0 2px var(--bad); }
.box .flag { position: absolute; right: 5px; top: 3px; font-size: 9.5px; font-weight: 600; }
.box .flag.ok { color: var(--ok); }
.box .flag.no { color: var(--bad); }
.static { border-bottom: 1px solid var(--paper-line); padding: 6px 8px; font-size: 9.5px; line-height: 1.35; color: #3A3C41; background: var(--surface-2); }
.awb-top { display: flex; align-items: stretch; border-bottom: 1.5px solid var(--paper-line); }
.awb-top .box { flex: 0 0 auto; }
.awb-top .box.pre { width: 84px; }
.awb-top .box.dep { width: 90px; }
.awb-top .box.ser { width: 150px; }
.awb-top .awbno { flex: 1 1 auto; display: flex; align-items: center; justify-content: flex-end; padding: 6px 12px; font: 600 16px 'IBM Plex Mono', monospace; letter-spacing: .04em; }
@media (max-width: 560px) { .awb-top { flex-wrap: wrap; } .awb-top .box.pre, .awb-top .box.dep { width: 50%; } .awb-top .box.ser { width: 100%; border-right: 0; } .awb-top .awbno { width: 100%; justify-content: flex-start; border-top: 1px solid var(--paper-line); } }
.sech { background: var(--ink); color: #fff; font: 600 10px 'IBM Plex Sans', sans-serif; letter-spacing: .1em; text-transform: uppercase; padding: 3px 8px; }

/* Rating table */
.rating { border-bottom: 1.5px solid var(--paper-line); }
.rate-row { display: grid; grid-template-columns: 70px 90px 64px 96px 84px 94px 84px 100px minmax(160px, 1fr); }
.rate-row > .box { min-height: 0; }
.rate-head { background: var(--surface-2); }
.rate-head > div { font-size: 9.5px; line-height: 1.2; padding: 5px 6px; border-right: 1px solid var(--paper-line); border-bottom: 1px solid var(--paper-line); color: #3A3C41; }
.rate-head > div:last-child, .rate-row > .box:last-child { border-right: 0; }
.rate-dims { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 4px 8px; border-bottom: 1px solid var(--paper-line); background: var(--surface-2); font-size: 11.5px; color: var(--ink-2); }
.rate-dims .box { flex: 0 0 96px; min-height: 0; border: 1px solid var(--line-strong); border-radius: 6px; padding: 2px 6px; }
.rate-dims .vol { font: 500 12px 'IBM Plex Mono', monospace; color: var(--ink); }
.rate-dims .rm { margin-left: auto; border: 0; background: none; color: var(--bad); cursor: pointer; font-size: 12.5px; text-decoration: underline; }
.rate-foot { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; padding: 6px 8px; font: 600 12.5px 'IBM Plex Mono', monospace; background: var(--surface-2); }
.rate-foot .add { margin-left: auto; font: 500 13px 'IBM Plex Sans', sans-serif; border: 1px solid var(--line-strong); background: #fff; border-radius: 8px; padding: 5px 10px; cursor: pointer; }
.rating-scroll { overflow-x: auto; }
.rating-scroll .rate-row, .rating-scroll .rate-head { min-width: 860px; }
@media (max-width: 720px) {
  .rating-scroll .rate-head { display: none; }
  .rating-scroll .rate-row { min-width: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rating-scroll .rate-row > .box { border-right: 1px solid var(--paper-line); }
  .rating-scroll .rate-row > .box.nat { grid-column: 1 / -1; border-right: 0; }
}
.rate-row .box .bl-sm { display: none; font-size: 9.5px; color: #3A3C41; }
@media (max-width: 720px) { .rate-row .box .bl-sm { display: block; } }

/* Charges */
.charges { display: grid; grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .charges { grid-template-columns: 1fr; } }
.chg-table { border-right: 1px solid var(--paper-line); }
@media (max-width: 720px) { .chg-table { border-right: 0; } }
.chg { display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr 1fr; border-bottom: 1px solid var(--paper-line); }
.chg > * { padding: 4px 6px; border-right: 1px solid var(--paper-line); min-width: 0; }
.chg > *:last-child { border-right: 0; }
.chg .lab { font-size: 10.5px; color: #3A3C41; display: flex; align-items: center; }
.chg .pp, .chg .cc { font: 600 12.5px 'IBM Plex Mono', monospace; text-align: right; display: flex; align-items: center; justify-content: flex-end; }
.chg.head { background: var(--surface-2); }
.chg.head > * { font-size: 9.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #3A3C41; }
.chg.tot { background: var(--surface-2); }
.chg .in { padding: 0; display: flex; }
.chg .in .box { border: 0; flex: 1; min-height: 0; }
.cert { font-size: 9.5px; line-height: 1.35; color: #3A3C41; padding: 6px 8px; border-bottom: 1px solid var(--paper-line); }

/* Helper panel */
.helper { position: sticky; top: 76px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.helper-close { display: none; }
.helper-box { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.helper-title { font: 600 19px/1.25 'Space Grotesk', sans-serif; margin-top: 4px; }
.helper-text { color: var(--ink-2); margin: 8px 0 0; font-size: 14.5px; }
.helper-live { margin: 10px 0 0; font-size: 13.5px; font-weight: 600; }
.helper-live:empty { display: none; }
.helper-live.ok { color: var(--ok); }
.helper-live.no { color: var(--bad); }
@media (max-width: 1020px) {
  .helper { position: fixed; left: 10px; right: 10px; top: auto; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 40; max-height: 42vh; overflow-y: auto; padding: 14px 44px 14px 16px; box-shadow: 0 12px 40px rgba(20, 22, 26, .25); transform: translateY(calc(100% + 30px)); transition: transform .2s; }
  .helper.show { transform: none; }
  .helper-close { display: block; position: absolute; right: 8px; top: 6px; border: 0; background: none; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 8px; }
  .helper-title { font-size: 17px; }
  .helper-text { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) { .helper { transition: none; } }

/* FFR */
.ffr-sec { padding-top: 40px; }
.sec-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 14px; }
.sec-head h2 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.sec-head p { margin: 4px 0 0; color: var(--muted); max-width: 70ch; }
.ffr { overflow: hidden; }
.ffr-line { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); border-bottom: 1px solid var(--line); }
.ffr-line:last-child { border-bottom: 0; }
.ffr-line code { font: 500 13.5px/1.45 'IBM Plex Mono', monospace; background: #1C1D20; color: #F4F4F1; padding: 12px 16px; white-space: pre-wrap; word-break: break-all; }
.ffr-line .ex { padding: 10px 16px; }
.ffr-line .ex b { display: block; color: var(--ink); font-size: 14px; }
.ffr-line .ex span { color: var(--ink-2); font-size: 13.5px; }
@media (max-width: 720px) { .ffr-line { grid-template-columns: 1fr; } }
.ffr-missing { padding: 12px 16px; background: #FBF1EF; color: var(--bad); font-size: 13.5px; border-bottom: 1px solid var(--line); }
.note { font-size: 13px; color: var(--muted); max-width: 90ch; margin: 12px 0 0; }

.footer { color: var(--muted); font-size: 12.5px; padding-top: 40px; padding-bottom: 60px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; }
.atlas-links a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.box .bl-sm { display: none; }
.rate-row .box .bl { display: none; }
.rate-dims .box .bl { display: none; }
.rate-dims .box .bl-sm { display: block; font-size: 9.5px; color: #3A3C41; }
@media (max-width: 720px) { .rate-row .box .bl-sm { display: block; font-size: 9.5px; color: #3A3C41; } }

/* Yes / no questions, FWB and houses */
.msg-sec { padding-top: 28px; }
.ask { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; padding: 16px 18px; }
.ask-q b { display: block; font: 600 17px 'Space Grotesk', sans-serif; color: var(--ink); }
.ask-q span { color: var(--muted); font-size: 14px; }
.yesno { display: inline-flex; background: #EFEFEC; border-radius: 999px; padding: 3px; }
.yesno button { border: 0; background: transparent; padding: 8px 20px; border-radius: 999px; font: 600 14px 'IBM Plex Sans', sans-serif; color: var(--ink-2); cursor: pointer; min-width: 64px; }
.yesno button.on { background: var(--ink); color: #fff; }
#fwbWrap, #hawbWrap { padding-top: 18px; }
.sec-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.fhl-head { margin-top: 24px; }
.house-check { font-size: 14px; margin: 0 0 12px; padding: 10px 14px; border-radius: 10px; background: #EEF5F0; color: var(--ok); }
.house-check.bad { background: #FBF1EF; color: var(--bad); }
.house-check:empty { display: none; }
.houses { display: grid; gap: 14px; }
.house { position: relative; }
.house-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--ink); color: #fff; padding: 6px 10px; font: 600 12px 'IBM Plex Sans', sans-serif; letter-spacing: .06em; text-transform: uppercase; border-radius: 3px 3px 0 0; }
.house-head .rm { border: 0; background: none; color: #fff; text-decoration: underline; cursor: pointer; font: 500 12.5px 'IBM Plex Sans', sans-serif; text-transform: none; letter-spacing: 0; }
.house .r.wrap-md { flex-wrap: wrap; }
@media (max-width: 720px) { .house .r.wrap-md > * { flex-basis: 50%; } }

/* What do you need? */
.need { padding: 16px 18px; margin-bottom: 16px; }
.need-title { font: 600 18px 'Space Grotesk', sans-serif; margin-bottom: 10px; }
.need-opts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 860px) { .need-opts { grid-template-columns: 1fr; } }
.need-opt { position: relative; display: flex; gap: 12px; align-items: flex-start; border: 1.5px solid var(--line-strong); border-radius: 12px; padding: 12px 14px; cursor: pointer; background: var(--surface); }
.need-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.need-opt .tick { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--line-strong); display: grid; place-items: center; color: transparent; font-size: 14px; font-weight: 700; margin-top: 1px; }
.need-opt b { display: block; color: var(--ink); font-size: 15px; }
.need-opt span:not(.tick) { color: var(--muted); font-size: 13px; }
.need-opt.on { border-color: var(--ink); background: #F3F3F0; }
.need-opt.on .tick { background: var(--ink); border-color: var(--ink); color: #fff; }
.need-opt.fixed { cursor: default; }
.need-opt:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.jump { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin-top: 12px; font-size: 13px; color: var(--muted); }
.jump a { color: var(--ink); text-decoration: none; border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 11px; background: var(--surface); font-weight: 500; }
.jump a:hover { background: var(--surface-2); }
#awbSec, #ffr, #fwbSec, #hawbSec, #fhlHead { scroll-margin-top: 80px; }
.msg-empty { padding: 16px 18px; }
.msg-empty b { display: block; color: var(--ink); margin-bottom: 6px; }
.msg-empty ul { margin: 0; padding: 0 0 0 18px; color: var(--ink-2); font-size: 14px; columns: 2; column-gap: 28px; }
@media (max-width: 720px) { .msg-empty ul { columns: 1; } }
.msg-tip { padding: 10px 16px; background: #F7F4EA; color: #6B5A1E; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.msg-empty .msg-ex { margin-top: 14px; }
button.copy.off { opacity: .45; }
.msg-lead { margin: 0 0 8px; font-size: 13.5px; color: var(--muted); }
.goto-list { list-style: none; padding: 0 !important; columns: 2; column-gap: 12px; }
@media (max-width: 720px) { .goto-list { columns: 1; } }
.goto-list li { break-inside: avoid; margin: 0 0 6px; }
.goto { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left; font: 500 14px 'IBM Plex Sans', sans-serif; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 12px; min-height: 42px; cursor: pointer; }
.goto:hover { border-color: var(--ink); }
.goto span { color: var(--muted); }
@keyframes flash { 0%, 40% { box-shadow: inset 0 0 0 3px #E0A100; background: #FFF6D6; } 100% { box-shadow: inset 0 0 0 3px transparent; } }
.flash { animation: flash 1.6s ease-out; }
.decode-note { margin: 14px 0 0; font-size: 14.5px; color: var(--ink-2); }
.decode-note a { color: var(--ink); font-weight: 600; }

/* FFR and FWB Generators */
.gen-form { padding: 16px 18px; }
@media (max-width: 720px) { .gen-form { padding: 12px; } }
.gen-group { border: 0; margin: 0 0 14px; padding: 0; min-width: 0; }
.gen-group:last-of-type { margin-bottom: 0; }
.gen-group legend { font: 600 14px 'Space Grotesk', sans-serif; color: var(--ink); padding: 0; margin-bottom: 8px; }
.gen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.gen-grid .box { border: 1px solid var(--line-strong); border-radius: 8px; min-height: 0; padding: 5px 9px 4px; }
.gen-grid .box:last-child { border-right: 1px solid var(--line-strong); }
.gen-grid .box .bl { display: none; }
.gen-grid .box .bl-sm { display: block; font-size: 11.5px; line-height: 1.25; color: var(--muted); font-weight: 500; }
.gen-grid .box input, .gen-grid .box textarea, .gen-grid .box select { font-size: 15px; padding: 4px 0 2px; }
.gen-grid .box.wide { grid-column: 1 / -1; }
.gen-grid .box .flag { display: none; }
.gen-note { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.out { margin-top: 14px; overflow: hidden; }
.out-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.out-state { font-size: 13px; font-weight: 600; border-radius: 999px; padding: 2px 10px; }
.out-state.ok { background: #E6F4EA; color: #1B4D2E; }
.out-state.no { background: #FBF1EF; color: #6E2F29; }
.out-text { margin: 0; padding: 14px 16px; background: #1C1D20; color: #F4F4F1; font: 500 14px/1.55 'IBM Plex Mono', monospace; white-space: pre-wrap; word-break: break-all; min-height: 60px; }
.out-text.draft { color: #BFC1C6; }
.out-missing:not(:empty) { padding: 12px 16px 4px; background: #FBF6EC; border-top: 1px solid var(--line); }
.out-missing b { display: block; font-size: 14px; margin-bottom: 8px; color: var(--ink); }
.out-acts { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); }
.out-acts .btn-ghost { text-decoration: none; }
@media (max-width: 480px) { .out-acts > * { flex: 1 1 100%; justify-content: center; } }
.explain-lines { margin-top: 12px; }
.explain-lines summary { cursor: pointer; font-weight: 600; color: var(--ink); padding: 8px 0; }
.explain-lines .ffr { margin-top: 6px; }
.awb-end { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 16px; }
.awb-end span { font-size: 13.5px; color: var(--muted); max-width: 60ch; }
