/* ============================================================
   WHY THE SIRENS? — "INCOMING" Theme
   Edgy Command-Center HUD
   Palette: #0d0d0d charcoal / #39ff6e phosphor / #fbbf24 amber
   ============================================================ */
:root {
  --bg: #0d0d0d;
  --bg-panel: #111111;
  --bg-panel-2: #161616;
  --line: #2a2a2a;
  --line-bright: #3a3a3a;
  --phosphor: #39ff6e;
  --phosphor-dim: #1f8a3f;
  --phosphor-glow: rgba(57, 255, 110, 0.3);
  --amber: #fbbf24;
  --red: #ff3b3b;
  --text: #d4d4d4;
  --text-dim: #8a8a8a;
  --text-faint: #555555;
  --mono: "JetBrains Mono", "Fira Code", "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Scanline overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.06) 2px,
    rgba(0, 0, 0, 0.06) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* CRT vignette */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 0%, rgba(0,0,0,0.25) 100%);
  pointer-events: none;
  z-index: 9998;
}

/* ============ STATUS BAR ============ */
.status-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 36px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--phosphor);
  font-weight: 700;
}

.live-dot {
  width: 8px;
  height: 8px;
  background: var(--phosphor);
  border-radius: 50%;
  animation: blink 1.2s infinite;
  box-shadow: 0 0 8px var(--phosphor);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

.status-right {
  color: var(--text-dim);
  display: flex;
  gap: 20px;
}

/* ============ TICKER ============ */
.ticker-wrap {
  position: fixed;
  top: 36px;
  left: 0;
  right: 0;
  height: 32px;
  background: var(--bg-panel-2);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  z-index: 999;
  display: flex;
  align-items: center;
}

.ticker-label {
  flex-shrink: 0;
  padding: 0 16px;
  height: 100%;
  display: flex;
  align-items: center;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  z-index: 2;
}

.ticker {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
}

.ticker-inner {
  display: inline-block;
  animation: tickerScroll 40s linear infinite;
  color: var(--amber);
  font-size: 12px;
  letter-spacing: 0.05em;
}

.ticker-inner span {
  margin-right: 60px;
}

.ticker-inner .t-severity-high { color: var(--red); }
.ticker-inner .t-severity-med  { color: var(--amber); }
.ticker-inner .t-severity-low  { color: var(--phosphor); }

@keyframes tickerScroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ============ MAIN LAYOUT ============ */
.main {
  margin-top: 68px;
  min-height: calc(100vh - 68px);
}

/* ============ CONTAINER ============ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* ============ HERO SECTION ============ */
.hero {
  text-align: center;
  padding: 80px 24px 60px;
  position: relative;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(57, 255, 110, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(251, 191, 36, 0.03) 0%, transparent 60%);
  pointer-events: none;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border: 1px solid var(--line-bright);
  background: var(--bg-panel);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 32px;
}

.hero-tag .dot {
  width: 6px;
  height: 6px;
  background: var(--amber);
  border-radius: 50%;
  animation: blink 1.5s infinite;
}

.hero h1 {
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  margin-bottom: 24px;
  color: var(--text);
}

.hero h1 .accent {
  color: var(--phosphor);
  text-shadow: 0 0 30px var(--phosphor-glow);
}

.hero-sub {
  font-size: clamp(0.9rem, 2vw, 1.15rem);
  color: var(--text-dim);
  max-width: 640px;
  line-height: 1.7;
  margin: 0 auto 40px;
}

.hero-sub strong { color: var(--text); font-weight: 600; }

/* ============ FEATURES ============ */
.features {
  padding: 60px 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 40px;
}

.section-header::before,
.section-header::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.section-title {
  font-size: 11px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.feature-card {
  background: var(--bg-panel);
  padding: 28px;
  position: relative;
  transition: background 0.15s;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
}

.feature-card:hover {
  background: var(--bg-panel-2);
}

.feature-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--phosphor);
  opacity: 0;
  transition: opacity 0.15s;
}

.feature-card:hover::before { opacity: 1; }

.feature-num {
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.2em;
  margin-bottom: 12px;
  display: block;
}

.feature-icon {
  font-size: 28px;
  margin-bottom: 16px;
  display: block;
}

.feature-card h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.feature-card p {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.7;
}

/* ============ AUTH SECTION ============ */
.auth-section {
  padding: 60px 24px 80px;
  display: flex;
  justify-content: center;
}

