:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #1b2330;
  --muted: #667085;
  --border: #e3e7ee;
  --accent: #c8102e;        /* Canadian red */
  --accent-ink: #ffffff;
  --link: #1d4ed8;
  --ok-bg: #e7f6ec; --ok: #1b7a3a;
  --warn-bg: #fff4e0; --warn: #9a5b00;
  --bad-bg: #fde8e8; --bad: #a61b1b;
  --info-bg: #e8effd; --info: #1d4ed8;
  --neutral-bg: #eef0f3;
  /* Chart series, validated for colour-blind separation and contrast on this surface. */
  --series-1: #2a78d6;
  --series-2: #eb6834;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151b; --surface: #181e26; --text: #e6e9ee; --muted: #9aa4b2; --border: #2a323d;
    --link: #8ab4ff;
    --ok-bg: #12301d; --ok: #7bd897;
    --warn-bg: #3a2a0c; --warn: #f2c06b;
    --bad-bg: #3a1515; --bad: #f19a9a;
    --info-bg: #172443; --info: #8ab4ff;
    --neutral-bg: #262d37;
    --series-1: #3987e5;
    --series-2: #d95926;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.8rem; margin: .4em 0; }
h2 { font-size: 1.2rem; margin: 1.6em 0 .5em; }
.muted { color: var(--muted); font-size: .9em; }
.small { font-size: .85em; }
.warn { color: var(--warn); font-size: .9em; }

header.site {
  display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); }
.brand span { color: var(--accent); }
header nav { display: flex; flex-wrap: wrap; gap: 16px; }
header nav a { color: var(--text); }
main { max-width: 1180px; margin: 0 auto; padding: 16px 24px 48px; }
footer.site { text-align: center; color: var(--muted); font-size: .85em; padding: 24px; border-top: 1px solid var(--border); }

.flash { background: var(--ok-bg); color: var(--ok); padding: 10px 14px; border-radius: 8px; margin: 8px 0 16px; }
.errors { background: var(--bad-bg); color: var(--bad); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.errors ul { margin: 4px 0 0; }

.hero { padding: 24px 0 8px; }
.hero h1 { font-size: 2.2rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; margin: 16px 0; }
.card h2 { margin-top: 0; }
.empty { padding: 32px; text-align: center; background: var(--surface); border: 1px dashed var(--border); border-radius: 10px; }

input, select, textarea, button, .button {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; max-width: 100%;
}
button, .button {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent); cursor: pointer;
  display: inline-block; white-space: nowrap;
}
button:hover, .button:hover { filter: brightness(1.08); text-decoration: none; }
button.secondary, .button.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
button.small, .button.small { padding: 3px 8px; font-size: .82em; }

form.inline, form.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
form.filters input[type=search] { flex: 1 1 260px; }
form.inline select { flex: 1 1 220px; min-width: 0; }
form.calc { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 16px; }
form.calc label { display: flex; flex-direction: column; font-size: .85em; color: var(--muted); gap: 4px; }
form.calc .or { color: var(--muted); padding-bottom: 8px; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78em; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--bg); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: flex-start; }
.actions form { margin: 0; }
.actions details { width: 100%; }
.actions summary { cursor: pointer; color: var(--muted); }

/* Fee tables use fixed widths so columns line up from one fee type's table to the next. */
.table-scroll { overflow-x: auto; }
table.fee-rules { table-layout: fixed; min-width: 620px; }
.fee-rules .c-applies { width: 20%; }
.fee-rules .c-rate { width: 24%; }
.fee-rules .c-source { width: 24%; }
.fee-rules .c-updated { width: 14%; }
.fee-rules .c-actions { width: 18%; }
.fee-rules td { overflow-wrap: anywhere; }
tr.superseded td, tr.rejected td { opacity: .65; }

.badge { display: inline-block; font-size: .75em; padding: 1px 7px; border-radius: 999px; background: var(--neutral-bg); white-space: nowrap; margin: 1px 0; }
.src-official { background: var(--info-bg); color: var(--info); }
.src-crowd { background: var(--neutral-bg); color: var(--text); }
.st-verified { background: var(--ok-bg); color: var(--ok); }
.st-unverified { background: var(--neutral-bg); color: var(--muted); }
.st-rejected { background: var(--bad-bg); color: var(--bad); }
.st-superseded { background: var(--neutral-bg); color: var(--muted); }
.fr-fresh { background: var(--ok-bg); color: var(--ok); }
.fr-aging { background: var(--warn-bg); color: var(--warn); }
.fr-stale { background: var(--bad-bg); color: var(--bad); }

