/* Vanuatu Planning Guide — design system (v2, professional).
   Restrained palette: deep navy chrome, slate neutrals, one teal accent, a warm amber
   reserved for cautions. Inter for the interface, Newsreader for page titles.
   No emoji, no tinted pastel panels. Layout: header + sidebar + ONE section at a time in a
   viewport-height panel, so on desktop only the panel scrolls (see app.js). */

:root {
  --navy: #0b1f33;           /* header */
  --navy-2: #142d47;
  --accent: #0e5a6b;         /* primary action / links / active state */
  --accent-strong: #0a4553;
  --accent-soft: #e8f1f3;
  --page: #f4f6f8;           /* app background */
  --panel: #f4f6f8;
  --card: #ffffff;
  --ink: #101c2b;
  --ink-2: #2c3b4e;
  --muted: #5d6b7c;
  --faint: #8794a4;
  --line: #dfe4ea;
  --line-soft: #eceff3;
  --good: #1d7a4f;
  --warn: #9a6200;
  --bad: #b03a3a;
  --good-bg: #e9f5ee; --warn-bg: #fbf3e2; --bad-bg: #fbeaea;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 28, 43, .05);
  --ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  /* aliases used by inline styles in the section scripts */
  --chrome: var(--navy); --chrome-ink: #fff; --border: var(--line); --text: var(--ink);
  --panel-2: #f7f9fb; --accent-2: var(--accent); --danger: var(--bad); --cond: var(--ui);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.6 var(--ui);
  font-feature-settings: "cv11", "ss01", "tnum";
  -webkit-font-smoothing: antialiased;
  color: var(--ink);
  background: var(--page);
  height: 100vh; overflow: hidden;
  display: grid; grid-template-rows: auto minmax(0, 1fr);
}
button, select, input, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--accent); text-decoration-color: rgba(14, 90, 107, .35); text-underline-offset: 2px; }
a:hover { color: var(--accent-strong); text-decoration-color: currentColor; }
h1, h2, h3, h4 { font-family: var(--ui); font-weight: 600; letter-spacing: -.01em; color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- top bar ---------- */
.topbar {
  background: var(--navy); color: #fff;
  display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 56px;
  border-bottom: 1px solid #000;
}
.brand { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.brand .mark { width: 28px; height: 28px; flex: none; }
.brand b { font: 600 16px/1.1 var(--ui); letter-spacing: -.005em; display: block; color: #fff; }
.brand span { display: block; font-size: 11.5px; color: #9fb3c8; margin-top: 2px; letter-spacing: .01em; }
.search { flex: 1; max-width: 560px; margin-left: 12px; position: relative; }
.search input {
  width: 100%; height: 36px; padding: 0 14px 0 38px; border-radius: 6px; border: 1px solid #2a4560;
  background: #0f2740 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%239fb3c8' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 3.5 3.5'/%3E%3C/svg%3E") 12px 50% no-repeat;
  color: #fff;
}
.search input::placeholder { color: #8aa0b6; }
.search input:focus { outline: none; border-color: #4f86a0; background-color: #12304d; }
.search-results {
  position: absolute; top: 100%; left: 0; right: 0; margin-top: 6px; z-index: 50; display: none;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); max-height: 62vh; overflow-y: auto;
  box-shadow: 0 16px 40px rgba(11, 31, 51, .22); color: var(--ink);
}
.search-results button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line-soft); background: none; padding: 9px 14px; cursor: pointer; color: var(--ink); }
.search-results button:last-child { border-bottom: 0; }
.search-results button:hover { background: var(--accent-soft); }
.search-results small { color: var(--muted); display: block; font-size: 12px; margin-top: 1px; }
.topbar .spacer { flex: 1; }
.topbar .meta { font-size: 12px; color: #9fb3c8; white-space: nowrap; font-variant-numeric: tabular-nums; }
.btn-out { white-space: nowrap; border: 1px solid #2a4560; background: transparent; color: #fff; border-radius: 6px; padding: 7px 13px; cursor: pointer; font-weight: 500; font-size: 13px; }
.btn-out:hover { background: var(--navy-2); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 272px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); min-height: 0; }
.side { background: var(--card); min-height: 0; overflow-y: auto; padding: 12px 10px 24px; border-right: 1px solid var(--line); scrollbar-width: thin; }
.side .grp { margin: 0 0 2px; }
.side h5 {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; user-select: none;
  margin: 14px 0 3px; padding: 4px 10px; font: 600 11px var(--ui); text-transform: uppercase; letter-spacing: .08em; color: var(--faint);
  border-radius: 6px;
}
.side .grp:first-child h5 { margin-top: 2px; }
.side h5:hover { color: var(--ink-2); }
.side h5::after { content: ""; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); margin-top: -3px; transition: transform .15s; }
.side .grp.closed h5::after { transform: rotate(-45deg); margin-top: 0; }
.side .grp.closed button { display: none; }
.side button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: none;
  padding: 6px 10px 6px 12px; border-radius: 6px; cursor: pointer; color: var(--ink-2); font-size: 13.5px;
  border-left: 2px solid transparent; line-height: 1.35;
}
.side button:hover { background: var(--page); color: var(--ink); }
.side button.on { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; border-left-color: var(--accent); border-top-left-radius: 2px; border-bottom-left-radius: 2px; }
.side button .n { margin-left: auto; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; font-weight: 500; }
.main { background: var(--page); min-height: 0; overflow-y: auto; padding: 28px 40px 64px; }
#sec { max-width: 1180px; margin: 0 auto; }
.mobile-nav { display: none; }

@media (max-width: 900px) {
  body { height: auto; overflow: auto; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px 14px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .main { overflow: visible; padding: 18px 14px 40px; min-width: 0; }
  .brand span { display: none; }
  .mobile-nav { display: block; margin: 0 0 14px; }
  .mobile-nav select { width: 100%; padding: 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
  .search { order: 3; max-width: none; flex-basis: 100%; margin-left: 0; }
  .topbar .meta { display: none; }
}

/* ---------- section head ---------- */
.sec-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; padding-bottom: 18px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.sec-head h1 { margin: 0; font: 600 32px/1.12 var(--serif); letter-spacing: -.015em; color: var(--ink); }
.sec-head > div:first-child { flex: 1 1 auto; min-width: 0; max-width: 820px; }
.sec-head p { margin: 8px 0 0; color: var(--muted); max-width: 780px; font-size: 14.5px; line-height: 1.55; }
.sec-head .stamp { flex: 0 1 260px; font-size: 12px; color: var(--muted); text-align: right; }
h2.sub { font: 600 15px var(--ui); margin: 32px 0 12px; color: var(--ink); letter-spacing: -.005em; display: flex; align-items: center; gap: 12px; }
h2.sub::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 0 0 22px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 13px; box-shadow: var(--shadow); }
.kpi .l { font: 500 12px var(--ui); color: var(--muted); letter-spacing: .005em; }
.kpi .v { font: 600 26px/1.15 var(--ui); letter-spacing: -.02em; color: var(--ink); margin: 5px 0 4px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--muted); line-height: 1.45; }
.kpi-link { display: block; color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.kpi-link:hover, .kpi-link:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(73, 98, 117, .14); outline: none; }
/* tap a chart for its figures; tap a table heading to sort the column */
.chart .box canvas { cursor: pointer; }
.chart-pick { margin-top: 8px; padding: 8px 10px; background: var(--accent-soft); border-radius: 8px; font-size: 13px; line-height: 1.5; }
.chart-pick:empty { display: none; }
.chart-pick .cp-title { font-weight: 600; margin-bottom: 2px; }
.chart-pick .cp-row { display: inline-block; margin-right: 14px; }
.tbl th { cursor: pointer; }
.tbl th[data-sort="asc"]::after { content: " ▲"; font-size: 10px; opacity: .7; }
.tbl th[data-sort="desc"]::after { content: " ▼"; font-size: 10px; opacity: .7; }
.map-box { height: 380px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #eef2f5; }

/* ---------- cards & grids ---------- */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 6px; font-size: 15.5px; line-height: 1.3; }
.card p { margin: 0; }
.card .src { font-size: 12px; color: var(--muted); margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line-soft); word-break: break-word; }
.card.flag { border-color: #ead7ae; background: var(--warn-bg); }
.callout { background: var(--warn-bg); border: 1px solid #ecdcb6; border-left: 3px solid #c98a16; border-radius: var(--radius); padding: 11px 15px; color: #5b3f08; margin: 0 0 18px; font-size: 13.5px; }
.callout.info { background: var(--accent-soft); border-color: #cfe2e7; border-left-color: var(--accent); color: #123e49; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
/* long URLs and agency names must wrap, not widen their box */
.card p, .card h3, .card .src, .small, li, .kpi .s { overflow-wrap: anywhere; }

/* ---------- charts ---------- */
.chart { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 10px; box-shadow: var(--shadow); }
.chart h3 { margin: 0 0 3px; font-size: 15.5px; }
.chart .cap { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; line-height: 1.5; }
.chart .box { position: relative; height: 260px; }
.chart.tall .box { height: 340px; }
.chart .foot { font-size: 11.5px; color: var(--muted); margin-top: 8px; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { font: 600 11.5px var(--ui); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #f8fafb; white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.tbl tbody tr:hover td, .tbl tr:hover td { background: #fafcfd; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- pills, badges, buttons ---------- */
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.pill { border: 1px solid var(--line); background: var(--card); color: var(--ink-2); border-radius: 6px; padding: 5px 12px; cursor: pointer; font-size: 13px; font-weight: 500; }
.pill:hover { border-color: #c4ccd6; background: #fafbfc; }
.pill.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 4px; padding: 1px 7px; white-space: nowrap; vertical-align: 1px; letter-spacing: .01em; }
.badge.good { color: var(--good); background: var(--good-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.bad { color: var(--bad); background: var(--bad-bg); }
.badge.info { color: var(--accent); background: var(--accent-soft); }
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 6px; padding: 7px 14px; cursor: pointer; color: var(--ink); font-weight: 500; box-shadow: var(--shadow); }
.btn:hover { background: #fafbfc; border-color: #c4ccd6; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
input.in, select.in { padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--ink); }
input.in:focus, select.in:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14, 90, 107, .14); }

/* ---------- steps timeline ---------- */
.steps { counter-reset: s; position: relative; margin-left: 10px; }
.step { position: relative; padding: 0 0 20px 40px; border-left: 1px solid var(--line); }
.step:last-child { border-left-color: transparent; }
.step::before {
  counter-increment: s; content: counter(s); position: absolute; left: -14px; top: -2px; width: 27px; height: 27px; border-radius: 50%;
  background: var(--navy); color: #fff; font: 600 12.5px/27px var(--ui); text-align: center;
}
.step h3 { margin: 0 0 4px; font-size: 15.5px; }

/* ---------- document (markdown) ---------- */
.doc { max-width: 860px; }
.doc h2 { font: 600 22px var(--serif); margin: 26px 0 8px; color: var(--ink); }
.doc h3 { font-size: 16px; margin: 18px 0 6px; }
.doc p, .doc li { line-height: 1.7; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* map: airport-code labels hidden until zoomed in (see flights-ui drawMap) */
.lbl-off .leaflet-tooltip.code-lbl { display: none; }
.leaflet-tooltip.code-lbl { padding: 1px 5px; font: 600 11px var(--ui); }
.leaflet-container { border-radius: var(--radius); font-family: var(--ui); }

/* ---------- data & updates bar (under every section heading) ---------- */
.updbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 14px; margin: -4px 0 20px; font-size: 12.5px; color: var(--ink-2); box-shadow: var(--shadow); }
.updbar::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--good); flex: none; margin-right: -6px; }
.updbar .sp { flex: 1; }
.updbar .btn { padding: 5px 12px; font-size: 12.5px; }
.updbar .updout { flex-basis: 100%; font-size: 12.5px; }
.updbar .updout:empty { display: none; }

/* ---------- Vanuatu news ---------- */
.news-day { font: 600 11.5px var(--ui); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 22px 0 6px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.news-item { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.news-t { font-weight: 600; font-size: 15px; line-height: 1.4; color: var(--ink); text-decoration: none; }
.news-t:hover { color: var(--accent); text-decoration: underline; }
.news-m { font-size: 12.5px; color: var(--muted); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.news-s { font-size: 13.5px; color: var(--ink-2); margin: 5px 0 0; line-height: 1.5; }

/* ---------- scrollbars ---------- */
.main, .side, .search-results { scrollbar-color: #c5cdd7 transparent; }
.main::-webkit-scrollbar, .side::-webkit-scrollbar { width: 10px; }
.main::-webkit-scrollbar-thumb, .side::-webkit-scrollbar-thumb { background: #cdd4dc; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }

@media print {
  body { height: auto; overflow: visible; background: #fff; }
  .topbar, .side, .updbar, .mobile-nav { display: none; }
  .main { overflow: visible; padding: 0; }
  .card, .chart, .kpi { box-shadow: none; break-inside: avoid; }
}

/* ---------- phones: MUST stay last so these beat the base card/grid rules above ---------- */
@media (max-width: 900px) {
  .sec-head { flex-direction: column; align-items: flex-start; gap: 6px; }
  .sec-head h1 { font-size: 26px; }
  .sec-head .stamp { text-align: left; white-space: normal; }
  .grid, .grid.two { grid-template-columns: minmax(0, 1fr); }
  .card, .chart, .kpi { min-width: 0; }
  ol.small { columns: 1 !important; }
  .grid[style*="1fr 1fr"] { grid-template-columns: minmax(0, 1fr) !important; }
  select.in, input.in { max-width: 100%; }
}
