/* Ninja Navigate — Underway Navigation */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --header-height: 44px;
  --toolbar-width: 48px;
  --accent: #0078d4;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* App header */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1100;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: linear-gradient(135deg, #0a1628 0%, #142744 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.app-header__back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  color: #fff;
  text-decoration: none;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.app-header__back:hover { background: rgba(255,255,255,0.12); }
.app-header__title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Map fills below header, right of toolbar */
#map {
  position: fixed;
  top: var(--header-height);
  left: var(--toolbar-width);
  right: 0;
  bottom: 0;
}

/* ── Left toolbar ───────────────────────────────────────────── */
.toolbar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--toolbar-width);
  z-index: 1050;
  background: #1a2a44;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 4px;
  box-shadow: 2px 0 6px rgba(0,0,0,0.2);
}
.toolbar__btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.toolbar__btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}
.toolbar__btn.active {
  background: var(--accent);
  color: #fff;
}
.toolbar__separator {
  width: 28px;
  height: 1px;
  background: rgba(255,255,255,0.15);
  margin: 6px 0;
}
.toolbar__spacer {
  flex: 1;
}

/* ── Right-side floating buttons ────────────────────────────── */
.map-btn {
  position: fixed;
  z-index: 1000;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: #fff;
  color: #333;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.map-btn:hover { background: #f0f0f0; }
.map-btn:active { transform: scale(0.93); }

#btn-locate {
  bottom: 30px;
  right: 12px;
}
#btn-locate.active {
  background: var(--accent);
  color: #fff;
}

/* ── Panels ─────────────────────────────────────────────────── */
.map-panel {
  position: fixed;
  z-index: 1000;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  padding: 8px 12px;
  font-size: 13px;
  color: #333;
}

