:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0d10;
  --surface: #14151b;
  --elev: #1c1d25;
  --fg: #ecece8;
  --muted: #9b9ba4;
  --subtle: #6e6e77;
  --line: rgba(236, 236, 232, 0.12);
  --accent: #d6d3c9;
  --accent-fg: #0c0d10;
  --alarm: #c45c4a;
  --ok: #6f9b7a;
  --ontest: #c47a3a;
  --fire: #e07040;
  --trouble: #c9a227;
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f2ef;
  --surface: #ffffff;
  --elev: #ffffff;
  --fg: #1a1b20;
  --muted: #5c5e68;
  --subtle: #8a8c96;
  --line: rgba(26, 27, 32, 0.1);
  --accent: #2a2b31;
  --accent-fg: #f3f2ef;
  --alarm: #c44536;
  --ok: #3f7a52;
  --ontest: #b86a1c;
  --fire: #c45c26;
  --trouble: #a68512;
}
html[data-theme="interface"] {
  color-scheme: light;
  --bg: #f7f5f2;
  --surface: #ffffff;
  --elev: #ffffff;
  --fg: #1b1c22;
  --muted: #5a5c66;
  --subtle: #8b8d96;
  --line: rgba(27, 28, 34, 0.09);
  --accent: #fd6654;
  --accent-fg: #ffffff;
  --alarm: #c13a32;
  --ok: #2f7a4a;
  --ontest: #d97706;
  --fire: #e07040;
  --trouble: #b8860b;
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; background: var(--bg); color: var(--fg); }
body {
  font-family: "Roboto", "Segoe UI", sans-serif;
  font-size: 15px;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.screen { min-height: 100%; padding: calc(8px + env(safe-area-inset-top)) 0 calc(24px + env(safe-area-inset-bottom)); }
.pad { padding-left: 16px; padding-right: 16px; }
.bar, .acct {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px 10px 16px;
  border-bottom: 1px solid var(--line);
}
.logo { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; }
.brand b, .acct b { display: block; font-size: 16px; font-weight: 700; }
.brand small, .acct small { color: var(--muted); font-size: 12px; }
.icon-btn {
  width: 48px;
  height: 48px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
}
h1 { font-size: 22px; margin: 28px 0 0; font-weight: 700; }
.lead { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
.kicker {
  color: var(--subtle);
  font-size: 11px;
  letter-spacing: 0.12em;
  margin: 20px 0 8px;
}
input[type="text"], input[type="password"], input[type="search"] {
  width: 100%;
  height: 48px;
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 16px;
}
input::placeholder { color: var(--subtle); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 12px; font-size: 14px; }
.primary, .ghost {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 12px;
  margin-top: 12px;
}
.primary { background: var(--accent); color: var(--accent-fg); font-weight: 650; }
.ghost { background: var(--elev); color: var(--fg); border: 1px solid var(--line); }
.chips, .tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.chip {
  height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--elev);
  color: var(--fg);
  white-space: nowrap;
}
.chip.on { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.row, .card {
  width: 100%;
  text-align: left;
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  margin: 0 0 8px;
}
.row b, .card b { display: block; font-size: 15px; }
.row small, .card small, .muted { color: var(--muted); font-size: 12px; }
.section { color: var(--subtle); font-size: 11px; letter-spacing: 0.14em; margin: 16px 16px 8px; }
.list { padding: 0 16px; }
.event {
  display: flex;
  gap: 10px;
  align-items: stretch;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.rail { width: 3px; border-radius: 2px; background: var(--subtle); flex: none; }
.rail.alarm { background: var(--alarm); }
.rail.fire { background: var(--fire); }
.rail.trouble { background: var(--trouble); }
.rail.restore, .rail.open { background: var(--ok); }
.rail.ontest { background: var(--ontest); }
.when { width: 78px; flex: none; }
.when b { display: block; color: var(--muted); font-size: 11px; font-weight: 500; }
.when small { color: var(--subtle); font-size: 11px; }
.event .body b { font-size: 14px; }
.sheet {
  position: fixed;
  z-index: 30;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  justify-content: flex-end;
  padding: calc(12px + env(safe-area-inset-top)) 12px 12px;
}
.sheet .card { width: min(360px, 100%); max-height: 88vh; overflow: auto; margin: 0; background: var(--elev); }
.swatch { display: flex; gap: 4px; margin-top: 6px; }
.swatch i { width: 18px; height: 18px; border-radius: 4px; display: block; }
.server { display: flex; gap: 8px; align-items: center; }
.server .row { flex: 1; }
.theme-row.on { outline: 2px solid var(--accent); }
#leaflet { position: fixed; inset: 0; background: #101218; }
.map-ui {
  position: fixed;
  z-index: 500;
  left: 12px;
  right: 12px;
  top: calc(12px + env(safe-area-inset-top));
  display: flex;
  gap: 8px;
  align-items: center;
}
.map-ui .chips { flex: 1; margin: 0; }
.you, .pin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #0c0d10; }
.you { background: #7eb6ff; }
.pin { background: var(--accent); }
.leaflet-container { background: #101218; font: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--elev); color: var(--fg); }
.empty { color: var(--muted); padding: 8px 0 16px; }
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  z-index: 40;
}
.hours { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