.crumbs { color: var(--muted); margin: 8px 0 0; }
.codes { color: var(--muted); font-weight: 500; font-size: .7em; }
.links { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.estimate { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 24px; margin: 12px 0 4px; }
.estimate dt { font-size: .8em; color: var(--muted); }
.estimate dd { margin: 0; font-size: 1.1em; }
.visit-total { border-top: 1px solid var(--border); padding-top: 8px; margin: 8px 0 4px; }
.history { margin-top: 24px; }
.history summary { cursor: pointer; color: var(--muted); margin-bottom: 8px; }
.tags a { display: inline-block; margin: 2px 6px 2px 0; }

form.grid { display: grid; gap: 16px; max-width: 820px; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px 16px; background: var(--surface);
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
legend { font-weight: 600; padding: 0 6px; }
fieldset label { display: flex; flex-direction: column; gap: 4px; font-size: .88em; color: var(--muted); }
fieldset label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.stack textarea { min-height: 60px; }
button.primary { justify-self: start; padding: 10px 20px; font-weight: 600; }
.hp { position: absolute; left: -9999px; }

.map { height: 70vh; min-height: 420px; border: 1px solid var(--border); border-radius: 10px; z-index: 0; }
.map.mini { height: 100%; min-height: 220px; }
.map.home { height: 420px; min-height: 0; }
.map.picker { height: 320px; grid-column: 1 / -1; }
.airport-top { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 16px; margin: 16px 0; }
.airport-top > * { min-width: 0; }
.airport-top .card { margin: 0; }
.airport-top > .card:only-child { grid-column: 1 / -1; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; list-style: none; padding: 0; font-size: .88em; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.dot.fr-fresh { background: #1b7a3a; } .dot.fr-aging { background: #c27c00; } .dot.fr-stale { background: #a61b1b; } .dot.none { background: #98a2b3; }
.leaflet-tooltip.fee-label { font-weight: 600; padding: 1px 5px; }
.leaflet-popup-content { font: 14px/1.45 system-ui, sans-serif; }
.admin-link { margin-top: 32px; }
.admin-nav { display: flex; gap: 16px; border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 8px; }
.admin-nav a.active { font-weight: 600; color: var(--text); }
.missing { color: var(--warn); font-size: .85em; }
.notice { background: var(--warn-bg); color: var(--warn); padding: 10px 14px; border-radius: 8px; margin: 8px 0 12px; }
.ap-pending { background: var(--warn-bg); color: var(--warn); }
.ap-rejected { background: var(--bad-bg); color: var(--bad); }
.new-airport { grid-column: 1 / -1; }
.new-airport summary { cursor: pointer; color: var(--link); }
.new-airport .fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }

.prose { max-width: 720px; }
.prose li { margin-bottom: 6px; }
code { background: var(--neutral-bg); padding: 1px 5px; border-radius: 4px; }

@media (max-width: 720px) {
  main { padding: 12px 16px 40px; }
  header.site { padding: 12px 16px; }
  table:not(.fee-rules) { display: block; overflow-x: auto; }
  .airport-top { grid-template-columns: 1fr; }
  .map.mini { height: 220px; }
}
.leaflet-container a.map-add-fee { color: var(--accent-ink); font-size: 14px; font-weight: 600; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.leaflet-container a.map-add-fee:hover { text-decoration: none; }
.with-unit { display: flex; gap: 4px; }
.with-unit input { width: 8em; }

.stat-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin: 16px 0; }
.stat-tiles .card { margin: 0; }
.stat { font-size: 1.9rem; font-weight: 700; line-height: 1.2; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 24px; }
.two-col > * { min-width: 0; }
h3 { font-size: 1rem; margin: 1.2em 0 .5em; }
tr.selected td { background: var(--info-bg); }
th.c-bar, td.c-bar { width: 30%; }
.bar { display: inline-block; height: 10px; border-radius: 3px; background: var(--accent); opacity: .75; vertical-align: middle; }
/* Fixed columns so the cheapest and most expensive tables line up side by side. */
table.rank { table-layout: fixed; }
table.rank .c-prov { width: 70px; }
table.rank .c-amount { width: 110px; }
table.rank th { white-space: nowrap; }

/* Bar charts on the stats page */
.charts { margin: 12px 0 16px; }
figure.chart { margin: 0 0 16px; }
figure.chart figcaption { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.chart-legend { display: flex; gap: 16px; list-style: none; padding: 0; margin: 0 0 10px; font-size: .85em; color: var(--muted); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: fit-content(36%) 1fr auto; gap: 6px 10px; align-items: center; font-size: .88em; }
.hbar .label { line-height: 1.25; }
.hbar .track { display: flex; gap: 2px; height: 14px; min-width: 0; }
.hbar .seg { height: 100%; min-width: 2px; }
.hbar .seg:last-child { border-radius: 0 4px 4px 0; }
.hbar .val { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.s1 { background: var(--series-1); }
.s2 { background: var(--series-2); }
