/* MarineGlobe 3D — Maritime Navigation Console Design System */

:root {
  --bg: #040b14;
  --surface: rgba(9, 21, 35, 0.88);
  --surface-solid: #0a1726;
  --surface-hover: rgba(20, 42, 66, 0.85);
  --border: rgba(148, 184, 214, 0.16);
  --border-strong: rgba(148, 184, 214, 0.28);
  --text: #e6f0f8;
  --text-muted: #8ea6bd;
  --accent: #0ea5e9;
  --accent-soft: rgba(14, 165, 233, 0.16);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --radius: 10px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Pretendard", "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

body.theme-light {
  --bg: #e8eff5;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-solid: #ffffff;
  --surface-hover: rgba(241, 245, 249, 0.95);
  --border: rgba(15, 23, 42, 0.12);
  --border-strong: rgba(15, 23, 42, 0.22);
  --text: #0f172a;
  --text-muted: #475569;
  --accent: #0284c7;
  --accent-soft: rgba(2, 132, 199, 0.12);
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Main App Layout */
.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.globe-viewport {
  position: absolute;
  inset: 0;
  z-index: 1;
}

#globe-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

/* Top Navigation Bar */
.topbar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-shrink: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent-soft);
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  color: var(--accent);
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.preset-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  justify-content: safe center;
}

.preset-bar::-webkit-scrollbar {
  display: none;
}

.preset-bar > * {
  flex-shrink: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.telemetry-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.14);
  font-size: 12px;
}

body.theme-light .telemetry-strip {
  background: rgba(15, 23, 42, 0.04);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  margin-right: 5px;
}

.status-dot.sim {
  background: var(--accent);
}

.status-dot.error {
  background: var(--danger);
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  filter: brightness(1.08);
  background: var(--accent);
}

.btn-icon {
  padding: 5px 8px;
}

/* Left Sidebar: Vessel Explorer */
.sidebar {
  position: absolute;
  top: 72px;
  left: 12px;
  bottom: 12px;
  width: 312px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  transition: transform 0.22s ease;
}

.sidebar.collapsed {
  transform: translateX(calc(-100% - 20px));
}

.sidebar-header {
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-box {
  width: 100%;
  padding: 7px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-size: 12.5px;
  outline: none;
}

body.theme-light .search-box {
  background: rgba(15, 23, 42, 0.04);
}

.search-box:focus {
  border-color: var(--accent);
}

.filter-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.filter-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.filter-chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.filter-chip.active {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
  font-weight: 600;
}

.type-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.vessel-list-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.vessel-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vessel-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 8px 9px;
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.vessel-item:hover {
  background: var(--surface-hover);
  border-color: var(--border);
}

.vessel-item.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.vessel-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.vessel-name {
  font-weight: 600;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vessel-speed {
  font-size: 11.5px;
  color: var(--accent);
  flex-shrink: 0;
}

.vessel-item-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

/* Right Panel: Selected Vessel Telemetry */
.inspector {
  position: absolute;
  top: 72px;
  right: 12px;
  width: 368px;
  max-height: calc(100vh - 144px);
  overflow-y: auto;
  z-index: 16;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.inspector.hidden {
  display: none;
}

.inspector-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.inspector-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.inspector-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.mini-badge {
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.16);
  color: var(--text-muted);
}

body.theme-light .mini-badge {
  background: rgba(15, 23, 42, 0.05);
}

.section-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: -5px;
}

.route-banner {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 9px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.16);
}

body.theme-light .route-banner {
  background: rgba(15, 23, 42, 0.04);
}

.route-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.route-port {
  font-weight: 700;
  font-size: 13px;
}

.route-port-name {
  font-size: 10.5px;
  color: var(--text-muted);
}

.route-arrow {
  color: var(--accent);
  font-size: 12px;
  flex-shrink: 0;
}

.progress-track {
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: rgba(148, 184, 214, 0.18);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.route-metrics {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-muted);
}

.kv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.kv-cell {
  padding: 7px 9px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
}

.kv-cell.full {
  grid-column: 1 / -1;
}

body.theme-light .kv-cell {
  background: rgba(15, 23, 42, 0.03);
}

.kv-label {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.kv-value {
  font-size: 12px;
  font-weight: 600;
  word-break: break-word;
}

.kv-sub {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.trail-log {
  max-height: 92px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.12);
  font-size: 10.5px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

body.theme-light .trail-log {
  background: rgba(15, 23, 42, 0.03);
}

.inspector-actions {
  display: flex;
  gap: 8px;
}

.inspector-actions .btn {
  flex: 1;
  justify-content: center;
}

/* Sidebar Enhancements */
.sidebar-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.sort-select {
  padding: 3px 6px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
}

.fleet-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 10.5px;
}

.fleet-stat {
  display: flex;
  flex-direction: column;
  padding: 4px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.14);
  border: 1px solid var(--border);
}

