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

    body {
      font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
      background: #0f172a;
      color: #e2e8f0;
      height: 100vh;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    /* ── Header ── */
    header {
      background: #1e293b;
      border-bottom: 1px solid #334155;
      padding: 0 16px;
      height: 48px;
      display: flex;
      align-items: center;
      gap: 20px;
      flex-shrink: 0;
    }

    header h1 {
      font-size: 1rem;
      font-weight: 700;
      color: #f1f5f9;
      letter-spacing: -0.02em;
      white-space: nowrap;
    }

    header h1 span { color: #38bdf8; }

    .divider { width: 1px; height: 20px; background: #334155; }

    .stat {
      font-size: 0.78rem;
      color: #64748b;
      white-space: nowrap;
    }
    .stat b { color: #cbd5e1; font-weight: 600; }

    .conn-indicator {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 0.78rem;
    }
    .conn-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: #475569;
      flex-shrink: 0;
      transition: background 0.3s, box-shadow 0.3s;
    }
    .conn-dot.connected  { background: #22c55e; box-shadow: 0 0 6px #22c55e88; }
    .conn-dot.error      { background: #ef4444; }
    .conn-dot.connecting { background: #f59e0b; }
    #conn-label { color: #94a3b8; }

    .alert-pill {
      margin-left: auto;
      background: #7f1d1d;
      color: #fca5a5;
      font-size: 0.72rem;
      font-weight: 700;
      padding: 2px 9px;
      border-radius: 999px;
      display: none;
    }
    .alert-pill.visible { display: inline-block; }

    /* ── Layout ── */
    main {
      display: flex;
      flex: 1;
      overflow: hidden;
    }

    #map { flex: 1; }

    /* ── Sidebar ── */
    aside {
      width: 280px;
      background: #1e293b;
      border-left: 1px solid #334155;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      flex-shrink: 0;
    }

    .sidebar-header {
      padding: 10px 14px 8px;
      border-bottom: 1px solid #334155;
      display: flex;
      align-items: baseline;
      gap: 8px;
    }
    .sidebar-header h2 {
      font-size: 0.72rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: #475569;
    }
    #alert-count-label {
      font-size: 0.72rem;
      color: #64748b;
    }

    #alert-list {
      overflow-y: auto;
      flex: 1;
    }
    #alert-list::-webkit-scrollbar { width: 4px; }
    #alert-list::-webkit-scrollbar-track { background: transparent; }
    #alert-list::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

    .no-alerts {
      padding: 24px 14px;
      font-size: 0.78rem;
      color: #334155;
      text-align: center;
      line-height: 1.6;
    }

    .alert-item {
      padding: 9px 14px;
      border-bottom: 1px solid #0f172a;
      cursor: pointer;
      transition: background 0.1s;
    }
    .alert-item:hover { background: #263248; }
    .alert-item-wl { border-left: 3px solid #f59e0b; }
    .alert-item-watchlist {
      margin: 3px 0; padding: 2px 6px; border-radius: 4px;
      font-size: 0.66rem; font-weight: 700; letter-spacing: 0.02em; display: inline-block;
    }

    .alert-item-mmsi {
      font-size: 0.82rem;
      font-weight: 700;
      color: #f87171;
      font-variant-numeric: tabular-nums;
    }
    .alert-item-reason {
      font-size: 0.73rem;
      color: #94a3b8;
      margin-top: 1px;
    }
    .alert-item-meta {
      font-size: 0.70rem;
      color: #64748b;
      margin-top: 1px;
    }
    .alert-item-time {
      font-size: 0.68rem;
      color: #475569;
      margin-top: 1px;
    }

    /* ── History panel ── */
    .history-section {
      border-top: 1px solid #334155;
      flex-shrink: 0;
    }

    .history-toggle {
      width: 100%;
      background: none;
      border: none;
      padding: 9px 14px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      cursor: pointer;
      color: #475569;
      font-size: 0.72rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.08em;
    }
    .history-toggle:hover { background: #1a2740; color: #64748b; }
    .history-toggle-arrow { transition: transform 0.2s; }
    .history-toggle.open .history-toggle-arrow { transform: rotate(180deg); }

    .history-body {
      display: none;
      padding: 10px 14px 12px;
      border-top: 1px solid #1e293b;
    }
    .history-body.open { display: block; }

    .history-row {
      display: flex;
      gap: 6px;
      align-items: center;
      margin-bottom: 7px;
    }
    .history-label {
      font-size: 0.7rem;
      color: #64748b;
      width: 28px;
      flex-shrink: 0;
    }
    .history-input {
      flex: 1;
      background: #0f172a;
      border: 1px solid #334155;
      border-radius: 4px;
      padding: 4px 7px;
      color: #e2e8f0;
      font-size: 0.72rem;
      outline: none;
      transition: border-color 0.15s;
    }
    .history-input:focus { border-color: #38bdf8; }

    .history-btn {
      width: 100%;
      background: #0f2744;
      color: #7dd3fc;
      border: 1px solid #1d4ed8;
      border-radius: 4px;
      padding: 6px;
      font-size: 0.75rem;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.15s;
      margin-top: 4px;
    }
    .history-btn:hover { background: #1e3a5f; }
    .history-btn:disabled { opacity: 0.5; cursor: not-allowed; }

    .history-status {
      font-size: 0.7rem;
      color: #64748b;
      margin-top: 6px;
      min-height: 14px;
    }

    .history-result-item {
      padding: 6px 0;
      border-bottom: 1px solid #1a2030;
      cursor: pointer;
    }
    .history-result-item:hover { color: #e2e8f0; }
    .history-result-mmsi {
      font-size: 0.78rem;
      font-weight: 700;
      color: #f59e0b;
      font-variant-numeric: tabular-nums;
    }
    .history-result-meta {
      font-size: 0.68rem;
      color: #475569;
      margin-top: 1px;
    }
    .history-result-track {
      font-size: 0.68rem;
      color: #38bdf8;
      cursor: pointer;
      margin-top: 2px;
      display: inline-block;
    }
    .history-result-track:hover { text-decoration: underline; }

    #history-results {
      max-height: 180px;
      overflow-y: auto;
      margin-top: 8px;
    }
    #history-results::-webkit-scrollbar { width: 3px; }
    #history-results::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

    .history-quick {
      display: flex;
      gap: 4px;
      margin-bottom: 8px;
      flex-wrap: wrap;
    }
    .hist-quick-btn {
      flex: 1;
      background: #0f172a;
      color: #64748b;
      border: 1px solid #1e293b;
      border-radius: 3px;
      padding: 3px 0;
      font-size: 0.68rem;
      font-weight: 600;
      cursor: pointer;
      transition: color 0.15s, border-color 0.15s;
      white-space: nowrap;
    }
    .hist-quick-btn:hover { color: #7dd3fc; border-color: #334155; }

    .history-clear-btn {
      font-size: 0.68rem;
      color: #475569;
      background: none;
      border: none;
      cursor: pointer;
      padding: 0;
      margin-top: 6px;
      display: none;
    }
    .history-clear-btn:hover { color: #94a3b8; }

    /* ── Leaflet popup dark theme ── */
    .leaflet-popup-content-wrapper {
      background: #1e293b;
      color: #e2e8f0;
      border: 1px solid #334155;
      border-radius: 8px;
      box-shadow: 0 8px 30px rgba(0,0,0,0.6);
    }
    .leaflet-popup-tip { background: #1e293b; }
    .leaflet-popup-content {
      margin: 12px 14px;
      font-size: 0.78rem;
      line-height: 1.7;
    }
    .popup-mmsi  { font-weight: 700; font-size: 0.88rem; color: #f1f5f9; }
    .popup-field { color: #94a3b8; }
    .popup-field b { color: #cbd5e1; font-weight: 600; }
    .popup-alert { color: #f87171; font-weight: 600; margin-top: 4px; }

    /* Sanctioned / shadow-fleet watchlist banner in the vessel card */
    .popup-watchlist {
      margin: 5px 0; padding: 5px 8px; border-radius: 5px;
      font-size: 0.74rem; font-weight: 700; letter-spacing: 0.02em;
    }
    .popup-watchlist a { color: inherit; text-decoration: underline; }
    .popup-watchlist .wl-attrib { font-size: 0.62rem; font-weight: 400; opacity: 0.7; margin-top: 1px; }
    .wl-sanctioned { background: rgba(239,68,68,0.16); border: 1px solid #ef4444; color: #fca5a5; }
    .wl-shadow     { background: rgba(245,158,11,0.14); border: 1px solid #f59e0b; color: #fcd34d; }
    .wl-risk       { background: rgba(56,189,248,0.14); border: 1px solid #38bdf8; color: #7dd3fc; }

    .leaflet-container { background: #0c1929; }

    /* ── Login overlay ── */
    #login-screen {
      position: fixed;
      inset: 0;
      z-index: 9999;
      background: #0f172a;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    #login-box {
      width: 320px;
      background: #1e293b;
      border: 1px solid #334155;
      border-radius: 12px;
      padding: 36px 32px 28px;
      display: flex;
      flex-direction: column;
      gap: 14px;
    }

    #login-box h1 {
      font-size: 1.5rem;
      font-weight: 700;
      color: #f1f5f9;
      letter-spacing: -0.03em;
      margin-bottom: 2px;
    }
    #login-box h1 span { color: #38bdf8; }

    #login-subtitle {
      font-size: 0.78rem;
      color: #475569;
      margin-top: -8px;
    }

    .login-input {
      width: 100%;
      background: #0f172a;
      border: 1px solid #334155;
      border-radius: 6px;
      padding: 9px 12px;
      color: #e2e8f0;
      font-size: 0.85rem;
      outline: none;
      transition: border-color 0.15s;
    }
    .login-input:focus { border-color: #38bdf8; }
    .login-input::placeholder { color: #475569; }

    #login-btn {
      width: 100%;
      background: #0369a1;
      color: #e0f2fe;
      border: none;
      border-radius: 6px;
      padding: 10px;
      font-size: 0.85rem;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.15s;
      margin-top: 2px;
    }
    #login-btn:hover { background: #0284c7; }

    #login-error {
      font-size: 0.75rem;
      color: #f87171;
      text-align: center;
      min-height: 16px;
    }

    /* ── Drone Prediction ── */
    .drone-toggle {
      background: #0f2744;
      color: #7dd3fc;
      border: 1px solid #1d4ed8;
      border-radius: 5px;
      font-size: 0.75rem;
      font-weight: 600;
      padding: 4px 11px;
      cursor: pointer;
      white-space: nowrap;
      transition: background 0.15s, color 0.15s, border-color 0.15s;
      letter-spacing: 0.01em;
    }
    .drone-toggle:hover { background: #1e3a5f; }
    .adsb-window-sel {
      background: #0f2744; color: #7dd3fc; border: 1px solid #1d4ed8;
      border-radius: 5px; font-size: 0.72rem; font-weight: 600;
      padding: 4px 6px; cursor: pointer;
    }

    /* ── Layers ▾ dropdown — groups the map-overlay toggles so the header never
       overflows on narrow desktop widths (they used to sit inline and get clipped
       between ~1025–1500 px, where the mobile hamburger hadn't kicked in yet). */
    .layers-group { position: relative; display: inline-flex; }
    .layers-btn { display: inline-flex; align-items: center; gap: 5px; }
    .layers-btn.active { background: #1e3a5f; color: #bae6fd; border-color: #38bdf8; }
    .layers-caret { font-size: 0.7rem; opacity: 0.85; }
    .layers-count {
      display: none; min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box;
      border-radius: 8px; background: #38bdf8; color: #06263f;
      font-size: 0.66rem; font-weight: 700; line-height: 16px; text-align: center;
    }
    .layers-count.show { display: inline-block; }
    .layers-panel {
      display: none;
      position: absolute; top: calc(100% + 6px); left: 0; z-index: 6500;
      flex-direction: column; align-items: stretch; gap: 5px;
      min-width: 214px;
      background: #1e293b; border: 1px solid #334155; border-radius: 8px;
      padding: 7px; box-shadow: 0 10px 34px rgba(0,0,0,0.55);
    }
    .layers-panel.open { display: flex; }
    .layers-panel > button, .layers-panel .adsb-window-sel { width: 100%; text-align: left; }
    .layers-panel-label {
      font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.08em;
      color: #64748b; font-weight: 700; padding: 2px 4px 3px;
    }
    .logout-btn {
      background: transparent;
      color: #94a3b8;
      border: 1px solid #334155;
      border-radius: 5px;
      font-size: 0.75rem;
      font-weight: 600;
      padding: 4px 11px;
      cursor: pointer;
      white-space: nowrap;
      margin-left: auto;
    }
    .logout-btn:hover { color: #f87171; border-color: #f87171; }

    /* ── Admin modal ── */
    #admin-overlay {
      position: fixed;
      inset: 0;
      z-index: 8000;
      background: rgba(0,0,0,0.65);
      display: flex;
      align-items: center;
      justify-content: center;
    }
    #admin-modal {
      width: 580px;
      max-width: 95vw;
      max-height: 90vh;
      background: #1e293b;
      border: 1px solid #334155;
      border-radius: 12px;
      padding: 28px 28px 22px;
      display: flex;
      flex-direction: column;
      gap: 0;
    }
    .admin-header { flex-shrink: 0; margin-bottom: 16px; }
    .admin-tabs   { flex-shrink: 0; }
    .admin-tab-panel {
      overflow-y: auto;
      flex: 1;
      min-height: 0;
      padding-right: 4px;
    }
    .admin-tab-panel::-webkit-scrollbar { width: 5px; }
    .admin-tab-panel::-webkit-scrollbar-track { background: transparent; }
    .admin-tab-panel::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
    #admin-msg { flex-shrink: 0; margin-top: 8px; }
    .admin-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
    .admin-header h2 {
      font-size: 1.1rem;
      font-weight: 700;
      color: #f1f5f9;
      margin: 0;
    }
    .admin-close {
      background: none;
      border: none;
      color: #64748b;
      font-size: 1.1rem;
      cursor: pointer;
      padding: 2px 6px;
      border-radius: 4px;
    }
    .admin-close:hover { color: #f87171; }
    .admin-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 0.82rem;
    }
    .admin-table th {
      text-align: left;
      color: #64748b;
      font-weight: 600;
      padding: 0 6px 8px;
      border-bottom: 1px solid #334155;
    }
    .admin-table td {
      padding: 8px 6px;
      color: #cbd5e1;
      border-bottom: 1px solid #1e293b;
    }
    .admin-table tr:last-child td { border-bottom: none; }
    /* Clickable emitter coordinates in the admin Emitters list -> focus the 2D map.
       Carries its own font-family: the `mono` class used across these tables is not
       defined in this stylesheet or anywhere else, so it cannot be relied on. */
    .em-focus {
      background: none;
      border: none;
      padding: 0;
      font: inherit;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 0.82rem;
      color: #60a5fa;
      cursor: pointer;
      text-align: left;
      border-bottom: 1px dotted #475569;
    }
    .em-focus:hover { color: #93c5fd; border-bottom-color: #60a5fa; }
    .em-focus:focus-visible { outline: 2px solid #60a5fa; outline-offset: 2px; }
    .admin-del-btn {
      background: none;
      border: 1px solid #334155;
      color: #64748b;
      border-radius: 4px;
      font-size: 0.72rem;
      padding: 2px 8px;
      cursor: pointer;
    }
    .admin-del-btn:hover { color: #f87171; border-color: #f87171; }
    .admin-del-btn:disabled { opacity: 0.3; cursor: default; }
    .admin-add-form {
      display: flex;
      gap: 8px;
      align-items: center;
      border-top: 1px solid #334155;
      padding-top: 14px;
    }
    .admin-add-form .login-input { flex: 1; }
    .admin-role-select {
      background: #0f172a;
      border: 1px solid #334155;
      border-radius: 6px;
      padding: 9px 10px;
      color: #e2e8f0;
      font-size: 0.82rem;
      outline: none;
      cursor: pointer;
      white-space: nowrap;
    }
    .admin-role-select:focus { border-color: #38bdf8; }
    .admin-add-btn {
      background: #0369a1;
      color: #e0f2fe;
      border: none;
      border-radius: 6px;
      padding: 9px 14px;
      font-size: 0.8rem;
      font-weight: 600;
      cursor: pointer;
      white-space: nowrap;
    }
    .admin-add-btn:hover { background: #0284c7; }
    #admin-msg {
      font-size: 0.75rem;
      min-height: 14px;
      text-align: center;
    }
    #admin-msg.ok  { color: #4ade80; }
    #admin-msg.err { color: #f87171; }
    .admin-expiry-row {
      display: flex;
      align-items: center;
      gap: 6px;
      padding-top: 8px;
      flex-wrap: wrap;
    }
    .admin-expiry-label { color: #64748b; font-size: 0.78rem; white-space: nowrap; }
    .admin-quick-btn {
      background: #0f172a;
      border: 1px solid #334155;
      color: #94a3b8;
      border-radius: 4px;
      font-size: 0.72rem;
      font-weight: 600;
      padding: 4px 9px;
      cursor: pointer;
      white-space: nowrap;
    }
    .admin-quick-btn:hover { border-color: #38bdf8; color: #38bdf8; }
    .admin-quick-btn.active { border-color: #38bdf8; color: #38bdf8; background: #0c2340; }
    .admin-date-input {
      background: #0f172a;
      border: 1px solid #334155;
      border-radius: 6px;
      padding: 4px 8px;
      color: #e2e8f0;
      font-size: 0.78rem;
      outline: none;
      cursor: pointer;
    }
    .admin-date-input:focus { border-color: #38bdf8; }
    .admin-edit-row td {
      background: #0f172a;
      padding: 10px 12px;
      border-bottom: 1px solid #334155;
    }
    .admin-edit-inner {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }
    .admin-save-btn {
      background: #0369a1;
      color: #e0f2fe;
      border: none;
      border-radius: 5px;
      padding: 5px 12px;
      font-size: 0.78rem;
      font-weight: 600;
      cursor: pointer;
    }
    .admin-save-btn:hover { background: #0284c7; }
    .admin-cancel-btn {
      background: none;
      border: 1px solid #334155;
      color: #64748b;
      border-radius: 5px;
      padding: 5px 10px;
      font-size: 0.78rem;
      cursor: pointer;
    }
    .admin-cancel-btn:hover { color: #f87171; border-color: #f87171; }
    .admin-edit-btn {
      background: none;
      border: 1px solid #334155;
      color: #64748b;
      border-radius: 4px;
      font-size: 0.72rem;
      padding: 2px 8px;
      cursor: pointer;
      margin-right: 4px;
    }
    .admin-edit-btn:hover { color: #38bdf8; border-color: #38bdf8; }
    #login-expired {
      display: none;
      flex-direction: column;
      gap: 14px;
      text-align: center;
    }
    #login-expired h2 { color: #f1f5f9; font-size: 1.1rem; font-weight: 700; margin: 0; }
    #login-expired p  { color: #94a3b8; font-size: 0.83rem; margin: 0; line-height: 1.5; }
    #login-expired a  { color: #38bdf8; text-decoration: none; }
    #login-expired a:hover { text-decoration: underline; }
    .login-back-btn {
      background: none;
      border: 1px solid #334155;
      color: #64748b;
      border-radius: 6px;
      padding: 8px;
      font-size: 0.8rem;
      cursor: pointer;
      margin-top: 4px;
    }
    .login-back-btn:hover { border-color: #94a3b8; color: #94a3b8; }
    .admin-tabs {
      display: flex;
      flex-wrap: wrap;              /* wrap to more rows so no tab (e.g. Sessions) is clipped */
      gap: 2px 4px;
      border-bottom: 1px solid #334155;
      margin-bottom: 14px;
    }
    .admin-tab {
      background: none;
      border: none;
      border-bottom: 2px solid transparent;
      color: #64748b;
      font-size: 0.82rem;
      font-weight: 600;
      padding: 6px 11px 8px;
      cursor: pointer;
      margin-bottom: -1px;
      white-space: nowrap;
    }
    .admin-tab.active { color: #38bdf8; border-bottom-color: #38bdf8; }
    .admin-tab-panel { display: none; }
    .admin-tab-panel.active { display: block; }
    .admin-section-title {
      font-size: 0.72rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.07em;
      color: #475569;
      margin: 14px 0 8px;
    }
    .admin-section-title:first-child { margin-top: 0; }
    .excl-candidate {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      padding: 8px 0;
      border-bottom: 1px solid #1e293b;
    }
    .excl-candidate:last-child { border-bottom: none; }
    .excl-candidate-info { flex: 1; font-size: 0.78rem; }
    .excl-mmsi { font-weight: 700; color: #f1f5f9; }
    .excl-stats { color: #64748b; margin-top: 2px; }
    .excl-stat-bad { color: #f87171; }
    .excl-action-btns { display: flex; gap: 6px; flex-shrink: 0; }
    .excl-exclude-btn {
      background: #7f1d1d;
      color: #fca5a5;
      border: 1px solid #991b1b;
      border-radius: 4px;
      font-size: 0.72rem;
      font-weight: 600;
      padding: 3px 9px;
      cursor: pointer;
    }
    .excl-exclude-btn:hover { background: #991b1b; }
    .excl-dismiss-btn {
      background: none;
      border: 1px solid #334155;
      color: #64748b;
      border-radius: 4px;
      font-size: 0.72rem;
      padding: 3px 9px;
      cursor: pointer;
    }
    .excl-dismiss-btn:hover { color: #94a3b8; border-color: #475569; }
    .excl-add-row {
      display: flex;
      gap: 8px;
      align-items: center;
      margin-top: 12px;
      padding-top: 12px;
      border-top: 1px solid #334155;
    }
    .alarm-bell-btn {
      background: transparent;
      border: 1px solid #334155;
      border-radius: 5px;
      font-size: 0.75rem;
      font-weight: 600;
      padding: 4px 11px;
      cursor: pointer;
      white-space: nowrap;
      position: relative;
      color: #94a3b8;
    }
    .alarm-bell-btn:hover { color: #f1f5f9; border-color: #64748b; }
    .alarm-bell-btn.has-new { color: #fbbf24; border-color: #fbbf24; }
    .alarm-badge {
      display: inline-block;
      background: #ef4444;
      color: #fff;
      border-radius: 9px;
      font-size: 0.65rem;
      font-weight: 700;
      padding: 1px 5px;
      margin-left: 4px;
      vertical-align: middle;
    }
    /* Alarm rule / duty roster admin UI */
    .rule-row {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 0;
      border-bottom: 1px solid #1e293b;
      font-size: 0.8rem;
    }
    .rule-row:last-child { border-bottom: none; }
    .rule-sev {
      font-size: 0.68rem;
      font-weight: 700;
      border-radius: 3px;
      padding: 2px 6px;
      text-transform: uppercase;
      flex-shrink: 0;
    }
    .rule-sev.info     { background:#1e3a5f; color:#93c5fd; }
    .rule-sev.warning  { background:#451a03; color:#fbbf24; }
    .rule-sev.critical { background:#450a0a; color:#f87171; }
    .rule-name { flex:1; color:#e2e8f0; }
    .rule-cond { color:#475569; font-size:0.72rem; }
    .rule-toggle {
      background: none;
      border: 1px solid #334155;
      border-radius: 4px;
      font-size: 0.7rem;
      padding: 2px 7px;
      cursor: pointer;
      color: #64748b;
    }
    .rule-toggle.on  { color:#4ade80; border-color:#4ade80; }
    .rule-toggle.off { color:#475569; }
    .duty-shift-row {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 7px 0;
      border-bottom: 1px solid #1e293b;
      font-size: 0.78rem;
    }
    .duty-shift-row:last-child { border-bottom: none; }
    .duty-active { color:#4ade80; font-weight:700; }
    .duty-user   { color:#e2e8f0; flex:1; }
    .duty-time   { color:#64748b; font-size:0.72rem; }
    .notify-row  { display:flex; align-items:center; gap:8px; margin-top:6px; flex-wrap:wrap; font-size:0.78rem; }
    .notify-label { color:#64748b; white-space:nowrap; }
    .admin-users-btn {
      background: transparent;
      color: #94a3b8;
      border: 1px solid #334155;
      border-radius: 5px;
      font-size: 0.75rem;
      font-weight: 600;
      padding: 4px 11px;
      cursor: pointer;
      white-space: nowrap;
    }
    .admin-users-btn:hover { color: #38bdf8; border-color: #38bdf8; }
    .drone-toggle.active {
      background: #0c4a6e;
      border-color: #38bdf8;
      color: #38bdf8;
      box-shadow: 0 0 8px #38bdf844;
    }
    .heat-reset-btn {
      background: none;
      color: #475569;
      border: 1px solid #334155;
      border-radius: 4px;
      font-size: 0.68rem;
      font-weight: 600;
      padding: 3px 7px;
      cursor: pointer;
      transition: color 0.15s, border-color 0.15s;
      white-space: nowrap;
    }
    .heat-reset-btn:hover { color: #94a3b8; border-color: #475569; }

    main { position: relative; }

    /* All map legends stack in the bottom-left corner, newest visible one on top.
       Hidden legends collapse (flex) so there are never gaps. */
    #update-banner {
      position: fixed;
      top: 12px;
      left: 50%;
      transform: translateX(-50%);
      z-index: 4000;
      display: flex;
      align-items: center;
      gap: 12px;
      max-width: min(680px, 94vw);
      padding: 10px 14px;
      background: rgba(15, 23, 42, 0.97);
      border: 1px solid #2563eb;
      border-radius: 10px;
      box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
      color: #e2e8f0;
      font-size: 0.82rem;
      line-height: 1.35;
      backdrop-filter: blur(4px);
    }
    #update-banner .ub-sub { color: #94a3b8; }
    #update-banner #ub-reload {
      flex: 0 0 auto;
      cursor: pointer;
      border: none;
      border-radius: 7px;
      padding: 6px 12px;
      background: #2563eb;
      color: #fff;
      font-weight: 700;
      font-size: 0.78rem;
    }
    #update-banner #ub-reload:hover { background: #1d4ed8; }
    #update-banner #ub-dismiss {
      flex: 0 0 auto;
      cursor: pointer;
      border: none;
      background: transparent;
      color: #64748b;
      font-size: 1rem;
      line-height: 1;
      padding: 2px 4px;
    }
    #update-banner #ub-dismiss:hover { color: #cbd5e1; }

    #legend-stack {
      position: absolute;
      left: 14px;                       /* bottom-left corner (original position) */
      bottom: 24px;
      z-index: 1000;
      display: none;                    /* revealed only when a legend is active (.has-legend) */
      flex-direction: column-reverse;   /* toggle button at the corner, cards stack upward */
      align-items: flex-start;
      gap: 8px;
      pointer-events: none;
    }
    #legend-stack.has-legend { display: flex; }
    #legend-cards {
      display: flex;
      flex-direction: column-reverse;
      align-items: flex-start;
      gap: 8px;
      pointer-events: none;
    }
    #legend-stack.collapsed #legend-cards { display: none; }
    #legend-toggle {
      pointer-events: auto;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      background: rgba(15,23,42,0.9);
      border: 1px solid #334155;
      border-radius: 8px;
      color: #cbd5e1;
      font-size: 0.72rem;
      font-weight: 600;
      padding: 5px 11px;
      backdrop-filter: blur(4px);
    }
    #legend-toggle:hover { border-color: #475569; color: #e2e8f0; }
    .map-legend {
      position: static;                 /* flow inside #legend-stack */
      background: rgba(15,23,42,0.9);
      border: 1px solid #334155;
      border-radius: 8px;
      padding: 10px 14px;
      pointer-events: none;
      backdrop-filter: blur(4px);
    }
    .sa-legend .legend-title,
    .jam-legend .legend-title,
    .adsb-legend .legend-title { color: #64748b; }
    .adsb-plane { background: none; border: none; }
    .leaflet-tooltip.sa-tip {
      background: #1e293b;
      color: #e2e8f0;
      border: 1px solid #334155;
      border-radius: 8px;
      box-shadow: 0 6px 20px rgba(0,0,0,0.55);
      padding: 8px 11px;
      font-size: 0.75rem;
      line-height: 1.5;
      white-space: nowrap;
    }
    .leaflet-tooltip.sa-tip::before { display: none; }
    .legend-title {
      font-size: 0.69rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: #475569;
      margin-bottom: 8px;
    }
    .legend-row {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 0.75rem;
      color: #94a3b8;
      margin-top: 5px;
    }
    .legend-swatch {
      width: 14px;
      height: 14px;
      border-radius: 3px;
      flex-shrink: 0;
    }
    .popup-drone { color: #fbbf24; margin-top: 4px; font-size: 0.74rem; }

    /* ── Vessel info cards container ── */
    #vessel-cards-container {
      position: absolute;
      top: 54px;
      left: 10px;
      z-index: 1000;
      display: flex;
      flex-direction: column;
      flex-wrap: wrap;
      align-content: flex-start;
      gap: 8px;
      max-height: calc(100vh - 120px);
      pointer-events: none;
    }
    .vessel-card {
      pointer-events: all;
      width: 256px;
      background: rgba(15,23,42,0.96);
      border: 1px solid #334155;
      border-left-width: 3px;
      border-radius: 10px;
      padding: 12px 14px 10px;
      backdrop-filter: blur(6px);
      box-shadow: 0 4px 24px rgba(0,0,0,0.45);
      flex-shrink: 0;
    }
    .vessel-card-close {
      position: absolute;
      top: 8px;
      right: 10px;
      background: none;
      border: none;
      color: #475569;
      font-size: 1rem;
      cursor: pointer;
      line-height: 1;
      padding: 2px 4px;
      border-radius: 3px;
    }
    .vessel-card-close:hover { color: #f87171; }
    .vessel-card-body { padding-right: 18px; }
    .vessel-card-legend {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-top: 10px;
      padding-top: 8px;
      border-top: 1px solid #1e293b;
      font-size: 0.72rem;
      color: #475569;
    }
    .vessel-card-legend span {
      display: inline-flex;
      align-items: center;
      gap: 5px;
    }
    .track-swatch {
      display: inline-block;
      width: 14px;
      height: 3px;
      border-radius: 2px;
      vertical-align: middle;
    }

    /* ── Cluster control panel ── */
    .pred-controls {
      position: absolute;
      top: 10px;
      right: 290px;
      z-index: 1000;
      background: rgba(15,23,42,0.9);
      border: 1px solid #334155;
      border-radius: 8px;
      padding: 7px 12px;
      display: flex;
      align-items: center;
      gap: 10px;
      backdrop-filter: blur(4px);
    }
    .pred-ctrl-label {
      font-size: 0.72rem;
      color: #94a3b8;
      white-space: nowrap;
    }
    #cluster-slider {
      width: 90px;
      accent-color: #38bdf8;
      cursor: pointer;
    }
    .pred-ctrl-val {
      font-size: 0.72rem;
      color: #cbd5e1;
      font-variant-numeric: tabular-nums;
      min-width: 38px;
    }
    .pred-ctrl-divider { width: 1px; height: 14px; background: #334155; }
    .pred-ctrl-clusters {
      font-size: 0.72rem;
      color: #64748b;
      white-space: nowrap;
    }
    .pred-ctrl-clusters b { color: #94a3b8; }

    .approach-ctrl { display: flex; align-items: center; gap: 3px; }
    .approach-btn {
      background: #1e3a5f; color: #7dd3fc; border: 1px solid #1d4ed8;
      border-radius: 3px; width: 18px; height: 18px; cursor: pointer;
      font-size: 0.72rem; padding: 0; line-height: 1;
      display: flex; align-items: center; justify-content: center;
    }
    .approach-btn:hover { background: #1e4a7f; }
    /* Drone-threat controls */
    .drone-threat-btn {
      background: #3f1620; color: #fda4af; border: 1px solid #9f1239;
      border-radius: 4px; font-size: 0.72rem; font-weight: 600;
      padding: 3px 8px; cursor: pointer; white-space: nowrap;
    }
    .drone-threat-btn:hover { background: #5a1f2e; }
    .drone-threat-btn.active { background: #9f1239; color: #fff; border-color: #f43f5e; }
    #drone-threat-group { display: inline-flex; align-items: center; gap: 4px; }
    .drone-sel, .drone-num, .drone-emitter {
      background: #1e293b; color: #e2e8f0; border: 1px solid #334155;
      border-radius: 3px; font-size: 0.72rem; padding: 2px 4px;
    }
    .drone-num { width: 52px; }
    .drone-emitter { width: 96px; }
    .drone-unit { color: #64748b; font-size: 0.68rem; }
    .threat-impact { color: #f43f5e; font-size: 1.15rem; line-height: 1;
      text-shadow: 0 0 3px #000; text-align: center; }
    .approach-reset {
      background: none; border: none; color: #475569;
      cursor: pointer; font-size: 0.9rem; padding: 0 1px; line-height: 1;
    }
    .ring-toggle-label {
      display: flex; align-items: center; gap: 4px;
      font-size: 0.72rem; color: #94a3b8; white-space: nowrap; cursor: pointer;
    }
    .ring-toggle-label input[type=checkbox] { accent-color: #818cf8; cursor: pointer; margin: 0; }

    /* ── Profile button ─────────────────────────────────── */
    .profile-btn {
      background: transparent; border: 1px solid #334155; border-radius: 5px;
      font-size: 0.75rem; font-weight: 600; padding: 4px 10px; cursor: pointer;
      color: #94a3b8; white-space: nowrap;
    }
    .profile-btn:hover { color: #f1f5f9; border-color: #64748b; }

    /* ── Alarm toast ────────────────────────────────────── */
    #alarm-toast {
      position: fixed; bottom: 20px; right: 20px; z-index: 9999;
      display: none; flex-direction: column; gap: 8px;
      pointer-events: none;
    }
    .alarm-toast-item {
      display: flex; align-items: flex-start; gap: 10px;
      background: #0f172a; border: 1px solid #334155; border-radius: 8px;
      padding: 12px 14px; min-width: 280px; max-width: 360px;
      box-shadow: 0 4px 24px rgba(0,0,0,0.5);
      pointer-events: all; animation: toast-in 0.2s ease;
    }
    .alarm-toast-item.critical { border-color: #ef4444; }
    .alarm-toast-item.warning  { border-color: #f59e0b; }
    .alarm-toast-item.info     { border-color: #3b82f6; }
    @keyframes toast-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
    .toast-sev {
      font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
      border-radius: 3px; padding: 2px 6px; flex-shrink: 0; margin-top: 1px;
    }
    .toast-sev.critical { background:#450a0a; color:#f87171; }
    .toast-sev.warning  { background:#451a03; color:#fbbf24; }
    .toast-sev.info     { background:#1e3a5f; color:#93c5fd; }
    .toast-body { flex: 1; }
    .toast-title { color: #e2e8f0; font-size: 0.8rem; font-weight: 600; }
    .toast-time  { color: #64748b; font-size: 0.7rem; margin-top: 2px; }
    .toast-view  {
      background: none; border: 1px solid #334155; border-radius: 4px;
      color: #94a3b8; font-size: 0.72rem; padding: 2px 8px; cursor: pointer;
      white-space: nowrap; align-self: center; flex-shrink: 0;
    }
    .toast-view:hover { color: #f1f5f9; border-color: #64748b; }

    /* ── Alarm inbox modal ──────────────────────────────── */
    #alarm-inbox-overlay {
      display: none; position: fixed; inset: 0;
      background: rgba(0,0,0,0.6); z-index: 4000;
      align-items: flex-start; justify-content: flex-end;
    }
    #alarm-inbox-overlay.open { display: flex; }
    #alarm-inbox-modal {
      background: #0f172a; border-left: 1px solid #334155;
      width: 460px; max-width: 100vw; height: 100vh;
      display: flex; flex-direction: column; overflow: hidden;
    }
    .inbox-header {
      display: flex; align-items: center; justify-content: space-between;
      padding: 14px 18px; border-bottom: 1px solid #1e293b; flex-shrink: 0;
    }
    .inbox-header h2 { margin: 0; font-size: 1rem; color: #f1f5f9; }
    .inbox-close {
      background: none; border: none; color: #64748b; font-size: 1.3rem;
      cursor: pointer; padding: 0 4px; line-height: 1;
    }
    .inbox-close:hover { color: #f1f5f9; }
    .inbox-resolve-all {
      background: none; border: 1px solid #4ade80; color: #4ade80;
      font-size: 0.72rem; padding: 3px 10px; border-radius: 4px;
      cursor: pointer; white-space: nowrap;
    }
    .inbox-resolve-all:hover { background: #14532d; }
    .inbox-tabs {
      display: flex; gap: 0; border-bottom: 1px solid #1e293b; flex-shrink: 0;
    }
    .inbox-tab {
      flex: 1; padding: 8px 4px; background: none; border: none;
      color: #64748b; font-size: 0.76rem; cursor: pointer;
      border-bottom: 2px solid transparent; text-align: center;
    }
    .inbox-tab:hover { color: #94a3b8; }
    .inbox-tab.active { color: #38bdf8; border-bottom-color: #38bdf8; }
    .inbox-body { flex: 1; overflow-y: auto; padding: 8px 0; }
    .inbox-body::-webkit-scrollbar { width: 5px; }
    .inbox-body::-webkit-scrollbar-track { background: transparent; }
    .inbox-body::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }
    .inbox-empty { color: #475569; font-size: 0.82rem; padding: 24px 18px; }
    .inbox-item {
      border-bottom: 1px solid #1e293b; padding: 12px 18px; cursor: pointer;
    }
    .inbox-item:last-child { border-bottom: none; }
    .inbox-item:hover { background: #0d1f36; }
    .inbox-item-header { display: flex; align-items: center; gap: 8px; }
    .inbox-sev {
      font-size: 0.66rem; font-weight: 700; text-transform: uppercase;
      border-radius: 3px; padding: 2px 6px; flex-shrink: 0;
    }
    .inbox-sev.critical { background:#450a0a; color:#f87171; }
    .inbox-sev.warning  { background:#451a03; color:#fbbf24; }
    .inbox-sev.info     { background:#1e3a5f; color:#93c5fd; }
    .inbox-title { flex: 1; color: #e2e8f0; font-size: 0.82rem; font-weight: 600; }
    .inbox-status-badge {
      font-size: 0.66rem; color: #475569; border: 1px solid #334155;
      border-radius: 3px; padding: 1px 5px; flex-shrink: 0;
    }
    .inbox-status-badge.acknowledged { color: #4ade80; border-color: #4ade80; }
    .inbox-status-badge.resolved     { color: #64748b; border-color: #334155; }
    .inbox-meta { color: #475569; font-size: 0.72rem; margin-top: 4px; }
    .inbox-coord { color: #38bdf8; cursor: pointer; text-decoration: underline dotted; }
    .inbox-coord:hover { color: #7dd3fc; }
    .inbox-actions {
      display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap;
    }
    .inbox-btn {
      background: none; border: 1px solid #334155; border-radius: 4px;
      color: #94a3b8; font-size: 0.72rem; padding: 3px 10px; cursor: pointer;
    }
    .inbox-btn:hover { color: #f1f5f9; border-color: #64748b; }
    .inbox-btn.ack  { border-color: #3b82f6; color: #93c5fd; }
    .inbox-btn.ack:hover  { background: #1e3a5f; }
    .inbox-btn.res  { border-color: #4ade80; color: #4ade80; }
    .inbox-btn.res:hover  { background: #14532d; }
    .inbox-detail {
      margin-top: 10px; padding: 10px 12px;
      background: #0d1f36; border-radius: 6px; display: none;
    }
    .inbox-detail.open { display: block; }
    .inbox-audit { color: #475569; font-size: 0.72rem; margin-bottom: 8px; }
    .inbox-audit-row { padding: 2px 0; }
    .inbox-audit-row b { color: #94a3b8; }
    .inbox-mmsis { color: #64748b; font-size: 0.72rem; margin-bottom: 8px; word-break: break-all; }
    .inbox-conf  { font-size: 0.75rem; margin-bottom: 8px; min-height: 1em; }
    .inbox-note-row { display: flex; gap: 6px; margin-top: 6px; }
    .inbox-note-input {
      flex: 1; background: #1e293b; border: 1px solid #334155; border-radius: 4px;
      color: #e2e8f0; font-size: 0.76rem; padding: 4px 8px;
    }
    .inbox-note-input::placeholder { color: #475569; }
    .inbox-note-send {
      background: none; border: 1px solid #334155; border-radius: 4px;
      color: #94a3b8; font-size: 0.72rem; padding: 4px 10px; cursor: pointer;
    }
    .inbox-note-send:hover { color: #f1f5f9; border-color: #64748b; }

    /* ── Profile modal ──────────────────────────────────── */
    #profile-overlay {
      display: none; position: fixed; inset: 0;
      background: rgba(0,0,0,0.5); z-index: 5000;
      align-items: center; justify-content: center;
    }
    #profile-overlay.open { display: flex; }
    #profile-modal {
      background: #0f172a; border: 1px solid #334155; border-radius: 10px;
      padding: 20px 22px; min-width: 300px; max-width: 380px;
      display: flex; flex-direction: column; gap: 14px;
    }
    .profile-modal-header {
      display: flex; justify-content: space-between; align-items: center;
    }
    .profile-modal-header h3 { margin: 0; font-size: 0.95rem; color: #f1f5f9; }
    .profile-close {
      background: none; border: none; color: #64748b; font-size: 1.2rem;
      cursor: pointer; padding: 0 2px; line-height: 1;
    }
    .profile-close:hover { color: #f1f5f9; }
    .profile-row {
      display: flex; align-items: center; gap: 10px; font-size: 0.82rem;
    }
    .profile-row-label { color: #64748b; flex-shrink: 0; min-width: 130px; }
    .profile-push-btn {
      background: none; border: 1px solid #334155; border-radius: 4px;
      color: #94a3b8; font-size: 0.76rem; padding: 4px 12px; cursor: pointer;
    }
    .profile-push-btn:hover { color: #f1f5f9; border-color: #64748b; }
    .profile-push-btn.enabled { border-color: #4ade80; color: #4ade80; }
    .profile-push-btn.enabled:hover { background: #14532d; }
    #profile-push-status { font-size: 0.72rem; color: #64748b; margin-top: 2px; }
    #profile-sev-sel { background: #1e293b; border: 1px solid #334155; border-radius: 4px;
      color: #e2e8f0; font-size: 0.76rem; padding: 4px 8px; cursor: pointer; }
    #profile-msg { font-size: 0.74rem; min-height: 14px; color: #4ade80; }
    .approach-reset:hover { color: #94a3b8; }
    #approach-val { min-width: 52px; }

    /* ── Reports modal (reuses the profile modal look) ── */
    #report-overlay {
      display: none; position: fixed; inset: 0;
      background: rgba(0,0,0,0.5); z-index: 5000;
      align-items: center; justify-content: center;
    }
    #report-overlay.open { display: flex; }
    #report-modal {
      background: #0f172a; border: 1px solid #334155; border-radius: 10px;
      padding: 20px 22px; min-width: 320px; max-width: 420px;
      display: flex; flex-direction: column; gap: 14px;
    }
    #report-modal .report-intro { color: #94a3b8; font-size: 0.78rem; line-height: 1.45; margin: -2px 0 2px; }
    .report-sel { background: #1e293b; border: 1px solid #334155; border-radius: 4px;
      color: #e2e8f0; font-size: 0.78rem; padding: 5px 8px; cursor: pointer; }
    #aifindings-overlay { display: none; position: fixed; inset: 0;
      background: rgba(0,0,0,0.5); z-index: 5000; align-items: center; justify-content: center; }
    #aifindings-overlay.open { display: flex; }
    #aifindings-modal { background: #0f172a; border: 1px solid #334155; border-radius: 10px;
      padding: 18px 20px; width: 580px; max-width: 94vw; max-height: 88vh;
      display: flex; flex-direction: column; gap: 10px; overflow: hidden; }
    #aifindings-modal #aifb-body { overflow-y: auto; flex: 1; min-height: 80px; }
    .report-dl-btn { background: #1e293b; border: 1px solid #334155; border-radius: 5px;
      color: #e2e8f0; font-size: 0.8rem; padding: 7px 14px; cursor: pointer; width: 100%;
      text-align: center; }
    .report-dl-btn:hover { border-color: #38bdf8; color: #f1f5f9; }
    .report-dl-btn.primary { border-color: #2563eb; background: #1d3a8a; }
    .report-dl-btn.primary:hover { background: #1e46b0; }
    #report-modal .report-sub { color: #64748b; font-size: 0.72rem; margin-top: 8px;
      border-top: 1px solid #1e293b; padding-top: 10px; }

    /* ── Playback bar ── */
    .playback-bar {
      background: #1a2535;
      border-top: 2px solid #f59e0b55;
      height: 52px;
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 0 14px;
      flex-shrink: 0;
    }
    .pb-btn {
      background: #0f2744; color: #7dd3fc;
      border: 1px solid #1d4ed8; border-radius: 5px;
      width: 30px; height: 26px; cursor: pointer; font-size: 0.9rem;
      display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    }
    .pb-btn:hover { background: #1e3a5f; }
    .pb-btn.playing { background: #422006; border-color: #f59e0b; color: #f59e0b; }
    .pb-speed-sel {
      background: #0f172a; color: #94a3b8;
      border: 1px solid #334155; border-radius: 4px;
      padding: 3px 4px; font-size: 0.72rem; cursor: pointer; flex-shrink: 0;
    }
    .pb-scrubber { flex: 1; min-width: 80px; accent-color: #f59e0b; cursor: pointer; }
    .pb-time {
      font-size: 0.72rem; color: #f59e0b; font-weight: 600;
      font-variant-numeric: tabular-nums; white-space: nowrap;
      min-width: 150px; flex-shrink: 0;
    }
    .pb-divider { width: 1px; height: 20px; background: #334155; flex-shrink: 0; }
    .pb-label { font-size: 0.68rem; color: #64748b; white-space: nowrap; flex-shrink: 0; }
    .pb-date-input {
      background: #0f172a; border: 1px solid #334155; border-radius: 4px;
      padding: 3px 5px; color: #e2e8f0; font-size: 0.68rem; outline: none; flex-shrink: 0;
    }
    .pb-date-input:focus { border-color: #f59e0b; }
    .pb-load-btn {
      background: #0f2744; color: #7dd3fc; border: 1px solid #1d4ed8;
      border-radius: 4px; padding: 3px 10px; font-size: 0.72rem; font-weight: 600;
      cursor: pointer; white-space: nowrap; flex-shrink: 0;
    }
    .pb-load-btn:hover { background: #1e3a5f; }
    .pb-load-btn:disabled { opacity: 0.5; cursor: not-allowed; }
    .pb-status { font-size: 0.68rem; color: #64748b; white-space: nowrap; }
    .pb-close {
      background: none; border: none; color: #475569;
      cursor: pointer; font-size: 1rem; padding: 0 2px; flex-shrink: 0; line-height: 1;
    }
    .pb-close:hover { color: #94a3b8; }
    .pb-snap-btn {
      background: #0f172a; color: #94a3b8; border: 1px solid #334155;
      border-radius: 4px; padding: 3px 8px; font-size: 0.72rem; font-weight: 600;
      cursor: pointer; white-space: nowrap; flex-shrink: 0;
    }
    .pb-snap-btn:hover { background: #1a2535; }
    .pb-snap-btn.active { background: #422006; border-color: #f59e0b; color: #f59e0b; }
    .pb-step-label { font-size: 0.68rem; color: #94a3b8; white-space: nowrap; flex-shrink: 0; min-width: 80px; }

    /* Vessel arrow icon — strip default Leaflet div-icon chrome */
    .sv-vessel-icon { background: none !important; border: none !important; }

    /* ══════════════════════════════════════════════════════════════════════════
       Mobile usability
       ══════════════════════════════════════════════════════════════════════════ */

    /* Hamburger nav — base/desktop: the wrapper is invisible so its buttons flow
       into the header exactly as before; the ☰ toggle is hidden on desktop. */
    header { position: relative; }
    #nav-menu { display: contents; }
    #nav-toggle {
      display: none;
      background: #0f2744; color: #7dd3fc; border: 1px solid #1d4ed8;
      border-radius: 6px; font-size: 1.2rem; line-height: 1;
      padding: 4px 11px; cursor: pointer; margin-left: auto;
    }
    #nav-toggle:hover { background: #1e3a5f; }

    /* Floating map buttons (mobile only) — reveal Active Alerts / Legend over the map */
    .map-fab {
      display: none;
      position: fixed; bottom: 12px; z-index: 1600;
      background: rgba(15,23,42,0.94); color: #e2e8f0; border: 1px solid #334155;
      border-radius: 22px; font-size: 0.8rem; font-weight: 600;
      padding: 10px 15px; min-height: 40px; cursor: pointer;
      box-shadow: 0 4px 16px rgba(0,0,0,0.45); backdrop-filter: blur(4px);
    }
    #alerts-fab { right: 12px; }
    #alerts-fab.has-alerts { border-color: #f87171; color: #fca5a5; }
    #legend-fab { left: 12px; }

    /* Narrow desktop / small laptops: drop the numeric stats + alert pill (still
       shown on the Active-Alerts panel) so the single-row header keeps the full
       button set on-screen before the hamburger takes over at ≤1024. */
    @media (max-width: 1200px) {
      header .stat, header .alert-pill, header .divider { display: none; }
    }

    /* Phone & tablet (covers the user's phone + iPad; breakpoint is tunable) */
    @media (max-width: 1024px) {
      html, body { -webkit-text-size-adjust: 100%; }
      body { height: 100dvh; }

      header { gap: 10px; padding: 0 10px; }
      header .stat, header .alert-pill, header .divider { display: none; }   /* free up bar space */
      #nav-toggle { display: inline-flex; align-items: center; }

      /* toggle group → dropdown panel anchored under the header */
      #nav-menu {
        display: none;
        position: absolute; top: 48px; right: 0; z-index: 6000;
        flex-direction: column; align-items: stretch; gap: 6px;
        width: min(300px, 92vw); max-height: calc(100dvh - 48px); overflow-y: auto;
        background: #1e293b; border: 1px solid #334155; border-radius: 0 0 0 12px;
        padding: 8px; box-shadow: 0 8px 30px rgba(0,0,0,0.5);
      }
      #nav-menu.open { display: flex; }
      #nav-menu button, #nav-menu .adsb-window-sel {
        width: 100%; text-align: left; min-height: 44px; font-size: 0.9rem; padding: 10px 12px;
      }
      #nav-menu > .divider { display: none; }

      /* Layers group flattens into the hamburger column — its overlay toggles flow
         inline as a labelled section, no nested popover on touch. */
      .layers-group { display: contents; }
      #layers-btn { display: none; }
      .layers-panel {
        position: static; display: flex; z-index: auto;
        background: transparent; border: none; box-shadow: none;
        padding: 0; min-width: 0; gap: 6px;
      }
      .layers-panel-label {
        display: block; min-height: 0; padding: 2px 4px 0; font-size: 0.62rem;
      }

      /* Active Alerts → floating panel over a full-screen map, behind a bottom-right
         button (#alerts-fab); the panel sits above the button so the button stays tappable. */
      #map { flex: 1; }
      aside {
        position: fixed; right: 12px; bottom: 62px; z-index: 1500;
        width: min(340px, 92vw); max-height: 68dvh;
        border: 1px solid #334155; border-radius: 12px;
        box-shadow: 0 8px 30px rgba(0,0,0,0.55);
        display: none;
      }
      aside.open { display: flex; }
      .map-fab { display: inline-flex; align-items: center; }

      /* Legend → hidden by default, revealed by the bottom-left button (#legend-fab).
         The desktop collapse toggle is replaced by the FAB here; auto-show is ignored
         (the FAB, i.e. .show, is the only reveal on mobile). */
      #legend-stack { left: 12px; bottom: 62px; display: none; }
      #legend-stack.show { display: flex; }
      #legend-stack.has-legend:not(.show) { display: none; }
      #legend-stack.collapsed #legend-cards { display: flex; }
      #legend-toggle { display: none; }

      /* modals & side panels fill the screen and scroll */
      #admin-modal, #report-modal, #profile-modal {
        width: 100%; max-width: 100vw; max-height: 92dvh; overflow-y: auto;
      }
      #admin-overlay { padding: 8px; }
      #alarm-inbox-modal { width: 100vw; max-width: 100vw; height: 100dvh; border-radius: 0; }

      /* Drone Prediction controls: span the width & wrap instead of the desktop
         right:290px offset (which ran off the left edge on portrait phones) */
      .pred-controls { left: 8px; right: 8px; top: 8px; flex-wrap: wrap; justify-content: center; gap: 5px 10px; }

      /* legends & cards never exceed the viewport */
      .map-legend { font-size: 0.7rem; padding: 7px 9px; max-width: 82vw; }
      #vessel-cards-container { max-height: calc(58dvh - 60px); }
      .vessel-card { width: min(256px, 86vw); }
      #login-box { max-width: 92vw; }

      /* bottom bar wraps so its controls stay reachable */
      .playback-bar { height: auto; flex-wrap: wrap; padding: 6px 10px; gap: 6px; }
    }

    /* Very small phones */
    @media (max-width: 480px) {
      header h1 { font-size: 0.9rem; }
      aside { width: 92vw; max-height: 62dvh; }
    }

/* Drone-exposure raster: keep cell edges crisp instead of Leaflet's default smoothing,
   so a ~550 m cell reads as a discrete assessed area rather than a soft gradient. */
.dronex-img { image-rendering: pixelated; image-rendering: crisp-edges; }

      /* ── AI chat: a FLOATING, draggable, resizable window OVER the map ──────────
         Deliberately NOT the modal-overlay pattern (#report-overlay, #profile-overlay,
         #aifindings-overlay): those dim the whole screen and close on outside-click,
         which would hide the chart and dismiss the window the moment an analyst touched
         the map. This follows the Active Alerts <aside> instead — fixed, own z-index,
         .open toggles display.
         z-index 3000 sits ABOVE the map (1000), the alerts aside (1500) and the FABs
         (1600), but BELOW the alarm backdrop (4000), the modals (5000) and the
         nav/layers menus (6000-6500) — so opening Options or Reports cleanly covers the
         chat, and the hamburger dropdown is never occluded by it. */
      #aichat-window {
        display: none; position: fixed; top: 84px; left: 16px;
        width: 460px; height: 560px;
        min-width: 320px; min-height: 200px; max-width: 96vw; max-height: 88dvh;
        background: #0f172a; border: 1px solid #334155; border-radius: 12px;
        box-shadow: 0 10px 34px rgba(0,0,0,0.6);
        z-index: 3000; flex-direction: column;
        /* `resize` is a no-op unless overflow is anything but visible. */
        overflow: hidden; resize: both;
      }
      #aichat-window.open { display: flex; }
      #aichat-window.collapsed { height: auto !important; min-height: 0; resize: none; }
      #aichat-window.collapsed #aichat-body,
      #aichat-window.collapsed #aichat-input-row { display: none; }

      #aichat-titlebar {
        display: flex; align-items: center; gap: 8px; flex: 0 0 auto;
        padding: 8px 10px; background: #111c31; border-bottom: 1px solid #1e293b;
        border-radius: 11px 11px 0 0;
        /* touch-action:none is what makes the pointer-event drag work on a touchscreen
           instead of the browser scrolling the page out from under it. */
        cursor: grab; touch-action: none; user-select: none;
      }
      #aichat-titlebar.dragging { cursor: grabbing; }
      #aichat-title { font-size: 0.82rem; color: #e2e8f0; font-weight: 600; white-space: nowrap; }
      #aichat-stage { font-size: 0.7rem; color: #38bdf8; white-space: nowrap; overflow: hidden; }
      .aichat-tbtn {
        background: transparent; border: none; color: #94a3b8; cursor: pointer;
        font-size: 0.8rem; line-height: 1; padding: 4px 7px; border-radius: 4px;
      }
      .aichat-tbtn:hover { background: #1e293b; color: #e2e8f0; }

      #aichat-body { flex: 1 1 auto; overflow-y: auto; padding: 10px; min-height: 60px; }
      #aichat-input-row {
        display: flex; gap: 6px; flex: 0 0 auto;
        padding: 8px 10px; border-top: 1px solid #1e293b;
      }
      #aichat-q {
        flex: 1; resize: none; background: #0b1220; color: #e2e8f0;
        border: 1px solid #334155; border-radius: 6px; padding: 6px 8px;
        font: inherit; font-size: 0.8rem; line-height: 1.45;
        /* No fixed max-height: autoGrowAiChatInput() sizes this to fit the text and caps
           it against the window's own height, so a long question never has to be
           scrolled inside a tiny box. overflow starts hidden and JS turns it back on
           only at the cap. */
        overflow-y: hidden;
      }
      #aichat-send {
        background: #1d4ed8; color: #fff; border: none; border-radius: 6px;
        padding: 6px 14px; cursor: pointer; font-size: 0.8rem; white-space: nowrap;
      }
      #aichat-send:disabled { background: #334155; color: #64748b; cursor: default; }

      .aic-turn { margin-bottom: 14px; }
      .aic-q {
        background: #1e293b; color: #e2e8f0; border-radius: 10px 10px 10px 2px;
        padding: 6px 10px; font-size: 0.8rem; display: inline-block; max-width: 92%;
      }
      .aic-a { font-size: 0.82rem; line-height: 1.5; color: #e2e8f0; margin-top: 6px; }
      .aic-err { color: #f87171; font-size: 0.8rem; margin-top: 6px; }
      .aic-meta { color: #64748b; font-size: 0.7rem; margin-top: 4px; }
      .aic-turn details { margin-top: 4px; }
      .aic-turn details summary { cursor: pointer; color: #64748b; font-size: 0.7rem; }
      .aic-turn pre {
        white-space: pre-wrap; font-size: 0.7rem; color: #94a3b8;
        background: #0b1220; padding: 6px 8px; border-radius: 4px; overflow-x: auto; margin: 4px 0 0;
      }
      .aic-table-wrap { overflow: auto; max-height: 220px; margin-top: 6px; }
      .aic-table-wrap table { font-size: 0.7rem; border-collapse: collapse; width: 100%; }
      .aic-table-wrap th {
        text-align: left; padding: 2px 6px; border-bottom: 1px solid #1e293b;
        position: sticky; top: 0; background: #0b1220; color: #94a3b8;
      }
      .aic-table-wrap td { padding: 2px 6px; border-bottom: 1px solid #0f172a; }
      /* Rows carrying a coordinate recentre the map without closing the window. */
      .aic-row-map { cursor: pointer; }
      .aic-row-map:hover td { background: #1e293b; }

      /* A floating resizable window is meaningless at phone width: go full-bleed and make
         drag/resize inert, matching #alarm-inbox-modal's behaviour. */
      @media (max-width: 1024px) {
        #aichat-window {
          top: 0 !important; left: 0 !important;
          width: 100vw !important; height: 100dvh !important;
          max-width: 100vw; max-height: 100dvh;
          border-radius: 0; resize: none;
        }
        #aichat-titlebar { cursor: default; border-radius: 0; }
      }

      /* ── FinnRef GNSS layer ─────────────────────────────────────────────────
         ★ Colour polarity is deliberately DIFFERENT from the emitter-activity light,
         which is intentionally inverted (green = emitter firing recently). Here green
         means the station is healthy. To keep the two unmistakable the GNSS marker is a
         SQUARE with a cyan ramp rather than a coloured dot, and the legend states each
         meaning explicitly. */
      .gnss-legend-row { display: flex; align-items: center; gap: 6px; font-size: 0.72rem; color: #94a3b8; }
      .gnss-swatch { width: 12px; height: 12px; border-radius: 2px; border: 1px solid #0b1220; }
      .gnss-ok    { background: #22d3ee; }
      .gnss-warn  { background: #f59e0b; }
      .gnss-bad   { background: #ef4444; }
      .gnss-stale { background: #64748b; }
      #gnss-msg { color: #f59e0b; font-size: 0.72rem; }

      /* ── ADS-B air teleport onsets (Phase 2) ────────────────────────────────
         Violet, deliberately distinct from the RED vessel spoof-jump connectors: same
         visual grammar (onset dot + dashed line to the false position) so the analogy
         reads, different hue so air and sea are never confused. Also distinct from the
         magenta onboard-falsification marker and the cyan GNSS station square. */
      #teleport-msg { color: #f59e0b; font-size: 0.72rem; }
      .teleport-swatch { width: 12px; height: 12px; border-radius: 50%; background: #a855f7; }
