:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #16202b;
  --muted: #5b6878;
  --line: #d9dfe7;
  --brand: #0b3a6e;
  --brand-2: #1560b0;
  --ok: #1a7f37;
  --ok-bg: #e6f4ea;
  --warn: #9a6700;
  --warn-bg: #fff4d6;
  --bad: #b42318;
  --bad-bg: #fde7e5;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a;
    --card: #18202a;
    --text: #e6edf3;
    --muted: #9aa7b5;
    --line: #2b3643;
    --brand: #0b3a6e;
    --brand-2: #4a9bea;
    --ok: #56d364;
    --ok-bg: #12301b;
    --warn: #e3b341;
    --warn-bg: #33290c;
    --bad: #ff7b72;
    --bad-bg: #3a1614;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", Sarabun, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
[hidden] { display: none !important; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--brand); color: #fff;
}
.brand span { opacity: .8; margin-left: 6px; font-size: .9em; }
.userbox { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .9em; }
.userbox .ghost { color: #fff; border-color: rgba(255,255,255,.5); }
.safety {
  background: var(--warn-bg); color: var(--text); border-bottom: 1px solid var(--line);
  padding: 8px 16px; font-size: .9em;
}
main { max-width: 900px; margin: 0 auto; padding: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
}
.narrow { max-width: 420px; margin: 24px auto; }
h1 { font-size: 1.3em; margin: 0 0 12px; }
h2 { font-size: 1.15em; margin: 0 0 12px; }
h3 { font-size: 1.05em; margin: 20px 0 8px; }
label { display: block; margin: 0 0 10px; font-size: .92em; color: var(--muted); }
label.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 9px 10px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
label.inline input { width: auto; margin: 0; }
textarea { min-height: 70px; resize: vertical; }
button {
  font: inherit; cursor: pointer; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--brand-2);
  background: var(--brand-2); color: #fff;
}
button.ghost { background: transparent; color: var(--brand-2); }
button.danger { background: var(--bad); border-color: var(--bad); }
button.small { padding: 4px 10px; font-size: .88em; }
button:disabled { opacity: .5; cursor: default; }
form button { margin: 4px 6px 4px 0; }
.msg { min-height: 1.2em; color: var(--bad); font-size: .92em; }
.msg.ok { color: var(--ok); }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; }
.tab { flex: 1; background: var(--card); color: var(--text); border-color: var(--line); white-space: nowrap; }
.tab.active { background: var(--brand-2); color: #fff; border-color: var(--brand-2); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.list { display: grid; gap: 10px; }
.empty { color: var(--muted); text-align: center; padding: 24px; }
.date-head { margin: 14px 0 2px; font-weight: 600; color: var(--muted); }

.flight-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.flight-no { font-size: 1.2em; font-weight: 700; }
.meta { color: var(--muted); font-size: .92em; display: flex; gap: 12px; flex-wrap: wrap; margin: 4px 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chip { padding: 2px 10px; border-radius: 999px; font-size: .85em; border: 1px solid var(--line); }
.chip.need { background: var(--bad-bg); color: var(--bad); border-color: transparent; font-weight: 600; }
.badge { padding: 2px 10px; border-radius: 999px; font-size: .82em; font-weight: 600; }
.badge.open { background: var(--ok-bg); color: var(--ok); }
.badge.caution, .badge.pending, .badge.new { background: var(--warn-bg); color: var(--warn); }
.badge.closed, .badge.cancelled, .badge.unavailable, .badge.rejected, .badge.declined { background: var(--bad-bg); color: var(--bad); }
.badge.filled, .badge.volunteer, .badge.approved, .badge.assigned, .badge.acknowledged { background: var(--ok-bg); color: var(--ok); }
.notes { white-space: pre-wrap; margin: 6px 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.my-report { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--bg); font-size: .92em; }

table.reports { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: .88em; }
table.reports th, table.reports td { text-align: left; padding: 6px 4px; border-top: 1px solid var(--line); vertical-align: top; }
table.reports select { padding: 4px; margin: 0; }
.table-wrap { overflow-x: auto; }

.route { border-left: 5px solid var(--line); }
.route.open { border-left-color: var(--ok); }
.route.caution { border-left-color: var(--warn); }
.route.closed { border-left-color: var(--bad); }
.small-muted { color: var(--muted); font-size: .85em; }

dialog {
  width: min(520px, calc(100vw - 24px)); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--text); padding: 16px;
}
dialog::backdrop { background: rgba(0,0,0,.45); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 10px; }
@media (max-width: 480px) { .grid2, .grid3 { grid-template-columns: 1fr 1fr; } }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); max-width: calc(100vw - 32px);
  background: #16202b; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.grow { flex: 1; min-width: 200px; margin: 0; }