/* Measure/route info panel */
.measure-panel {
  bottom: 30px;
  left: calc(var(--toolbar-width) + 12px);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "SF Mono", "Consolas", "Courier New", monospace;
  font-size: 13px;
  white-space: nowrap;
}
.measure-clear {
  border: none;
  background: none;
  color: #999;
  font-size: 18px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.measure-clear:hover { color: #e63946; }

/* GPS coordinates display */
.coords-panel {
  bottom: 80px;
  right: 12px;
  font-family: "SF Mono", "Consolas", "Courier New", monospace;
  font-size: 12px;
  letter-spacing: 0.02em;
  display: none;
}
.coords-panel.visible { display: block; }

/* Loading indicator */
.loading-indicator {
  position: fixed;
  top: calc(var(--header-height) + 8px);
  right: 12px;
  z-index: 1001;
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s;
}
.loading-indicator.hidden { opacity: 0; }

/* ── GPS styles ─────────────────────────────────────────────── */
.gps-accuracy-circle {
  stroke: var(--accent);
  stroke-width: 1.5;
  fill: rgba(0, 120, 212, 0.1);
}
.gps-dot {
  width: 16px;
  height: 16px;
  background: var(--accent);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

/* ── Popup styles ───────────────────────────────────────────── */
.coord-popup .leaflet-popup-content-wrapper {
  border-radius: 8px;
  font-size: 13px;
}
.coord-popup .leaflet-popup-content {
  margin: 8px 12px;
  font-family: "SF Mono", "Consolas", "Courier New", monospace;
  line-height: 1.5;
}
.info-popup .leaflet-popup-content-wrapper {
  border-radius: 8px;
  min-width: 280px;
  max-width: 340px;
}
.info-popup .leaflet-popup-content {
  margin: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
  max-height: 280px;
  overflow-y: auto;
}
.info-popup table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
  table-layout: fixed;
}
.info-popup td {
  padding: 2px 6px 2px 0;
  vertical-align: top;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.info-popup td:first-child {
  font-weight: 600;
  color: #555;
  width: 40%;
}

/* ── Measure/route map elements ─────────────────────────────── */
.measure-label {
  background: rgba(0,0,0,0.7);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-family: "SF Mono", "Consolas", "Courier New", monospace;
  white-space: nowrap;
  border: none;
  box-shadow: none;
}
.measure-dot {
  width: 14px;
  height: 14px;
  background: #e63946;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  cursor: grab;
}
.measure-dot:active {
  cursor: grabbing;
}
.route-midpoint {
  width: 18px;
  height: 18px;
  background: rgba(0,120,212,0.25);
  border: 2px dashed var(--accent);
  border-radius: 50%;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.route-midpoint:hover {
  background: rgba(0,120,212,0.5);
  color: #fff;
}
.route-marker {
  width: 24px;
  height: 24px;
  background: var(--accent);
  color: #fff;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

/* ── Modal backdrop & panels ────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1059;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  z-index: 1060;
  width: 90vw;
  max-width: 600px;
  max-height: 80vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.modal-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}
.modal-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid #e5e5e5;
  flex-shrink: 0;
}
.modal-panel__header h3 {
  font-size: 15px;
  font-weight: 700;
  color: #1a2a44;
}
.modal-panel__close {
  border: none;
  background: none;
  font-size: 22px;
  color: #999;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.modal-panel__close:hover { color: #333; }
.modal-panel__body {
  padding: 12px 16px 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-panel__footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 10px 16px 14px;
  border-top: 1px solid #e5e5e5;
  flex-shrink: 0;
}
.modal-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.modal-btn--primary {
  background: var(--accent);
  color: #fff;
}
.modal-btn--primary:hover { background: #0063b1; }
.modal-btn--danger {
  background: #fee;
  color: #c0392b;
}
.modal-btn--danger:hover { background: #fdd; }

/* Route details table */
.route-table-wrap {
  overflow-x: auto;
}
.route-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.route-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #888;
  padding: 6px 8px;
  border-bottom: 2px solid #e5e5e5;
}
.route-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #f0f0f0;
  font-family: "SF Mono", "Consolas", "Courier New", monospace;
  font-size: 12px;
}
.legend-section {
  margin-bottom: 18px;
}
.legend-section h4 {
  font-size: 13px;
  font-weight: 700;
  color: #1a2a44;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 4px;
}
.legend-note {
  font-size: 11px;
  color: #666;
  margin-bottom: 8px;
  font-style: italic;
}
.legend-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: #444;
  line-height: 1.4;
}
.legend-item strong {
  color: #1a2a44;
  display: block;
  font-size: 12.5px;
}
.legend-svg {
  width: 28px;
  height: 40px;
  flex-shrink: 0;
}
.legend-section:nth-child(n+5) .legend-svg {
  height: 28px;
}
.legend-swatch {
  display: inline-block;
  width: 28px;
  height: 16px;
  border: 1px solid #ccc;
  border-radius: 2px;
  flex-shrink: 0;
}
.legend-line {
  display: inline-block;
  width: 28px;
  height: 0;
  border-bottom: 2px solid;
  flex-shrink: 0;
}
.legend-patch {
  display: inline-block;
  width: 28px;
  height: 16px;
  border: 1px dashed #999;
  border-radius: 2px;
  flex-shrink: 0;
}
.legend-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  font-size: 13px;
  font-weight: 700;
  color: #1a3a5c;
  font-style: italic;
  flex-shrink: 0;
}
.legend-abbr {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  font-style: italic;
  color: #555;
  margin-right: 2px;
}
.legend-abbr-row {
  margin-top: 10px;
  font-size: 12px;
  color: #555;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.legend-abbr-row .legend-abbr {
  margin-left: 0;
  margin-right: 3px;
}
.legend-pdf-link {
  display: block;
  margin-top: 16px;
  padding: 10px;
  text-align: center;
  background: #f0f4f8;
  border-radius: 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.legend-pdf-link:hover {
  background: #e2e8f0;
}

/* ── Settings tabs ─────────────────────────────────────────── */
.settings-tabs {
  display: flex;
  border-bottom: 2px solid #e2e8f0;
  padding: 0 16px;
}
.settings-tab {
  padding: 8px 16px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: #888;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.settings-tab:hover { color: #1a2a44; }
.settings-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.settings-tab-content { display: none; }
.settings-tab-content.active { display: block; }

/* ── Settings panel ────────────────────────────────────────── */
.settings-group {
  margin-bottom: 18px;
}
.settings-group:last-child {
  margin-bottom: 0;
}
.settings-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #1a2a44;
  margin-bottom: 8px;
}
.settings-radio-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.settings-radio {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #444;
  cursor: pointer;
}
.settings-radio input[type="radio"] {
  accent-color: var(--accent);
  margin: 0;
}
.settings-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}
.settings-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #444;
  cursor: pointer;
}
.settings-checkbox input[type="checkbox"] {
  accent-color: var(--accent);
  margin: 0;
}
.settings-layer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.settings-layer .settings-checkbox {
  flex-shrink: 0;
  min-width: 140px;
}
.settings-slider-sm {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
  height: 18px;
}

