/* VSR Fleet — dark operations dashboard. Accent comes from the VSR logo's indigo. */
:root {
  color-scheme: dark;
  --bg: #0B1220;
  --bg-2: #0E1628;
  --panel: #111A2C;
  --panel-2: #172238;
  --panel-3: #1C2943;
  --line: #22304B;
  --line-soft: #1A2740;
  --text: #E9EDF5;
  --muted: #8E9AB3;
  --faint: #5E6B86;
  --brand: #2F317E;
  --brand-hi: #8186F2;
  --brand-soft: rgba(129, 134, 242, 0.14);
  --air: #3DDC91;
  --air-soft: rgba(61, 220, 145, 0.13);
  --ground: #7EA8F0;
  --ground-soft: rgba(126, 168, 240, 0.13);
  --maint: #F4B740;
  --maint-soft: rgba(244, 183, 64, 0.14);
  --aog: #FF6F61;
  --aog-soft: rgba(255, 111, 97, 0.14);
  --off: #A3ACBE;
  --off-soft: rgba(163, 172, 190, 0.12);
  --globe: #0D1524;
  --radius-l: 14px;
  --radius-m: 10px;
  --radius-s: 7px;
  --display: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;
  --sans: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --shadow: 0 10px 30px rgba(3, 7, 16, 0.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 var(--sans);
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body.loading #main, body.loading .foot { visibility: hidden; }
a { color: var(--brand-hi); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { width: 18px; height: 18px; flex: none; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 600; letter-spacing: 0.005em; }
h1 { font-size: 30px; line-height: 1.1; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand-hi); outline-offset: 2px; border-radius: 6px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 20px;
  height: 62px; padding: 0 22px;
  background: rgba(11, 18, 32, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none !important; }
.brand img { height: 28px; width: auto; display: block; }
.brand span { font-family: var(--display); font-weight: 500; font-size: 21px; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--line); line-height: 1; }
.tabs { display: flex; gap: 4px; margin: 0 auto; }
.tabs a {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: var(--radius-m);
  color: var(--muted); font-weight: 500; text-decoration: none;
  border: 1px solid transparent;
}
.tabs a:hover { color: var(--text); background: var(--panel); }
.tabs a[aria-current="page"] { color: var(--text); background: var(--panel-2); border-color: var(--line); }
.tabs a[aria-current="page"] svg { color: var(--brand-hi); }
.top-actions { display: flex; align-items: center; gap: 10px; }

.seg { display: inline-flex; padding: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; }
.seg button { border: 0; background: none; padding: 4px 10px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--panel-3); color: var(--text); }

.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 9px;
  border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.badge-dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--aog); box-shadow: 0 0 0 2px var(--bg); }

.avatar-btn { display: flex; align-items: center; gap: 4px; padding: 3px 6px 3px 3px; border: 0; background: none; border-radius: 22px; cursor: pointer; color: var(--muted); }
.avatar-btn:hover { background: var(--panel-2); }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 600; font-size: 14px; letter-spacing: 0.02em; }
.chev { width: 16px; height: 16px; }

/* ---------- Popovers ---------- */
.pop-wrap { position: relative; }
.pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40;
  width: 340px; max-height: 70vh; overflow: auto;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-l);
  box-shadow: var(--shadow); padding: 6px;
}
.pop-menu { width: 240px; }
.pop-head { display: flex; flex-direction: column; padding: 10px 12px 8px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; background: none; border-radius: 8px; color: var(--text); text-align: left; cursor: pointer; text-decoration: none !important; font-size: 14px; }
.menu-item:hover { background: var(--panel-3); }
.menu-item svg { color: var(--muted); }
.menu-seg { display: none; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 12px 10px; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.check:hover { background: var(--panel-3); }
.check input { accent-color: var(--brand-hi); width: 16px; height: 16px; }
.feed { list-style: none; margin: 0; padding: 0 4px 6px; }
.feed li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 9px 8px; border-radius: 8px; }
.feed li + li { border-top: 1px solid var(--line-soft); }
.feed .f-ico { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--panel-3); color: var(--muted); }
.feed .f-ico svg { width: 16px; height: 16px; }
.feed .f-ico.departed { background: var(--air-soft); color: var(--air); }
.feed .f-ico.landed { background: var(--ground-soft); color: var(--ground); }
.feed .f-ico.status { background: var(--maint-soft); color: var(--maint); }
.feed .f-ico.security { background: var(--aog-soft); color: var(--aog); }
.feed .f-text { font-size: 14px; }
.feed .f-time { font-size: 12px; color: var(--faint); }
.feed .unread .f-text { font-weight: 600; }
.feed-empty { padding: 14px 12px; color: var(--muted); font-size: 14px; }

