/* ═══════════════════════════════════════════════════════════
   RNLI LAUNCH BOARD — Emergency Services / CAD Dark Theme
   Fonts: Rajdhani (display), Share Tech Mono (data)
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;600;700&family=Share+Tech+Mono&display=swap');

/* ── Variables ───────────────────────────────────────────── */
:root {
  --bg:           #0a0c10;
  --bg-panel:     #0e1117;
  --bg-panel2:    #121620;
  --bg-header:    #060809;
  --border:       #1e2a38;
  --border-bright:#2e4a68;

  --rnli-blue:    #005EB8;
  --rnli-yellow:  #FFD700;
  --rnli-red:     #E30613;
  --accent:       #00b4ff;
  --accent-dim:   #005580;
  --green:        #00e676;
  --green-dim:    #00512a;
  --amber:        #FFB300;
  --red-alert:    #ff1744;
  --red-dim:      #4a0010;

  --text:         #d8e4f0;
  --text-muted:   #5a7a99;
  --text-bright:  #ffffff;
  --text-label:   #4a7a9b;

  --font-display: 'Rajdhani', 'Segoe UI', sans-serif;
  --font-mono:    'Share Tech Mono', 'Courier New', monospace;

  --radius:       3px;
  --panel-gap:    2px;
}

/* ── Reset / Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* ── Scanline overlay ────────────────────────────────────── */
body::after {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.08) 3px,
    rgba(0,0,0,0.08) 4px
  );
  z-index: 9999;
}

/* ── Header ──────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-header);
  border-bottom: 2px solid var(--rnli-blue);
  padding: 0 16px;
  height: 56px;
  flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 14px; }

.rnli-logo {
  height: 60px;
  width: auto;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
}

.header-titles { display: flex; flex-direction: column; }
.header-main {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-bright);
  text-transform: uppercase;
}
.header-sub {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: #d8e2ee;
  text-transform: uppercase;
}

.header-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }

.clock {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.status-bar {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted);
}

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
  transition: background 0.4s, box-shadow 0.4s;
}
.status-dot.connected {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse-dot 2s infinite;
}
.status-dot.error { background: var(--red-alert); }

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 4px var(--green); }
  50%       { box-shadow: 0 0 14px var(--green); }
}

/* ── Main split ──────────────────────────────────────────── */
.main-split {
  display: flex;
  height: calc(100vh - 56px);
  gap: var(--panel-gap);
  padding: var(--panel-gap);
  background: #050709;
}

/* ── Panels ──────────────────────────────────────────────── */
.panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-left  { flex: 1; }
.panel-right { width: 420px; flex-shrink: 0; }

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-bright);
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
}
.panel-icon { color: var(--rnli-blue); font-size: 1rem; }

.launch-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-bright);
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* ── Log list ────────────────────────────────────────────── */
.log-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-dim) transparent;
}
.log-list::-webkit-scrollbar { width: 6px; }
.log-list::-webkit-scrollbar-track { background: transparent; }
.log-list::-webkit-scrollbar-thumb { background: var(--accent-dim); border-radius: 3px; }

.log-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  padding: 40px 20px;
  line-height: 1.8;
}

/* ── Log entry ───────────────────────────────────────────── */
.log-entry {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 2px 12px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  animation: slideIn 0.3s ease;
}
.log-entry:hover { background: rgba(0, 90, 184, 0.07); }

.log-entry.log-entry--new {
  background: rgba(0, 180, 255, 0.06);
  border-left: 3px solid var(--accent);
}

