:root {
  --bg: #0b0e14;
  --panel: #131822;
  --panel-2: #1a212e;
  --border: #232c3b;
  --border-soft: #1c2531;
  --text: #e9eef5;
  --muted: #8b97a8;
  --muted-2: #6b7689;
  --accent: #ff3b4e;
  --accent-dim: #7a1f29;
  --ok: #29c46b;
  --warn: #f5a623;

  --font-ui: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* tinted shadows that carry the background hue, not flat black */
  --shadow-lg: 0 18px 50px -12px rgba(4, 8, 16, 0.7), 0 2px 8px rgba(4, 8, 16, 0.4);
  --shadow-md: 0 8px 24px -8px rgba(4, 8, 16, 0.55);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.hidden { display: none !important; }

/* numbers/coords read as data */
.time, .alert-item .meta, .detail .kv, .who { font-variant-numeric: tabular-nums; }

button, input { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.brand {
  font-weight: 800;
  letter-spacing: 1.5px;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 59, 78, 0.12), 0 0 14px var(--accent);
}

/* ---------- Login ---------- */
.login-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 50% -10%, #1b2737 0%, transparent 60%),
    radial-gradient(circle at 50% 120%, #16202e, var(--bg));
}
.login-card {
  width: 340px;
  background: linear-gradient(180deg, var(--panel) 0%, #10151e 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 30px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow-lg);
}
.login-card .brand { font-size: 22px; margin-bottom: 2px; }
.login-card .subtitle { color: var(--muted); margin: 0 0 10px; font-size: 13px; letter-spacing: .2px; }
.login-card input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 13px;
  border-radius: 10px;
  font-size: 14px;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.login-card input::placeholder { color: var(--muted-2); }
.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 59, 78, 0.14);
}

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 12px 15px;
  font-weight: 600;
  font-size: 14px;
  background: var(--accent);
  color: white;
  transition: filter 0.18s var(--ease), transform 0.1s var(--ease), background 0.18s var(--ease);
}
button:hover { filter: brightness(1.08); }
button:active { transform: scale(0.98); }
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
button.ghost:hover { color: var(--text); border-color: var(--muted-2); filter: none; }
.error { color: var(--accent); font-size: 13px; min-height: 16px; }

/* ---------- App shell ---------- */
.app { height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  z-index: 600;
}
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 13px; }
.status { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); letter-spacing: .3px; }
.ws-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); transition: background 0.3s var(--ease), box-shadow 0.3s var(--ease); }
.ws-dot.online { background: var(--ok); box-shadow: 0 0 0 4px rgba(41, 196, 107, 0.12), 0 0 10px var(--ok); }
.ws-dot.offline { background: var(--warn); }

.layout { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 348px; flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.filter-row { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); }
.filter {
  flex: 1; background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--border); font-size: 13px; font-weight: 500; padding: 8px;
  border-radius: 9px;
}
.filter:hover { color: var(--text); }
.filter.active { background: rgba(255, 59, 78, 0.14); color: var(--text); border-color: var(--accent); }

.alert-list { overflow-y: auto; flex: 1; }
.alert-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.18s var(--ease), border-left-color 0.18s var(--ease);
}
.alert-item:hover { background: var(--panel-2); }
.alert-item.selected { background: var(--panel-2); border-left-color: var(--accent); }
.alert-item.active { border-left-color: var(--accent); }
.alert-item .row1 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.alert-item .who { font-weight: 600; font-size: 14px; color: var(--text); }
.alert-item .time { font-size: 11px; color: var(--muted); font-family: var(--font-mono); }
.alert-item .meta { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; gap: 10px; align-items: center; }
.badge {
  font-size: 10px; text-transform: uppercase; letter-spacing: .6px;
  padding: 3px 8px; border-radius: 6px; font-weight: 700;
}
.badge.active { background: var(--accent); color: white; }
.badge.acknowledged { background: var(--warn); color: #2a1d00; }
.badge.resolved { background: var(--ok); color: #04220f; }
.badge.cancelled { background: var(--border); color: var(--muted); }

/* ---------- Map + detail ---------- */
.map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #aadaff; }
/* No tile filter — show the real, full-colour map. */
.leaflet-container { font-family: var(--font-ui); }

.detail {
  position: absolute; top: 14px; right: 14px; width: 330px;
  max-height: calc(100% - 28px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px; z-index: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.25s var(--ease);
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}
.detail h3 { margin: 0 0 4px; font-size: 17px; font-weight: 700; letter-spacing: -0.2px; }
.detail .sub { color: var(--muted); font-size: 12px; margin-bottom: 14px; }
.detail .kv { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 7px 0; border-bottom: 1px solid var(--border-soft); }
.detail .kv span:first-child { color: var(--muted); }
.detail .kv span:last-child { font-family: var(--font-mono); }
.detail .actions { display: flex; gap: 8px; margin: 16px 0; }
.detail .actions button { flex: 1; font-size: 13px; padding: 10px; }
.detail .actions .ack { background: var(--warn); color: #2a1d00; }
.detail .actions .resolve { background: var(--ok); color: #04220f; }
.detail .section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 16px 0 9px; font-weight: 600; }
.detail audio { width: 100%; margin-bottom: 8px; border-radius: 8px; }
.detail .close {
  position: absolute; top: 12px; right: 14px;
  background: transparent; color: var(--muted); padding: 3px 7px;
  font-size: 14px; line-height: 1;
}
.detail .close:hover { color: var(--text); filter: none; }
.detail a.sub { color: var(--accent); text-decoration: none; display: inline-block; margin-top: 8px; }
.detail a.sub:hover { text-decoration: underline; }
.empty { color: var(--muted); padding: 40px 18px; text-align: center; font-size: 13px; line-height: 1.6; }

/* scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }
::-webkit-scrollbar-track { background: transparent; }