/* ---------- Layout ---------- */
main { flex: 1; padding: 22px 22px 8px; width: 100%; max-width: 1640px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.lede { margin: 6px 0 0; color: var(--muted); }
.updated { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.updated .icon-btn { border-color: var(--line); background: var(--panel); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.live-dot.ok { background: var(--air); box-shadow: 0 0 0 3px var(--air-soft); }
.live-dot.stale { background: var(--maint); }

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.stat {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 14px;
  align-items: center; text-align: left;
  padding: 14px 16px; background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius-l);
  color: var(--text); cursor: pointer; text-decoration: none !important;
}
.stat:hover { border-color: var(--line); background: var(--panel-2); }
.stat.active { border-color: var(--brand-hi); box-shadow: inset 0 0 0 1px var(--brand-hi); }
.stat-ico { grid-row: 1 / 3; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; }
.stat-ico svg { width: 22px; height: 22px; }
.ico-all { background: var(--brand-soft); color: var(--brand-hi); }
.ico-air { background: var(--air-soft); color: var(--air); }
.ico-ground { background: var(--ground-soft); color: var(--ground); }
.ico-maint { background: var(--maint-soft); color: var(--maint); }
.ico-sched { background: var(--brand-soft); color: var(--brand-hi); }
.stat-n { font-family: var(--display); font-weight: 600; font-size: 28px; line-height: 1; }
.stat-l { color: var(--muted); font-size: 14px; }

.dash { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.side { display: grid; gap: 16px; position: sticky; top: 78px; }
.panel { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius-l); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.count { color: var(--muted); font-weight: 500; }
.tools { display: flex; gap: 8px; align-items: center; }
.search { display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 38px; width: 260px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-m); color: var(--muted); }
.search:focus-within { border-color: var(--brand-hi); }
.search input { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); font: inherit; font-size: 14px; outline: none; }
.search input::placeholder { color: var(--faint); }
.pop-right { right: 0; }

/* ---------- Buttons & form controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: var(--radius-m);
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap; text-decoration: none !important;
}
.btn:hover { background: var(--panel-3); }
.btn.primary { background: var(--brand-hi); border-color: var(--brand-hi); color: #0B1024; font-weight: 600; }
.btn.primary:hover { background: #9397F5; }
.btn.danger { color: var(--aog); border-color: rgba(255, 111, 97, 0.4); background: transparent; }
.btn.danger:hover { background: var(--aog-soft); }
.btn.ghost { background: transparent; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.link { border: 0; background: none; padding: 0; color: var(--brand-hi); cursor: pointer; font: inherit; }
.link:hover { text-decoration: underline; }

label.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-s);
  color: var(--text); font: inherit; font-size: 15px;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.input:focus { outline: none; border-color: var(--brand-hi); box-shadow: 0 0 0 3px var(--brand-soft); }
.input.code { text-transform: uppercase; font-family: var(--display); font-weight: 600; letter-spacing: 0.03em; }
.input::placeholder { color: var(--faint); text-transform: none; font-family: var(--sans); font-weight: 400; letter-spacing: 0; }
input[type="date"].input, input[type="time"].input { color-scheme: dark; }
.form-error { color: var(--aog); font-size: 14px; margin: 0; }
.form-ok { color: var(--air); font-size: 14px; margin: 0; }
.hint { color: var(--faint); font-size: 13px; margin: 0; }

/* ---------- Status pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px; border-radius: 8px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.pill svg { width: 15px; height: 15px; }
.pill.air { background: var(--air-soft); color: var(--air); }
.pill.ground { background: var(--ground-soft); color: var(--ground); }
.pill.maintenance { background: var(--maint-soft); color: var(--maint); }
.pill.aog { background: var(--aog-soft); color: var(--aog); }
.pill.unavailable, .pill.unknown { background: var(--off-soft); color: var(--off); }
.pill.late { background: var(--maint-soft); color: var(--maint); }
.pill.enroute { background: var(--air-soft); color: var(--air); }
.pill.upcoming { background: var(--brand-soft); color: var(--brand-hi); }
.pill.landed { background: var(--ground-soft); color: var(--ground); }
.pill.past { background: var(--off-soft); color: var(--off); }
.pill.sm { height: 24px; padding: 0 8px; font-size: 12px; }

/* ---------- Fleet table ---------- */
.table { width: 100%; }
.thead, .row {
  display: grid;
  grid-template-columns: minmax(180px, 1.25fr) 128px minmax(130px, 0.95fr) minmax(170px, 1.2fr) 28px;
  gap: 14px; align-items: center; padding: 0 18px;
}
.thead { height: 42px; color: var(--muted); font-size: 13px; font-weight: 500; border-bottom: 1px solid var(--line-soft); }
.row { min-height: 72px; border-bottom: 1px solid var(--line-soft); cursor: pointer; position: relative; }
.row:last-child { border-bottom: 0; }
.row:hover { background: rgba(255, 255, 255, 0.02); }
.row.selected { background: var(--brand-soft); }
.row.selected::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand-hi); }
.ac { display: flex; align-items: center; gap: 12px; min-width: 0; }
.thumb {
  flex: none; width: 68px; height: 44px; border-radius: 8px; overflow: hidden;
  background: linear-gradient(160deg, #1D2A46, #121B2E); display: grid; place-items: center; border: 1px solid var(--line-soft);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .sil { width: 58px; height: 28px; color: #3A4A6C; }
.tail { font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: 0.02em; line-height: 1.1; }
.sub { color: var(--muted); font-size: 13px; line-height: 1.3; }
.ac-text { min-width: 0; }
.ac-text .sub, .loc .sub, .nf .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.route-line { font-family: var(--display); font-weight: 600; font-size: 15.5px; letter-spacing: 0.02em; white-space: nowrap; }
.route-line .arrow { color: var(--faint); margin: 0 4px; font-family: var(--sans); }
.nf { display: grid; grid-template-columns: 18px 1fr; column-gap: 8px; align-items: start; }
.nf > div { min-width: 0; }
.nf svg { width: 16px; height: 16px; color: var(--faint); margin-top: 2px; }
.nf-when { font-size: 14px; font-weight: 500; }
.go { color: var(--faint); display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; border: 0; background: none; cursor: pointer; }
.go:hover { color: var(--text); background: var(--panel-3); }
.empty { padding: 26px 18px; color: var(--muted); text-align: center; margin: 0; }

/* ---------- Map ---------- */
.map-panel { position: relative; height: 380px; overflow: hidden; }
#map { position: absolute; inset: 0; background: var(--globe); }
.map-tools { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; z-index: 2; }
.map-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 10px;
  border-radius: 8px; border: 1px solid var(--line); background: rgba(17, 26, 44, 0.9); color: var(--muted);
  font-size: 13px; font-weight: 500; cursor: pointer; backdrop-filter: blur(6px);
}
.map-btn:hover { color: var(--text); }
.map-btn[aria-pressed="true"] { color: var(--text); border-color: rgba(129, 134, 242, 0.5); }
.map-btn[aria-pressed="true"] svg { color: var(--brand-hi); }
.map-btn svg { width: 16px; height: 16px; }
.maplibregl-ctrl-group { background: rgba(17, 26, 44, 0.92) !important; border: 1px solid var(--line); box-shadow: none !important; border-radius: 9px !important; }
.maplibregl-ctrl-group button { width: 34px; height: 34px; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--line) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(0.85); }
.maplibregl-ctrl-attrib { background: rgba(11, 18, 32, 0.75) !important; color: var(--faint); font-size: 11px; }
.maplibregl-ctrl-attrib a { color: var(--muted); }
.maplibregl-ctrl-attrib-button { filter: invert(0.8); }

