/* ---------- themes ---------- */
:root, [data-theme="light"] {
  --bg: #f2f4f8;
  --card: #ffffff;
  --card-2: #f7f8fb;
  --text: #121a2a;
  --muted: #5b687c;
  --line: #e3e8f0;
  --primary: #1d4ed8;
  --primary-2: #2563eb;
  --primary-soft: #e3ebff;
  --on-primary: #ffffff;
  --topbar: #1d4ed8;
  --green: #15803d; --green-soft: #dcfce7;
  --amber: #b45309; --amber-soft: #fef3c7;
  --blue: #1d4ed8;  --blue-soft: #dbeafe;
  --grey: #475569;  --grey-soft: #e9edf3;
  --red: #b91c1c;   --red-soft: #fee2e2;
  --note: #fff8db; --note-text: #422006;
  --plane: #1d4ed8;
  --ship: #0e7490;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 6px 18px rgba(15, 23, 42, .06);
  --skeleton: #e6eaf1;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0b1120;
  --card: #151e31;
  --card-2: #1b263c;
  --text: #e8edf6;
  --muted: #95a3ba;
  --line: #26334c;
  --primary: #5b8cff;
  --primary-2: #7aa2ff;
  --primary-soft: #1d2b4f;
  --on-primary: #0b1120;
  --topbar: #0f1729;
  --green: #4ade80; --green-soft: #133122;
  --amber: #fbbf24; --amber-soft: #3a2b0c;
  --blue: #7aa2ff;  --blue-soft: #1c2a4d;
  --grey: #a3b0c5;  --grey-soft: #222e45;
  --red: #f87171;   --red-soft: #3b1518;
  --note: #2f2a16; --note-text: #f6e7b0;
  --plane: #7aa2ff;
  --ship: #22d3ee;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .25);
  --skeleton: #1f2a40;
  color-scheme: dark;
}
:root { --radius: 20px; --nav-h: 70px; }
html { font-size: 18px; }
html[data-font="large"] { font-size: 20px; }
html[data-font="xl"] { font-size: 22px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  transition: background .2s;
}
a { color: var(--primary); }
button, input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--primary-2); outline-offset: 2px; }

/* ---------- top & bottom bars ---------- */
.topbar {
  position: sticky; top: 0; z-index: 600;
  background: var(--topbar); color: #fff;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px 18px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand, .auth-brand {
  font-family: "Outfit Variable", "Outfit", -apple-system, "Segoe UI", sans-serif;
  font-weight: 800; letter-spacing: -.035em; line-height: 1; text-decoration: none;
}
.brand { color: #fff; font-size: 1.55rem; }
.brand span, .auth-brand span { font-weight: 300; letter-spacing: -.02em; }
.brand span { color: #bfd3ff; }
[data-theme="dark"] .brand span { color: var(--primary-2); }
.auth-brand { font-size: 2.4rem; text-align: center; color: var(--text); margin: 6px 0 10px; }
.auth-brand span { color: var(--primary); }
h1, h3, .status-big, .hero h1 { font-family: "Outfit Variable", "Outfit", -apple-system, "Segoe UI", sans-serif; letter-spacing: -.015em; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(255,255,255,.12); color: #fff;
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.i-sun { display: none; }
[data-theme="dark"] .i-sun { display: block; }
[data-theme="dark"] .i-moon { display: none; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 600;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  flex: 1; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none; color: var(--muted); font-size: .78rem; font-weight: 700; gap: 3px; position: relative;
}
.bottomnav svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; }
.bottomnav a.active { color: var(--primary); }
.bottomnav a.active::before {
  content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--primary);
}

main { max-width: 720px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.5rem; margin: 4px 0 12px; line-height: 1.2; }
h2 { font-size: .95rem; margin: 22px 4px 10px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
h3 { margin: 0 0 6px; font-size: 1.25rem; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }

/* ---------- cards ---------- */
.card {
  display: block; background: var(--card); border-radius: var(--radius); border: 1px solid var(--line);
  padding: 16px 18px; margin-bottom: 14px; text-decoration: none; color: inherit; box-shadow: var(--shadow);
}
a.card { transition: transform .08s; }
a.card:active { transform: scale(.985); }
.trip-head { display: flex; gap: 14px; align-items: flex-start; }
.trip-icon {
  flex: none; width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center;
  background: var(--primary-soft); font-size: 1.6rem;
}
.trip-icon.ship { background: color-mix(in srgb, var(--ship) 18%, transparent); }
.trip-main { flex: 1; min-width: 0; }
.trip-title { font-weight: 800; font-size: 1.1rem; overflow-wrap: anywhere; line-height: 1.25; }
.trip-sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.trip-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.trip-status .line { font-size: .9rem; font-weight: 600; }
.trip-note { margin-top: 12px; background: var(--note); color: var(--note-text); border-radius: 12px; padding: 9px 12px; font-size: .9rem;
             white-space: pre-wrap; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.chev { color: var(--muted); align-self: center; font-size: 1.4rem; }

.pill { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: .82rem; font-weight: 800; white-space: nowrap; }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.grey { background: var(--grey-soft); color: var(--grey); }
.pill.live::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.progress { margin-top: 14px; }
.progress-bar { position: relative; height: 10px; background: var(--grey-soft); border-radius: 99px; }
.progress-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--primary), var(--primary-2)); border-radius: 99px; }
.progress-plane { position: absolute; top: 50%; transform: translate(-50%, -52%) rotate(0deg); font-size: 1.25rem; color: var(--primary); line-height: 1; }
.progress-labels { display: flex; justify-content: space-between; font-size: .82rem; color: var(--muted); margin-top: 6px; font-weight: 700; }

