:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --good: #22c55e;
  --fair: #eab308;
  --poor: #f97316;
  --bad: #ef4444;
  --idle: #64748b;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#bar {
  flex: 0 0 auto;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 8px;
  background: var(--idle);
  color: #fff;
}
main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 8px 12px 12px;
  width: 100%;
  margin: 0;
  overflow: auto;
}
.stats { display: flex; justify-content: space-between; align-items: baseline; }
#rtt { font-size: 2.4rem; font-weight: 800; }
#pkts { color: var(--muted); font-size: 1.2rem; }
.actions { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; align-items: center; }
.actions .spacer { flex: 1 1 auto; min-width: 8px; }
.nav-link {
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 8px 10px;
  border-radius: 8px;
  background: #334155;
}
.nav-link:hover { background: #475569; }
button {
  font: inherit;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  background: #334155;
  color: #fff;
  cursor: pointer;
}
button.primary { background: var(--good); color: #052e16; font-weight: 700; }
button.stop { background: var(--bad); color: #fff; }
button:disabled { opacity: 0.5; }
.banner {
  background: #7c2d12;
  color: #ffedd5;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.banner button { background: #fdba74; color: #7c2d12; font-weight: 700; }
.hidden { display: none; }
#map {
  flex: 1 1 auto;
  height: 0;
  min-height: 280px;
  border-radius: 10px;
  overflow: hidden;
  background: #0b1220;
  margin: 8px 0;
}
.status-card {
  background: var(--panel);
  border: 1px solid #334155;
  border-radius: 10px;
  overflow: hidden;
  margin: 4px 0 8px;
}
.status-card table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.status-card th {
  width: 6.5rem;
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 8px 12px;
  border-bottom: 1px solid #243044;
  vertical-align: top;
  white-space: nowrap;
}
.status-card td {
  padding: 8px 12px;
  border-bottom: 1px solid #243044;
  color: var(--text);
  word-break: break-word;
}
.status-card tr:last-child th,
.status-card tr:last-child td { border-bottom: 0; }
.hint { color: #64748b; font-size: 0.85rem; margin: 4px 0 0; }
form { margin-top: 8px; display: grid; gap: 8px; max-width: 720px; }
label { display: grid; gap: 4px; color: var(--muted); font-size: 0.85rem; }
input, select {
  font: inherit;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #334155;
  background: var(--panel);
  color: var(--text);
}
.host-row { display: flex; align-items: center; gap: 8px; }
.host-row input { flex: 1; }
#dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: #94a3b8; display: inline-block;
}
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 0.95rem; }
fieldset {
  border: 1px solid #334155;
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 8px 10px;
}
legend { color: var(--muted); }
details {
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 10px;
}
details summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
}
details[open] summary { margin-bottom: 8px; }
details[open] { display: grid; gap: 8px; }
.thresholds {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.thresholds label { min-width: 0; }
body[data-role="server"] .collector-only { display: none !important; }
body[data-role="collector"] .server-only { display: none !important; }
.day-pick { color: var(--muted); font-size: 0.85rem; display: flex; align-items: center; gap: 8px; }
.day-pick select { min-width: 10rem; }
.leaflet-container { background: #0b1220; font: inherit; }
.leaflet-tooltip.hex-tooltip {
  font-size: 9px;
  font-weight: 600;
  line-height: 1.15;
  padding: 0 3px;
  margin: 0;
  border: 0;
  border-radius: 3px;
  background: rgba(15, 23, 42, 0.78);
  color: #f8fafc;
  box-shadow: none;
  white-space: nowrap;
}
.leaflet-tooltip.hex-tooltip::before { display: none; }
.leaflet-tooltip.hex-tooltip.hidden-label { display: none; }

body.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 24px 12px;
}
body.admin {
  display: block;
  overflow: auto;
  height: auto;
  min-height: 100dvh;
}
.auth-card {
  width: min(26rem, 100%);
  background: var(--panel);
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 28px 24px 24px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
.auth-card .brand {
  color: var(--good);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.auth-card h1 { margin: 6px 0 6px; font-size: 1.55rem; }
.auth-card .sub { color: var(--muted); margin: 0 0 18px; font-size: 0.95rem; }
.auth-card form { display: grid; gap: 12px; margin: 0; max-width: none; }
.auth-card button { width: 100%; margin-top: 4px; }
.auth-error { color: #fecaca; background: #7f1d1d; border-radius: 8px; padding: 8px 10px; font-size: 0.9rem; }
.admin-wrap { padding: 8px 12px 24px; max-width: 720px; margin: 0 auto; width: 100%; }
.admin-wrap h1 { margin: 12px 0 4px; font-size: 1.4rem; }
.admin-wrap .sub { color: var(--muted); margin: 0 0 16px; }
.admin-wrap table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 10px; overflow: hidden; }
.admin-wrap th, .admin-wrap td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #243044; font-size: 0.92rem; }
.admin-wrap th { color: var(--muted); font-weight: 600; }
.admin-wrap tr:last-child td { border-bottom: 0; }
.admin-wrap .role { color: var(--muted); font-size: 0.8rem; }
.admin-wrap .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-wrap .row-actions button { padding: 6px 10px; font-size: 0.85rem; }
.admin-add {
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 14px;
  display: grid;
  gap: 10px;
}
.admin-add h2 { margin: 0; font-size: 1rem; }
.admin-add .row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
@media (max-width: 640px) {
  .admin-add .row { grid-template-columns: 1fr; }
}