.mk { display: flex; align-items: center; gap: 6px; cursor: pointer; transform-origin: 17px 50%; }
.mk-dot {
  position: relative; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: rgba(13, 21, 36, 0.9); border: 2px solid currentColor; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}
.mk-dot svg { width: 20px; height: 20px; transition: transform 0.6s ease; }
.mk-label {
  font-family: var(--display); font-weight: 700; font-size: 13.5px; letter-spacing: 0.03em; color: var(--text);
  background: rgba(13, 21, 36, 0.92); border: 1px solid var(--line); padding: 2px 7px; border-radius: 6px; white-space: nowrap;
}
.mk.air { color: var(--air); }
.mk.ground { color: var(--ground); }
.mk.maintenance { color: var(--maint); }
.mk.aog { color: var(--aog); }
.mk.unavailable { color: var(--off); }
.mk.est .mk-dot { border-style: dashed; }
.mk.sel .mk-dot { box-shadow: 0 0 0 5px rgba(129, 134, 242, 0.35), 0 2px 10px rgba(0, 0, 0, 0.5); }
.mk.sel .mk-label { border-color: var(--brand-hi); }
.mk.dim { opacity: 0.45; }
.mk-ap { width: 9px; height: 9px; border-radius: 50%; background: var(--bg); border: 2px solid var(--muted); }
.mk-ap-label { font-family: var(--display); font-weight: 600; font-size: 12px; color: var(--muted); margin-left: 4px; text-shadow: 0 1px 3px #000; }
.map-list { display: none; }

/* ---------- Selected aircraft ---------- */
.detail { padding: 16px 18px 18px; }
.d-head { display: flex; gap: 14px; align-items: center; }
.d-head .thumb { width: 110px; height: 64px; }
.d-head .thumb .sil { width: 92px; height: 40px; }
.d-title { flex: 1; min-width: 0; }
.d-title .tail { font-size: 26px; }
.d-route { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; margin: 18px 0 14px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.d-end .code { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: 0.03em; }
.d-end .sub { font-size: 13px; }
.d-end.right { text-align: right; }
.track { position: relative; height: 24px; }
.track .rail { position: absolute; left: 0; right: 0; top: 11px; height: 2px; background: var(--line); border-radius: 2px; }
.track .done { position: absolute; left: 0; top: 11px; height: 2px; background: var(--air); border-radius: 2px; }
.track .plane { position: absolute; top: 0; width: 24px; height: 24px; margin-left: -12px; color: var(--air); transform: rotate(90deg); }
.track .plane svg { width: 24px; height: 24px; }
.track.ground .done { background: var(--ground); }
.track.ground .plane { color: var(--ground); }
.track.planned .rail { background: repeating-linear-gradient(90deg, var(--line) 0 6px, transparent 6px 11px); }
.d-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.metric { display: grid; grid-template-columns: 22px 1fr; column-gap: 8px; align-items: center; padding: 10px 12px; background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--radius-m); }
.metric svg { grid-row: 1 / 3; width: 20px; height: 20px; color: var(--faint); }
.metric .m-l { font-size: 12px; color: var(--muted); }
.metric .m-v { font-family: var(--display); font-weight: 600; font-size: 17px; white-space: nowrap; }
.d-note { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0 0; padding: 10px 12px; border-radius: var(--radius-m); background: var(--maint-soft); color: var(--maint); font-size: 14px; }
.d-note.info { background: var(--panel-2); color: var(--muted); }
.d-note svg { margin-top: 1px; }
.d-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.d-empty { color: var(--muted); padding: 20px 4px; text-align: center; }

/* ---------- Map tab: the map takes the page ---------- */
body[data-view="map"] .page-head, body[data-view="map"] .stats, body[data-view="map"] .fleet-panel, body[data-view="map"] .foot { display: none; }
body[data-view="map"] main { max-width: none; padding: 0; }
body[data-view="map"] .dash { display: block; }
body[data-view="map"] .side { position: static; display: block; }
body[data-view="map"] .map-panel { height: calc(100vh - 62px); border-radius: 0; border: 0; }
body[data-view="map"] .detail { position: fixed; right: 16px; bottom: 16px; width: 440px; max-height: calc(100vh - 110px); overflow: auto; z-index: 5; box-shadow: var(--shadow); background: rgba(17, 26, 44, 0.96); backdrop-filter: blur(8px); }
body[data-view="map"] .d-metrics { grid-template-columns: repeat(2, 1fr); }
body[data-view="map"] .map-list {
  display: grid; gap: 4px; position: absolute; top: 56px; left: 12px; z-index: 2; width: 230px; max-height: calc(100% - 80px); overflow: auto;
  padding: 6px; background: rgba(17, 26, 44, 0.94); border: 1px solid var(--line); border-radius: var(--radius-l); backdrop-filter: blur(8px);
}
.ml-item { display: grid; grid-template-columns: 10px 1fr; column-gap: 10px; align-items: center; padding: 8px 10px; border: 0; background: none; border-radius: 8px; text-align: left; cursor: pointer; }
.ml-item:hover { background: var(--panel-3); }
.ml-item.selected { background: var(--brand-soft); }
.ml-item .dot { grid-row: 1 / 3; width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.ml-item .tail { font-size: 16px; color: var(--text); }
.ml-item .sub { font-size: 12.5px; }
.ml-item.air { color: var(--air); } .ml-item.ground { color: var(--ground); } .ml-item.maintenance { color: var(--maint); } .ml-item.aog { color: var(--aog); } .ml-item.unavailable, .ml-item.unknown { color: var(--off); }

/* ---------- Schedule ---------- */
.view-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.view-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-weight: 500; font-size: 13.5px; cursor: pointer; }
.chip.tailchip { font-family: var(--display); font-weight: 600; font-size: 14px; letter-spacing: 0.03em; }
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { background: var(--brand-soft); border-color: rgba(129, 134, 242, 0.55); color: var(--text); }
.toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; cursor: pointer; margin-left: auto; }
.toggle input { accent-color: var(--brand-hi); width: 16px; height: 16px; }
.day { margin-bottom: 18px; }
.day-head { display: flex; align-items: baseline; gap: 10px; padding: 0 4px 8px; }
.day-head h3 { font-size: 17px; }
.day.today .day-head h3::after { content: "Today"; margin-left: 10px; font-family: var(--sans); font-size: 12px; font-weight: 600; color: var(--brand-hi); background: var(--brand-soft); padding: 2px 8px; border-radius: 6px; vertical-align: 2px; }
.legs { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius-l); overflow: hidden; }
.leg {
  display: grid; grid-template-columns: 92px minmax(250px, 1.6fr) 74px 64px 112px minmax(0, 1fr) 76px;
  gap: 14px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
}
.leg:last-child { border-bottom: 0; }
.leg.is-past { opacity: 0.72; }
.leg .tail { font-size: 17px; }
.leg-main { min-width: 0; }
.leg-times { display: grid; grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr); align-items: center; gap: 6px; }
.leg-end .t { font-family: var(--display); font-weight: 600; font-size: 17px; white-space: nowrap; }
.leg-end .c { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leg-end .c b { font-family: var(--display); color: var(--text); font-weight: 600; letter-spacing: 0.03em; }
.leg-times .arrow { color: var(--faint); text-align: center; }
.leg > .pill { justify-self: start; }
.leg .meta { font-size: 13px; color: var(--muted); }
.leg .meta b { display: block; font-family: var(--display); font-size: 15px; color: var(--text); font-weight: 600; }
.leg .note { font-size: 13px; color: var(--muted); min-width: 0; }
.leg .note .by { color: var(--faint); font-size: 12px; }
.leg .acts { display: flex; gap: 2px; justify-content: flex-end; }
.leg .actual { font-size: 12px; color: var(--muted); margin-top: 3px; }
.empty-state { display: grid; justify-items: center; gap: 12px; padding: 48px 20px; text-align: center; background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius-l); color: var(--muted); }
.empty-state svg { width: 36px; height: 36px; color: var(--faint); }