.auth-box {
  width: 100%;
  max-width: 440px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
  padding: 36px;
  position: relative;
}

.auth-box::before {
  content: "SECURE ACCESS";
  position: absolute;
  top: -1px;
  left: 24px;
  background: var(--bg);
  padding: 0 12px;
  font-size: 9px;
  letter-spacing: 0.3em;
  color: var(--text-faint);
  text-transform: uppercase;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 28px;
  border: 1px solid var(--line);
}

.auth-tab {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
  border-right: 1px solid var(--line);
}

.auth-tab:last-child { border-right: none; }
.auth-tab:hover { color: var(--text); background: var(--bg-panel-2); }
.auth-tab.active { background: var(--phosphor); color: var(--bg); }

.auth-content { display: none; }
.auth-content.active { display: block; }

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--phosphor);
  box-shadow: 0 0 0 1px var(--phosphor);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-faint);
}

.btn-submit {
  width: 100%;
  padding: 14px;
  background: var(--phosphor);
  color: var(--bg);
  border: none;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}

.btn-submit:hover {
  background: #2ee65c;
  box-shadow: 0 0 30px var(--phosphor-glow);
}

.emergency-note {
  margin: 0;
  padding: 6px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.emergency-note strong { color: var(--red); }

.auth-msg {
  margin-top: 16px;
  font-size: 12px;
  text-align: center;
  min-height: 20px;
}

.auth-msg.error { color: var(--red); }
.auth-msg.success { color: var(--phosphor); }

/* ============ DASHBOARD HEADER ============ */
.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
  gap: 12px;
}

.dash-header h1 {
  font-size: 1.4rem;
  color: var(--phosphor);
  text-shadow: 0 0 20px var(--phosphor-glow);
  margin: 0;
}

.user-info { display: flex; align-items: center; gap: 14px; min-width: 0; }

#user-display {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#logout-btn {
  padding: 7px 14px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--line-bright);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
}

#logout-btn:hover { border-color: var(--red); color: var(--red); }

/* ============ NAVIGATION ============ */
.main-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.main-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
}

.main-tab:hover { background: var(--bg-panel-2); color: var(--text); }

.main-tab.active {
  background: var(--phosphor);
  color: var(--bg);
  border-color: var(--phosphor);
}

.main-content { display: none; }
.main-content.active { display: block; }

/* ============ FILTERS & SMALL CONTROLS ============ */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: stretch;
}

.filter-bar input,
.filter-bar select {
  padding: 10px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}

.filter-bar input[type="search"] { flex: 1 1 260px; min-width: 0; }
.filter-bar select { max-width: 100%; cursor: pointer; }
.filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: var(--phosphor); }
.filter-bar input::placeholder { color: var(--text-faint); }
.map-window { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.map-window[hidden] { display: none; }
.map-window input { color-scheme: dark; padding: 9px 10px; }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--bg-panel);
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.toggle input { accent-color: var(--phosphor); width: 15px; height: 15px; }
.toggle:has(input:checked) { border-color: var(--phosphor); color: var(--phosphor); }

