:root {
  color-scheme: dark;
  --bg: #0f1218;
  --panel: #171c24;
  --panel-2: #1f2631;
  --text: #edf2f8;
  --muted: #9fb0c5;
  --line: #2e3948;
  --accent: #3f88ff;
  --danger: #ff7070;
  --ok: #73d78d;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
#app {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}
.hidden { display: none !important; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
}
.auth-card {
  max-width: 420px;
  margin: 10vh auto 0;
}
.topbar, .section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.topbar-actions, .toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
}
.wide-toolbar { min-width: min(520px, 100%); }
.tabbar {
  display: flex;
  gap: 10px;
  margin: 20px 0;
  overflow-x: auto;
}
.tab-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}
.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
}
.tab-panel { display: block; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card { display: grid; gap: 8px; }
.stat-label { color: var(--muted); font-size: 14px; }
.stat-card strong { font-size: 32px; }
.stat-help { color: var(--muted); font-size: 13px; }
.overview-grid, .alert-layout {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 20px;
}
.summary-list { display: grid; gap: 14px; }
.summary-list > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.chip-list { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.chip {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
}
.map-card { min-height: 100%; }
#alert-map {
  height: 420px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
}
label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 14px;
}
input, textarea, select, button { font: inherit; }
input, textarea, select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 12px 14px;
}
button {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 600;
}
button.secondary {
  background: transparent;
  border: 1px solid var(--line);
}
.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.two-col {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}
.muted { color: var(--muted); margin-top: 4px; }
.status { min-height: 20px; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.error { color: var(--danger); }
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-top: 16px;
}
.wide-table-wrap { max-width: 100%; }
.users-table, .locations-table, table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}
th, td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.small-btn {
  padding: 8px 10px;
  font-size: 13px;
}
.action-row {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 190px;
}
.coord {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.coord-muted { color: var(--muted); }
.matched-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
}
.notice-inline {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
}
@media (max-width: 1100px) {
  .stats-grid, .overview-grid, .alert-layout {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 720px) {
  #app { padding: 16px; }
  .topbar, .section-header, .toolbar, .button-row, .two-col {
    grid-template-columns: 1fr;
    display: grid;
  }
  .wide-toolbar { min-width: 0; }
}


.inset-card {
  margin-bottom: 16px;
}

#locations-map {
  height: 420px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.device-dot {
  background: #3f88ff;
  border: 2px solid #ffffff;
  border-radius: 999px;
  width: 14px;
  height: 14px;
}

.home-dot {
  background: #f59e0b;
  border: 2px solid #ffffff;
  border-radius: 999px;
  width: 14px;
  height: 14px;
}
