:root {
  --bg: #0f1115;
  --panel: #1a1d24;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --muted: #8a93a6;
  --accent: #43a047;
  --danger: #e53935;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 48px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; z-index: 1000;
}
.topbar .brand { font-weight: 600; letter-spacing: .3px; }
.topbar .right { display: flex; gap: 16px; align-items: center; color: var(--muted); }
.topbar a { color: var(--muted); text-decoration: none; }
.topbar a:hover { color: var(--text); }
.topbar a.nav { padding: 4px 0; }
.topbar a.nav.active { color: var(--text); border-bottom: 2px solid var(--accent); }

.sidebar {
  position: fixed; top: 48px; left: 0; bottom: 0; width: 280px;
  background: var(--panel); border-right: 1px solid var(--border);
  padding: 16px; overflow-y: auto; z-index: 999;
}
.sidebar h3 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase;
              letter-spacing: 1px; color: var(--muted); }
.sidebar h3:first-child { margin-top: 0; }
.sidebar label { display: block; font-size: 13px; margin-bottom: 10px; color: var(--muted); }
.sidebar label input, .sidebar label select {
  width: 100%; margin-top: 4px; padding: 6px 8px; background: #11141a;
  color: var(--text); border: 1px solid var(--border); border-radius: 4px;
}
.sidebar label.cb { display: flex; align-items: center; gap: 8px; color: var(--text); }
.sidebar label.cb input { width: auto; margin: 0; }
.sidebar button {
  width: 100%; padding: 8px; background: var(--accent); color: #fff;
  border: 0; border-radius: 4px; cursor: pointer; font-weight: 600;
}
.sidebar button:hover { filter: brightness(1.1); }
.stats { margin-top: 16px; font-size: 12px; color: var(--muted); }

#map { position: fixed; top: 48px; left: 280px; right: 0; bottom: 0; }

body.busy { cursor: progress; }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center;
              min-height: 100vh; background: var(--bg); }
.login-card { background: var(--panel); padding: 32px; border-radius: 8px;
              border: 1px solid var(--border); width: 320px; }
.login-card h1 { margin: 0 0 20px; font-size: 22px; }
.login-card label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.login-card input { width: 100%; margin-top: 4px; padding: 8px;
                    background: #11141a; color: var(--text);
                    border: 1px solid var(--border); border-radius: 4px; }
.login-card button { width: 100%; padding: 10px; background: var(--accent);
                     color: #fff; border: 0; border-radius: 4px; cursor: pointer; font-weight: 600; }
.login-card .err { background: rgba(229,57,53,.15); color: #ff8b88;
                   border: 1px solid rgba(229,57,53,.4); padding: 8px;
                   border-radius: 4px; margin-bottom: 14px; font-size: 13px; }

/* Leaflet popup style override */
.leaflet-popup-content-wrapper { background: var(--panel); color: var(--text); }
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content code { background: #11141a; padding: 2px 4px; border-radius: 3px; }
.leaflet-popup-content hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.leaflet-popup-content small { color: var(--muted); }

/* Mode switcher and cell-mode controls */
.mode-row { display: flex; gap: 16px; margin-bottom: 8px; }
.mode-row label.cb { margin: 0; }
.net-types { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin-top: 4px; }
.sidebar input[type=range] { width: 100%; margin-top: 6px; }

/* Collapsible "Show in popup" sections */
.sidebar details { margin-bottom: 8px; }
.sidebar details summary {
  cursor: pointer; font-size: 12px; color: var(--text);
  padding: 4px 0; user-select: none; outline: none;
}
.sidebar details summary:hover { color: var(--accent); }
.sidebar details > label.cb { margin-left: 12px; font-size: 12px; }