/* Selected entry — user clicked to view in right panel */
.log-entry.log-entry--selected {
  background: rgba(0, 94, 184, 0.12);
  border-left: 3px solid var(--rnli-blue);
}
.log-entry.log-entry--selected .log-station {
  color: var(--text-bright);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.log-station {
  font-size: 0.85rem;
  font-weight: 700;
  color: #e2eaf4;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  grid-column: 1;
}
.log-id {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  grid-column: 2;
  text-align: right;
  align-self: center;
}
.log-title {
  font-size: 0.8rem;
  color: #c8d8e8;
  grid-column: 1 / 3;
  line-height: 1.35;
}
.log-meta {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: #e2eaf4;
  grid-column: 1 / 3;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.log-meta span { white-space: nowrap; }
.log-meta .lm-label { color: #f59e0b; margin-right: 3px; font-weight: 600; }

/* ── Right panel: standby ────────────────────────────────── */
.alert-standby {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  overflow: hidden;
}
.standby-icon {
  font-size: 3.5rem;
  color: var(--rnli-blue);
  animation: breathe 3s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50%       { opacity: 0.7; transform: scale(1.08); }
}
.standby-text {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--text-muted);
}
.standby-sub {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ── Right panel: active alert ───────────────────────────── */
.alert-active {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.alert-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--rnli-red);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 10px;
  animation: flash-banner 1s ease-in-out infinite;
}
@keyframes flash-banner {
  0%, 100% { background: var(--rnli-red); }
  50%       { background: #b0000d; }
}

.alert-flash {
  animation: blink 0.8s step-end infinite;
  color: var(--rnli-yellow);
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.alert-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px;
  overflow-y: auto;
}

.alert-field {
  background: var(--bg-panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.alert-field--row {
  flex-direction: row;
  gap: 0;
}
.alert-field--row > div {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.alert-field--row > div + div {
  border-left: 1px solid var(--border);
  padding-left: 12px;
  margin-left: 0;
}

.alert-label {
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-label);
  font-weight: 600;
}
.alert-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: 0.04em;
  line-height: 1.2;
}
.alert-value--title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--rnli-yellow);
}
.alert-value--id {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent);
}

/* Website field */
.alert-field--website { padding-top: 6px; }
.alert-value--link {
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
  transition: color 0.15s;
}
.alert-value--link:hover { color: #fff; text-decoration: underline; }

.alert-multi {
  background: rgba(255, 180, 0, 0.1);
  border-top: 1px solid var(--amber);
  color: var(--amber);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 6px 12px;
  text-align: center;
}

/* ── Admin bar ───────────────────────────────────────────── */
.admin-bar {
  display: flex;
  gap: 4px;
  padding: 8px;
  border-top: 1px solid var(--border);
  background: var(--bg-header);
}

.btn {
  flex: 1;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  background: var(--bg-panel2);
  color: var(--text);
  padding: 10px 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }

.btn--reload:hover, .btn--reload:focus {
  background: var(--rnli-blue);
  border-color: #0080ff;
  color: #fff;
}
.btn--clear:hover, .btn--clear:focus {
  background: #2a1010;
  border-color: var(--rnli-red);
  color: var(--rnli-red);
}
.btn--test:hover, .btn--test:focus {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}

/* ── XML error strip ─────────────────────────────────────── */
.xml-error {
  background: var(--red-dim);
  border-top: 1px solid var(--rnli-red);
  color: var(--rnli-red);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 6px 12px;
  letter-spacing: 0.04em;
}

/* ── Responsive: portrait / small screen ─────────────────── */
@media (max-width: 700px) {
  /* ── Viewport / scroll ──────────────────────────────────────
     height: auto unlocks the page from the viewport so the user
     can always scroll to the true top.
     min-height: 100svh uses the small viewport height (excludes
     browser chrome) so the body is never shorter than the screen.
     padding-top: env(safe-area-inset-top) shifts content below
     the notch / status bar — applied once here on body only.
     padding-bottom: gives clearance below the sticky admin bar
     and the home indicator on Face ID iPhones.
     NOTE: safe-area insets are set on body only — NOT repeated
     on .header — to prevent double-offsetting on notched devices. */
  html {
    height: auto;
    min-height: 100svh;
    overflow-x: hidden;
    overflow-y: auto; /* Must be set explicitly — base rule sets html,body{overflow:hidden}
                         and overflow-x:hidden alone does not override overflow-y on html.
                         Without this, Safari clips body scroll at the html level. */
  }

  body {
    height: auto;
    min-height: 100svh;
    overflow-x: hidden;
    overflow-y: auto;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }

  /* ── Header ─────────────────────────────────────────────────
     Flat 8px top padding only — body already handles the
     safe-area-inset-top so we do not add it here again. */
  .header {
    height: auto;
    min-height: 56px;
    padding-top: 8px;
    padding-bottom: 8px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .header-main { font-size: 0.95rem; }
  .header-sub  { font-size: 0.6rem; }
  .clock       { font-size: 1.1rem; }
  .rnli-logo   { height: 40px; }

  /* ── Main split ──────────────────────────────────────────── */
  .main-split {
    flex-direction: column;
    height: auto;
    min-height: 0;
    gap: 48px;
  }

  /* Left panel: svh excludes Safari chrome so the panel never
     extends below the visible area on first load. */
  .panel-left {
    height: 75svh;
    min-height: 300px;
    flex-shrink: 0;
  }

  /* Right panel: full width, auto height so content + buttons are never clipped */
  .panel-right {
    width: 100%;
    height: auto;
    flex-shrink: 0;
    overflow: visible;
  }

  /* Allow alert-active to grow to fit its content rather than clipping */
  .alert-active {
    overflow: visible;
    flex: none;
  }

  /* Alert fields scroll if they somehow overflow, but buttons stay below */
  .alert-fields {
    max-height: 55vh;
    overflow-y: auto;
  }

  /* Acknowledge bar: full width, large tap target, always visible */
  .acknowledge-bar {
    position: static;
    width: 100%;
  }

  .btn--acknowledge {
    padding: 16px;
    font-size: 1rem;
  }

  /* Admin bar buttons: larger tap targets on mobile */
  .btn {
    padding: 14px 4px;
    font-size: 0.7rem;
  }

  /* ── Admin bar — sticky at true bottom of scroll container ──
     bottom: 0 anchors to the natural bottom of the scrollable
     panel. The hardcoded 60px Safari toolbar offset is removed —
     it was unreliable across devices and caused a false floor
     that prevented scrolling back to the top.
     padding-bottom with env(safe-area-inset-bottom) clears the
     home indicator on Face ID iPhones without needing a fixed offset. */
  .admin-bar {
    position: sticky;
    bottom: 0;
    z-index: 100;
    background: var(--bg-header);
    border-top: 2px solid var(--rnli-blue);
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
  }
}

/* ══════════════════════════════════════════════════════════
   VISUAL ALERT ANIMATIONS (replaces audio)
   ══════════════════════════════════════════════════════════ */

/* Pulsing orange/RNLI border on the right panel during active alert */
@keyframes rnli-border-pulse {
  0%   { box-shadow: 0 0 0 2px #E8600A, 0 0 12px 4px rgba(232,96,10,0.4); border-color: #E8600A; }
  40%  { box-shadow: 0 0 0 4px #FFB300, 0 0 28px 10px rgba(255,179,0,0.55); border-color: #FFB300; }
  100% { box-shadow: 0 0 0 2px #E8600A, 0 0 12px 4px rgba(232,96,10,0.4); border-color: #E8600A; }
}

.panel-right--alerting {
  border-color: #E8600A;
  animation: rnli-border-pulse 1.1s ease-in-out infinite;
}

/* NEW badge on log entries */
.log-new-badge {
  display: inline-block;
  margin-left: 8px;
  background: #E8600A;
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 1px 5px;
  border-radius: 2px;
  vertical-align: middle;
  animation: badge-blink 1.4s step-end 6;  /* blinks 6 times then stays solid */
}
@keyframes badge-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* Acknowledge bar — prominent full-width button above admin bar */
.acknowledge-bar {
  padding: 8px;
  border-top: 1px solid #E8600A;
  background: rgba(232, 96, 10, 0.08);
}

.btn--acknowledge {
  width: 100%;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: #E8600A;
  color: #fff;
  border: 1px solid #FFB300;
  border-radius: var(--radius);
  padding: 13px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
  animation: acknowledge-pulse 2s ease-in-out infinite;
}
.btn--acknowledge:hover, .btn--acknowledge:active {
  background: #c45008;
  animation: none;
}
@keyframes acknowledge-pulse {
  0%, 100% { background: #E8600A; box-shadow: 0 0 0 0 rgba(232,96,10,0); }
  50%       { background: #ff7520; box-shadow: 0 0 0 4px rgba(232,96,10,0.3); }
}

/* Fade-out animation on acknowledge */
.alert-active--fade {
  animation: alert-fadeout 0.6s ease forwards;
}
@keyframes alert-fadeout {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.98); }
}

/* ── Latest launch ticker ────────────────────────────────── */

/* Header needs to flex properly to give the ticker room to grow */
.header {
  align-items: stretch;   /* children fill the 56px height */
  padding: 0;             /* remove side padding — children handle their own */
}

/* Re-apply horizontal padding to the left and right groups */
.header-left {
  align-items: center;
  padding: 0 0 0 16px;
  flex: 0 0 auto;         /* size to content — do not grow */
  min-width: 0;
}

.header-right {
  align-items: flex-end;
  padding: 0 16px;
  justify-content: center;
}

.ticker-wrap {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex: 1 1 0;            /* true centre column — grows to fill between left and right */
  min-width: 0;           /* allow shrink on narrow viewports */
  max-width: 520px;       /* centred feature — constrained to avoid dominating header */
  margin: 8px 16px 8px -60px; /* negative left pulls ticker left to compensate for 60px logo */
  overflow: hidden;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  background: #080c12;
}

.ticker-label {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  color: #fff;
  background: #E8600A;
  padding: 0 12px;
  display: flex;
  align-items: center;
  border-right: 2px solid #c44d00;
  white-space: nowrap;
  text-transform: uppercase;
}

.ticker-viewport {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* The track holds two copies of the text for seamless looping */
.ticker-track {
  display: flex;
  width: max-content;
  height: 100%;
  will-change: transform;
}

.ticker-item {
  display: flex;
  align-items: center;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.88rem;     /* up from 0.7rem — clearly readable */
  color: #fff;
  padding: 0 48px 0 14px; /* right gap keeps copies visually separated */
  height: 100%;
  letter-spacing: 0.04em;
}

/* RNLI orange bullet separators between data segments */
.ticker-sep {
  color: #E8600A;
  margin: 0 8px;
  font-weight: 700;
  font-size: 1em;
}

@keyframes ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(var(--ticker-shift)); }
}

/* Desktop hover pause */
@media (hover: hover) {
  .ticker-wrap:hover .ticker-track {
    animation-play-state: paused;
  }
}

/* Mobile: wrap below badge + titles, full width, always scrolling */
@media (max-width: 700px) {
  /* Restore normal header layout for stacking */
  .header {
    align-items: center;
    flex-wrap: wrap;
    height: auto;
    padding: 8px 12px 0;
  }

  .header-left {
    flex-wrap: wrap;
    padding: 0;
    gap: 8px;
  }

  .header-right {
    padding: 0;
  }

  .ticker-wrap {
    flex: 0 0 100%;
    max-width: 100%;
    min-width: 0;
    margin: 6px 0 0 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: 1px solid var(--border-bright);
    height: 32px;
  }

  .ticker-item {
    font-size: 0.8rem;
  }
}

/* ══════════════════════════════════════════════════════════
   CALENDAR / ARCHIVE BROWSER
   ══════════════════════════════════════════════════════════ */

/* ── Tab bar ─────────────────────────────────────────────── */
.log-tabs {
  display: flex;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.log-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 7px 0;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.log-tab:hover { color: var(--text); }
.log-tab--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── View containers ─────────────────────────────────────── */
.log-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.log-view--hidden { display: none; }

/* Recent view: log-list fills it */
#viewRecent { overflow: hidden; }
#viewRecent .log-list { flex: 1; }

/* ── Calendar nav ────────────────────────────────────────── */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cal-month-label {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.cal-nav-btn {
  background: none;
  border: 1px solid var(--border-bright);
  color: var(--accent);
  font-size: 1.2rem;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.cal-nav-btn:hover { background: rgba(0,180,255,0.1); }

/* ── Calendar grid ───────────────────────────────────────── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 4px 6px 4px;
  flex-shrink: 0;
}

.cal-cell {
  height: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 0.72rem;
  position: relative;
  overflow: hidden;
}

.cal-cell--head {
  height: 20px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.cal-cell--blank { background: none; }

.cal-cell--day {
  color: var(--text);
  border: 1px solid transparent;
  cursor: default;
  user-select: none;
}

.cal-cell--has-data {
  border-color: var(--border-bright);
  cursor: pointer;
  background: rgba(0, 90, 184, 0.07);
}
.cal-cell--has-data:hover {
  background: rgba(0, 180, 255, 0.12);
  border-color: var(--accent-dim);
}

.cal-cell--today .cal-day-num {
  color: var(--accent);
  font-weight: 700;
}

.cal-cell--selected {
  background: rgba(0, 94, 184, 0.2) !important;
  border-color: var(--rnli-blue) !important;
}

.cal-day-num {
  font-size: 0.74rem;
  line-height: 1;
  font-weight: 600;
}

.cal-count {
  font-size: 0.52rem;
  font-family: var(--font-mono);
  color: var(--rnli-yellow);
  line-height: 1;
  margin-top: 1px;
  letter-spacing: 0;
}

/* ── Day result panel ────────────────────────────────────── */
.cal-day-result {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  border-top: 1px solid var(--border-bright);
  min-height: 0;
}

.cal-day-header {
  padding: 6px 14px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rnli-yellow);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cal-day-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

/* ── Search placeholder ──────────────────────────────────── */
.search-placeholder {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 10px 10px 0;
  flex-shrink: 0;
}

.search-input {
  background: var(--bg-panel2);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  padding: 9px 12px;
  outline: none;
}
.search-input:focus {
  border-color: var(--accent);
}

#viewSearch .log-list {
  flex: 1;
  overflow-y: auto;
}

/* ── Mobile adjustments ──────────────────────────────────── */
@media (max-width: 700px) {
  .cal-grid { padding: 3px 4px; gap: 2px; }
  .cal-cell { height: 32px; }
  .cal-cell--head { height: 18px; }
  .cal-cell--day { font-size: 0.68rem; }
  .log-tab { font-size: 0.65rem; padding: 6px 0; }
}

/* ── Search section labels (live / historical) ───────────── */
.search-section-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 8px 12px 4px;
  border-top: 1px solid rgba(255,255,255,0.07);
  margin-top: 4px;
}
.search-section-label:first-child {
  border-top: none;
  margin-top: 0;
}
.search-section-searching {
  opacity: 0.6;
  animation: pulse 1s ease-in-out infinite alternate;
}
@keyframes pulse {
  from { opacity: 0.4; }
  to   { opacity: 0.8; }
}

/* ══════════════════════════════════════════════════════════
   CALENDAR SUB-TABS
   ══════════════════════════════════════════════════════════ */

.cal-subtabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-header);
  flex-shrink: 0;
}

.cal-subtab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 7px 4px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.cal-subtab:hover {
  color: var(--accent);
}
.cal-subtab--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Sub-views ───────────────────────────────────────────── */
.cal-subview {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.cal-subview--hidden {
  display: none;
}

/* ── Picker bar (dropdowns) ──────────────────────────────── */
.cal-picker-bar {
  display: flex;
  gap: 6px;
  padding: 7px 10px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cal-select {
  flex: 1;
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2300b4ff'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}
.cal-select:focus {
  border-color: var(--accent);
}
.cal-select option {
  background: #1a2330;
  color: #e0e8f0;
  text-transform: none;
  letter-spacing: 0;
}

/* ── Year / Month list rows ──────────────────────────────── */
.cal-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.cal-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.cal-list-row:hover {
  background: rgba(0, 180, 255, 0.07);
}
.cal-list-row:last-child {
  border-bottom: none;
}
.cal-list-row--empty {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.cal-list-label {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-primary);
}
.cal-list-count {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
}
.cal-list-arrow {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-left: 8px;
}

/* ── Total bar ───────────────────────────────────────────── */
.cal-total-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  background: var(--bg-header);
  border-top: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.cal-total-bar span {
  color: var(--accent);
  font-size: 0.85rem;
}

/* ── Stations tab ────────────────────────────────────────── */
.stn-filter-bar {
  display: flex;
  gap: 6px;
  padding: 7px 10px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.stn-sort-btn {
  background: none;
  border: 1px solid var(--border-bright);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.stn-sort-btn:hover { background: rgba(0,180,255,0.1); }

.stn-split {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.stn-list-col {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid var(--border);
  transition: flex 0.2s;
}
.stn-detail-col {
  display: flex;
  flex-direction: column;
  flex: 1.2;
  min-width: 0;
  overflow: hidden;
}

.stn-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.stn-row:hover { background: rgba(0,180,255,0.07); }
.stn-row--active { background: rgba(0,180,255,0.12); }

.stn-rank {
  font-size: 0.65rem;
  color: var(--text-muted);
  width: 16px;
  text-align: right;
  flex-shrink: 0;
}
.stn-name {
  flex: 1;
  min-width: 0;
}
.stn-name-main {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stn-name-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stn-bar-wrap {
  width: 40px;
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  flex-shrink: 0;
}
.stn-bar-fill {
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
}
.stn-count {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  width: 32px;
  text-align: right;
  flex-shrink: 0;
}

.stn-detail-header {
  padding: 7px 10px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  flex-shrink: 0;
}
.stn-detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.stn-meta-cell {
  background: var(--bg-panel);
  padding: 6px 10px;
}
.stn-meta-label {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.stn-meta-value {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: 1px;
}

.stn-launch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.stn-launch-row:hover { background: rgba(0,180,255,0.07); }
.stn-launch-date {
  font-size: 0.68rem;
  color: #e8a020;
  width: 78px;
  flex-shrink: 0;
}
.stn-launch-boat {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  color: #e0eaf5;
  flex: 1;
}
.stn-launch-time {
  font-size: 0.68rem;
  color: #8aa0b8;
}
.stn-badge {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}
.stn-badge--live {
  background: rgba(0,180,255,0.15);
  color: var(--accent);
}
.stn-badge--hist {
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
}

/* ── Stats dashboard (standby panel) ────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  flex-shrink: 0;
}
.stats-cell {
  background: var(--bg-panel);
  padding: 12px 14px;
}
.stats-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #e8a020;
  margin-bottom: 5px;
}
.stats-val {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1;
}
.stats-val--sm {
  font-size: 1.6rem;
}
.stats-divider {
  height: 1px;
  background: var(--border);
  flex-shrink: 0;
}
.stats-section-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #e8a020;
  padding: 10px 14px 4px;
  flex-shrink: 0;
}
.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}
.stats-row-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #e8a020;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.stats-row-val {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  color: #ffffff;
  text-align: right;
}

/* ── Busiest stations section ─────────────────────────────── */
#statTopStations {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 4px 0 12px;
  min-height: 0;
}
.stats-top-row {
  padding: 14px 14px 0;
  flex-shrink: 0;
}
.stats-top-name {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 10px;
}
.stats-top-name > span:first-child {
  flex: 1 1 0;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}
.stats-top-name > .stats-top-count {
  flex-shrink: 0;
  text-align: right;
}
.stats-top-count {
  color: #e8a020;
  font-size: 1.25rem;
  font-weight: 700;
}
.stats-top-bar {
  height: 12px;
  background: rgba(255,255,255,0.08);
  border-radius: 6px;
  margin-bottom: 4px;
  width: 100%;
}
.stats-top-fill {
  height: 12px;
  background: #e8a020;
  border-radius: 6px;
}

/* ══════════════════════════════════════════════════════════
   LIVE MAP MODULE — Phase 1
   All selectors use .lm-* prefix. Zero collision with
   existing Launch Board styles.
   ══════════════════════════════════════════════════════════ */

/* ── Header: LIVE MAP button wrap ─────────────────────── */
/* Standalone flex item between .ticker-wrap and .header-right */
.lm-header-btn-wrap {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding: 0 10px;
}

.lm-header-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(0, 94, 184, 0.18);
  border: 1px solid var(--rnli-blue);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 7px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s, border-color 0.18s, color 0.18s, box-shadow 0.18s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.lm-header-btn:hover,
.lm-header-btn:focus {
  background: rgba(0, 94, 184, 0.38);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px rgba(0, 180, 255, 0.25);
  outline: none;
}

.lm-header-btn:active {
  transform: scale(0.96);
}

.lm-header-btn-icon {
  font-size: 1rem;
  line-height: 1;
  color: var(--accent);
  animation: lm-btn-pulse 3s ease-in-out infinite;
}

@keyframes lm-btn-pulse {
  0%, 100% { opacity: 0.6; }
  50%       { opacity: 1; }
}

/* ── Full-screen overlay ──────────────────────────────── */
.lm-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;          /* TEST: raised above scanline body::after (z-index:9999)
                              to suppress scanlines inside Live Map overlay.
                              Scanlines remain on main Launch Board.
                              Revert to 9000 to restore if needed. */
  background: rgba(4, 6, 10, 0.97);
  display: flex;
  flex-direction: column;

  /* Hidden state — opacity + pointer-events transition for smooth open/close */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.lm-overlay.lm-overlay--open {
  opacity: 1;
  pointer-events: all;
}

/* ── Workspace container ──────────────────────────────── */
.lm-workspace {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;

  /* Slide-up on open — the overlay handles opacity */
  transform: translateY(12px);
  transition: transform 0.28s ease;
}

.lm-overlay.lm-overlay--open .lm-workspace {
  transform: translateY(0);
}

/* ── Workspace header bar ─────────────────────────────── */
.lm-ws-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-header);
  border-bottom: 2px solid var(--rnli-blue);
  padding: 0 16px;
  height: 54px;
  flex-shrink: 0;
  gap: 12px;
}

.lm-ws-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.lm-ws-icon {
  font-size: 1.5rem;
  color: var(--rnli-blue);
  flex-shrink: 0;
  animation: lm-btn-pulse 3s ease-in-out infinite;
}

.lm-ws-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.lm-ws-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-bright);
  text-transform: uppercase;
  white-space: nowrap;
}

.lm-ws-sub {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
  white-space: nowrap;
}

.lm-ws-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Live pill indicator */
.lm-ws-live-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(0, 230, 118, 0.08);
  border: 1px solid rgba(0, 230, 118, 0.3);
  border-radius: 20px;
  padding: 4px 12px;
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--green);
  text-transform: uppercase;
  white-space: nowrap;
}

.lm-ws-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse-dot 2s infinite;
  flex-shrink: 0;
}

/* Close button */
.lm-close-btn {
  background: none;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 7px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.lm-close-btn:hover,
.lm-close-btn:focus {
  background: rgba(227, 6, 19, 0.12);
  border-color: var(--rnli-red);
  color: #fff;
  outline: none;
}

.lm-close-btn:active {
  transform: scale(0.96);
}

/* ── KPI analytics bar ────────────────────────────────── */
.lm-kpi-bar {
  display: flex;
  gap: 1px;
  background: var(--border);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-bright);
}

.lm-kpi-card {
  flex: 1;
  background: var(--bg-panel);
  padding: 6px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* Highlighted KPI card (Busiest Station) */
.lm-kpi-card--accent {
  background: rgba(0, 94, 184, 0.1);
  border-left: 2px solid var(--rnli-blue);
}

.lm-kpi-label {
  font-family: var(--font-display);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #e8a020;
}

.lm-kpi-value {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

/* Smaller value text for longer strings (station names etc.) */
.lm-kpi-value--sm {
  font-size: 0.92rem;
  line-height: 1.25;
}

.lm-kpi-sub {
  font-size: 0.58rem;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ── Main body (map + sidebar) ────────────────────────── */
.lm-body {
  display: flex;
  flex: 1;
  gap: 1px;
  background: var(--border);
  min-height: 0;
  overflow: hidden;
}

/* ── Map column ───────────────────────────────────────── */
.lm-map-col {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  background: var(--bg-panel);
}

.lm-map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-bright);
  flex-shrink: 0;
  gap: 10px;
}

.lm-map-header-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
}

.lm-map-header-icon {
  color: var(--rnli-blue);
  font-size: 1rem;
}

.lm-map-phase-badge {
  font-family: var(--font-display);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--amber);
  background: rgba(255, 179, 0, 0.1);
  border: 1px solid rgba(255, 179, 0, 0.3);
  border-radius: 2px;
  padding: 3px 8px;
  white-space: nowrap;
}

/* ── Phase 2A: real Leaflet map container ─────────────── */
/* Replaces Phase 1 .lm-map-placeholder and decorative grid */
.lm-map-area {
  flex: 1;              /* fills remaining height in .lm-map-col flex column */
  min-height: 0;        /* allow flex item to shrink below content size */
  position: relative;   /* scopes any z-index children; does NOT make this
                           a containing block for the map div (map stays in flow) */
  overflow: hidden;     /* clips Leaflet panes at the column boundary */
  background: #0a0e14; /* fallback colour while tiles load */
}

/* #lmMapContainer stays IN FLOW (no absolute positioning).
   width:100% + height:100% fills .lm-map-area which is a
   sized flex item — so 100% resolves correctly in all browsers.
   Leaflet renders into this in-flow div without escaping the layout. */
#lmMapContainer {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── Leaflet dark theme overrides ─────────────────────── */
/* Keep Leaflet UI controls consistent with RNLI dark theme */
#lmMapContainer .leaflet-bar a {
  background-color: #0e1117;
  border-color: #1e2a38;
  color: #00b4ff;
  font-weight: 700;
  transition: background 0.15s, color 0.15s;
}
#lmMapContainer .leaflet-bar a:hover {
  background-color: #121620;
  color: #ffffff;
  border-color: #2e4a68;
}
#lmMapContainer .leaflet-bar a.leaflet-disabled {
  background-color: #080c12;
  color: #2e4a68;
}