/* hero / summary */
.hero { background: linear-gradient(135deg, var(--primary), #1e3a8a); color: #fff; border: 0; }
[data-theme="dark"] .hero { background: linear-gradient(135deg, #1e3a8a, #172554); }
.hero .muted { color: rgba(255,255,255,.8); }
.hero h1 { margin: 0 0 4px; }

/* ---------- chips & segmented ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 6px; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px;
  padding: 8px 16px; font-weight: 700; font-size: .9rem; cursor: pointer;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.segmented { display: flex; background: var(--grey-soft); border-radius: 16px; padding: 5px; margin-bottom: 12px; }
.segmented button {
  flex: 1; border: 0; background: transparent; border-radius: 12px; padding: 11px 0; font-weight: 800; cursor: pointer; color: var(--muted);
}
.segmented button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.15); }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px; border-radius: 14px; border: 0; cursor: pointer;
  background: var(--primary); color: var(--on-primary); font-weight: 800; font-size: 1rem; text-decoration: none;
}
.btn.secondary { background: var(--grey-soft); color: var(--text); }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.danger-solid { background: #dc2626; color: #fff; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: .88rem; border-radius: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.btn-row .btn { flex: 1; }

label.field { display: block; font-weight: 700; margin: 14px 0 6px; }
.hint { color: var(--muted); font-size: .86rem; font-weight: 400; margin-top: 4px; }
input[type=text], input[type=password], input[type=date], input[type=search], input[type=number], textarea, select {
  width: 100%; border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--card-2);
  font-size: 1.05rem; outline: none; color: var(--text);
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); }
textarea { min-height: 110px; resize: vertical; }
.searchbar { display: flex; gap: 10px; }
.searchbar input { flex: 1; min-width: 0; }
.searchbar.upper input { text-transform: uppercase; }
.searchbar input::placeholder { text-transform: none; }
.check-list { display: grid; gap: 6px; margin: 10px 0; }
.check { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--card-2); cursor: pointer; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); }
.error { color: var(--red); font-weight: 600; font-size: .9rem; min-height: 1.2em; }

/* ---------- maps ---------- */
.map { height: 46vh; min-height: 260px; border-radius: var(--radius); margin-bottom: 14px; z-index: 1; border: 1px solid var(--line); }
.map.search-map { height: 44vh; min-height: 260px; }
.map-wrap { position: relative; }
.map-overlay {
  position: absolute; left: 10px; bottom: 24px; z-index: 500; display: flex; gap: 8px; flex-wrap: wrap; pointer-events: none;
}
.map-overlay > * { pointer-events: auto; }
.map-badge { background: var(--card); color: var(--text); border-radius: 999px; padding: 6px 12px; font-size: .8rem; font-weight: 700; box-shadow: var(--shadow); }
.map-btn { background: var(--card); color: var(--text); border: 0; border-radius: 12px; padding: 8px 12px; font-weight: 700; font-size: .85rem; box-shadow: var(--shadow); cursor: pointer; }
.leaflet-container { background: var(--card-2); font: inherit; }
[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.88) saturate(.55); }
[data-theme="dark"] .leaflet-bar a, [data-theme="dark"] .leaflet-control-attribution { background: var(--card); color: var(--muted); border-color: var(--line); }
[data-theme="dark"] .leaflet-control-attribution a { color: var(--primary); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--card); color: var(--text); }
.leaflet-popup-content { margin: 14px 16px; font-size: .92rem; min-width: 190px; }
.leaflet-popup-content b { font-size: 1.05rem; }
.leaflet-popup-content .btn { margin-top: 10px; width: 100%; color: var(--on-primary); }
.ap-tip { background: var(--card); color: var(--text); border: 0; font-weight: 800; box-shadow: var(--shadow); }
.ap-tip::before { border-top-color: var(--card) !important; }
.vehicle-icon { background: none; border: 0; }
.vehicle-icon svg { filter: drop-shadow(0 2px 2px rgba(0,0,0,.4)); transition: transform .3s; }
.vehicle-icon.muted { opacity: .85; }

/* ---------- detail ---------- */
.status-big { font-size: 1.3rem; font-weight: 800; }
.status-detail { color: var(--muted); margin-top: 4px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; }
.grid .k { font-size: .8rem; color: var(--muted); font-weight: 600; }
.grid .v { font-weight: 800; font-size: 1.05rem; overflow-wrap: anywhere; }
.route { display: flex; align-items: center; gap: 10px; }
.route .ap { flex: 1; min-width: 0; }
.route .ap.right { text-align: right; }
.route .code { font-size: 1.9rem; font-weight: 900; letter-spacing: .02em; line-height: 1.1; }
.route .city { color: var(--muted); font-size: .86rem; }
.route .arrow { font-size: 1.4rem; color: var(--muted); }
.photo { width: 100%; border-radius: 14px; margin-top: 14px; display: block; }
.note-card { background: var(--note); color: var(--note-text); border-color: transparent; }
.note-text { white-space: pre-wrap; font-size: 1.05rem; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-weight: 700; font-size: .9rem; margin-bottom: 4px; }

/* ---------- lists (admin) ---------- */
.list-item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.list-item .main { flex: 1; min-width: 0; }
.avatar { flex: none; width: 42px; height: 42px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 900; }
.link-box { background: var(--card-2); border: 1px dashed var(--line); border-radius: 12px; padding: 10px 12px; font-family: ui-monospace, Consolas, monospace; font-size: .8rem; overflow-wrap: anywhere; margin: 10px 0; }

/* ---------- empty, skeleton, misc ---------- */
.empty { text-align: center; padding: 30px 14px; }
.empty .big { font-size: 3.4rem; }
.skeleton { background: var(--skeleton); border-radius: var(--radius); height: 120px; margin-bottom: 14px; animation: pulse 1.4s infinite; }
.stamp { text-align: center; font-size: .8rem; color: var(--muted); margin: 6px 0 2px; }
.export-preview { background: var(--card-2); border-radius: 14px; padding: 10px; margin-top: 12px; max-height: 42vh; overflow: auto; }
.export-preview img { width: 100%; display: block; border-radius: 8px; }
.fab-row { display: flex; gap: 10px; margin-bottom: 4px; }
.fab-row .btn { flex: 1; }

/* ---------- modal & toast ---------- */
.modal {
  position: fixed; inset: 0; z-index: 1000; background: rgba(2, 6, 23, .55);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--card); color: var(--text); width: 100%; max-width: 680px; max-height: 92vh; overflow-y: auto;
  border-radius: 24px 24px 0 0; padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
  animation: sheet-in .22s ease;
}
@keyframes sheet-in { from { transform: translateY(30px); opacity: 0; } }
.sheet-handle { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
@media (min-width: 720px) { .modal { align-items: center; } .sheet { border-radius: 24px; } .sheet-handle { display: none; } .sheet { padding-top: 22px; } }

.toast {
  position: fixed; left: 50%; z-index: 1100; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  background: #0f172a; color: #fff; padding: 12px 20px; border-radius: 14px; font-weight: 700; max-width: 90vw;
  transition: opacity .2s, transform .2s; box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
[data-theme="dark"] .toast { background: #e8edf6; color: #0b1120; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.auth { max-width: 440px; margin: 6vh auto 0; }
.auth .logo { width: 64px; height: 64px; border-radius: 18px; display: block; margin: 0 auto 12px; }
.auth h1 { text-align: center; }

/* ---------- search layout (desktop: map left, list right) ---------- */
body.wide main { max-width: 1440px; }
.search-layout { display: block; }
.map-tools { position: absolute; top: 10px; left: 10px; z-index: 500; display: flex; gap: 8px; }
.map-btn.active { background: var(--primary); color: var(--on-primary); }
.res-head { margin: 12px 4px 10px; color: var(--muted); font-size: .92rem; }
.res-head b { color: var(--text); }
.result.clickable { cursor: pointer; }
.result.clickable:hover { border-color: var(--primary); }
.result .trip-icon svg, .trip-icon svg { display: block; }
.chip svg { vertical-align: -3px; }
.chip.small { padding: 5px 12px; font-size: .82rem; }
#filters { margin-top: 10px; }
.timeline { margin-top: -4px; padding: 12px 16px; }
.timeline input[type=range] { width: 100%; margin: 10px 0 2px; accent-color: var(--primary); height: 28px; }
@media (min-width: 960px) {
  .search-layout { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(360px, 1fr); gap: 20px; align-items: start; }
  .search-map-col { position: sticky; top: 76px; }
  .map.search-map { height: calc(100vh - 210px); min-height: 520px; }
  .search-side { max-height: calc(100vh - 110px); overflow-y: auto; padding-right: 4px; }
  .bottomnav { justify-content: center; }
  .bottomnav a { flex: 0 1 200px; }
}

/* ---------- legend ---------- */
.legend { background: var(--card); color: var(--text); border-radius: 12px; box-shadow: var(--shadow); font-size: .78rem; padding: 6px 10px; max-width: 220px; }
.lg-toggle { border: 0; background: none; font-weight: 800; font-size: .8rem; padding: 2px 0; cursor: pointer; color: var(--text); }
.lg-body { margin-top: 4px; display: grid; gap: 3px; }
.lg-row { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.lg-row svg { flex: none; }
.lg-dot { width: 12px; height: 12px; border-radius: 50%; background: #64748b; border: 2px solid #fff; margin: 0 3px; box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.vehicle-icon.hl svg { filter: drop-shadow(0 0 3px #fff) drop-shadow(0 2px 4px rgba(0,0,0,.5)); }

/* ---------- trips list ---------- */
.map.trips-map { height: 34vh; min-height: 220px; }
.trip-card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.trip-card[data-sel] { cursor: pointer; }
.sel-box { flex: none; width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 900; color: var(--on-primary); align-self: center; }
.trip-card.selected .sel-box { background: var(--primary); border-color: var(--primary); }
.action-bar {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 650; width: min(680px, calc(100% - 24px));
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 10px);
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
}
.action-bar span { flex: 1; }
.more-actions { margin: 16px 0 6px; color: var(--muted); }
.more-actions summary { cursor: pointer; font-weight: 700; font-size: .9rem; padding: 8px 4px; list-style: none; }
.more-actions summary::before { content: "⋯ "; }
.danger-text { color: var(--red) !important; }
#dTitle svg { vertical-align: -5px; }

/* ---------- administration ---------- */
.admin-grid { display: grid; gap: 0 14px; }
@media (min-width: 900px) { .admin-grid { grid-template-columns: 1fr 1fr; } body:has(.admin-grid) main { max-width: 1100px; } }
.admin-grid .card { margin-bottom: 14px; }
.admin-grid h3 { margin-bottom: 12px; }

.spinner { width: 34px; height: 34px; border: 4px solid var(--grey-soft); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- sharing within the family ---------- */
.pill.share { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.trip-card.locked { opacity: .55; cursor: not-allowed; }
.share-list { display: grid; gap: 6px; margin: 8px 0 4px 18px; }
.share-info { background: var(--primary-soft); color: var(--text); font-weight: 600; }

/* ---------- weather & local time at the destination ---------- */
.weather { display: flex; gap: 14px; align-items: center; background: var(--card); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.weather .w-emoji { font-size: 2.2rem; line-height: 1; }

/* ---------- login: disclaimer, version, license ---------- */
.legal { max-width: 460px; margin: 18px auto 0; text-align: center; font-size: .78rem; line-height: 1.5; color: var(--muted); }
.legal p { margin: 0 0 6px; }

/* ---------- demo access (read-only) ---------- */
.demo-pill { margin-left: auto; margin-right: 10px; background: rgba(255,255,255,.16); color: #fff; font-weight: 800; font-size: .8rem; padding: 5px 12px; border-radius: 999px; white-space: nowrap; }
.demo-box { display: grid; gap: 6px; justify-items: center; text-align: center; margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); font-weight: 700; }
.demo-box .hint { font-weight: 500; }
.demo-note { background: var(--amber-soft); color: var(--text); }

/* ---------- desktop (from 960 px): smaller type, navigation in the header, two columns ---------- */
.split-layout { display: block; }
@media (min-width: 960px) {
  html { font-size: 16px; }
  html[data-font="large"] { font-size: 17.5px; }
  html[data-font="xl"] { font-size: 19px; }
  body { padding-bottom: 32px; }
  main { padding: 22px 24px; }
  .topbar { padding: 10px 20px 10px 26px; min-height: 64px; }
  .brand { font-size: 1.6rem; }
  /* the bottom navigation becomes a tab bar inside the header */
  .bottomnav {
    top: 0; bottom: auto; left: 50%; right: auto; transform: translateX(-50%);
    height: 64px; padding: 0; background: transparent; border: 0; z-index: 700; justify-content: center;
  }
  .bottomnav a { flex: 0 0 auto; height: 64px; flex-direction: row; gap: 8px; padding: 0 18px; font-size: .95rem; color: rgba(255,255,255,.72); }
  .bottomnav a:hover { color: #fff; }
  .bottomnav a.active { color: #fff; }
  .bottomnav a.active::before { top: auto; bottom: 0; left: 14px; right: 14px; height: 3px; border-radius: 3px 3px 0 0; background: #fff; }
  .bottomnav svg { width: 20px; height: 20px; }
  .action-bar { bottom: 20px; }
  .card { padding: 16px 18px; }
  h1 { font-size: 1.6rem; }
  .btn:hover:not(:disabled) { filter: brightness(1.06); }
  a.trip-card:hover { border-color: var(--primary); }
  .sheet { max-width: 560px; }
}
@media (min-width: 1100px) {
  body.split main { max-width: 1320px; }
  .split-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(400px, 1fr); gap: 24px; align-items: start; }
  .split-side { position: sticky; top: 86px; }
  .split-side .map.trips-map { height: calc(100vh - 330px); min-height: 360px; }
  .split-layout.detail .map { height: calc(100vh - 210px); min-height: 420px; margin-bottom: 0; }
  .split-main > .card:first-child, .list-tools { margin-top: 0; }
  .split-main h2:first-child { margin-top: 6px; }
}

/* ---------- language switch (login, invitation, account) ---------- */
.auth .lang-switch { width: fit-content; margin: -4px auto 14px; }
.lang-switch button { padding: 6px 12px; font-size: .85rem; }

/* ---------- logo (white PNG used as mask: the colour comes from `color`) ---------- */
.logo {
  display: inline-block; width: 1.25em; height: 1.25em; vertical-align: -.22em; margin-right: .35em;
  background-color: currentColor;
  -webkit-mask: url(/static/logo.png) center / contain no-repeat;
  mask: url(/static/logo.png) center / contain no-repeat;
}
.brand { display: inline-flex; align-items: center; }
.brand .logo { width: 1.45em; height: 1.45em; margin-right: .4em; vertical-align: 0; }
.auth-logo { display: block; width: 92px; height: 92px; margin: 2px auto 6px; color: var(--primary); }

/* ---------- trip list: cards with map preview ---------- */
.trip-grid { display: grid; gap: 0 14px; }
@media (min-width: 900px) { .trip-grid { grid-template-columns: 1fr 1fr; } }
.trip-thumb { flex: none; width: 108px; height: 72px; border-radius: 12px; overflow: hidden; background: var(--card-2); display: grid; place-items: center; font-size: 1.6rem; border: 1px solid var(--line); }
.trip-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
[data-theme="dark"] .trip-thumb img { filter: brightness(.85) contrast(1.05); }
.trip-card.archived { opacity: .75; }
@media (max-width: 420px) { .trip-thumb { width: 84px; height: 60px; } }

/* ---------- detail: manage, notes, photo, save button ---------- */
.btn-row.wrap { flex-wrap: wrap; justify-content: flex-start; }
.btn-row.wrap .btn { flex: 0 1 auto; }
.manage-card .trip-actions { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.note-item { padding: 10px 12px; border-radius: 12px; background: var(--note); color: var(--note-text); margin-bottom: 8px; }
.note-item .note-text { white-space: pre-wrap; }
.note-meta { opacity: .75; margin-top: 4px; display: flex; gap: 10px; align-items: center; }
.link-btn { border: 0; background: none; color: inherit; text-decoration: underline; cursor: pointer; padding: 0; font-size: inherit; }
.note-form { display: grid; gap: 8px; margin-top: 8px; }
.note-form .btn { justify-self: start; }
.photo-box { margin: 0; }
.photo-box .photo { width: 100%; max-height: 320px; object-fit: cover; border-radius: 12px; display: block; }
.photo-box figcaption { margin-top: 6px; }
.save-row { margin: 4px 0 14px; }

/* ---------- charts ---------- */
.chart-box { position: relative; margin-bottom: 8px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; touch-action: pan-y; }
.chart .gridline { stroke: var(--line); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 12px; }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--primary); opacity: .1; }
.chart .dot { fill: var(--primary); stroke: var(--card); stroke-width: 2; }
.chart .end { fill: var(--text); font-size: 13px; font-weight: 700; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart .bar { fill: var(--primary); transition: opacity .15s; }
.chart .bar.dim { opacity: .35; }
.chart .nodata { fill: var(--line); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hidden { display: none; }
.chart-tip { position: absolute; transform: translate(-50%, calc(-100% - 12px)); background: var(--text); color: var(--bg); padding: 5px 9px; border-radius: 8px; font-size: .8rem; pointer-events: none; opacity: 0; white-space: nowrap; z-index: 5; }
.chart-tip.show { opacity: 1; }
h4 { margin: 10px 0 6px; font-size: .9rem; color: var(--muted); }

/* ---------- extras ---------- */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat-tile { background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-tile .k { color: var(--muted); font-size: .85rem; font-weight: 600; }
.stat-tile .v { font-family: "Outfit Variable", "Outfit", sans-serif; font-size: 1.9rem; font-weight: 700; line-height: 1.15; }
.stat-tile .s { font-size: .9rem; }
.grid2 { display: grid; gap: 4px 24px; }
@media (min-width: 760px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.cls-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.cls-row span { flex: 1; }
.rank { display: grid; gap: 6px; }
.rank-row { display: grid; grid-template-columns: minmax(70px, 38%) 1fr; gap: 10px; align-items: center; font-size: .9rem; }
.rank-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-track { display: flex; align-items: center; gap: 6px; }
.rank-bar { height: 12px; background: var(--primary); border-radius: 0 4px 4px 0; }
.rank-val { font-weight: 700; font-size: .85rem; color: var(--text); }
.map.heat-map { height: 52vh; min-height: 320px; }
.heat-legend { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.heat-scale { display: inline-flex; }
.heat-scale i { width: 22px; height: 10px; display: inline-block; }
.small-seg { margin: 0; }
.small-seg button { padding: 6px 12px; font-size: .85rem; }
.squawk { text-decoration: none; color: inherit; }
.squawk .avatar { font-weight: 800; font-size: .8rem; color: #fff; background: var(--red); }
.squawk .avatar.sq-7600 { background: var(--amber); }
.tl-jumps { margin-top: 8px; }
#tlTime { width: 100%; }

/* ---------- print layout (PDF report) ---------- */
#print { display: none; }
@media print {
  body { padding: 0; background: #fff; }
  body > *:not(#print) { display: none !important; }
  #print { display: block; color: #0f172a; font-size: 11pt; }
  #print .rp-head { display: flex; gap: 14px; align-items: center; border-bottom: 2px solid #1d4ed8; padding-bottom: 8px; margin-bottom: 14px; }
  #print .rp-head .logo { width: 48px; height: 48px; color: #1d4ed8; margin: 0; }
  #print h1 { font-size: 18pt; margin: 0; }
  #print .rp-head p { margin: 2px 0 0; color: #475569; }
  #print .rp-trip { break-inside: avoid; page-break-inside: avoid; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid #cbd5e1; }
  #print .rp-trip h2 { font-size: 14pt; margin: 0 0 2px; color: #0f172a; text-transform: none; letter-spacing: 0; }
  #print .rp-sub { color: #475569; margin: 0 0 8px; }
  #print .rp-map { width: 100%; border-radius: 8px; margin: 4px 0 8px; }
  #print .rp-table { border-collapse: collapse; width: 100%; }
  #print .rp-table th { text-align: left; width: 32%; color: #475569; font-weight: 600; padding: 3px 8px 3px 0; vertical-align: top; }
  #print .rp-table td { padding: 3px 0; }
  #print .rp-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
  #print .rp-charts h4 { color: #475569; margin: 4px 0; }
  #print .chart .gridline { stroke: #e2e8f0; } #print .chart .tick { fill: #64748b; }
  #print .chart .line { stroke: #1d4ed8; } #print .chart .area { fill: #1d4ed8; } #print .chart .dot { fill: #1d4ed8; stroke: #fff; }
  #print .chart .end { fill: #0f172a; }
  #print h3 { font-size: 12pt; margin: 10px 0 4px; }
  #print .rp-notes { margin: 0; padding-left: 18px; }
  #print .rp-notes p { margin: 0; white-space: pre-wrap; }
  #print .rp-notes small { color: #64748b; }
  #print .rp-foot { color: #64748b; font-size: 9pt; margin-top: 12px; }
  @page { margin: 14mm; }
}

/* ---------- airport weather (METAR/TAF) ---------- */
.pill.red { background: var(--red-soft); color: var(--red); }
.apwx { padding: 8px 0; border-top: 1px solid var(--line); }
.apwx:first-of-type { border-top: 0; padding-top: 0; }
.apwx code.raw { display: block; margin-top: 6px; padding: 6px 8px; border-radius: 8px; background: var(--card-2); font-size: .78rem; overflow-wrap: anywhere; white-space: pre-wrap; }
.apwx details summary { cursor: pointer; margin-top: 6px; color: var(--muted); }

/* ---------- 3.8.1: UI review fixes ---------- */
/* sheets: visible close button (desktop has no swipe, seniors look for an X) */
.sheet { position: relative; }
.sheet-close {
  position: absolute; top: 10px; right: 12px; width: 40px; height: 40px; border: 0; border-radius: 12px;
  background: var(--grey-soft); color: var(--muted); font-size: 1.05rem; font-weight: 800; cursor: pointer;
}
.sheet > h3:first-of-type { padding-right: 46px; }
/* segmented controls: buttons as wide as their text; wrap instead of breaking words with large fonts */
.segmented { flex-wrap: wrap; gap: 2px; }
.segmented button { flex: 1 1 auto; padding: 11px 8px; white-space: nowrap; }
/* narrow phones: the demo badge must not push the theme button off screen */
@media (max-width: 430px) {
  .topbar { padding-left: 12px; padding-right: 10px; gap: 8px; }
  .brand { font-size: 1.3rem; min-width: 0; }
  .demo-pill { margin-right: 0; padding: 4px 9px; font-size: .72rem; }
  .icon-btn { width: 40px; height: 40px; flex: none; }
}

/* ---------- 3.9: canvas map, groups, extras ---------- */
.map-canvas { position: absolute; left: 0; top: 0; pointer-events: none; }
.lg-bubble { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: .62rem; font-weight: 800; background: #1d4ed8; border: 2px solid #fff; }
.lg-bubble.ship { background: #0e7490; }
.cls-row span.muted { flex: none; min-width: 3.2em; text-align: right; }
.heat-legend { display: block; margin-top: 4px; }
.heat-steps { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.heat-steps div { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.heat-steps i { display: block; width: 100%; height: 12px; }
.heat-steps div:first-child i { border-radius: 6px 0 0 6px; }
.heat-steps div:last-child i { border-radius: 0 6px 6px 0; }
.heat-steps span { font-size: .72rem; font-weight: 700; color: var(--text); white-space: nowrap; }
.heat-ends { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-top: 2px; }
.hint .block { display: block; margin-top: 6px; }
.scope { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 2px 0 12px; padding: 9px 12px; border-radius: 12px; background: var(--card-2); font-size: .84rem; }
.scope dt { font-weight: 800; color: var(--muted); }
.scope dd { margin: 0; }
.stat-tile .s { font-size: .78rem; }
.row:has(> .small-seg) { flex-wrap: wrap; }
.row:has(> .small-seg) h3 { min-width: 12em; }
.small-seg { flex-wrap: nowrap; margin-bottom: 6px; }

/* ---------- 3.10: guest pages, detail modes, finished trips, technical admin ---------- */
/* login, invitation and offline page: no top bar (logo and language are on the card) */
body.guest .topbar { display: none; }
body.guest main { padding-top: calc(env(safe-area-inset-top) + 8px); }
/* phones: a taller search map */
@media (max-width: 959px) {
  .map.search-map { height: 62vh; min-height: 340px; }
}
/* which kind of detail page: live view (blue), own trip being recorded (green), finished trip (grey) */
.mode-banner { display: flex; gap: 10px; align-items: center; padding: 9px 14px; border-radius: 12px; margin: 0 0 10px; font-size: .9rem; line-height: 1.35; }
.mode-banner.live { background: var(--blue-soft); color: var(--blue); }
.mode-banner.rec { background: var(--green-soft); color: var(--green); }
.mode-banner.done { background: var(--grey-soft); color: var(--grey); }
.mode-banner b { font-weight: 800; }
.mode-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; animation: dot-pulse 2s infinite; }
@keyframes dot-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); } 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .mode-dot { animation: none; } }
body.mode-live .split-layout.detail .map { border: 2px solid var(--blue); }
body.mode-rec .split-layout.detail .map { border: 2px solid var(--green); }
body.mode-done .split-layout.detail .map { border: 2px dashed var(--grey); }
body.mode-live #dBody > .card:first-child { border-left: 5px solid var(--blue); }
body.mode-rec #dBody > .card:first-child { border-left: 5px solid var(--green); }
body.mode-done #dBody > .card:first-child { border-left: 5px solid var(--grey); background: var(--card-2); }
.pill.done { background: var(--grey-soft); color: var(--grey); font-weight: 700; margin-left: 4px; }
.trip-card.finished { background: var(--card-2); }
.list-tools { gap: 8px; flex-wrap: wrap; margin-top: 4px; }
/* administration: label and value side by side, plain weight for long technical values */
.admin-grid .grid { grid-template-columns: 1fr; gap: 10px; }
.admin-grid .grid > div { display: grid; grid-template-columns: minmax(9em, 34%) 1fr; gap: 10px; align-items: baseline; }
.admin-grid .grid .v { font-weight: 600; font-size: .95rem; }
.admin-grid .grid .v b { font-weight: 800; }
@media (max-width: 520px) { .admin-grid .grid > div { grid-template-columns: 1fr; gap: 2px; } }
.table-wrap { overflow-x: auto; margin: 0 -4px 12px; }
.src-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.src-table th { text-align: left; font-size: .76rem; color: var(--muted); font-weight: 700; padding: 4px; border-bottom: 1px solid var(--line); }
.src-table td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.src-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.meter { height: 10px; border-radius: 99px; background: var(--grey-soft); overflow: hidden; margin: 0 0 14px; }
.meter-fill { height: 100%; background: var(--green); border-radius: 99px; }
.meter-fill.warn { background: var(--amber, #d97706); }
.meter-fill.bad { background: var(--red); }
.src-use { display: none; }
@media (max-width: 520px) {
  .src-table th:nth-child(2), .src-table td:nth-child(2) { display: none; }
  .src-use { display: block; }
}

/* ---------- 4.0: placeholders that pulse until their data is loaded ---------- */
.skeleton.slot-weather { height: 64px; }
.skeleton.slot-wx { height: 150px; }
.skeleton.slot-photo { height: 220px; }
.skeleton[aria-busy] > * { visibility: hidden; }
.trip-thumb[data-thumb]:not([data-done]) { animation: pulse 1.4s infinite; }
@media (prefers-reduced-motion: reduce) { .skeleton, .trip-thumb[data-thumb] { animation: none; } }
.bottomnav a.locked { opacity: .4; cursor: not-allowed; }
.bottomnav a.locked span::after { content: " 🔒"; font-size: .8em; }
/* info and privacy pages */
.legal-page { max-width: 720px; margin: 0 auto; }
.legal-page .card p { margin: 0 0 8px; line-height: 1.5; }
.legal-page ul { margin: 0; padding-left: 20px; line-height: 1.5; }
.legal-page li { margin-bottom: 6px; }
.legal-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 14px 0 0; }
.legal-facts dt { font-weight: 800; color: var(--muted); }
.legal-facts dd { margin: 0; overflow-wrap: anywhere; }
.legal-links { font-weight: 700; }

/* ---------- 4.1: map layers, places, sky, records ---------- */
.layer-panel { margin-top: -4px; padding: 12px 16px; }
.layer-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 4px 18px; }
.layer-groups h4 { margin: 6px 0 4px; }
.layer-check { padding: 4px 0; min-height: 34px; }
.layer-legend { margin-top: 8px; line-height: 1.45; }
.layer-legend .block { display: block; margin-top: 4px; }
.lg-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin: 0 2px 0 6px; }
.lg-sym { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: -2px; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.lg-sym.ap { background: #475569; }
.lg-sym.port { background: #0e7490; }
.sky-icon { background: none; border: 0; }
.sky-icon.emoji span { font-size: 22px; line-height: 24px; display: block; text-align: center; filter: drop-shadow(0 1px 2px rgba(0,0,0,.45)); }
.sky-icon svg { filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
/* phones: one finger scrolls the page, two fingers move the map */
.map-hint { position: absolute; inset: 0; z-index: 1000; display: grid; place-items: center; background: rgba(15,23,42,.45);
  color: #fff; font-weight: 800; font-size: 1rem; text-align: center; padding: 20px; pointer-events: none; transition: opacity .2s; }
.map-hint.hidden { display: grid !important; opacity: 0; }
.chart .ground { fill: #a16207; opacity: .35; }
.warn-card { border-left: 5px solid var(--amber, #d97706); font-size: .92rem; line-height: 1.45; }
.cam-row { padding: 6px 0; border-top: 1px solid var(--line); }
.cam-row:first-of-type { border-top: 0; }
.avatar.plain { background: transparent; width: 30px; height: 30px; }
.avatar.rank { width: 32px; height: 32px; font-size: .9rem; }
.rec-grid { display: grid; gap: 0 16px; }
@media (min-width: 1100px) { .rec-grid { grid-template-columns: 1fr 1fr; } }
.rec-row { color: inherit; text-decoration: none; }
.rec-val { font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rec-row .icon-btn { width: 36px; height: 36px; font-size: 1rem; }
.tech-card .grid .v { font-weight: 400; }

/* ---------- 4.2: search map buttons, reduced background map, weather contrast, legend ---------- */
.map-btn.prominent { font-size: .92rem; padding: 9px 15px; border: 2px solid var(--primary); color: var(--primary); }
.map-btn.prominent.active { color: var(--on-primary); }
.map-btn.subtle { font-size: .76rem; font-weight: 600; padding: 6px 10px; opacity: .85; align-self: center; }
.map-btn.subtle.active { opacity: 1; }
/* weather / GPS layers on: the background map grey and pale, borders, places, rivers and roads stay readable */
.map.reduced .leaflet-tile-pane { filter: grayscale(1) contrast(.6) brightness(1.12); }
[data-theme="dark"] .map.reduced .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) grayscale(1) brightness(.62) contrast(.85); }
/* clouds (infrared image: cold clouds bright, ground dark) are blended into the map:
   light mode inverted + multiply = grey clouds on the light map, dark mode screen = light clouds on the dark map */
.leaflet-clouds-pane { mix-blend-mode: multiply; }
.leaflet-clouds-pane .wx-clouds { filter: invert(1) grayscale(1) contrast(1.5); }
[data-theme="dark"] .leaflet-clouds-pane { mix-blend-mode: screen; }
[data-theme="dark"] .leaflet-clouds-pane .wx-clouds { filter: grayscale(1) contrast(1.5) brightness(1.1); }
.wx-rain { filter: saturate(2.6) contrast(1.25); }
.wx-lightning { filter: saturate(1.6) contrast(1.2); }
[data-theme="dark"] .wx-storms { filter: brightness(1.4) saturate(1.3); }
.lg-icon { flex: none; width: 22px; display: grid; place-items: center; font-size: 15px; }
.lg-icon svg { display: block; }
.lg-sep { height: 1px; background: var(--line); margin: 4px 0; }
.lg-box { display: inline-block; width: 16px; height: 12px; border-radius: 3px; }
.lg-box.night { background: rgba(15,23,42,.45); }
.lg-box.clouds { background: linear-gradient(90deg, #cbd5e1, #64748b); }
[data-theme="dark"] .lg-box.clouds { background: linear-gradient(90deg, #475569, #f1f5f9); }
.lg-box.rain { background: linear-gradient(90deg, #d9ef8b, #41b6c4, #225ea8); }
.lg-box.lightning { background: linear-gradient(90deg, #fde047, #f97316, #dc2626); }
.lg-box.storms { background: transparent; border: 2px solid #ef4444; }
.lg-wind { display: inline-flex; gap: 1px; }
.lg-wind i { width: 4px; height: 12px; border-radius: 1px; }
.lg-bubble { border: 0; background: rgba(37,99,235,.6); }
.lg-bubble.ship { background: rgba(14,116,144,.6); }
.layer-check input:disabled + span { opacity: .45; }
.legend .lg-body { max-height: 46vh; overflow-y: auto; }
.route a.ap-link { color: inherit; text-decoration: none; border-radius: 10px; padding: 4px 6px; margin: -4px -6px; }
.route a.ap-link .code { color: var(--primary); }
.route a.ap-link .code::after { content: " ›"; font-size: 1.1rem; }
.route a.ap-link:hover { background: var(--card-2); }
.sky-icon.emoji.big span { font-size: 30px; line-height: 34px; }
.sky-pin span { display: block; width: 26px; height: 26px; border-radius: 50%; background: #dc2626; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5); cursor: grab; }
#dBody.updating { opacity: .55; transition: opacity .2s; }
