:root {
  --bg: #0a1220;
  --bg2: #0f1b2e;
  --bg3: #16233a;
  --line: #233452;
  --text: #e6edf7;
  --muted: #8ba0bd;
  --accent: #3b82f6;
  --accent2: #22d3ee;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
}
h1, h2 { margin: 0; font-weight: 650; }

/* gate */
#gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #152a4a 0%, var(--bg) 60%);
}
#gate[hidden] { display: none; }
.gate-card {
  width: min(360px, 90vw);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px;
  text-align: center;
}
.gate-card h1 { font-size: 22px; }
.gate-card input {
  width: 100%;
  margin: 14px 0;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg3);
  color: var(--text);
}
.muted { color: var(--muted); }
.err { color: #f87171; }
.admin-link { color: var(--accent2); text-decoration: none; }
.admin-link:hover { text-decoration: underline; }

/* layout */
#app[hidden] { display: none; }
#app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo-symbol {
  width: 14px; height: 18px;
  position: relative;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--accent2), var(--accent));
  clip-path: polygon(50% 0, 100% 42%, 78% 46%, 100% 62%, 50% 100%, 0 62%, 22% 46%, 0 42%);
}
.brand h1 { font-size: 17px; letter-spacing: .3px; }
.status { color: var(--muted); font-size: 13px; flex: 1; }
.status b { color: var(--text); }
.status .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.dot.ok { background: #34d399; }
.dot.err { background: #f87171; }
.dot.stale { background: #fbbf24; }

.controls { display: flex; align-items: center; gap: 8px; }
.mini { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }

button {
  cursor: pointer;
  border-radius: 8px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  background: var(--bg3);
  color: var(--text);
  font-size: 13px;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; }
button.danger:hover { border-color: #f87171; color: #f87171; }
button.active { background: var(--accent); border-color: var(--accent); }

select, input[type="text"], input[type="number"], input[type="password"] {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

.layout { display: grid; grid-template-columns: 300px 1fr; flex: 1; min-height: 0; }

.sidebar {
  overflow-y: auto;
  background: var(--bg2);
  border-right: 1px solid var(--line);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sidebar h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.frow { display: flex; flex-direction: column; gap: 4px; }
.frow label { font-size: 12px; color: var(--muted); }
.fd { width: 100%; }
.fd.small { width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.btnrow { display: flex; gap: 6px; align-items: center; }
.btnrow .fd { flex: 1; }
.tiny { font-size: 11px; }

#summaryBox { background: var(--bg3); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
#summaryBox h3 { margin: 0 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.sumrow { display: flex; justify-content: space-between; padding: 3px 0; font-size: 13px; }
.sumrow .bar { flex: 1; height: 5px; background: var(--line); border-radius: 3px; margin: 0 8px; align-self: center; overflow: hidden; }
.sumrow .bar i { display: block; height: 100%; background: var(--accent2); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.maptoolbar { position: relative; flex: 1 1 55%; min-height: 240px; }
#map { position: absolute; inset: 0; background: #0d1626; z-index: 0; }
.legend {
  position: absolute;
  z-index: 500;
  right: 10px;
  bottom: 24px;
  background: rgba(13, 22, 38, .85);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11px;
  color: var(--muted);
}
.legend span { margin-right: 10px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  background: var(--bg2);
  border-top: 1px solid var(--line);
}
.tabs button { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }

.pane { flex: 1 1 45%; overflow: auto; background: var(--bg); }
#flightsTable { width: 100%; border-collapse: collapse; font-size: 13px; }
#flightsTable th {
  position: sticky; top: 0;
  text-align: left;
  background: var(--bg2);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
#flightsTable td { padding: 6px 10px; border-bottom: 1px solid #16233a; white-space: nowrap; }
#flightsTable tbody tr { cursor: pointer; }
#flightsTable tbody tr:hover { background: var(--bg2); }
#flightsTable .num { text-align: right; font-variant-numeric: tabular-nums; }
.idchip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
  color: #fff;
}
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* map marker styles */
.mk { background: transparent; border: none; }
.mk-inner {
  width: 11px; height: 11px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid rgba(255,255,255,.9);
  box-shadow: 0 0 6px rgba(0,0,0,.6);
}
.mk-projected { opacity: .45; }

/* drawer */
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(440px, 92vw);
  background: var(--bg2);
  border-left: 1px solid var(--line);
  box-shadow: -10px 0 30px rgba(0,0,0,.4);
  z-index: 900;
  padding: 18px;
  overflow-y: auto;
}
.drawer[hidden] { display: none; }
#closeDrawer { position: absolute; top: 12px; right: 14px; }
.drawer h2 { font-size: 18px; margin-bottom: 4px; }
.drawer .sub { color: var(--muted); }
.drow { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #16233a; font-size: 13px; }
.drow .k { color: var(--muted); }
.drawl { padding: 6px 0; font-size: 13px; }
.drawl .k { color: var(--muted); display: block; margin-bottom: 2px; }
.detail-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 10px;
}
.badge-airborne { background: #164e63; color: #67e8f9; }
.badge-scheduled { background: #1e293b; color: #cbd5e1; }
.badge-landed { background: #14532d; color: #86efac; }
a.fa-link { color: var(--accent2); }

#ftNote { margin-top: auto; }

/* maldives fis board */
.seg { display: flex; gap: 4px; }
.seg button { padding: 5px 10px; font-size: 12px; }
.seg button.active { background: var(--accent); border-color: var(--accent); }

.fisbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
}
.fisbar select, .fisbar input { width: auto; min-width: 110px; padding: 6px 8px; }
.fis-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.fis-filters[hidden] { display: none; }
#fisFilterToggle { font-size: 12px; padding: 6px 8px; line-height: 1; }
#fisQuery { flex: 1; min-width: 160px; }
#fisMeta { color: var(--muted); font-size: 12px; }

#fisTable { width: 100%; border-collapse: collapse; font-size: 13px; }
#fisTable th {
  position: sticky; top: 0;
  text-align: left;
  background: var(--bg2);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
#fisTable td { padding: 6px 10px; border-bottom: 1px solid #16233a; white-space: nowrap; }
.fis-flight { font-weight: 600; }
.fis-id-intl { background: var(--accent); }
.fis-id-dom { background: var(--accent2); color: #062033; }
.fis-airline { color: var(--muted); }
.delay { color: #fbbf24; font-size: 12px; }
.fis-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.st-on-time { background: #14532d; color: #86efac; }
.st-delayed { background: #78350f; color: #fcd34d; }
.st-cancelled { background: #7f1d1d; color: #fca5a5; }
.st-landed { background: #1e3a8a; color: #93c5fd; }
.st-departed { background: #581c87; color: #d8b4fe; }
.st-boarding { background: #155e75; color: #67e8f9; }
.st-scheduled { background: #1e293b; color: #cbd5e1; }

.leaflet-container { font: 13px/1.4 ui-sans-serif, system-ui, sans-serif; }
.leaflet-tile-pane { filter: saturate(.85) brightness(.9); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { max-height: 42vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .maptoolbar { min-height: 200px; }
}