/* Zoom control border */
#lmMapContainer .leaflet-bar {
  border: 1px solid #1e2a38;
  box-shadow: 0 2px 8px rgba(0,0,0,0.6);
  border-radius: 3px;
}

/* Attribution strip — dark and unobtrusive */
#lmMapContainer .leaflet-control-attribution {
  background: rgba(6, 8, 9, 0.75);
  color: #3a5a7a;
  font-size: 0.58rem;
  letter-spacing: 0.03em;
  padding: 2px 6px;
  border-top-left-radius: 3px;
}
#lmMapContainer .leaflet-control-attribution a {
  color: #4a7a9b;
}

/* Tile fade-in removed — Leaflet manages tile opacity internally.
   Custom opacity:0 default was masking tiles on init. */


/* ── Phase 2A prep: .lm-map-placeholder-pills, .lm-map-pill, .lm-map-coord
   rules retired — HTML nodes removed in polish pass.
   Phase 2A will introduce Leaflet layer controls instead. ── */

/* ── Sidebar ──────────────────────────────────────────── */
.lm-sidebar {
  width: clamp(220px, 25%, 340px);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  overflow: hidden;
  gap: 1px;
}

/* ── Section component ────────────────────────────────── */
.lm-section {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* Section that fills remaining space */
.lm-section--flex {
  flex: 1;
  min-height: 0;
}

.lm-section-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-bright);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
  flex-shrink: 0;
}