/* ---------- Analytics ---------- */
.an-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.an-tile { padding: 16px 18px; background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius-l); }
.an-tile .n { font-family: var(--display); font-weight: 600; font-size: 30px; line-height: 1.1; }
.an-tile .l { color: var(--muted); font-size: 14px; }
.an-cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.an-panel { padding: 18px; }
.an-panel h2 { margin-bottom: 4px; }
.bars { display: grid; gap: 12px; margin-top: 16px; }
.bar-row { display: grid; grid-template-columns: 80px 1fr 64px; gap: 12px; align-items: center; }
.bar-row .tail { font-size: 16px; }
.bar { height: 22px; background: var(--bg-2); border-radius: 6px; overflow: hidden; position: relative; }
.bar span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; background: var(--brand-hi); min-width: 2px; }
.bar span.sched { background: repeating-linear-gradient(135deg, rgba(129, 134, 242, 0.55) 0 5px, rgba(129, 134, 242, 0.25) 5px 10px); }
.bar-row .v { text-align: right; font-family: var(--display); font-weight: 600; }
.an-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 12px; }
.an-table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 13px; padding: 8px 6px; border-bottom: 1px solid var(--line-soft); }
.an-table td { padding: 9px 6px; border-bottom: 1px solid var(--line-soft); }
.an-table td.num, .an-table th.num { text-align: right; }
.an-table .code { font-family: var(--display); font-weight: 600; letter-spacing: 0.03em; }

