:root {
  color-scheme: dark;
  --ink: #f2fbff;
  --muted: #9cb6c5;
  --panel: rgba(3, 18, 30, .82);
  --panel-border: rgba(73, 210, 255, .34);
  --cyan: #28dcff;
  --green: #22e6a8;
  --danger: #ff4265;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body, .app-shell, #globeMap { width: 100%; height: 100%; margin: 0; }
body { overflow: hidden; background: #020b13; color: var(--ink); }
button, input { font: inherit; }
button, .view-switch a, .brand { -webkit-tap-highlight-color: transparent; }

#globeMap { position: absolute; inset: 0; background: radial-gradient(circle at 50% 45%, #0b2c43 0, #020811 66%); }
.maplibregl-canvas { cursor: grab; }
.maplibregl-canvas:active { cursor: grabbing; }
.maplibregl-ctrl-bottom-left { left: 8px; bottom: 48px; }
.maplibregl-ctrl-bottom-right { right: 324px; }
.maplibregl-ctrl-attrib { border-radius: 8px; background: rgba(2, 12, 21, .72) !important; color: #b8cad5; }
.maplibregl-ctrl-attrib a { color: #54dfff; }
.maplibregl-ctrl-group { overflow: hidden; border: 1px solid rgba(75, 210, 255, .35); background: rgba(3, 19, 31, .84) !important; box-shadow: 0 12px 38px rgba(0,0,0,.28); }
.maplibregl-ctrl-group button span { filter: invert(1); }

.glass {
  background: linear-gradient(145deg, rgba(4, 23, 37, .91), rgba(2, 15, 27, .78));
  border: 1px solid var(--panel-border);
  box-shadow: 0 16px 48px rgba(0,0,0,.34), inset 0 1px rgba(255,255,255,.04);
  backdrop-filter: blur(16px) saturate(135%);
}

.topbar {
  position: absolute;
  z-index: 5;
  top: max(14px, env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  min-height: 64px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 12px;
}

.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 11px; min-width: 185px; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid #30dbff; border-radius: 11px; color: #3be2ff; font-size: 13px; font-weight: 900; letter-spacing: .14em; box-shadow: inset 0 0 18px rgba(34,209,255,.11); }
.brand span:last-child { display: grid; line-height: 1.08; }
.brand small, .health small { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.brand strong { margin-top: 3px; font-size: 20px; letter-spacing: .02em; }

.health { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.health > span:last-child { display: grid; text-align: right; }
.health strong { font-size: 12px; margin-top: 3px; color: #dff9ff; }
.health-dot { width: 10px; height: 10px; border-radius: 50%; background: #8697a2; box-shadow: 0 0 0 5px rgba(134,151,162,.12); }
.health-dot.live { background: var(--green); box-shadow: 0 0 0 5px rgba(34,230,168,.13), 0 0 16px rgba(34,230,168,.8); }
.health-dot.error { background: var(--danger); box-shadow: 0 0 0 5px rgba(255,66,101,.13), 0 0 16px rgba(255,66,101,.7); }

.view-switch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; border: 1px solid rgba(91, 216, 244, .3); border-radius: 12px; background: rgba(2, 15, 26, .72); }
.view-switch a { min-width: 88px; min-height: 38px; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; color: #91b8c8; text-decoration: none; white-space: nowrap; font-size: 10px; font-weight: 850; transition: border-color .18s, background .18s, color .18s; }
.view-switch a b { color: inherit; font-size: 10px; letter-spacing: .05em; }
.view-switch a:hover { color: #f4fdff; border-color: rgba(73, 220, 255, .4); background: rgba(10, 61, 79, .62); }
.view-switch a.active { color: #001821; border-color: transparent; background: linear-gradient(135deg, #5beaff, #20bff0); box-shadow: 0 5px 20px rgba(32, 208, 255, .2); }

.control-dock { position: absolute; z-index: 5; top: 94px; left: 16px; width: min(1120px, calc(100vw - 348px)); padding: 10px; border-radius: 15px; display: grid; grid-template-columns: auto auto minmax(170px, 1fr); gap: 9px; }
.control-row { display: flex; gap: 6px; }
button { color: #d9edf6; background: rgba(8, 38, 57, .75); border: 1px solid rgba(126, 191, 217, .23); border-radius: 9px; min-height: 38px; padding: 0 11px; font-size: 11px; font-weight: 850; cursor: pointer; transition: border-color .18s, background .18s, color .18s, transform .18s; }
button:hover { border-color: var(--cyan); color: white; transform: translateY(-1px); }
button.active, button[aria-pressed="true"] { color: #00141d; background: linear-gradient(135deg, #46e9ff, #19c5f1); border-color: transparent; box-shadow: 0 5px 22px rgba(32,208,255,.22); }
.action-row button { white-space: nowrap; }
#qualityButton { color: #b9f7ff; border-color: rgba(55,225,255,.42); background: linear-gradient(135deg, rgba(9,65,84,.88), rgba(7,36,56,.84)); }
#qualityButton[data-quality="ultra"] { color: #08111d; border-color: #ffd977; background: linear-gradient(135deg, #fff09c, #ffb928); box-shadow: 0 5px 22px rgba(255,185,40,.24); }
#qualityButton[data-quality="performance"] { color: #d8e7ed; border-color: rgba(156,182,197,.36); background: rgba(31,48,59,.82); }
.search-box { display: grid; grid-template-columns: auto minmax(120px, 1fr); align-items: center; gap: 8px; padding: 0 10px; min-height: 38px; border: 1px solid rgba(126, 191, 217, .23); background: rgba(2, 16, 27, .7); border-radius: 9px; }
.search-box span { font-size: 9px; font-weight: 900; letter-spacing: .12em; color: #6edff4; text-transform: uppercase; }
.search-box input { min-width: 0; width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 12px; }
.search-box input::placeholder { color: #6f8998; }

.status-card { position: absolute; z-index: 4; right: 16px; top: 94px; width: 300px; border-radius: 16px; padding: 15px; }
.eyebrow { color: #54dff7; font-size: 9px; font-weight: 950; letter-spacing: .17em; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 13px 0; }
.stat-grid div { min-width: 0; border: 1px solid rgba(122,190,218,.18); background: rgba(5, 29, 44, .64); border-radius: 10px; padding: 10px 7px; text-align: center; }
.stat-grid strong { display: block; font-size: 21px; color: #f4fdff; }
.stat-grid span { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.freshness-line { display: flex; justify-content: space-between; gap: 12px; padding: 5px 1px; color: var(--muted); font-size: 11px; }
.freshness-line strong { color: #dff9ff; }
.fleet-quick-list { display: grid; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(123,194,220,.16); }
.fleet-quick-list button { min-height: 34px; display: grid; grid-template-columns: 30px minmax(0,1fr) auto; align-items: center; gap: 7px; padding: 0 9px; text-align: left; background: linear-gradient(135deg, rgba(8,55,73,.9), rgba(4,29,44,.9)); border-color: rgba(63,226,246,.32); }
.fleet-quick-list button:hover { border-color: #53efff; background: linear-gradient(135deg, rgba(10,78,96,.95), rgba(5,39,56,.95)); }
.fleet-quick-list b { color: #31efff; font-size: 10px; letter-spacing: .08em; }
.fleet-quick-list span { min-width: 0; overflow: hidden; color: #e8fbff; font-size: 10px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.fleet-quick-list small { color: #9db7c4; font-size: 9px; white-space: nowrap; }
.fleet-quick-list .stale b, .fleet-quick-list .stale small { color: #ffbd5d; }
.status-card p { margin: 10px 0 0; padding-top: 10px; border-top: 1px solid rgba(123,194,220,.16); color: #a9c0cd; font-size: 11px; line-height: 1.45; }

.legend { position: absolute; z-index: 4; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 16px; padding: 10px 14px; border-radius: 13px; white-space: nowrap; }
.legend span { display: flex; align-items: center; gap: 6px; color: #c6dbe5; font-size: 10px; font-weight: 750; }
.legend i { width: 10px; height: 10px; border-radius: 3px 7px 7px 3px; background: var(--legend); box-shadow: 0 0 10px color-mix(in srgb, var(--legend), transparent 35%); }

.relief-scale { position: absolute; z-index: 4; left: 16px; top: 158px; width: min(330px, calc(100vw - 32px)); padding: 10px 12px; border-radius: 12px; }
.relief-scale strong { display: block; margin-bottom: 7px; color: #dffaff; font-size: 9px; letter-spacing: .13em; }
.relief-gradient { height: 10px; border: 1px solid rgba(235,250,255,.38); border-radius: 999px; background: linear-gradient(90deg, #061a43 0%, #073b72 16%, #0b6fa4 28%, #25b7c5 39%, #9adbd0 48%, #d5d89d 50%, #79b35a 58%, #4f913d 66%, #b49a45 76%, #a66b3d 84%, #7a4b35 90%, #c7b9ad 96%, #f8fbff 100%); box-shadow: 0 0 18px rgba(49,214,234,.18); }
.relief-values { display: flex; justify-content: space-between; margin-top: 5px; color: #9db8c6; font-size: 8px; }

.maplibregl-popup-content { min-width: 250px; padding: 0 !important; overflow: hidden; border: 1px solid rgba(48,205,255,.55); border-radius: 14px !important; color: #eafdff; background: rgba(3, 18, 29, .96) !important; box-shadow: 0 22px 65px rgba(0,0,0,.52) !important; }
.maplibregl-popup-tip { border-top-color: rgba(3,18,29,.96) !important; border-bottom-color: rgba(3,18,29,.96) !important; }
.maplibregl-popup-close-button { min-height: 0; padding: 2px 8px; font-size: 22px; color: #b7d1dd; background: transparent; border: 0; }
.vessel-popup { padding: 15px; }
.vessel-popup header { padding-right: 18px; }
.vessel-popup header small { display: block; color: #4eddf7; font-size: 9px; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.vessel-popup h2 { margin: 4px 0 2px; font-size: 17px; }
.vessel-popup header p { margin: 0; color: #9cb5c2; font-size: 11px; }
.popup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 13px; }
.popup-grid div { padding: 8px; border: 1px solid rgba(111,184,211,.17); border-radius: 8px; background: rgba(9,38,53,.55); }
.popup-grid span { display: block; color: #7f9baa; font-size: 8px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.popup-grid strong { display: block; margin-top: 3px; font-size: 11px; overflow-wrap: anywhere; }
.popup-freshness { margin: 11px 0 0; color: #9ab4c1; font-size: 10px; }

.fatal-error { position: absolute; z-index: 9; inset: 50% auto auto 50%; transform: translate(-50%, -50%); width: min(520px, calc(100vw - 34px)); padding: 20px; border: 1px solid #ff5471; border-radius: 14px; background: rgba(35, 4, 12, .94); color: #ffdce2; line-height: 1.5; box-shadow: 0 22px 70px rgba(0,0,0,.55); }
.hidden { display: none !important; }

@media (max-width: 1380px) {
  .control-dock { grid-template-columns: 1fr; width: min(560px, calc(100vw - 32px)); }
  .theme-row, .action-row { display: grid; grid-template-columns: repeat(5, 1fr); }
  .action-row { grid-template-columns: repeat(3, 1fr); }
  .status-card { top: 292px; }
  .relief-scale { top: 284px; left: 16px; width: min(300px, calc(100vw - 348px)); }
}

@media (max-width: 680px) {
  .topbar { left: 8px; right: 8px; top: 8px; min-height: 56px; }
  .brand { min-width: 0; }
  .brand-mark { width: 38px; height: 38px; font-size: 10px; }
  .brand strong { font-size: 15px; }
  .health { display: none; }
  .view-switch { margin-left: auto; }
  .view-switch a { min-width: 50px; min-height: 34px; padding: 0 8px; }
  .view-switch a span { display: none; }
  .control-dock { left: 8px; top: 76px; width: calc(100vw - 16px); }
  .theme-row { grid-template-columns: repeat(5, 1fr); }
  .theme-row button { padding: 0 5px; font-size: 9px; }
  .relief-scale { top: 292px; left: 8px; width: calc(100vw - 16px); }
  .status-card { top: auto; left: 8px; right: auto; bottom: 52px; width: min(310px, calc(100vw - 16px)); }
  .stat-grid { margin: 8px 0; }
  .legend { left: 8px; right: 8px; bottom: 8px; transform: none; overflow-x: auto; justify-content: flex-start; padding: 8px 10px; }
  .maplibregl-ctrl-bottom-right { bottom: 54px; }
  .maplibregl-ctrl-bottom-right { right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