.lm-section-icon {
  color: var(--rnli-blue);
  font-size: 0.9rem;
}

.lm-section-badge {
  margin-left: auto;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--amber);
  background: rgba(255, 179, 0, 0.1);
  border: 1px solid rgba(255, 179, 0, 0.25);
  border-radius: 2px;
  padding: 2px 6px;
  text-transform: uppercase;
}

.lm-section-body {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-dim) transparent;
}

.lm-section-body::-webkit-scrollbar { width: 4px; }
.lm-section-body::-webkit-scrollbar-thumb { background: var(--accent-dim); border-radius: 2px; }

.lm-section-body--charts {
  flex: 1;
  gap: 1px;
  padding: 0;
  overflow: hidden;
}

/* ── Top Stations placeholder rows ───────────────────── */
.lm-placeholder-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
}

.lm-placeholder-row:last-child {
  border-bottom: none;
}

.lm-placeholder-rank {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-muted);
  width: 18px;
  flex-shrink: 0;
  text-align: right;
}

.lm-placeholder-name {
  flex: 1;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.25);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lm-placeholder-bar {
  width: 50px;
  height: 3px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 2px;
  flex-shrink: 0;
  overflow: hidden;
}

.lm-placeholder-bar-fill {
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  opacity: 0.4;
}