/* ---------- Settings ---------- */
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.set-card { padding: 20px; }
.set-card h2 { margin-bottom: 6px; }
.set-card p.lead { margin: 0 0 16px; color: var(--muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.ac-list { display: grid; gap: 8px; margin-bottom: 16px; }
.ac-item { display: grid; grid-template-columns: 76px 1fr auto; gap: 14px; align-items: center; padding: 10px; background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--radius-m); }
.ac-item .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.span-2 { grid-column: 1 / -1; }

/* ---------- Dialogs ---------- */
dialog { color: var(--text); padding: 0; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(4, 8, 18, 0.66); backdrop-filter: blur(2px); }
.modal { width: min(680px, calc(100vw - 24px)); border-radius: var(--radius-l); max-height: calc(100vh - 40px); }
.modal.wide { width: min(880px, calc(100vw - 24px)); }
.modal-body { padding: 22px; }
.m-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.m-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.m-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; align-items: center; }
.m-foot .left { margin-right: auto; }
.drawer { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(520px, 100vw); border-radius: 0; border-width: 0 0 0 1px; }
.drawer[open] { animation: slide 0.22s ease-out; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer-body { padding: 22px; }
.dr-section { margin-top: 22px; }
.dr-section h3 { margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.mini-legs { display: grid; gap: 6px; }
.mini-leg { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 10px 12px; background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--radius-m); }
.mini-leg .route-line { font-size: 15px; }
.mini-leg button.mini-leg-btn { all: unset; display: contents; cursor: pointer; }
.flight-item { cursor: pointer; }
.flight-item:hover { border-color: var(--line); }

.leg-form { display: grid; gap: 10px; }
.leg-row { display: grid; grid-template-columns: 28px 1.25fr 0.8fr 0.85fr 0.8fr 0.85fr 0.7fr 0.55fr 28px; gap: 8px; align-items: end; padding: 10px; background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--radius-m); }
.leg-row .n { align-self: center; font-family: var(--display); font-weight: 700; color: var(--faint); text-align: center; }
.leg-row label.field { font-size: 12px; }
.leg-row .input { height: 38px; font-size: 14px; padding: 0 9px; }
.leg-row .note-field { grid-column: 2 / 9; }
.leg-row .rm { align-self: center; }