body.theme-light .fleet-stat {
  background: rgba(15, 23, 42, 0.03);
}

.fleet-stat span {
  color: var(--text-muted);
  font-size: 10px;
}

.fleet-stat strong {
  font-size: 11.5px;
  margin-top: 1px;
}

.mini-progress {
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: rgba(148, 184, 214, 0.15);
  overflow: hidden;
  margin-top: 2px;
}

.mini-progress > span {
  display: block;
  height: 100%;
  border-radius: 999px;
}

/* Bottom Controls Toolbar */
.bottom-bar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
  max-width: calc(100vw - 24px);
}

.divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 2px;
}

.coord-readout {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 14;
  padding: 5px 10px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  backdrop-filter: blur(10px);
}

/* Floating Hover Tooltip */
.hover-tooltip {
  position: absolute;
  z-index: 30;
  pointer-events: none;
  padding: 9px 11px;
  border-radius: 8px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  font-size: 11.5px;
  max-width: 280px;
  transition: opacity 0.1s ease;
}

.hover-tooltip.hidden {
  opacity: 0;
  visibility: hidden;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(2, 6, 14, 0.68);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-card h2 {
  margin: 0;
  font-size: 16px;
}

.modal-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 12.5px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-group label {
  font-size: 12px;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* Full Fleet Data Table Modal */
.fleet-modal-card {
  width: min(1360px, 96vw);
  height: min(86vh, 840px);
  max-width: none;
  padding: 16px;
  gap: 10px;
}

.fleet-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.fleet-table-wrap {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.fleet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  white-space: nowrap;
}

.fleet-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-solid);
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-strong);
  cursor: pointer;
  user-select: none;
}

.fleet-table thead th:hover {
  color: var(--text);
}

.fleet-table tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s ease;
}

.fleet-table tbody tr:hover {
  background: var(--surface-hover);
}

.fleet-table tbody tr.selected {
  background: var(--accent-soft);
}

.fleet-table td {
  padding: 6px 10px;
}

/* Desktop defaults for mobile-only helpers */
.btn,
.filter-chip,
.vessel-item {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.label-mobile,
.sidebar-mobile-bar,
.mobile-backdrop,
.sheet-handle {
  display: none;
}

/* Never leave floating mouse tooltips stuck on touch-only screens */
@media (hover: none) and (pointer: coarse) {
  .hover-tooltip {
    display: none !important;
  }
}

/* Tablet & Narrow Desktop (<= 960px) */
@media (max-width: 960px) {
  .brand-sub,
  .status-rate-wrap {
    display: none;
  }

  /* Keep sea-zone presets accessible as a swipeable pill row beneath the topbar */
  .preset-bar {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 19;
    justify-content: flex-start;
    gap: 6px;
    padding: 2px 0;
    -webkit-overflow-scrolling: touch;
  }

  .preset-bar .btn {
    background: var(--surface);
    border-color: var(--border);
    backdrop-filter: blur(10px);
    border-radius: 999px;
    padding: 5px 11px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.25);
  }

  .preset-bar .btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
  }

  .sidebar {
    top: 110px;
    width: 288px;
  }

  .inspector {
    top: 110px;
    width: calc(100vw - 24px);
    max-width: 360px;
    max-height: calc(100dvh - 178px);
  }
}

