/* ============================================================================
   EMFMap — map-first glass UI
   Design tokens drive both themes; [data-theme="dark"] overrides.
   ========================================================================== */

/* The HTML hidden attribute is a UA-stylesheet `display:none`, which author
   `display` rules (e.g. .gate { display: grid }) otherwise override. Force it
   to always win so toggling `el.hidden = true/false` reliably hides elements. */
[hidden] { display: none !important; }

:root {
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --accent-contrast: #ffffff;

  --bg: #eef1f6;
  --bg-grad: radial-gradient(1200px 800px at 80% -10%, #dbeafe 0%, transparent 60%),
             radial-gradient(900px 700px at -10% 110%, #ede9fe 0%, transparent 55%);
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.9);
  --glass-shadow: 0 10px 30px -12px rgba(15, 23, 42, 0.25), 0 2px 8px -4px rgba(15, 23, 42, 0.18);

  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --p1: #ef4444;   /* 1&1 */
  --p-tk: #ec4899; /* Telekom */
  --p-vf: #dc2626; /* Vodafone */
  --p-te: #3b82f6; /* Telefónica */

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --topbar-h: 60px;

  --font: -apple-system, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --accent: #818cf8;
  --accent-soft: rgba(99, 102, 241, 0.18);
  --accent-contrast: #0b1120;

  --bg: #070b16;
  --bg-grad: radial-gradient(1200px 800px at 85% -10%, rgba(59,130,246,0.18) 0%, transparent 60%),
             radial-gradient(900px 700px at -10% 110%, rgba(129,140,248,0.14) 0%, transparent 55%);
  --surface: #0f172a;
  --surface-alt: #111a2e;
  --glass: rgba(15, 23, 42, 0.62);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.7), 0 2px 10px -4px rgba(0, 0, 0, 0.5);

  --text: #e5e7eb;
  --text-muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.no-anim, body.no-anim * { transition: none !important; animation: none !important; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

::selection { background: var(--accent); color: var(--accent-contrast); }

/* Shared surface helpers */
.glass {
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* ============================== Auth gate (hero) ========================= */
.gate {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center;
  padding: 1.5rem;
}
.gate-bg {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, #0b1120 0%, #1e1b4b 55%, #312e81 100%);
  overflow: hidden;
}
.gate-bg::before {
  content: ""; position: absolute; inset: -20%;
  background-image:
    radial-gradient(2px 2px at 20% 30%, rgba(255,255,255,0.5), transparent),
    radial-gradient(2px 2px at 70% 60%, rgba(255,255,255,0.35), transparent),
    radial-gradient(1.5px 1.5px at 40% 80%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1.5px 1.5px at 85% 20%, rgba(255,255,255,0.3), transparent),
    radial-gradient(2px 2px at 55% 45%, rgba(255,255,255,0.25), transparent);
  background-size: 600px 600px;
  opacity: 0.6;
  animation: drift 60s linear infinite;
}
@keyframes drift { from { transform: translate3d(0,0,0); } to { transform: translate3d(-120px, -80px, 0); } }
.gate-bg::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(800px 500px at 70% 20%, rgba(99,102,241,0.35), transparent 60%),
              radial-gradient(700px 500px at 20% 90%, rgba(59,130,246,0.25), transparent 60%);
}

.gate-card {
  position: relative; z-index: 1;
  width: min(440px, 100%);
  padding: 2.5rem 2.25rem 2rem;
  border-radius: var(--radius-lg);
  color: #f8fafc;
  text-align: center;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
  animation: rise 0.5s cubic-bezier(.2,.8,.2,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.gate-lang { display: flex; justify-content: center; margin-bottom: 1.5rem; }
.gate-wordmark {
  font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; margin: 0;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.gate-wordmark .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, #818cf8, #3b82f6);
  box-shadow: 0 0 18px rgba(99,102,241,0.8);
}
.gate-tagline { color: rgba(248,250,252,0.78); font-size: 0.95rem; margin: 0.6rem 0 1.75rem; line-height: 1.5; }
.gate-foot { margin-top: 1.25rem; font-size: 0.82rem; color: rgba(248,250,252,0.75); }
.gate-foot button { background: none; border: none; color: #a5b4fc; font-weight: 600; cursor: pointer; padding: 0 0.2rem; }
.gate-foot button:hover { color: #c7d2fe; }

/* ============================== App shell =============================== */
.app { position: fixed; inset: 0; display: flex; flex-direction: column; }
.app[hidden] { display: none; }

/* ---- Top command bar ---- */
.topbar {
  position: relative; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0 0.9rem;
  border-bottom: 1px solid var(--glass-border);
}
.topbar .glass-bar {
  position: absolute; inset: 8px 0.6rem; border-radius: 14px;
}
.topbar > * { position: relative; z-index: 1; }

.brand {
  font-weight: 800; font-size: 1.05rem; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 0.45rem; white-space: nowrap;
  padding: 0 0.4rem 0 0.2rem;
}
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(135deg, #818cf8, #3b82f6); box-shadow: 0 0 14px rgba(99,102,241,0.7); }

.tb-spacer { flex: 1; }

/* live badge */
.live-badge {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.74rem; font-weight: 600; color: var(--text-muted);
  padding: 0.32rem 0.6rem; border-radius: 999px;
  background: var(--surface-alt); border: 1px solid var(--border);
}
.live-badge .live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.live-badge[data-state="live"] { color: #16a34a; }
.live-badge[data-state="live"] .live-dot { background: #22c55e; box-shadow: 0 0 0 0 rgba(34,197,94,0.6); animation: ping 1.8s ease-out infinite; }
.live-badge[data-state="connected"] { color: var(--accent); }
.live-badge[data-state="connected"] .live-dot { background: var(--accent); }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); } 70% { box-shadow: 0 0 0 7px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }

/* provider pills */
.provider-pills { display: flex; gap: 0.35rem; flex-wrap: nowrap; overflow: auto hidden; padding: 0.2rem 0; scrollbar-width: none; }
.provider-pills::-webkit-scrollbar { display: none; }
.pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.76rem; font-weight: 600; color: var(--text);
  padding: 0.32rem 0.62rem; border-radius: 999px;
  background: var(--surface-alt); border: 1px solid var(--border);
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.pill .swatch { width: 8px; height: 8px; border-radius: 50%; }
.pill .count { color: var(--text-muted); font-variant-numeric: tabular-nums; font-weight: 500; }
.pill:not([aria-pressed="true"]) { opacity: 0.45; }
.pill:hover { border-color: var(--border-strong); }

/* segmented control */
.segmented { display: inline-flex; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 10px; padding: 2px; }
.segmented button {
  border: none; background: none; color: var(--text-muted);
  font-size: 0.78rem; font-weight: 600; padding: 0.34rem 0.6rem;
  border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 0.3rem;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(15,23,42,0.16); }
[data-theme="dark"] .segmented button[aria-pressed="true"] { background: rgba(255,255,255,0.08); }

/* icon buttons */
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-alt); border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer; transition: color 0.15s, border-color 0.15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; }
.kbd { font-family: var(--mono); font-size: 0.68rem; color: var(--text-muted); padding: 0.1rem 0.32rem; border-radius: 5px; background: var(--surface); border: 1px solid var(--border); }

/* auth/user buttons */
.auth-btn {
  border: 1px solid var(--border); background: var(--surface-alt);
  color: var(--text); font-weight: 600; font-size: 0.84rem;
  padding: 0.5rem 0.85rem; border-radius: 10px; cursor: pointer;
}
.auth-btn:hover { border-color: var(--border-strong); }
.primary-btn {
  border: none; background: var(--accent); color: var(--accent-contrast);
  font-weight: 700; font-size: 0.92rem; padding: 0.6rem 1.1rem;
  border-radius: 10px; cursor: pointer; width: 100%;
  transition: filter 0.15s, transform 0.05s;
}
.primary-btn:hover { filter: brightness(1.07); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.ghost-btn {
  border: 1px solid var(--border-strong); background: transparent;
  color: var(--text); font-weight: 600; font-size: 0.86rem;
  padding: 0.5rem 0.9rem; border-radius: 10px; cursor: pointer;
}
.ghost-btn:hover { background: var(--surface-alt); }
.ghost-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* user chip */
.user-chip {
  display: inline-flex; align-items: center; gap: 0.45rem;
  border: 1px solid var(--border); background: var(--surface-alt);
  padding: 0.3rem 0.6rem 0.3rem 0.32rem; border-radius: 999px;
  cursor: pointer; color: var(--text);
}
.user-chip:hover { border-color: var(--border-strong); }
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-grid; place-items: center;
  font-size: 0.74rem; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #6366f1, #3b82f6);
}
.user-email { font-size: 0.8rem; font-weight: 500; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip[data-role="admin"] .user-avatar { background: linear-gradient(135deg, #f59e0b, #ef4444); }

/* user menu */
.user-menu {
  position: fixed; z-index: 200;
  min-width: 220px; padding: 0.4rem;
  border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--glass-shadow);
  animation: rise 0.16s ease;
}
.user-menu-header { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.6rem 0.6rem; border-bottom: 1px solid var(--border); margin-bottom: 0.3rem; }
.user-menu-email { font-size: 0.82rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }
.user-menu-item {
  display: block; width: 100%; text-align: left;
  border: none; background: none; color: var(--text);
  font-size: 0.86rem; font-weight: 500; padding: 0.5rem 0.6rem;
  border-radius: 8px; cursor: pointer;
}
.user-menu-item:hover { background: var(--surface-alt); }
.user-menu-item.danger { color: #dc2626; }
[data-theme="dark"] .user-menu-item.danger { color: #f87171; }

/* lang switch */
.lang-switch { display: inline-flex; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 999px; padding: 2px; }
.lang-switch button {
  border: none; background: none; color: var(--text-muted);
  font-size: 0.72rem; font-weight: 700; padding: 0.25rem 0.55rem;
  border-radius: 999px; cursor: pointer;
}
.lang-switch button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(15,23,42,0.16); }
[data-theme="dark"] .lang-switch button.active { background: rgba(255,255,255,0.1); }

/* Details-panel toggle (hamburger) — always visible in the top-right. */
.mobile-toggle { display: inline-flex; }

/* ============================== Map ===================================== */
.map-wrap { position: relative; flex: 1; min-height: 0; }
/* isolation: isolate keeps Leaflet's internal pane z-indexes (tiles 200,
   markers 600, controls ~1000) contained in the map's own stacking context so
   they can't paint over the floating overlays (details panel, search, toggles). */
#map { position: absolute; inset: 0; background: var(--surface-alt); isolation: isolate; }
.loading-indicator {
  position: absolute; z-index: 25; top: 12px; left: 50%; transform: translateX(-50%) translateY(-8px);
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.85rem; border-radius: 999px;
  font-size: 0.8rem; color: var(--text);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.loading-indicator.active { opacity: 1; transform: translateX(-50%) translateY(0); }
.loading-indicator .spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* scrape progress (floating, under topbar) */
.scrape-progress {
  position: absolute; z-index: 24; top: 12px; left: 12px;
  width: 240px; padding: 0.7rem 0.8rem; border-radius: 12px;
}
.scrape-progress[hidden] { display: none; }
.scrape-progress-bar { height: 6px; background: var(--surface-alt); border-radius: 999px; overflow: hidden; margin-bottom: 0.4rem; }
.scrape-progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, #6366f1, #3b82f6); border-radius: 999px; transition: width 0.3s; }
.scrape-progress-text { font-size: 0.74rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* activity ticker (bottom-left) */
.activity-ticker {
  position: absolute; z-index: 24; bottom: 12px; left: 12px;
  padding: 0.5rem 0.8rem; border-radius: 999px;
  font-size: 0.78rem; color: var(--text);
  display: inline-flex; align-items: center; gap: 0.45rem;
}
.activity-ticker[hidden] { display: none; }
.activity-ticker .pulse { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 0 rgba(34,197,94,0.6); animation: ping 1.8s ease-out infinite; }

/* ============================== Details slide-over ===================== */
.details-toggle {
  position: absolute; z-index: 26; top: 50%; right: 0; transform: translateY(-50%);
  width: 26px; height: 64px; border-radius: 12px 0 0 12px;
  background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border); border-right: none;
  color: var(--text-muted); cursor: pointer; display: grid; place-items: center;
  box-shadow: var(--glass-shadow);
}
.details-toggle svg { width: 16px; height: 16px; }
.details-panel {
  position: absolute; z-index: 27; top: 0; right: 0; bottom: 0;
  width: min(360px, 88vw);
  display: flex; flex-direction: column;
  border-left: 1px solid var(--glass-border);
  transform: translateX(0);
  transition: transform 0.28s cubic-bezier(.2,.8,.2,1);
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.details-panel.closed { transform: translateX(100%); }
.details-panel.closed + .details-toggle svg { transform: rotate(180deg); }

/* Focus mode: strip everything but the map for distraction-free viewing. */
body.focus-mode .topbar,
body.focus-mode .activity-ticker,
body.focus-mode .scrape-progress,
body.focus-mode .details-panel,
body.focus-mode .details-toggle { opacity: 0; pointer-events: none; transition: opacity 0.2s; }
body.focus-mode .topbar { transform: translateY(-100%); }
.focus-hint {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 40; padding: 0.4rem 0.9rem; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: var(--text-muted); font-size: 0.78rem; pointer-events: none;
}
.details-head { display: flex; align-items: center; justify-content: space-between; padding: 0.9rem 1rem 0.7rem; border-bottom: 1px solid var(--border); }
.details-head h2 { margin: 0; font-size: 1rem; font-weight: 700; }
.details-body { flex: 1; overflow-y: auto; padding: 0.8rem 1rem 1.2rem; }
.details-body::-webkit-scrollbar { width: 8px; }
.details-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }

.section-title { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin: 1.1rem 0 0.5rem; }
.section-title:first-child { margin-top: 0; }

/* stats grid */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.stat-card { padding: 0.6rem 0.7rem; border-radius: 10px; background: var(--surface-alt); border: 1px solid var(--border); }
.stat-card .v { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-card .l { font-size: 0.68rem; color: var(--text-muted); margin-top: 0.1rem; }
.stat-card .swatch { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.stat-row-line { display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem; padding: 0.35rem 0; }
.stat-row-line .v { font-variant-numeric: tabular-nums; font-weight: 600; }

/* freshness */
.freshness-row { display: flex; flex-direction: column; gap: 0.1rem; padding: 0.4rem 0; border-bottom: 1px dashed var(--border); }
.freshness-row:last-child { border-bottom: none; }
.freshness-row .l { font-size: 0.72rem; color: var(--text-muted); }
.freshness-row .v { font-size: 0.88rem; font-weight: 600; }

/* window switch */
.window-switch { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.6rem; }
.window-switch button {
  border: 1px solid var(--border); background: var(--surface-alt);
  color: var(--text-muted); font-size: 0.72rem; font-weight: 600;
  padding: 0.28rem 0.55rem; border-radius: 8px; cursor: pointer;
}
.window-switch button[data-window-active] { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

/* recent list */
.new-list { display: flex; flex-direction: column; gap: 0.35rem; }
.new-item {
  padding: 0.5rem 0.6rem; border-radius: 10px; background: var(--surface-alt);
  border: 1px solid var(--border); cursor: pointer; transition: border-color 0.15s, transform 0.05s;
}
.new-item:hover { border-color: var(--border-strong); }
.new-item:active { transform: translateY(1px); }
.new-item strong { display: block; font-size: 0.82rem; }
.new-item small { color: var(--text-muted); font-size: 0.72rem; }
.new-item.muted { cursor: default; text-align: center; color: var(--text-muted); font-size: 0.78rem; }
.new-item.muted:hover { border-color: var(--border); }

/* ============================== Command palette ======================== */
.palette-backdrop { position: fixed; inset: 0; z-index: 400; background: rgba(2,6,23,0.4); backdrop-filter: blur(2px); animation: fade 0.15s ease; }
.palette {
  position: fixed; z-index: 401; top: 18vh; left: 50%; transform: translateX(-50%);
  width: min(560px, 92vw);
  border-radius: 16px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.5);
  overflow: hidden; animation: rise 0.18s cubic-bezier(.2,.8,.2,1);
}
.palette[hidden] { display: none; }
.palette-input {
  width: 100%; border: none; outline: none;
  font-size: 1rem; padding: 0.95rem 1.1rem; color: var(--text);
  background: transparent; border-bottom: 1px solid var(--border);
}
.palette-results { max-height: 360px; overflow-y: auto; padding: 0.4rem; }
.palette-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.6rem; border-radius: 10px; cursor: pointer; }
.palette-row .pr-meta { color: var(--text-muted); font-size: 0.76rem; }
.palette-row .pr-main { flex: 1; min-width: 0; }
.palette-row .pr-title { font-size: 0.86rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-row .pr-sub { font-size: 0.72rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-row.active, .palette-row:hover { background: var(--surface-alt); }
.palette-row .pr-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-alt); color: var(--text-muted); }
.palette-row .pr-icon svg { width: 16px; height: 16px; }
.palette-empty { padding: 1.2rem; text-align: center; color: var(--text-muted); font-size: 0.84rem; }
.palette-hint { padding: 0.5rem 0.8rem; border-top: 1px solid var(--border); font-size: 0.7rem; color: var(--text-muted); display: flex; gap: 0.8rem; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ============================== Modals ================================= */
.modal { position: fixed; inset: 0; z-index: 1100; display: grid; place-items: center; padding: 1.2rem; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2,6,23,0.45); backdrop-filter: blur(3px); animation: fade 0.15s ease; }
.modal-card {
  position: relative; z-index: 1;
  width: min(420px, 100%); max-height: 88vh; overflow-y: auto;
  border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.5);
  padding: 1.6rem 1.5rem 1.4rem;
  animation: rise 0.22s cubic-bezier(.2,.8,.2,1);
}
.modal-card.admin-card, .modal-card.alerts-card { width: min(620px, 100%); }
.modal-close {
  position: absolute; top: 0.8rem; right: 0.8rem;
  width: 32px; height: 32px; border-radius: 8px;
  border: none; background: var(--surface-alt); color: var(--text-muted); cursor: pointer;
  font-size: 1.1rem; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-card h3 { margin: 0 0 0.3rem; font-size: 1.15rem; font-weight: 700; }
.modal-card h4 { margin: 0.5rem 0 0.3rem; font-size: 0.98rem; font-weight: 700; }
.modal-card .muted-note { color: var(--text-muted); font-size: 0.84rem; line-height: 1.5; }

/* forms */
.field { display: block; margin: 0.85rem 0; }
.field > span { display: block; font-size: 0.78rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.3rem; }
.field input, .field select, .palette-input {
  width: 100%; padding: 0.6rem 0.7rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-alt); color: var(--text);
  font-size: 0.9rem; font-family: inherit;
}
.field input:focus, .field select:focus, .palette-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.field .hint { color: var(--text-muted); font-size: 0.72rem; margin-top: 0.3rem; }
.code-input { font-family: var(--mono); font-size: 1.4rem; letter-spacing: 0.5em; text-align: center; padding-left: 1.1rem; }

.form-error, .form-success { font-size: 0.8rem; margin: 0.4rem 0; min-height: 1.1em; }
.form-error { color: #dc2626; }
.form-success { color: #16a34a; }
[data-theme="dark"] .form-error { color: #f87171; }
[data-theme="dark"] .form-success { color: #4ade80; }
.form-error.visible, .form-success.visible { opacity: 1; }
.form-error, .form-success { opacity: 0; transition: opacity 0.15s; }

/* auth modal panes */
.auth-form { display: grid; }
.auth-form[hidden] { display: none; }
.auth-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.auth-actions .ghost-btn { flex: 1; }

/* ---- alerts wizard ---- */
.wizard-steps { display: flex; gap: 0.4rem; margin-bottom 1rem; margin: 0 0 1.1rem; }
.wizard-step { flex: 1; height: 4px; border-radius: 999px; background: var(--border); }
.wizard-step.done { background: var(--accent); }
.wizard-step.current { background: linear-gradient(90deg, var(--accent), var(--accent-soft)); }
.wizard-pane[hidden] { display: none; }
.wizard-pane h4 { margin-top: 0; }
.type-options { display: grid; gap: 0.5rem; }
.type-option {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 0.8rem;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface-alt);
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.type-option:hover { border-color: var(--border-strong); }
.type-option[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.type-option .to-title { font-weight: 600; font-size: 0.9rem; }
.type-option .to-desc { font-size: 0.74rem; color: var(--text-muted); }
.type-option .to-icon { width: 32px; height: 32px; border-radius: 9px; background: var(--surface); display: grid; place-items: center; color: var(--accent); }

.alerts-center-row { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.alerts-center-row input { flex: 1; min-width: 90px; }
.alerts-center-row .ghost-btn { flex: 0 0 auto; }
.wizard-foot { display: flex; gap: 0.5rem; margin-top: 1rem; }
.wizard-foot .ghost-btn { flex: 0 0 auto; }
.wizard-foot .primary-btn { flex: 1; }

.existing-alerts { margin-top: 1.2rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.existing-alerts h4 { margin-top: 0; }
.alerts-list { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.6rem; }
.alerts-item { display: flex; align-items: center; justify-content: space-between; padding: 0.55rem 0.7rem; border-radius: 10px; background: var(--surface-alt); border: 1px solid var(--border); }
.alerts-item-main { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.alerts-item-type { font-weight: 600; font-size: 0.84rem; }
.alerts-item-meta { font-size: 0.72rem; color: var(--text-muted); }
.alerts-item-recipient { font-size: 0.72rem; color: var(--text-muted); }
.alerts-item .danger { border: 1px solid var(--border); background: var(--surface); color: #dc2626; padding: 0.35rem 0.55rem; border-radius: 8px; cursor: pointer; font-size: 0.74rem; }
[data-theme="dark"] .alerts-item .danger { color: #f87171; }

/* ---- admin slide-over ---- */
.admin-card { width: min(720px, 100%) !important; }
.admin-toolbar { display: flex; align-items: center; gap: 0.6rem; margin: 0.9rem 0; flex-wrap: wrap; }
.admin-search { flex: 1; min-width: 180px; position: relative; }
.admin-search input { width: 100%; padding: 0.5rem 0.7rem 0.5rem 2rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-alt); color: var(--text); font-size: 0.86rem; }
.admin-search .as-icon { position: absolute; left: 0.6rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); width: 16px; height: 16px; }
.admin-count { font-size: 0.8rem; color: var(--text-muted); }
.admin-scrape-bar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; padding: 0.6rem 0.7rem; border-radius: 10px; background: var(--surface-alt); border: 1px solid var(--border); margin-bottom: 0.8rem; }
.admin-scrape-bar .muted-note { font-size: 0.78rem; }
.admin-toolbar-group { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.admin-toolbar-group .auth-btn { font-size: 0.78rem; padding: 0.42rem 0.7rem; }

.admin-pending-section { margin-bottom: 0.9rem; }
.admin-pending-list { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.5rem; }
.admin-pending-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.55rem 0.7rem; border-radius: 10px; background: var(--surface-alt); border: 1px solid var(--border); flex-wrap: wrap; }
.admin-pending-email { font-weight: 600; font-size: 0.84rem; flex: 1; min-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.admin-pending-date { font-size: 0.72rem; color: var(--text-muted); }
.admin-pending-actions { display: flex; gap: 0.35rem; }
.admin-pending-actions .auth-btn { font-size: 0.76rem; padding: 0.35rem 0.6rem; }
.admin-pending-actions .primary { background: var(--accent); color: var(--accent-contrast); border: none; }
.admin-pending-empty { padding: 0.6rem 0; font-size: 0.8rem; color: var(--text-muted); }

.admin-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.admin-table th, .admin-table td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-table th { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); background: var(--surface-alt); }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tr.disabled td { opacity: 0.6; }
.role-badge { font-size: 0.68rem; font-weight: 700; padding: 0.15rem 0.45rem; border-radius: 999px; text-transform: capitalize; }
.role-badge[data-role="admin"] { background: rgba(245,158,11,0.16); color: #b45309; }
.role-badge[data-role="user"] { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }
[data-theme="dark"] .role-badge[data-role="admin"] { color: #fbbf24; }
.active-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 8px rgba(34,197,94,0.5); }
.admin-table tr.disabled .active-dot { background: var(--text-muted); box-shadow: none; }
.row-actions { display: flex; gap: 0.35rem; }
.row-actions button { font-size: 0.74rem; padding: 0.3rem 0.55rem; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text); }
.row-actions button:hover { border-color: var(--border-strong); }
.row-actions button.danger { color: #dc2626; }
[data-theme="dark"] .row-actions button.danger { color: #f87171; }
.row-actions button:disabled { opacity: 0.4; cursor: not-allowed; }
.muted-note { color: var(--text-muted); }

/* switch (admin active toggle) */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background 0.18s; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform 0.18s; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(16px); }

/* map pick hint */
.map-pick-hint {
  position: absolute; z-index: 28; top: 16px; left: 50%; transform: translateX(-50%);
  padding: 0.55rem 0.95rem; border-radius: 999px; font-size: 0.82rem; color: var(--text);
  background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow);
  animation: rise 0.2s ease;
}
.map-pick-hint[hidden] { display: none; }

/* flash marker (SSE new position) */
.flash-marker { pointer-events: none; }
.flash-pulse {
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(99,102,241,0.55); border: 2px solid #818cf8;
  animation: flash 1.6s ease-out forwards;
}
@keyframes flash { 0% { transform: scale(0.4); opacity: 0.9; } 70% { transform: scale(2.4); opacity: 0.2; } 100% { transform: scale(3); opacity: 0; } }

/* leaflet popup theming */
.leaflet-popup-content-wrapper { border-radius: 12px; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--glass-shadow); }
.leaflet-popup-tip { background: var(--surface); border: 1px solid var(--border); }
[data-theme="dark"] .leaflet-popup-content-wrapper, [data-theme="dark"] .leaflet-popup-tip { background: #0f172a; }
.standort-popup { min-width: 220px; font-size: 0.84rem; }
.standort-popup h4 { margin: 0 0 0.5rem; font-size: 0.95rem; }
.standort-popup .row { display: flex; justify-content: space-between; gap: 0.8rem; padding: 0.18rem 0; }
.standort-popup .row strong { color: var(--text-muted); font-weight: 600; }
.standort-popup .providers { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.5rem 0; }
.provider-tag { font-size: 0.7rem; font-weight: 600; padding: 0.15rem 0.45rem; border-radius: 999px; background: var(--surface-alt); border: 1px solid var(--border); }
.standort-popup .band-info { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.4rem; padding-top: 0.4rem; border-top: 1px solid var(--border); }

/* leaflet controls theme */
.leaflet-bar a, .leaflet-control-zoom a { background: var(--surface); color: var(--text); border-color: var(--border); }
.leaflet-control-attribution { background: var(--glass); color: var(--text-muted); }
[data-theme="dark"] .leaflet-control-attribution a { color: var(--text-muted); }

/* cluster cells */
.cluster-cell-wrap { display: grid; place-items: center; }
.cluster-cell { display: grid; place-items: center; border-radius: 50%; background: rgba(79,70,229,0.85); color: #fff; font-weight: 700; font-size: 0.78rem; box-shadow: 0 4px 12px rgba(79,70,229,0.4); }
[data-theme="dark"] .cluster-cell { background: rgba(129,140,248,0.85); }

/* network banner */
.network-banner {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%) translateY(1rem);
  background: #1e293b; color: #f8fafc; padding: 0.6rem 1rem; border-radius: 10px;
  font-size: 0.82rem; box-shadow: 0 6px 24px rgba(0,0,0,0.3);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 1500;
}
.network-banner.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================== Responsive ============================= */
@media (max-width: 860px) {
  .provider-pills, .segmented, .live-badge { display: none; }
  .user-email { display: none; }
  .details-panel { width: 100vw; }
  .details-toggle { display: none; }
  .brand .dot { display: none; }
}
@media (max-width: 560px) {
  .gate-card { padding: 2rem 1.5rem; }
  .modal { padding: 0.5rem; }
  .modal-card { border-radius: 14px; }
  .scrape-progress { width: calc(100vw - 24px); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}