.paste-area { min-height: 180px; font-size: 14px; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.preview { margin-top: 14px; }
.preview .legs .leg { grid-template-columns: 92px minmax(230px, 1.6fr) 74px 64px; }
.msg { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-m); font-size: 14px; margin-top: 10px; }
.msg.warn { background: var(--maint-soft); color: var(--maint); }
.msg.err { background: var(--aog-soft); color: var(--aog); }
.msg.ok { background: var(--air-soft); color: var(--air); }
.msg ul { margin: 4px 0 0; padding-left: 18px; }
.msg code { font-size: 12.5px; color: var(--text); }
.radio-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
.radio-card { display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-m); cursor: pointer; background: var(--bg-2); }
.radio-card:has(input:checked) { border-color: var(--brand-hi); background: var(--brand-soft); }
.radio-card input { accent-color: var(--brand-hi); margin: 2px 0 0; }
.radio-card b { display: block; font-weight: 600; }
.radio-card span { color: var(--muted); font-size: 13px; }

/* ---------- Toasts & footer ---------- */
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; justify-items: center; pointer-events: none; }
.toast { padding: 11px 16px; border-radius: 10px; background: var(--panel-3); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 14px; animation: rise 0.2s ease-out; }
.toast.err { border-color: rgba(255, 111, 97, 0.55); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.foot { padding: 14px 22px 20px; color: var(--faint); font-size: 12.5px; text-align: center; }
.foot a { color: var(--muted); }

/* ---------- Smaller screens ---------- */
@media (max-width: 1280px) {
  .dash { grid-template-columns: 1fr; }
  .side { position: static; grid-template-columns: 1.2fr 1fr; align-items: start; }
  .map-panel { height: 100%; min-height: 380px; }
  .an-cols { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .tabs a span { display: none; }
  .tabs a { padding: 8px 10px; }
  .brand span { display: none; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .side { grid-template-columns: 1fr; }
  .set-grid { grid-template-columns: 1fr; }
  .leg { grid-template-columns: auto auto 1fr auto; grid-template-areas: "tail tail st st" "main main main main" "eet pax note acts"; row-gap: 8px; column-gap: 16px; }
  .leg > .tail { grid-area: tail; }
  .leg > .pill, .leg > .pill-gap { grid-area: st; justify-self: end; }
  .leg > .leg-main { grid-area: main; }
  .leg > .m-eet { grid-area: eet; }
  .leg > .m-pax { grid-area: pax; }
  .leg > .note { grid-area: note; align-self: center; }
  .leg > .acts { grid-area: acts; }
  .leg .meta b { display: inline; margin-right: 4px; }
  .preview .legs .leg { grid-template-columns: auto auto 1fr auto; }
  .leg-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .leg-row .n { display: none; }
  .leg-row .note-field { grid-column: 1 / 3; }
  .leg-row .rm { grid-column: 3; justify-self: end; }
  .an-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  main { padding: 16px 16px 8px; }
  h1 { font-size: 26px; }
  .seg button { padding: 4px 8px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stats .stat:first-child { grid-column: 1 / -1; }
  .stat { padding: 12px; column-gap: 10px; }
  .stat-ico { width: 38px; height: 38px; }
  .stat-n { font-size: 24px; }
  .panel-head { padding: 14px; }
  .tools { width: 100%; }
  .search { flex: 1; width: auto; }
  .thead { display: none; }
  .row { grid-template-columns: 1fr auto; grid-template-areas: "ac st" "loc loc" "nf nf"; row-gap: 10px; padding: 14px; }
  .row > .ac { grid-area: ac; }
  .row > .st { grid-area: st; justify-self: end; }
  .row > .loc { grid-area: loc; padding-left: 80px; }
  .row > .nf { grid-area: nf; padding-left: 80px; }
  .row > .go { display: none; }
  .d-metrics { grid-template-columns: repeat(2, 1fr); }
  .d-route { gap: 10px; }
  .pop { position: fixed; left: 12px; right: 12px; top: 66px; width: auto; }
  body[data-view="map"] .map-list { display: flex; overflow-x: auto; top: auto; bottom: 12px; left: 12px; right: 12px; width: auto; max-height: none; }
  body[data-view="map"] .ml-item { flex: none; }
  body[data-view="map"] .detail { left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 52vh; }
  body[data-view="map"].has-detail .map-list { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .leg-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .leg-row .note-field { grid-column: 1 / -1; }
  .leg-row .rm { grid-column: 2; }
  .leg > .note { grid-column: 1 / -1; grid-row: 4; }
  .leg { grid-template-areas: "tail tail st st" "main main main main" "eet pax . acts"; }
  .d-head .thumb { width: 84px; height: 52px; }
  .d-head .thumb .sil { width: 72px; height: 32px; }
  .d-title .tail { font-size: 22px; }
  .d-title .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .d-route { grid-template-columns: 1fr 40px 1fr; }
  .radio-cards { grid-template-columns: 1fr; }
  .modal-body, .drawer-body { padding: 18px; }
  .ac-item { grid-template-columns: 60px 1fr; }
  .ac-item .acts { grid-column: 1 / -1; justify-content: flex-start; }
  .ac-item .thumb { width: 60px; height: 38px; }
  .bar-row { grid-template-columns: 70px 1fr 54px; }
}
@media (max-width: 560px) {
  .top-actions > .seg { display: none; }
  .menu-seg { display: flex; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