.settings-coverage {
  font-size: 10px;
  color: #8899aa;
  font-weight: normal;
}

/* Boat settings inputs */
.settings-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-input {
  width: 80px;
  padding: 6px 8px;
  border: 1px solid #ccd;
  border-radius: 4px;
  font-size: 13px;
  color: #1a2a44;
  background: #fff;
}
.settings-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}
.settings-input--wide { width: 100%; }
.settings-select {
  padding: 6px 8px;
  border: 1px solid #ccd;
  border-radius: 4px;
  font-size: 13px;
  color: #444;
  background: #fff;
  cursor: pointer;
}
.settings-select:focus {
  outline: none;
  border-color: var(--accent);
}
.settings-unit-label {
  font-size: 13px;
  color: #666;
}
.settings-hint {
  margin: 4px 0 0;
  font-size: 11px;
  color: #888;
}

/* Route depth warning */
.route-depth-warning {
  background: #fef3cd;
  border: 1px solid #ffc107;
  border-radius: 4px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 12px;
  color: #856404;
}
.route-depth-warning strong { color: #664d03; }
.route-passage-info {
  background: #e8f4f8;
  border: 1px solid #bee5eb;
  border-radius: 4px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 12px;
  color: #0c5460;
}

/* ── Info popup pilot content ─────────────────────────────── */
.info-learn-link {
  color: #0078d4;
  cursor: pointer;
  border-bottom: 1px dotted #0078d4;
}
.info-learn-link:hover {
  color: #005a9e;
  border-bottom-style: solid;
}
.pilot-content {
  font-size: 12px;
  line-height: 1.5;
}
.pilot-content h3 {
  font-size: 14px;
  margin: 0 0 8px;
  color: #1a2a44;
}
.pilot-content p {
  margin: 0 0 8px;
  color: #444;
}
.pilot-back {
  border: none;
  background: none;
  color: #0078d4;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  margin-bottom: 8px;
  display: block;
}
.pilot-back:hover {
  text-decoration: underline;
}
.pilot-tip {
  background: #f0f7ee;
  border-left: 3px solid #4caf50;
  padding: 6px 10px;
  margin: 8px 0;
  font-size: 11px;
  border-radius: 2px;
}
.pilot-warning {
  background: #fef3cd;
  border-left: 3px solid #ffc107;
  padding: 6px 10px;
  margin: 8px 0;
  font-size: 11px;
  border-radius: 2px;
}

/* ── Nautical mile scale bar ──────────────────────────────── */
.nm-scale {
  position: fixed;
  bottom: 8px;
  left: calc(var(--toolbar-width) + 10px);
  z-index: 1000;
  background: rgba(255,255,255,0.85);
  padding: 2px 8px 4px;
  border-radius: 4px;
  font-family: "SF Mono", "Consolas", "Courier New", monospace;
  font-size: 11px;
  color: #333;
  pointer-events: none;
  line-height: 1;
}
.nm-scale__bar {
  height: 4px;
  background: #333;
  border-left: 2px solid #333;
  border-right: 2px solid #333;
  margin-bottom: 2px;
}

/* ── Draw tool panel ───────────────────────────────────────── */
.draw-panel {
  top: calc(var(--header-height) + 8px);
  left: calc(var(--toolbar-width) + 8px);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
}
.draw-mode-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: #555;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.draw-mode-btn:hover { background: #e8e8e8; color: #333; }
.draw-mode-btn.active { background: var(--accent); color: #fff; }
.draw-mode-btn.active svg { stroke: #fff; }
.draw-clear-btn { color: #c0392b; }
.draw-clear-btn:hover { background: #fee; }
.draw-sep {
  width: 1px;
  height: 20px;
  background: #ccc;
  margin: 0 2px;
}

/* Draw markers */
.draw-point {
  width: 22px;
  height: 22px;
  background: #e63946;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  cursor: grab;
}
.draw-point:active { cursor: grabbing; }
.draw-point--standalone {
  background: #333;
}
.draw-coord-label {
  background: rgba(255,255,255,0.9);
  color: #333;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: "SF Mono", "Consolas", "Courier New", monospace;
  font-size: 10px;
  white-space: nowrap;
  border: 1px solid #ccc;
  box-shadow: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.draw-coord-label:hover {
  border-color: var(--accent);
}
.draw-dist-label {
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: "SF Mono", "Consolas", "Courier New", monospace;
  font-size: 11px;
  white-space: nowrap;
  border: none;
  box-shadow: none;
  cursor: pointer;
  transition: background 0.15s;
}
.draw-dist-label:hover {
  background: rgba(0,120,212,0.9);
}
.draw-edit-popup .leaflet-popup-content-wrapper {
  border-radius: 6px;
  padding: 0;
}
.draw-edit-popup .leaflet-popup-content {
  margin: 8px 10px;
}
.draw-edit-input {
  width: 180px;
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: "SF Mono", "Consolas", "Courier New", monospace;
  font-size: 12px;
  outline: none;
}
.draw-edit-input:focus { border-color: var(--accent); }
.draw-circle-outline {
  stroke: #e63946;
  stroke-width: 2;
  stroke-dasharray: 8,6;
  fill: rgba(230,57,70,0.08);
}

/* ── DR tool panel ────────────────────────────────────────── */
.dr-panel {
  top: calc(var(--header-height) + 8px);
  left: calc(var(--toolbar-width) + 8px);
  padding: 10px 14px;
  min-width: 260px;
}
.dr-row {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
  align-items: center;
}
.dr-row label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #444;
  font-weight: 600;
}
.dr-input {
  width: 60px;
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 12px;
  font-family: "SF Mono", "Consolas", "Courier New", monospace;
  outline: none;
  text-align: center;
}
.dr-input:focus { border-color: var(--accent); }
.dr-actions {
  margin-top: 4px;
  margin-bottom: 0;
}
.dr-btn {
  padding: 5px 14px;
  border: 1px solid #ccc;
  border-radius: 5px;
  background: #f5f5f5;
  color: #444;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.dr-btn:hover { background: #e8e8e8; }
.dr-btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.dr-btn--primary:hover { background: #0063b1; }
.dr-hint {
  font-size: 11px;
  color: #888;
  margin-top: 4px;
}

/* DR markers on map */
.dr-marker {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
}
.dr-marker__dot {
  width: 12px;
  height: 12px;
  background: #9b59b6;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  display: inline-block;
}
.dr-marker__label {
  position: absolute;
  left: 18px;
  top: -2px;
  background: rgba(155,89,182,0.9);
  color: #fff;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-family: "SF Mono", "Consolas", "Courier New", monospace;
  white-space: nowrap;
}

/* ── MOB styles ───────────────────────────────────────────── */
.toolbar__btn--mob {
  background: rgba(192,57,43,0.2) !important;
  color: #e74c3c !important;
}
.toolbar__btn--mob:hover {
  background: rgba(192,57,43,0.4) !important;
}
.toolbar__btn--mob.active {
  background: #e74c3c !important;
  color: #fff !important;
  animation: mob-pulse 1s infinite;
}
@keyframes mob-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(231,76,60,0.6); }
  50% { box-shadow: 0 0 0 6px rgba(231,76,60,0); }
}

.mob-panel {
  top: calc(var(--header-height) + 8px);
  right: 60px;
  min-width: 220px;
  border-left: 3px solid #e74c3c;
}
.mob-panel__title {
  font-weight: 700;
  color: #e74c3c;
  font-size: 14px;
  margin-bottom: 6px;
}
.mob-clear-btn {
  margin-top: 6px;
  padding: 4px 12px;
  border: 1px solid #e74c3c;
  border-radius: 4px;
  background: #fee;
  color: #c0392b;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.mob-clear-btn:hover { background: #fdd; }

/* MOB marker on map */
.mob-marker {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
}
.mob-marker__ring {
  position: absolute;
  top: 0; left: 0;
  width: 40px;
  height: 40px;
  border: 3px solid #e74c3c;
  border-radius: 50%;
  animation: mob-ring 1.5s ease-out infinite;
}
@keyframes mob-ring {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(2); opacity: 0; }
}
.mob-marker__dot {
  position: absolute;
  top: 10px; left: 10px;
  width: 20px;
  height: 20px;
  background: #e74c3c;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
  color: #fff;
  font-size: 7px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: mob-flash 0.8s infinite;
}
@keyframes mob-flash {
  0%, 100% { background: #e74c3c; }
  50% { background: #ff6b6b; }
}

/* ── Anchor Watch styles ──────────────────────────────────── */
.anchor-panel {
  top: calc(var(--header-height) + 8px);
  right: 60px;
  min-width: 240px;
}
.anchor-panel__title {
  font-weight: 700;
  color: #1a2a44;
  font-size: 14px;
  margin-bottom: 6px;
}
.anchor-panel.anchor-alarm {
  border: 2px solid #e74c3c;
  background: rgba(255,200,200,0.95);
  animation: anchor-alarm-flash 0.5s infinite;
}
@keyframes anchor-alarm-flash {
  0%, 100% { background: rgba(255,200,200,0.95); }
  50% { background: rgba(255,150,150,0.95); }
}
.anchor-icon {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
}

/* ── Trip Log styles ──────────────────────────────────────── */
.triplog-panel {
  top: calc(var(--header-height) + 8px);
  right: 60px;
  min-width: 200px;
}
.triplog-panel__title {
  font-weight: 700;
  color: #1a2a44;
  font-size: 14px;
  margin-bottom: 8px;
}
.triplog-stat {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 12px;
}
.triplog-stat__label { color: #666; }
.triplog-stat__val {
  font-weight: 600;
  font-family: "SF Mono", "Consolas", "Courier New", monospace;
  color: #1a2a44;
}

/* ── Active Navigation Panel ──────────────────────────────── */
.nav-panel {
  position: fixed;
  top: calc(var(--header-height) + 8px);
  right: 12px;
  z-index: 1000;
  background: rgba(26,42,68,0.95);
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  min-width: 160px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.nav-panel__row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  gap: 12px;
}
.nav-panel__label {
  color: rgba(255,255,255,0.6);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.nav-panel__val {
  font-weight: 600;
  font-family: "SF Mono", "Consolas", "Courier New", monospace;
  font-size: 13px;
}

/* ── AIS vessel markers ───────────────────────────────────── */
.ais-vessel {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  cursor: pointer;
}
.ais-vessel__name {
  position: absolute;
  left: 28px;
  top: 4px;
  font-size: 9px;
  font-weight: 600;
  color: #1a2a44;
  white-space: nowrap;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff;
}

/* ── Night Mode ───────────────────────────────────────────── */
body.night-mode {
  filter: brightness(0.6) sepia(1) saturate(3) hue-rotate(-30deg);
}
body.night-mode .app-header {
  background: linear-gradient(135deg, #1a0000 0%, #2a0808 100%) !important;
}
body.night-mode .toolbar {
  background: #1a0505 !important;
}
body.night-mode .map-panel,
body.night-mode .nav-panel {
  background: rgba(30,5,5,0.95) !important;
  color: #ff8888 !important;
}
body.night-mode .modal-panel {
  background: #1a0505 !important;
  color: #ff8888 !important;
}
body.night-mode .modal-panel__header {
  border-bottom-color: #3a1010 !important;
}
body.night-mode .modal-panel__header h3 {
  color: #ff6666 !important;
}

/* ── Search bar (in header) ─────────────────────────────────── */
.search-bar {
  position: relative;
  margin-left: auto;
  width: 260px;
  flex-shrink: 0;
}
.search-bar__input-wrap {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 0 8px;
  height: 32px;
  transition: background 0.2s;
}
.search-bar__input-wrap:focus-within {
  background: rgba(255,255,255,0.95);
}
.search-bar__input-wrap:focus-within .search-bar__icon {
  stroke: #555;
}
.search-bar__icon {
  flex-shrink: 0;
  stroke: rgba(255,255,255,0.7);
  transition: stroke 0.2s;
}
.search-bar__input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 13px;
  padding: 0 6px;
  outline: none;
}
.search-bar__input::placeholder {
  color: rgba(255,255,255,0.55);
}
.search-bar__input-wrap:focus-within .search-bar__input {
  color: #222;
}
.search-bar__input-wrap:focus-within .search-bar__input::placeholder {
  color: #999;
}
.search-bar__clear {
  display: none;
  border: none;
  background: none;
  color: rgba(255,255,255,0.6);
  font-size: 18px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.search-bar__input-wrap:focus-within .search-bar__clear {
  color: #888;
}
.search-bar__clear.visible {
  display: block;
}

/* Dropdown (scope toggle + results) */
.search-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  margin-top: 4px;
  background: #fff;
  color: #222;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  overflow: hidden;
  max-height: 55vh;
  flex-direction: column;
  z-index: 1200;
}
.search-dropdown.open {
  display: flex;
}
.search-scope-row {
  display: flex;
  padding: 6px 8px;
  gap: 0;
  border-bottom: 1px solid #e5e5e5;
}
.search-scope-btn {
  flex: 1;
  padding: 5px 0;
  border: 1px solid #ccc;
  background: #f5f5f5;
  color: #666;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.search-scope-btn:first-child {
  border-radius: 4px 0 0 4px;
}
.search-scope-btn:last-child {
  border-radius: 0 4px 4px 0;
  border-left: none;
}
.search-scope-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.search-results {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.search-results-group h4 {
  margin: 0;
  padding: 6px 12px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  background: #f7f7f7;
  border-bottom: 1px solid #eee;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.15s;
}
.search-result-item:hover {
  background: #e8f0fe;
}
.search-result-item.active {
  background: #d0e2fd;
}
.search-result-name {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-type {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 6px;
  border-radius: 3px;
  background: #e8e8e8;
  color: #555;
}
.search-result-type--place {
  background: #e0f2e9;
  color: #1b6e3d;
}
.search-result-type--nav {
  background: #e0ecf8;
  color: #1a5290;
}
.search-loading,
.search-empty {
  padding: 16px 12px;
  text-align: center;
  color: #888;
  font-size: 12px;
}
.search-marker-icon {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
}

/* ── Tutorial modal ────────────────────────────────────────── */
.tutorial-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}
.tutorial-item:last-child {
  border-bottom: none;
}
.tutorial-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a2a44;
  border-radius: 6px;
  color: #fff;
}
.tutorial-text strong {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
  color: #1a2a44;
}
.tutorial-text p {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: #555;
}
.tutorial-list {
  margin: 4px 0 0;
  padding-left: 16px;
  font-size: 12px;
  line-height: 1.5;
  color: #555;
}
.tutorial-list li {
  margin-bottom: 4px;
}
.tutorial-list li strong {
  color: #1a2a44;
}
.tutorial-text em {
  font-style: normal;
  font-weight: 600;
  color: #0078d4;
}
.tutorial-tip {
  margin-top: 12px;
  padding: 10px 12px;
  background: #f0f6ff;
  border-radius: 6px;
  font-size: 12px;
  color: #1a5290;
}
.tutorial-tip strong {
  color: #0078d4;
}
.tutorial-tip kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 11px;
  font-family: inherit;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 3px;
  box-shadow: 0 1px 0 #ddd;
}

/* ── Cursors for tool modes ─────────────────────────────────── */
.cursor-crosshair { cursor: crosshair; }
.cursor-route { cursor: crosshair; }
.cursor-info { cursor: help; }

/* ── Mobile adjustments ─────────────────────────────────────── */
@media (max-width: 480px) {
  :root {
    --toolbar-width: 42px;
  }
  .toolbar__btn {
    width: 36px;
    height: 36px;
  }
  #btn-locate {
    bottom: 20px;
    right: 8px;
  }
  .coords-panel {
    bottom: 70px;
    right: 8px;
    font-size: 11px;
  }
  .measure-panel {
    left: calc(var(--toolbar-width) + 8px);
    bottom: 20px;
    font-size: 12px;
  }
  .modal-panel {
    width: 95vw;
    max-height: 85vh;
  }
  .search-bar {
    width: 160px;
  }
  .mob-panel, .anchor-panel, .triplog-panel {
    right: 8px;
    left: calc(var(--toolbar-width) + 8px);
    min-width: auto;
  }
  .nav-panel {
    right: 8px;
    min-width: 140px;
  }
  .dr-panel {
    left: calc(var(--toolbar-width) + 4px);
    right: 8px;
    min-width: auto;
  }
}

/* ── Fix Tool sub-panel ────────────────────────────────────── */
.fix-panel {
  top: calc(var(--header-height) + 8px);
  left: calc(var(--toolbar-width) + 8px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  min-width: 150px;
  max-height: calc(100vh - var(--header-height) - 60px);
  overflow-y: auto;
}
.fix-mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: #555;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  text-align: left;
}
.fix-mode-btn:hover { background: #e8e8e8; color: #333; }
.fix-mode-btn.active { background: var(--accent); color: #fff; }
.fix-mode-btn.active svg { stroke: #fff; }
.fix-clear-btn { color: #c0392b; }
.fix-clear-btn:hover { background: #fee; }

/* ── Fix input bar (bottom command line) ──────────────────── */
.fix-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: rgba(18, 28, 42, 0.97);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  z-index: 900;
  color: #e0ecf8;
  font-size: 13px;
  box-sizing: border-box;
}
.fix-bar__cancel {
  flex-shrink: 0;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  color: #c8d8e8;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.fix-bar__cancel:hover { background: rgba(255, 255, 255, 0.18); }
.fix-bar__body {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
}
.fix-bar__sep {
  color: rgba(255, 255, 255, 0.35);
  font-size: 16px;
  flex-shrink: 0;
}
.fix-bar__label {
  font-weight: 700;
  color: #7ec8e3;
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}
.fix-bar__prompt {
  color: #c8d8e8;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
}
.fix-bar__input {
  width: 80px;
  min-width: 60px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 13px;
  outline: none;
  flex-shrink: 0;
}
.fix-bar__input:focus { border-color: #7ec8e3; background: rgba(126, 200, 227, 0.1); }
.fix-bar__unit {
  color: #7a8fa8;
  font-size: 12px;
  flex-shrink: 0;
  white-space: nowrap;
}
.fix-bar__skip,
.fix-bar__confirm {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}
.fix-bar__skip {
  background: rgba(255, 255, 255, 0.1);
  color: #c8d8e8;
}
.fix-bar__skip:hover { background: rgba(255, 255, 255, 0.18); }
.fix-bar__confirm {
  background: #2980b9;
  color: #fff;
}
.fix-bar__confirm:hover { background: #3498db; }
.fix-bar__step {
  flex-shrink: 0;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  white-space: nowrap;
}

/* Offset coords panel and other bottom elements when fix bar is visible */
body.fix-bar-open .coords-panel { bottom: 60px; }
body.fix-bar-open #btn-locate { bottom: 60px; }

/* ── Fix markers on chart ──────────────────────────────────── */
.fix-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}
.fix-marker__cross {
  width: 18px;
  height: 18px;
  position: relative;
}
.fix-marker__cross::before,
.fix-marker__cross::after {
  content: '';
  position: absolute;
  background: #e74c3c;
}
.fix-marker__cross::before { width: 18px; height: 2px; top: 8px; left: 0; }
.fix-marker__cross::after  { width: 2px; height: 18px; top: 0; left: 8px; }
.fix-marker__circle {
  width: 10px;
  height: 10px;
  border: 2px solid #e74c3c;
  border-radius: 50%;
  position: absolute;
  top: 4px;
  left: 4px;
  background: transparent;
}
.fix-marker__label {
  margin-top: 2px;
  font-size: 10px;
  font-weight: 700;
  color: #e74c3c;
  white-space: nowrap;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff;
}

/* ── Voyage Logbook overlay ──────────────────────────────────── */
.log-overlay {
  position: fixed;
  top: var(--header-height);
  left: var(--toolbar-width);
  right: 0;
  bottom: 0;
  background: var(--bg, #f0f4f8);
  z-index: 800;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.log-overlay__header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid #d0dce8;
  background: #fff;
  flex-shrink: 0;
}
.log-overlay__title {
  font-weight: 700;
  font-size: 14px;
  color: #1a2b3c;
  white-space: nowrap;
}
.log-overlay__close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 20px;
  color: #5a7080;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
}
.log-overlay__close:hover { color: #1a2b3c; }
.log-mode-toggle {
  display: flex;
  gap: 3px;
  background: #e8f0f8;
  border-radius: 6px;
  padding: 3px;
}
.log-mode-btn {
  padding: 4px 14px;
  border-radius: 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #5a7080;
  transition: background 0.15s, color 0.15s;
}
.log-mode-btn.active {
  background: #fff;
  color: #1a2b3c;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.log-section {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.log-section__bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid #d0dce8;
  background: #f8fafc;
  flex-shrink: 0;
}
.log-btn {
  padding: 5px 12px;
  border-radius: 5px;
  border: 1px solid #c0d0dc;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: #1a2b3c;
  transition: background 0.15s;
}
.log-btn:hover { background: #e8f0f8; }
.log-btn--primary {
  background: var(--accent, #2980b9);
  color: #fff;
  border-color: var(--accent, #2980b9);
}
.log-btn--primary:hover { background: #3498db; border-color: #3498db; }
.log-hint {
  font-size: 11px;
  color: #7a8fa8;
  margin-left: 0.5rem;
}
.log-table-wrap {
  flex: 1;
  overflow-x: auto;
  overflow-y: auto;
  padding: 0.75rem 1rem;
}
.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 700px;
}
.log-table th {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #7a8fa8;
  padding: 6px 10px;
  border-bottom: 2px solid #d0dce8;
  text-align: left;
  white-space: nowrap;
}
.log-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #e8f0f8;
  vertical-align: middle;
  color: #2d3d4a;
}
.log-table tr:hover td { background: #f0f7ff; }
.log-table .log-del-btn {
  background: none;
  border: none;
  color: #c0392b;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 3px;
}
.log-table .log-del-btn:hover { background: #fee; }
.log-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: #7a8fa8;
  font-size: 13px;
}

/* ── Log entry modal ───────────────────────────────────────── */
.log-entry-modal {
  max-width: 680px;
}
.log-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
}
.log-form-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #5a7080;
}
.log-form-input {
  padding: 6px 10px;
  border: 1px solid #c0d0dc;
  border-radius: 5px;
  font-size: 13px;
  color: #1a2b3c;
  background: #fff;
  width: 100%;
  box-sizing: border-box;
}
.log-form-input:focus { border-color: var(--accent); outline: none; }
.log-form-full {
  grid-column: 1 / -1;
}
.log-form-full .log-form-input { resize: vertical; }
.log-form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e0eaf4;
}

/* ── Dark mode (night mode) overrides ─────────────────────── */
body.night-mode .fix-panel { background: rgba(30,5,5,0.95) !important; }
body.night-mode .fix-mode-btn { color: #bb7777; }
body.night-mode .fix-mode-btn:hover { background: rgba(255,80,80,0.1); color: #cc9999; }
body.night-mode .fix-mode-btn.active { background: #600; color: #ffaaaa; }
body.night-mode .log-overlay {
  background: #1a0505 !important;
}
body.night-mode .log-overlay__header {
  background: rgba(30,5,5,0.95) !important;
  border-color: #400;
}
body.night-mode .log-overlay__title { color: #ffaaaa; }
body.night-mode .log-section__bar { background: #120202; border-color: #400; }
body.night-mode .log-table th { color: #995555; border-color: #400; }
body.night-mode .log-table td { border-color: #200; color: #cc9090; }
body.night-mode .log-table tr:hover td { background: rgba(255,50,50,0.05); }
body.night-mode .log-btn { background: #2a0505; border-color: #400; color: #cc9090; }
body.night-mode .log-btn:hover { background: #380606; }
body.night-mode .log-entry-modal { background: rgba(30,5,5,0.97) !important; }
body.night-mode .log-form-input { background: #1a0303; border-color: #500; color: #ffaaaa; }
body.night-mode .log-mode-toggle { background: rgba(80,0,0,0.4); }
body.night-mode .log-mode-btn { color: #995555; }
body.night-mode .log-mode-btn.active { background: #400; color: #ffaaaa; }

/* ── Responsive fix panel ─────────────────────────────────── */
@media (max-width: 480px) {
  .fix-panel {
    left: calc(var(--toolbar-width) + 4px);
    right: 8px;
    min-width: auto;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .fix-bar {
    padding: 0 0.5rem;
    gap: 0.4rem;
  }
  .fix-bar__prompt {
    display: none;
  }
  .log-overlay {
    left: 0;
  }
  .log-form-grid {
    grid-template-columns: 1fr;
  }
}
