/* NetPulse - dark monitoring UI */
:root {
  --bg: #070b12;
  --bg-soft: #0b1220;
  --panel: rgba(15, 23, 42, 0.62);
  --panel-solid: #0d1522;
  --line: rgba(148, 163, 184, 0.14);
  --line-strong: rgba(148, 163, 184, 0.26);
  --text: #e6edf7;
  --muted: #8b9bb4;
  --dim: #5b6b84;
  --accent: #22d3ee;
  --accent-2: #34d399;
  --excellent: #34d399;
  --good: #a3e635;
  --fair: #fbbf24;
  --poor: #fb923c;
  --bad: #f87171;
  --nodata: #64748b;
  --shadow: 0 18px 40px rgba(2, 6, 14, 0.55);
  --radius: 16px;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(1100px 560px at 8% -12%, rgba(34, 211, 238, 0.10), transparent 62%),
    radial-gradient(900px 520px at 102% -4%, rgba(52, 211, 153, 0.07), transparent 58%),
    radial-gradient(900px 700px at 50% 120%, rgba(56, 89, 138, 0.10), transparent 60%),
    var(--bg);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }

.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

/* ------------------------------------------------------------------ */
/* login                                                              */
/* ------------------------------------------------------------------ */
.auth-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-wrap { width: 100%; max-width: 400px; }

.auth-card {
  position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 36px 32px 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  overflow: hidden;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: -1px -1px auto -1px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(34, 211, 238, 0.7), rgba(52, 211, 153, 0.7), transparent);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.brand-mark svg { width: 30px; height: 30px; border-radius: 8px; display: block; }

.auth-card h1 {
  margin-top: 22px;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-card .subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13.5px;
}

.auth-form { margin-top: 26px; display: grid; gap: 16px; }

.field { display: grid; gap: 7px; }

.field label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: rgba(2, 6, 14, 0.55);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  border-color: rgba(34, 211, 238, 0.65);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.14);
}

.btn-primary {
  border: 0;
  border-radius: 11px;
  padding: 12px 16px;
  font-weight: 650;
  color: #04121a;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  transition: filter 0.15s, transform 0.05s;
}

.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.form-error {
  margin: 0;
  padding: 9px 12px;
  border-radius: 9px;
  background: rgba(248, 113, 113, 0.10);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: #fca5a5;
  font-size: 13px;
}

.auth-foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 12px;
}

/* ------------------------------------------------------------------ */
/* dashboard shell                                                    */
/* ------------------------------------------------------------------ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 26px;
  background: rgba(7, 11, 18, 0.78);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.topbar .brand-mark { margin-right: auto; }
.topbar .brand-mark svg { width: 28px; height: 28px; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(148, 163, 184, 0.07);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--nodata);
  box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.18);
}

.chip-excellent { color: var(--excellent); border-color: rgba(52, 211, 153, 0.35); }
.chip-excellent .dot { background: var(--excellent); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); }
.chip-good { color: var(--good); border-color: rgba(163, 230, 53, 0.32); }
.chip-good .dot { background: var(--good); box-shadow: 0 0 0 3px rgba(163, 230, 53, 0.16); }
.chip-fair { color: var(--fair); border-color: rgba(251, 191, 36, 0.35); }
.chip-fair .dot { background: var(--fair); box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.16); }
.chip-poor { color: var(--poor); border-color: rgba(251, 146, 60, 0.4); }
.chip-poor .dot { background: var(--poor); box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.16); }
.chip-bad { color: var(--bad); border-color: rgba(248, 113, 113, 0.42); }
.chip-bad .dot { background: var(--bad); box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.18); }
.chip-nodata .dot { animation: pulse 1.6s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(2, 6, 14, 0.45);
}

.seg button {
  border: 0;
  background: transparent;
  padding: 6px 13px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

.seg button:hover { color: var(--text); }

.seg button.active {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.95), rgba(52, 211, 153, 0.9));
  color: #04121a;
}

.updated {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--dim);
  white-space: nowrap;
}

.updated.stale { color: var(--poor); }

.btn-ghost {
  border: 1px solid var(--line-strong);
  background: transparent;
  border-radius: 9px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.15s, border-color 0.15s;
}

.btn-ghost:hover { color: var(--text); border-color: rgba(148, 163, 184, 0.45); }

main {
  max-width: 1480px;
  margin: 0 auto;
  padding: 26px 26px 60px;
}

/* ------------------------------------------------------------------ */
/* summary tiles                                                      */
/* ------------------------------------------------------------------ */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 30px;
}

.stat {
  position: relative;
  padding: 17px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.012));
  overflow: hidden;
}