/* Mobile Phones (<= 768px) */
@media (max-width: 768px) {
  .topbar {
    top: max(8px, env(safe-area-inset-top));
    left: 8px;
    right: 8px;
    padding: 6px 8px;
    gap: 6px;
    border-radius: 12px;
  }

  .brand {
    gap: 7px;
  }

  .brand-mark,
  .brand-sub {
    display: none;
  }

  .brand-title {
    font-size: 13.5px;
  }

  #btn-toggle-sidebar {
    min-width: 36px;
    min-height: 36px;
    justify-content: center;
    font-size: 16px;
    padding: 4px;
  }

  .topbar-right {
    gap: 5px;
  }

  .telemetry-strip {
    padding: 4px 8px;
    gap: 5px;
    font-size: 11.5px;
    min-height: 36px;
  }

  .status-mode-text,
  .status-label,
  .status-rate-wrap {
    display: none;
  }

  .status-dot {
    margin-right: 0;
    vertical-align: middle;
  }

  .label-desktop {
    display: none;
  }

  .label-mobile {
    display: inline;
  }

  .topbar-right .btn {
    min-height: 36px;
    padding: 6px 9px;
    font-size: 12px;
  }

  .topbar-right .btn-icon {
    min-width: 36px;
    padding: 6px;
    justify-content: center;
  }

  .preset-bar {
    top: calc(100% + 6px);
  }

  .preset-bar .btn {
    min-height: 32px;
    padding: 5px 11px;
    font-size: 12px;
  }

  /* Backdrop behind slide-over mobile drawer */
  .mobile-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(2, 8, 16, 0.56);
    backdrop-filter: blur(2px);
  }

  .mobile-backdrop.hidden {
    display: none;
  }

  /* Slide-over full-height mobile vessel drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(88vw, 340px);
    z-index: 40;
    border-radius: 0 16px 16px 0;
    border-left: none;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface-solid);
  }

  .sidebar.collapsed {
    transform: translateX(-105%);
    pointer-events: none;
  }

  .sidebar-mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 12px 6px;
    font-size: 14px;
    font-weight: 700;
  }

  #btn-close-sidebar {
    min-width: 36px;
    min-height: 36px;
    justify-content: center;
    font-size: 15px;
  }

  .sidebar-header {
    padding: 8px 12px 10px;
  }

  /* 16px prevents iOS Safari automatic zoom on input focus */
  .search-box,
  .sort-select {
    font-size: 16px;
    padding: 9px 11px;
  }

  .sort-select {
    font-size: 13px;
    padding: 6px 8px;
  }

  .filter-chip {
    padding: 6px 9px;
    font-size: 12px;
  }

  .vessel-item {
    padding: 11px 10px;
  }

  .vessel-name {
    font-size: 13.5px;
  }

  /* Native-feeling Bottom Sheet Vessel Inspector */
  .inspector {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    max-height: 48dvh;
    z-index: 34;
    border-radius: 18px 18px 0 0;
    border-bottom: none;
    padding: 0 14px calc(12px + env(safe-area-inset-bottom));
    background: var(--surface-solid);
    transition: max-height 0.24s ease;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .inspector.expanded {
    max-height: 82dvh;
  }

  .sheet-handle {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 0 8px;
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--surface-solid);
    margin: 0 -14px;
    border-radius: 18px 18px 0 0;
    cursor: pointer;
    touch-action: none;
  }

  .sheet-handle span {
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: var(--border-strong);
  }

  .inspector-head {
    padding-top: 2px;
  }

  #btn-close-inspector {
    min-width: 36px;
    min-height: 36px;
    justify-content: center;
    font-size: 15px;
  }

  .inspector-actions {
    position: sticky;
    bottom: calc(-12px - env(safe-area-inset-bottom));
    background: var(--surface-solid);
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    margin: 4px -14px calc(-12px - env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
  }

  .inspector-actions .btn {
    min-height: 42px;
    font-size: 13px;
  }

  /* Single-row horizontally swipeable bottom toolbar */
  .bottom-bar {
    left: 8px;
    right: 8px;
    bottom: max(10px, env(safe-area-inset-bottom));
    transform: none;
    max-width: none;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 6px 8px;
    gap: 6px;
    border-radius: 14px;
    transition: opacity 0.18s ease;
  }

  .bottom-bar::-webkit-scrollbar {
    display: none;
  }

  .bottom-bar .divider {
    display: none;
  }

  .bottom-bar .btn {
    flex-shrink: 0;
    min-height: 38px;
    padding: 7px 12px;
    font-size: 12.5px;
  }

  .bottom-bar .btn-icon {
    min-width: 38px;
    padding: 7px;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
  }

  /* Compact coordinate & zoom badge aligned with canvas scale bar */
  .coord-readout {
    display: block;
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 58px);
    left: 10px;
    right: auto;
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: opacity 0.18s ease;
  }

  /* Let the bottom sheet cleanly own the bottom area while inspecting a vessel */
  body.inspector-open .bottom-bar,
  body.inspector-open .coord-readout {
    opacity: 0;
    pointer-events: none;
  }

  /* Touch-friendly Modals */
  .modal-backdrop {
    padding: 8px;
  }

  .modal-card {
    max-height: 90dvh;
    overflow-y: auto;
    padding: 16px;
    border-radius: 14px;
  }

  .modal-card input,
  .modal-card select {
    font-size: 16px;
    padding: 9px 10px;
  }

  .modal-actions .btn {
    min-height: 40px;
    padding: 8px 14px;
  }

  .fleet-modal-card {
    width: 100%;
    height: 92dvh;
    padding: 12px;
    border-radius: 14px;
  }

  .fleet-modal-header h2 {
    font-size: 15px;
  }

  .fleet-modal-header p {
    font-size: 11.5px;
  }

  .fleet-table-wrap {
    -webkit-overflow-scrolling: touch;
  }

  .fleet-table td {
    padding: 10px 8px;
    font-size: 12px;
  }
}

/* Extra narrow phones (<= 380px) */
@media (max-width: 380px) {
  .brand-title {
    font-size: 12px;
  }
  .topbar {
    gap: 4px;
    padding: 5px 6px;
  }
  .topbar-right {
    gap: 4px;
  }
  .topbar-right .btn {
    padding: 5px 7px;
    font-size: 11.5px;
  }
  .telemetry-strip {
    padding: 4px 6px;
    font-size: 11px;
  }
}

/* Long AIS station keys / source IDs wrap cleanly */
.kv-value { overflow-wrap: anywhere; }