#formAddAdmin { margin-bottom: 12px; align-items: flex-end; }
.badge.unknown { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.route.unknown { border-left-color: var(--muted); }
.card.flight { padding-top: 0; overflow: hidden; }
.card.flight .flight-head { padding-top: 12px; }
.urgent-band {
  margin: 0 -16px; padding: 8px 16px; background: #3b1260; color: #fff; font-weight: 700;
  border-bottom: 3px solid #f2b705;
}
.sector { color: var(--muted); font-size: .8em; }
.aircraft {
  display: inline-block; margin: 6px 0 2px; padding: 3px 12px; border-radius: 999px;
  background: #3b1260; color: #f2b705; font-weight: 700;
}
img.poster { width: 100%; height: auto; border-radius: 8px; display: block; }
a.button {
  display: inline-block; padding: 8px 14px; border-radius: 8px; background: var(--brand-2); color: #fff; text-decoration: none;
}
.poster-view {
  position: fixed; inset: 0; z-index: 50; background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.poster-view img { max-width: 100vw; max-height: 100vh; object-fit: contain; cursor: pointer; }
.poster-bar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  align-items: center; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: rgba(0,0,0,.75);
}
.poster-bar .small-muted { color: #ccc; width: 100%; text-align: center; }
.poster-bar .ghost { color: #fff; border-color: #fff; }
.poster-view.clean .poster-bar { display: none; }
details.avail { margin: 8px 0; padding: 6px 10px; border-radius: 8px; background: var(--ok-bg); }
details.avail summary { cursor: pointer; font-weight: 600; color: var(--ok); }
details.avail ul { margin: 6px 0 0; padding-left: 18px; }
.tabs .tab { padding: 8px 6px; font-size: .92em; }
.card.update { border-left: 5px solid var(--brand-2); margin-bottom: 10px; }
.card.update.warning { border-left-color: var(--warn); background: var(--warn-bg); }
.card.update.critical { border-left-color: var(--bad); background: var(--bad-bg); }
#latestUpdate .card.update { margin-bottom: 12px; }
.refresh-info { margin: 0 0 8px; }
.is-new { outline: 3px solid #f2b705; outline-offset: -3px; animation: newpulse 1.2s ease-in-out 3; }
tr.is-new td, li.is-new { background: rgba(242,183,5,.18); }
tr.is-new, li.is-new { outline: none; animation: none; }
.new-tag {
  display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: .7em; font-weight: 700;
  background: #f2b705; color: #3b1260; vertical-align: middle;
}
@keyframes newpulse { 50% { outline-color: rgba(242,183,5,.25); } }
@media (prefers-reduced-motion: reduce) { .is-new { animation: none; } }

/* ---- guide page ---- */
.guide main { max-width: 820px; line-height: 1.6; }
.guide h2 { margin: 36px 0 10px; padding-top: 8px; border-top: 2px solid var(--line); font-size: 1.3em; }
.guide h3 { margin-top: 26px; }
.guide section { scroll-margin-top: 12px; }
.guide .lead { font-size: 1.05em; }
.guide .toc ol { margin: 6px 0 0; padding-left: 22px; }
.guide .toc ol ol { padding-left: 18px; }
.guide .steps li, .guide ul li { margin: 4px 0; }
.guide .note { padding: 8px 12px; border-radius: 8px; background: var(--warn-bg); }
.guide .chips-line .badge { margin: 0 2px; }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin: 12px 0 16px; }
.shots.one { grid-template-columns: minmax(140px, 260px); }
.shots figure { margin: 0; }
.shots img { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 10px; display: block; background: var(--card); }
.shots figcaption { font-size: .85em; color: var(--muted); text-align: center; margin-top: 4px; }
.guide-table { width: 100%; border-collapse: collapse; margin: 10px 0; background: var(--card); }
.guide-table th, .guide-table td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.faq dt { font-weight: 700; margin-top: 12px; }
.faq dd { margin: 2px 0 0 0; color: var(--muted); }
a.small-link { padding: 4px 10px; font-size: .88em; background: transparent; border: 1px solid rgba(255,255,255,.5); }
.guide-foot { margin: 30px 0; text-align: center; }
.guide-link { color: #fff; font-size: .88em; }