.btn-ghost {
  padding: 9px 16px;
  background: transparent;
  border: 1px solid var(--line-bright);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-ghost:hover { border-color: var(--phosphor); color: var(--phosphor); }
.btn-more { display: block; width: 100%; margin-top: 12px; padding: 12px; }
.btn-more[hidden] { display: none; }
.btn-link { display: inline-block; text-align: center; text-decoration: none; }
.narrow-btn { width: auto; padding: 12px 22px; }
.tg-btn { background: #2AABEE; color: #fff; }
.tg-btn:hover { background: #229ed9; box-shadow: none; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form-actions .btn-submit { width: auto; flex: 1 1 200px; }
.narrow-form { max-width: 420px; }

.empty { color: var(--text-dim); padding: 16px 0; font-size: 13px; }
.empty.error, .error-text { color: var(--red); }
.success-text { color: var(--phosphor); }
.dim { color: var(--text-dim); }
.small { font-size: 11px; }

.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.section-head h3 { margin-bottom: 0 !important; }

/* ============ CALLS ============ */
.feed { display: flex; flex-direction: column; gap: 8px; }

.call {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-bright);
  padding: 12px 16px;
  transition: border-color 0.15s, background 0.15s;
}

.call:hover { border-left-color: var(--phosphor); background: var(--bg-panel-2); }
.call-new { animation: callIn 2.5s ease-out; }

@keyframes callIn {
  0% { border-left-color: var(--amber); background: rgba(251, 191, 36, 0.08); }
  100% { border-left-color: var(--line-bright); background: var(--bg-panel); }
}

.call-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 6px;
  letter-spacing: 0.03em;
}

.call-tg { color: var(--phosphor); text-transform: uppercase; }

.tag {
  font-size: 10px;
  padding: 1px 8px;
  border: 1px solid var(--amber);
  color: var(--amber);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.call-loc-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.loc-flag { background: none; border: none; color: var(--text-faint); font-size: 11px; cursor: pointer; padding: 0; }
.loc-flag:hover { color: var(--amber); text-decoration: underline; }
.loc-flag:disabled { cursor: default; text-decoration: none; }
h3.subhead { margin-top: 24px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); margin-bottom: 12px; }
.stat { background: var(--bg-panel-2); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.stat-num { font-size: 20px; font-weight: 700; color: var(--phosphor); }
.stat-label { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); }
.call-loc { display: inline-block; font-size: 12px; color: var(--phosphor); text-decoration: none; margin-bottom: 4px; }
.call-loc:hover { text-decoration: underline; }
#feed-map { height: 360px; border: 1px solid var(--line); margin-bottom: 12px; position: relative; z-index: 1; }
#feed-map[hidden] { display: none; }
.leaflet-popup-content { font-family: var(--mono); font-size: 12px; }
.toggle-block { display: flex; height: 50px; width: 100%; }
.watch-time[hidden] { display: none; }
.watch-status.always { color: var(--phosphor); }
#watch-form[data-mode="place"] .mode-route, #watch-form[data-mode="route"] .mode-place { display: none; }
.watch-redraw { margin: 0 0 12px; }
.watch-redraw[hidden] { display: none; }
#map-draw.drawing { border-color: var(--phosphor); color: var(--phosphor); }
#map-draw-clear[hidden] { display: none; }
.route-preview-btn { margin: 0 0 12px; }
.call-text { font-size: 14px; color: var(--text); line-height: 1.55; overflow-wrap: anywhere; }

.call-actions { display: flex; gap: 6px; margin-top: 8px; }

.call-actions button {
  background: none;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  letter-spacing: 0.04em;
}

.call-actions button:hover { border-color: var(--line-bright); color: var(--text); }

#live-tab[data-view="calls"] .view-incidents, #live-tab[data-view="incidents"] .view-calls { display: none !important; }
#live-tab:not([data-view="map"]) .view-map, #live-tab[data-view="map"] .view-calls, #live-tab[data-view="map"] .view-incidents,
#live-tab[data-view="map"] #feed-map { display: none !important; }

/* ---- Live map mode: a pin per placed call, coloured by kind ---- */
#live-map { height: calc(100vh - 290px); min-height: 360px; border: 1px solid var(--line); position: relative; z-index: 1; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
/* The map's filters fold into one line (closed on phones, open on wider screens): the summary keeps the range and count */
.map-filters { margin-bottom: 10px; }
.map-filters > summary { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; cursor: pointer; list-style: none;
  padding: 9px 12px; background: var(--bg-panel); border: 1px solid var(--line); font-family: var(--mono); font-size: 13px; }
.map-filters > summary::-webkit-details-marker { display: none; }
.map-filters > summary::before { content: '▸'; color: var(--phosphor); }
.map-filters[open] > summary::before { content: '▾'; }
.map-filters[open] > summary { margin-bottom: 10px; }
.map-filters-title { font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; }
.map-filters .filter-bar { margin-bottom: 10px; }
.map-legend button { font-family: var(--mono); font-size: 12px; background: var(--bg-panel); color: var(--text);
  border: 1px solid var(--line-bright); border-left: 4px solid var(--kind); padding: 3px 8px; cursor: pointer; }
.map-legend button[aria-pressed="false"] { opacity: 0.4; text-decoration: line-through; }
.map-legend .n { color: var(--text-dim); margin-left: 4px; }
.map-note { margin-top: 6px; }
.call-pin { background: none; border: none; }
.call-pin span { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); background: #161616; border: 2px solid var(--kind); box-shadow: 0 1px 4px rgba(0,0,0,0.6); }
.call-pin span i { transform: rotate(45deg); font-style: normal; font-size: 14px; line-height: 1; }
.call-pin.mine span { box-shadow: 0 0 0 3px var(--amber), 0 1px 4px rgba(0,0,0,0.6); }
.call-pin.fresh span { animation: pin-drop 0.5s ease-out, pin-pulse 1.6s ease-out 0.5s 3; }
@keyframes pin-drop { from { transform: translateY(-30px) rotate(-45deg); opacity: 0; } to { transform: rotate(-45deg); opacity: 1; } }
@keyframes pin-pulse { 0% { box-shadow: 0 0 0 0 var(--kind); } 100% { box-shadow: 0 0 0 14px transparent; } }
.map-popup .leaflet-popup-content { margin: 8px 10px; width: min(320px, 70vw) !important; }
.map-popup .leaflet-popup-content-wrapper, .map-popup .leaflet-popup-tip { background: var(--bg-panel); color: var(--text); }
.map-popup .call { border: none; padding: 0; margin: 0; background: none; }
.map-popup .call-kind { color: var(--kind); font-weight: bold; }
@media (prefers-reduced-motion: reduce) { .call-pin.fresh span { animation: none; } }
.tag-incident { border-color: var(--phosphor-dim); color: var(--phosphor); cursor: pointer; background: none; font-family: var(--mono); }
.tag-incident:hover { border-color: var(--phosphor); }
.incident-calls .tag-incident { display: none; }
.incident { background: var(--bg-panel); border: 1px solid var(--line); border-left: 3px solid var(--amber); }
.incident.flash { box-shadow: 0 0 0 1px var(--phosphor); }
.incident > summary { list-style: none; cursor: pointer; padding: 12px 16px; }
.incident > summary::-webkit-details-marker { display: none; }
.incident-title { font-size: 14px; color: var(--text); font-weight: 700; }
.incident-meta { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.incident-calls { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.incident-calls .call { background: var(--bg-panel-2); }
.call-audio { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.call-audio[hidden] { display: none; }
.call-audio audio { height: 34px; width: min(420px, 100%); }
.call-explain {
  margin-top: 10px;
  padding: 12px 14px;
  border-left: 2px solid var(--phosphor);
  background: var(--bg);
  font-size: 13px;
  line-height: 1.65;
}

.call-explain p, .summary-body p { margin-bottom: 8px; }
.call-explain ul, .summary-body ul, .call-explain ol, .summary-body ol { padding-left: 20px; margin-bottom: 8px; }
.call-explain .cleaned { color: var(--text-dim); }
.map-link { color: var(--phosphor); font-size: 12px; text-decoration: none; }
.map-link:hover { text-decoration: underline; }

/* ============ SUMMARIES ============ */
.segmented { display: inline-flex; border: 1px solid var(--line); margin-bottom: 16px; }

.seg {
  padding: 9px 18px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--line);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

.seg:last-child { border-right: none; }
.seg.active { background: var(--phosphor); color: var(--bg); }
#summary-feed { display: flex; flex-direction: column; gap: 8px; }

.summary-card { background: var(--bg-panel); border: 1px solid var(--line); }

.summary-card summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
}

.summary-card summary::-webkit-details-marker { display: none; }
.summary-card summary::before { content: "▸"; color: var(--text-faint); margin-right: -4px; }
.summary-card[open] summary::before { content: "▾"; color: var(--phosphor); }
.summary-title { flex: 1; color: var(--text); font-weight: 700; }
.summary-count { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.summary-body { padding: 4px 16px 14px 32px; font-size: 13px; line-height: 1.7; color: var(--text); }
.summary-body h1, .summary-body h2, .summary-body h3 { font-size: 13px; color: var(--phosphor); margin: 12px 0 6px; text-transform: uppercase; }

/* ============ PANELS ============ */
.profile-section {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  padding: 22px;
  margin-bottom: 20px;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
}

.profile-section h3 {
  font-size: 14px;
  color: var(--phosphor);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.profile-section > p { font-size: 13px; color: var(--text-dim); margin-bottom: 14px; }
.profile-section > p a { color: var(--phosphor); }
.profile-section .feed .call { background: var(--bg-panel-2); }

#map {
  height: 380px;
  width: 100%;
  border: 1px solid var(--line);
  margin: 0 0 16px;
  position: relative;
  z-index: 1;
}

/* ============ TRIP WATCHES ============ */
#watch-form { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line-bright); }

#watch-map {
  height: 320px;
  width: 100%;
  border: 1px solid var(--line);
  margin: 0 0 8px;
  position: relative;
  z-index: 1;
}

.watch-search { display: flex; gap: 8px; }
.watch-search .btn-submit { width: auto; padding: 0 22px; }
p.watch-hint { font-size: 12px; margin-bottom: 18px; color: var(--text-dim); }
p.watch-hint.warn { color: var(--amber); }

p.watch-note {
  color: var(--amber);
  border: 1px solid var(--amber);
  background: rgba(251, 191, 36, 0.06);
  padding: 10px 14px;
  font-size: 12px;
  margin-bottom: 16px;
}

p.watch-note a { color: var(--amber); }

.watch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  column-gap: 16px;
}

.watch-item {
  padding: 14px 16px;
  background: var(--bg-panel-2);
  border: 1px solid var(--line);
  margin-bottom: 10px;
}

.watch-item-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.watch-item-head strong { color: var(--text); }
.watch-status { font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase; margin-left: 8px; }
.watch-status.active { color: var(--phosphor); }
.watch-status.upcoming { color: var(--amber); }
.watch-meta { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.watch-item details { font-size: 12px; color: var(--text-dim); margin-top: 8px; }
.watch-item summary { cursor: pointer; }

.watch-delete {
  background: none; border: 1px solid var(--line); color: var(--text-dim);
  font-family: var(--mono); font-size: 11px; padding: 6px 12px; cursor: pointer;
}

.watch-delete:hover { border-color: var(--red); color: var(--red); }

/* ============ ADMIN ============ */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; text-align: left; word-break: break-word; }
.admin-table th { color: var(--phosphor); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; padding: 8px 10px; border-bottom: 1px solid var(--line-bright); }
.admin-table td { padding: 10px; border-bottom: 1px solid var(--line); }
.admin-actions { white-space: nowrap; }

.admin-actions button {
  padding: 6px 12px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  margin: 2px 6px 2px 0;
}

.approve-btn { background: var(--phosphor); color: var(--bg); }
.reject-btn { background: var(--red); color: #fff; }
.delete-btn { background: #555; color: #fff; }

/* ============ ASSISTANT ============ */
.assistant-bubble {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid var(--phosphor);
  background: var(--bg-panel);
  color: var(--phosphor);
  font-size: 24px;
  cursor: pointer;
  z-index: 1500;
  box-shadow: 0 0 24px var(--phosphor-glow), 0 6px 24px rgba(0, 0, 0, 0.6);
  transition: transform 0.15s, box-shadow 0.15s;
}

.assistant-bubble:hover { transform: scale(1.06); box-shadow: 0 0 34px var(--phosphor-glow), 0 6px 24px rgba(0, 0, 0, 0.6); }
.assistant-bubble[hidden], .assistant-panel[hidden] { display: none; }

.assistant-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 400px;
  height: min(600px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--phosphor-dim);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.8), 0 0 20px var(--phosphor-glow);
  z-index: 1500;
}

.assistant-panel.maximized {
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  width: min(900px, calc(100vw - 48px));
  height: auto;
}

.assistant-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-panel-2);
}