.lm-placeholder-count {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(0, 180, 255, 0.35);
  width: 24px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Future Charts placeholder ────────────────────────── */
.lm-chart-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
  min-height: 0;
}

.lm-chart-placeholder:last-child {
  border-bottom: none;
}

/* Vertical bars */
.lm-chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 56px;
}

.lm-chart-bar {
  flex: 1;
  background: rgba(0, 94, 184, 0.25);
  border-top: 1px solid rgba(0, 180, 255, 0.2);
  border-radius: 1px 1px 0 0;
  min-width: 0;
}

/* Horizontal bars layout */
.lm-chart-bars--horizontal {
  flex-direction: column;
  align-items: stretch;
  height: auto;
  gap: 5px;
  justify-content: center;
}

.lm-chart-hbar {
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
}

.lm-chart-hbar-fill {
  height: 100%;
  background: rgba(0, 94, 184, 0.4);
  border-radius: 2px;
  border-right: 1px solid rgba(0, 180, 255, 0.25);
}

.lm-chart-label {
  font-family: var(--font-display);
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
}

/* ── Responsive: mobile (≤700px) ─────────────────────── */
@media (max-width: 700px) {

  /* Header button: compact on mobile */
  .lm-header-btn-wrap {
    padding: 0 6px;
  }

  .lm-header-btn {
    padding: 5px 9px;
    font-size: 0.68rem;
    gap: 5px;
    letter-spacing: 0.1em;
  }

  .lm-header-btn-icon {
    font-size: 0.85rem;
  }

  /* Workspace header: allow wrap */
  .lm-ws-header {
    height: auto;
    min-height: 48px;
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .lm-ws-title {
    font-size: 0.88rem;
  }

  .lm-ws-live-pill {
    display: none;  /* hide on mobile — saves space */
  }

  /* KPI bar: 2-column grid on mobile */
  .lm-kpi-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex-shrink: 0;
  }

  .lm-kpi-value {
    font-size: 1.1rem;
  }

  .lm-kpi-value--sm {
    font-size: 0.85rem;
  }

  /* Body: stack map above sidebar */
  .lm-body {
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* Map column: fixed height on mobile — Leaflet respects this via invalidateSize() */
  .lm-map-col {
    flex: none;
    height: 260px;   /* slightly taller than Phase 1 — gives Leaflet breathing room */
    min-height: 0;
  }

  /* Sidebar: full width, auto height */
  .lm-sidebar {
    width: 100%;
    flex-shrink: 0;
    flex: none;
    overflow: visible;
    max-height: none;
  }

  .lm-section--flex {
    flex: none;
  }

  .lm-section-body--charts {
    overflow: visible;
  }

  /* Map coords: removed in polish pass — rule retained as no-op for safety */

  /* Phase 2A: .lm-map-placeholder-title / -icon mobile rules retired (elements removed) */
}

/* ══════════════════════════════════════════════════════════
   LIVE MAP — Phase 2B: Map Layer Switcher
   All selectors use .lm-* prefix.
   ══════════════════════════════════════════════════════════ */

/* ── Layer switcher group ─────────────────────────────── */
/* Sits on the right side of .lm-map-header (flex row,
   justify-content: space-between already set) */
.lm-layer-switcher {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  flex-wrap: wrap;          /* wraps gracefully on narrow viewports */
  justify-content: flex-end;
}

/* "MAP STYLE" label */
.lm-layer-label {
  font-family: var(--font-display);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-right: 4px;
  white-space: nowrap;
}

/* Individual layer buttons */
.lm-layer-btn {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--bg-panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  padding: 4px 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}

.lm-layer-btn:hover {
  background: rgba(0, 180, 255, 0.1);
  border-color: var(--border-bright);
  color: var(--text);
}

.lm-layer-btn:active {
  transform: scale(0.95);
}

/* Active / selected state */
.lm-layer-btn--active {
  background: rgba(0, 94, 184, 0.25);
  border-color: var(--accent);
  color: var(--accent);
  cursor: default;
}

.lm-layer-btn--active:hover {
  background: rgba(0, 94, 184, 0.25);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Mobile: compact layer switcher ──────────────────── */
@media (max-width: 700px) {
  .lm-layer-label {
    display: none;     /* hide label on mobile to save space */
  }

  .lm-layer-btn {
    font-size: 0.58rem;
    padding: 4px 7px;
    letter-spacing: 0.05em;
  }
}

/* ══════════════════════════════════════════════════════════
   LIVE MAP — Phase 2C: Station Marker Popups
   ══════════════════════════════════════════════════════════ */

/* Override Leaflet popup chrome to match RNLI dark theme */
.lm-leaflet-popup .leaflet-popup-content-wrapper {
  background: #0e1117;
  border: 1px solid #2e4a68;
  border-radius: 3px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.7);
  color: #d8e4f0;
  padding: 0;
}

.lm-leaflet-popup .leaflet-popup-content {
  margin: 0;
  line-height: 1.4;
}

.lm-leaflet-popup .leaflet-popup-tip-container {
  margin-top: -1px;
}

.lm-leaflet-popup .leaflet-popup-tip {
  background: #2e4a68;
}

/* Close button on popup */
.lm-leaflet-popup .leaflet-popup-close-button {
  color: #5a7a99;
  font-size: 14px;
  padding: 4px 6px;
  top: 4px;
  right: 4px;
}
.lm-leaflet-popup .leaflet-popup-close-button:hover {
  color: #ffffff;
}

/* Popup content layout */
.lm-popup {
  padding: 10px 14px 10px;
  min-width: 150px;
}

.lm-popup-title {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffffff;
  margin-bottom: 3px;
}

.lm-popup-sub {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #E8600A;
  margin-bottom: 6px;
}

.lm-popup-note {
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  color: #4a7a9b;
  font-style: italic;
}

/* ══════════════════════════════════════════════════════════
   TABLET / iPad  (701px – 1200px)
   Safari viewport + layout fixes. Desktop unchanged.
   ══════════════════════════════════════════════════════════

   Problem 1 — viewport height:
   Safari on iPad reports 100vh including its own toolbars,
   so the layout overflows below the visible area. Admin
   buttons and lower busiest-station rows get clipped.
   Fix: dvh (dynamic viewport height) matches the ACTUAL
   visible area as Safari chrome expands and collapses.

   Problem 2 — header cramping:
   At ~1180px the single-row header cannot fit logo, titles,
   ticker (max-width 520px), Live Map button and clock cleanly.
   Fix: header wraps to two rows — row 1 holds logo/titles/
   button/clock, row 2 is the ticker at full width. The
   main-split height is adjusted to account for the taller
   header (~96px total: 56px top row + 40px ticker row).

   Problem 3 — stats panel not scrolling:
   #alertStandby has an inline style overflow:hidden which
   overrides CSS. !important is required to break through it
   so the busiest stations section can scroll into view.

   These rules ONLY apply between 701px and 1200px — they
   cannot affect iPhone (≤700px) or desktop (>1200px).      */

@media (min-width: 701px) and (max-width: 1200px) {

  /* ── Viewport ───────────────────────────────────────────── */
  /* dvh accounts for Safari toolbar; overflow:hidden keeps
     the two-column dashboard locked (no page-level scroll). */
  html {
    height: 100dvh;
    overflow: hidden;
  }

  body {
    height: 100dvh;
    overflow: hidden;
  }

  /* ── Header — two-row layout ────────────────────────────── */
  /* Row 1: logo + titles + Live Map button + clock (56px)
     Row 2: ticker, full width (40px)
     Total header height: ~96px                               */
  .header {
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    align-items: center;
    padding: 0;
  }

  /* Logo + titles group: fixed size, does not grow */
  .header-left {
    flex: 0 0 auto;
    padding: 0 0 0 12px;
    align-items: center;
    min-width: 0;
  }

  /* Shrink logo slightly to give titles more breathing room */
  .rnli-logo {
    height: 44px;
  }

  /* Tighten title text so it fits on one header row */
  .header-main {
    font-size: 0.92rem;
    letter-spacing: 0.08em;
  }

  .header-sub {
    font-size: 0.6rem;
  }

  /* Live Map button: compact on tablet */
  .lm-header-btn-wrap {
    flex: 0 0 auto;
    padding: 0 8px;
  }

  .lm-header-btn {
    padding: 6px 10px;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
  }

  /* Clock + status group: right-aligned, fixed size */
  .header-right {
    flex: 0 0 auto;
    padding: 0 12px;
    justify-content: center;
    align-items: flex-end;
  }

  .clock {
    font-size: 1.2rem;
  }

  /* Ticker: pushed to its own full-width second row.
     order:10 ensures it always sits below all row-1 items
     regardless of DOM order. margin:0 removes the desktop
     negative-left offset that compensated for the logo width. */
  .ticker-wrap {
    order: 10;
    flex: 0 0 100%;
    max-width: 100%;
    margin: 0;
    height: 40px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: 1px solid var(--border-bright);
    border-bottom: none;
  }

  /* ── Main split — adjusted for two-row header ───────────── */
  /* Header is now ~96px tall (56px row 1 + 40px ticker row).
     Using dvh so Safari toolbar is excluded from the calc.   */
  .main-split {
    height: calc(100dvh - 96px);
  }

  /* ── Admin bar ──────────────────────────────────────────── */
  /* Clear Safari home indicator / bottom toolbar safely.     */
  .admin-bar {
    padding-bottom: max(8px, env(safe-area-inset-bottom, 8px));
  }

  /* ── Stats / Monitoring panel ───────────────────────────── */
  /* #alertStandby has inline style overflow:hidden which
     cannot be overridden without !important. This unlocks
     the panel so the busiest stations rows can scroll.       */
  #alertStandby {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Compact the stats grid cells — reduces padding only,
     no font-size changes. Saves ~16px total.                 */
  .stats-cell {
    padding: 8px 12px;
  }

  /* Compact the large stat numbers slightly */
  .stats-val {
    font-size: 1.7rem;
  }

  .stats-val--sm {
    font-size: 1.4rem;
  }

  /* Compact the averages rows — saves ~18px total.           */
  .stats-row {
    padding: 5px 12px;
  }

  /* Compact section labels — saves ~12px total.              */
  .stats-section-label {
    padding: 6px 12px 3px;
  }

  /* Compact each busiest station row — saves ~30px total.    */
  .stats-top-row {
    padding: 8px 12px 0;
  }

  .stats-top-name {
    font-size: 1.05rem;
    margin-bottom: 6px;
  }

  .stats-top-count {
    font-size: 1.05rem;
  }

  .stats-top-bar {
    height: 8px;
    margin-bottom: 3px;
  }

  .stats-top-fill {
    height: 8px;
  }

  /* ── Alert fields (Selected Launch view) ───────────────── */
  /* Constrain and scroll so content never hides behind bar.  */
  .alert-fields {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}