.stat::after {
  content: "";
  position: absolute;
  inset: auto -30% -60% auto;
  width: 160px;
  height: 120px;
  background: radial-gradient(closest-side, rgba(34, 211, 238, 0.10), transparent);
}

.stat-label {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--dim);
}

.stat-value {
  margin-top: 8px;
  font-size: 27px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-value .unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 4px;
}

.stat-sub {
  margin-top: 5px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------------------------------------------ */
/* sections and cards                                                 */
/* ------------------------------------------------------------------ */
.section { margin-bottom: 30px; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 13px;
}

.section-head h2 {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.section-head .count {
  font-size: 11.5px;
  color: var(--dim);
  font-family: var(--mono);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 13px;
}

.card {
  --q: var(--nodata);
  position: relative;
  padding: 15px 16px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.042), rgba(255, 255, 255, 0.012));
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.card:hover, .card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: 0 14px 30px rgba(2, 6, 14, 0.42);
  outline: none;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: var(--q);
  opacity: 0.75;
}

.card.q-excellent { --q: var(--excellent); }
.card.q-good { --q: var(--good); }
.card.q-fair { --q: var(--fair); }
.card.q-poor { --q: var(--poor); }
.card.q-bad { --q: var(--bad); }
.card.q-nodata { --q: var(--nodata); }

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--q);
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.12);
  flex: none;
}

.card-id { min-width: 0; flex: 1; }

.card-id h3 {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-id p {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.q-badge {
  flex: none;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--q);
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.card-body {
  margin-top: 13px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  justify-content: space-between;
}

.latency {
  display: flex;
  align-items: baseline;
  gap: 4px;
  line-height: 1;
}

.latency .num {
  font-size: 29px;
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.latency .unit {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.card-sub {
  display: grid;
  gap: 2px;
  font-size: 11px;
  color: var(--dim);
  text-align: right;
  padding-bottom: 2px;
}

.card-sub b {
  color: var(--muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.spark {
  display: block;
  width: 100%;
  height: 44px;
  margin-top: 9px;
}

/* ------------------------------------------------------------------ */
/* detail modal                                                       */
/* ------------------------------------------------------------------ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(3, 7, 14, 0.72);
  backdrop-filter: blur(6px);
}

.modal[hidden] { display: none; }

.modal-panel {
  position: relative;
  width: min(920px, 100%);
  max-height: calc(100vh - 44px);
  overflow: auto;
  border-radius: 20px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #0f1826, #0b1320);
  box-shadow: var(--shadow);
  padding: 22px 24px 24px;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.modal-head h3 { font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
.modal-head .host { font-family: var(--mono); font-size: 11.5px; color: var(--dim); margin-top: 3px; }

.modal-close {
  margin-left: auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(2, 6, 14, 0.4);
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  flex: none;
}

.modal-close:hover { color: var(--text); }

.modal-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin: 16px 0 8px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(2, 6, 14, 0.32);
}

.mstat { display: grid; gap: 2px; }
.mstat .k { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.mstat .v { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mstat .v small { font-size: 11px; color: var(--muted); font-weight: 500; }

.chart-wrap { position: relative; margin-top: 10px; }
.chart-wrap canvas { display: block; width: 100%; height: 270px; }

.chart-legend {
  display: flex;
  gap: 18px;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--dim);
}

.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 14px; height: 2px; border-radius: 2px; background: var(--accent); }
.legend-swatch.loss { background: var(--bad); }

.chart-tip {
  position: absolute;
  pointer-events: none;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: rgba(8, 13, 22, 0.95);
  font-size: 11.5px;
  font-family: var(--mono);
  color: var(--text);
  white-space: nowrap;
  transform: translate(-50%, -100%);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 2;
}

.chart-tip.visible { opacity: 1; }
.chart-tip .t-time { color: var(--dim); }
.chart-tip .t-val { color: var(--accent-2); font-weight: 600; }
.chart-tip .t-loss { color: var(--bad); }

/* ------------------------------------------------------------------ */
/* footer                                                             */
/* ------------------------------------------------------------------ */
.page-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  justify-content: space-between;
  margin-top: 34px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 11.5px;
}

.page-footer .mono { color: var(--muted); }

/* ------------------------------------------------------------------ */
/* responsive                                                         */
/* ------------------------------------------------------------------ */
@media (max-width: 760px) {
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .topbar-right { gap: 10px; width: 100%; justify-content: flex-start; }
  main { padding: 18px 16px 48px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
  .stat-value { font-size: 23px; }
  .modal-panel { padding: 18px 16px 20px; }
  .chart-wrap canvas { height: 220px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}