.assistant-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--phosphor);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.assistant-controls button {
  background: none;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-size: 15px;
  width: 32px;
  height: 32px;
  cursor: pointer;
}

.assistant-controls button:hover { border-color: var(--line-bright); color: var(--text); }

.assistant-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg { max-width: 88%; padding: 10px 14px; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.msg-bot { align-self: flex-start; background: var(--bg-panel-2); border: 1px solid var(--line); color: var(--text); }
.msg-user { align-self: flex-end; background: rgba(57, 255, 110, 0.08); border: 1px solid var(--phosphor-dim); color: var(--text); }
.msg-bot b { color: var(--phosphor); }
.msg-quote { font-size: 11px; color: var(--text-dim); border-left: 2px solid var(--amber); padding-left: 8px; margin-bottom: 6px; }
.msg-action { align-self: stretch; max-width: 100%; background: rgba(251, 191, 36, 0.05); border: 1px solid var(--amber); color: var(--text); }
.action-summary { margin-bottom: 10px; }
.action-buttons { display: flex; gap: 8px; }
.action-buttons .btn-submit { width: auto; padding: 8px 16px; font-size: 11px; }
.action-buttons button:disabled { opacity: 0.5; cursor: default; }
.chips { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }

.chip {
  background: transparent;
  border: 1px solid var(--line-bright);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 7px 12px;
  cursor: pointer;
  text-align: left;
}

.chip:hover { border-color: var(--phosphor); color: var(--phosphor); }

.typing { display: inline-flex; gap: 4px; }
.typing i { width: 6px; height: 6px; background: var(--phosphor); border-radius: 50%; animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }

.assistant-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }

.assistant-form textarea {
  flex: 1;
  resize: none;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.4;
  max-height: 140px;
}

.assistant-form textarea:focus { outline: none; border-color: var(--phosphor); }

.assistant-form button {
  width: 44px;
  background: var(--phosphor);
  color: var(--bg);
  border: none;
  font-size: 16px;
  cursor: pointer;
}

/* ============ UTILITY ============ */
.error { color: var(--red); text-align: center; }
.success { color: var(--phosphor); text-align: center; }
button { font-family: var(--mono); }

/* ============ RESPONSIVE ============ */
@media (max-width: 640px) {
  .status-right { display: none; }
  .hero { padding: 60px 16px 40px; }
  .features { padding: 40px 16px; }
  .auth-section { padding: 40px 16px 60px; }
  .auth-box { padding: 28px 20px; }
  .container { padding: 12px 16px 96px; }
  .dash-header { padding: 4px 0 12px; margin-bottom: 14px; }
  .dash-header h1 { font-size: 1.05rem; }
  #user-display { display: none; }

  /* Navigation becomes a bottom bar */
  .main-tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    gap: 0;
    z-index: 1400;
    background: var(--bg-panel);
    border-top: 1px solid var(--line-bright);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .main-tab {
    flex: 1;
    flex-direction: column;
    gap: 2px;
    padding: 8px 2px 10px;
    border: none;
    background: transparent;
    font-size: 10px;
    letter-spacing: 0.05em;
  }

  .main-tab .tab-icon { font-size: 18px; }
  .main-tab.active { background: transparent; color: var(--phosphor); box-shadow: inset 0 2px 0 var(--phosphor); }

  .filter-bar select, .toggle { flex: 1 1 45%; }
  .map-window { flex: 1 1 100%; }
  .map-window input[type="date"] { flex: 1 1 100%; }
  .map-window input[type="time"] { flex: 1 1 30%; min-width: 0; }
  .toggle { padding: 10px 12px; }
  .profile-section { padding: 18px 16px; }
  #map { height: 300px; }
  #watch-map { height: 260px; }
  .call { padding: 12px; }

  .assistant-bubble { right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); width: 52px; height: 52px; font-size: 22px; }

  /* On phones the assistant is a full-screen sheet above the nav */
  .assistant-panel, .assistant-panel.maximized {
    top: 36px;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: auto;
    transform: none;
    border: none;
    z-index: 2000;
  }

  body.assistant-is-open { overflow: hidden; }
  #assistant-max { display: none; }
  .msg { max-width: 94%; }
}
.ai-tag { font-size: 9px; letter-spacing: 0.08em; border: 1px solid var(--phosphor-dim); padding: 0 3px; margin-left: 4px; vertical-align: 1px; }
.train-pin { background: none; border: none; }
.train-pin span { position: relative; display: flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  border-radius: 6px; background: #161616; border: 2px solid #facc15; box-shadow: 0 1px 5px rgba(0,0,0,0.7); }
.train-pin i { font-style: normal; font-size: 16px; line-height: 1; }
.train-pin b { position: absolute; inset: -11px 0 auto 0; text-align: center; color: #facc15; font-size: 10px; transform-origin: 50% 26px; }
.train-popup div { margin-top: 3px; }
.plane-pin { background: none; border: none; }
.plane-pin span { display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%;
                  background: rgba(15, 23, 42, 0.55); border: 1px solid #38bdf8; }
.plane-pin i { font-style: normal; font-size: 14px; line-height: 1; display: block; }
.plane-pin.small span { width: 22px; height: 22px; }
.plane-pin.small i { font-size: 12px; }
.plane-pin.ground span { opacity: 0.6; border-style: dashed; }
.plane-pin.alert span { border: 2px solid #ef4444; box-shadow: 0 0 8px #ef4444; }
.plane-popup div { margin-top: 3px; }
.plane-popup .alert-text { color: #ef4444; font-weight: bold; }
.plane-photo img { display: block; width: 100%; max-height: 180px; object-fit: cover; border-radius: 4px; margin-top: 6px; }
.plane-route { font-weight: bold; color: #38bdf8; }
.me-btn a { font-size: 17px; line-height: 30px; text-align: center; }
.me-btn.on a { background: #dbeafe; }
.me-btn.follow a { background: #3b82f6; }
