:root {
  /* light blue-white theme */
  --bg: #eef4fb;
  --panel: #fdfeff;
  --panel-edge: #d9e4f2;
  --panel-edge-hover: #c4d6ec;
  --text: #1b2a3d;
  --text-dim: #5a6b80;
  --text-faint: #8a99ab;
  --accent: #1e88e5;
  --accent-strong: #1668b8;
  --accent-ink: #ffffff;
  --ok: #16a874;
  --warn: #dd9226;
  --bad: #d84f4f;
  --mem: #8256d8;
  --tx: #d97a16;
  --shadow-card: 0 1px 2px rgba(30, 60, 100, .06), 0 8px 24px rgba(30, 60, 100, .07);
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Consolas, monospace;

  /* shape system: cards 12, controls 9, chips 7 */
  --r-card: 12px;
  --r-ctrl: 9px;
  --r-chip: 7px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { color-scheme: light; }

body {
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* blue-white gradient backdrop on a fixed layer so scrolling never breaks it */
body::before {
  content: "";
  position: fixed; inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 480px at 50% -8%, rgba(30, 136, 229, .16), transparent 70%),
    linear-gradient(175deg, #d7e8fa 0%, #e9f2fc 45%, #f9fcff 100%);
}

::selection { background: rgba(30, 136, 229, .22); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #c2d3e8; border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-chip);
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  clip: rect(0 0 0 0); overflow: hidden; white-space: nowrap;
}

.hidden { display: none !important; }
[hidden] { display: none !important; }

/* ---------- login ---------- */
.overlay {
  position: fixed; inset: 0;
  background:
    radial-gradient(1100px 560px at 50% -10%, rgba(30, 136, 229, .2), transparent 72%),
    linear-gradient(175deg, #cfe2f8 0%, #e6f0fb 50%, #f8fbff 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--r-card);
  padding: 42px 38px 38px;
  width: min(370px, 90vw);
  text-align: center;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 24px 70px rgba(30, 60, 100, .18);
}
.login-logo-glyph {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px;
  font-size: 30px;
  background: linear-gradient(160deg, #e8f2fd, #f6faff);
  border: 1px solid var(--panel-edge);
  border-radius: 18px;
  margin-inline: auto;
}
.login-card h1 { font-size: 21px; letter-spacing: .4px; color: var(--text); }
.login-hint { color: var(--text-dim); font-size: 13px; }
.login-card input {
  background: #f4f8fd;
  border: 1px solid var(--panel-edge);
  border-radius: var(--r-ctrl);
  color: var(--text);
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  transition: border-color .25s ease, background-color .25s ease, box-shadow .25s ease;
}
.login-card input::placeholder { color: var(--text-faint); }
.login-card input:focus {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(30, 136, 229, .15);
}
.login-card button {
  background: var(--accent-strong);
  border: none; border-radius: var(--r-ctrl);
  color: var(--accent-ink);
  font-size: 15px; font-weight: 600;
  padding: 12px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(30, 136, 229, .3);
  transition: filter .2s ease, transform .12s ease;
}
.login-card button:hover { filter: brightness(1.06); }
.login-card button:active { transform: scale(.98); }
.login-card button:disabled { opacity: .6; cursor: wait; }
.login-error { color: var(--bad); font-size: 13px; }

/* ---------- top bar ---------- */
.topbar {
  position: relative;
  z-index: 30; /* keep the host menu above the cards below (backdrop-filter creates a stacking context) */
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--panel-edge);
  background: rgba(253, 254, 255, .82);
  backdrop-filter: blur(10px);
  flex-wrap: wrap; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.status-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--text-faint); flex-shrink: 0;
  margin-top: 2px;
  /* transparent baseline so online/offline shadows interpolate instead of snapping */
  box-shadow: 0 0 0 rgba(22, 168, 116, 0);
  transition: background-color 250ms ease-out, box-shadow 250ms ease-out;
}
.status-dot.online { background: var(--ok); box-shadow: 0 0 6px rgba(22, 168, 116, .5); }
.status-dot.offline { background: var(--bad); }
.brand-text { min-width: 0; position: relative; }
.host-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.brand h1 {
  font-size: 17px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
.host-menu-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border: 1px solid var(--panel-edge);
  border-radius: var(--r-chip);
  background: var(--panel);
  color: var(--text-dim);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.host-menu-btn:hover { color: var(--text); border-color: var(--panel-edge-hover); }
.host-menu-btn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }
.host-menu {
  position: absolute;
  top: calc(100% + 8px); left: 0;
  min-width: 250px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--r-card);
  box-shadow: 0 12px 40px rgba(30, 60, 100, .16);
  padding: 6px;
  z-index: 20;
}
.host-menu-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  border: none; background: none;
  color: var(--text);
  font-size: 13.5px;
  padding: 9px 11px;
  border-radius: var(--r-chip);
  cursor: pointer;
  text-align: left;
  transition: background-color .15s ease;
}
.host-menu-item:hover { background: #eef4fb; }
.host-menu-item .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}
.host-menu-item .dot.online { background: var(--ok); }
.host-menu-item .dot.offline { background: var(--bad); }
.host-menu-item .name {
  flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.host-menu-item .seen { color: var(--text-faint); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.host-menu-item[aria-checked="true"] { background: #e8f1fc; }
.host-menu-item[aria-checked="true"] .name { color: var(--accent-strong); font-weight: 600; }
.brand-meta {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 1px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.meta-dot {
  width: 3px; height: 3px; border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}

.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.updated-chip {
  color: var(--text-dim);
  font-size: 12px;
  background: #eaf1f9;
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  padding: 4px 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- jelly radio (ported from React Bits, spring physics in JS) ---------- */
.jelly-radio {
  --jr-chip: #eaf1f9;
  --jr-chip-hover: rgba(27, 42, 61, 0.11);
  /* active chip follows the theme's blue-white gradient: light blue fading to white,
     with the accent-strong blue for the label (5+:1 contrast on this light fill) */
  --jr-active: linear-gradient(180deg, #eaf3fe, #d0e4fa);
  --jr-active-text: var(--accent-strong);
  --jr-gap: 6px;
  --jr-radius: 15px;
  --jr-h: 30px;
  --jr-font: 13px;
  --jr-px: 14px;
  --jr-pad-x: 12px;
  --jr-pad-y: 5px;

  display: inline-flex;
  align-items: center;
  gap: var(--jr-gap);
  padding: var(--jr-pad-y) var(--jr-pad-x);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.jelly-chip {
  position: relative;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  outline: none;
  transform-origin: 50% 50%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.jelly-chip[aria-checked="true"] { cursor: default; }
.jelly-skin {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--jr-h);
  padding: 0 var(--jr-px);
  border-radius: var(--jr-radius);
  background: var(--jr-chip);
  color: var(--jr-text);
  font-size: var(--jr-font);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition:
    transform 160ms cubic-bezier(0.23, 1, 0.32, 1),
    background-color 200ms ease,
    color 200ms ease;
}
.jelly-skin::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--jr-text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .jelly-chip[aria-checked="false"]:hover .jelly-skin::before { opacity: 0.11; }
}
.jelly-chip:active .jelly-skin { transform: scale(0.97); }
.jelly-chip[aria-checked="true"] .jelly-skin {
  background: var(--jr-active);
  color: var(--jr-active-text);
  font-weight: 600;
  box-shadow:
    inset 0 0 0 1px rgba(30, 136, 229, .45),
    0 2px 8px rgba(30, 136, 229, .18);
}
.jelly-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--jr-radius); }

.logout-btn { color: var(--text-dim); font-size: 13px; text-decoration: none; transition: color .2s ease; }
.logout-btn:hover { color: var(--text); }

/* ---------- stats ---------- */
main { padding: 40px 44px 44px; max-width: 1320px; margin: 0 auto; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 36px;
}
.stat-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--r-card);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  transition: border-color .25s ease, transform .25s ease, box-shadow .25s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(30, 60, 100, .07), 0 14px 32px rgba(30, 60, 100, .11);
}
.stat-card h2 { font-size: 12px; font-weight: 500; color: var(--text-dim); letter-spacing: .12em; }
.stat-main {
  font-family: var(--mono);
  font-size: 31px;
  font-weight: 600;
  margin: 8px 0 10px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  color: var(--text);
}
.stat-main .unit {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 15px; color: var(--text-dim); margin-left: 4px; font-weight: 400; letter-spacing: 0;
}
.net-main { display: flex; gap: 16px; font-size: 21px; flex-wrap: wrap; }
.net-item { white-space: nowrap; }
.stat-sub { color: var(--text-dim); font-size: 12.5px; margin-top: 9px; font-variant-numeric: tabular-nums; }

/* cursor-following spotlight border */
.spot::before {
  content: "";
  position: absolute; inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: radial-gradient(220px circle at var(--mx, 50%) var(--my, 50%), rgba(30, 136, 229, .5), transparent 75%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
          mask-composite: exclude;
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
}
.spot:hover::before { opacity: 1; }

.bar {
  height: 6px;
  background: #e6edf7;
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill {
  height: 100%; width: 100%;
  background: var(--ok);
  transform: scaleX(0);
  transform-origin: left center;
  border-radius: 0;
}
.bar-fill.warn { background: var(--warn); }
.bar-fill.bad { background: var(--bad); }

/* ---------- charts ---------- */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  margin-top: 56px; /* larger than the column gap: separates the two sections */
}
.chart-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--r-card);
  padding: 16px 18px 10px;
  box-shadow: var(--shadow-card);
}
.chart-card h2 { font-size: 13px; font-weight: 500; color: var(--text-dim); margin-bottom: 10px; }
.chart-wrap { position: relative; height: 240px; }

/* ---------- empty state ---------- */
.empty-state {
  text-align: center;
  padding: 72px 20px 88px;
}
.empty-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 76px; height: 76px;
  font-size: 34px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 22px;
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
}
.empty-state h2 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.empty-state p { color: var(--text-dim); font-size: 13.5px; line-height: 1.8; }
.empty-state code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: #e6eef8;
  border: 1px solid var(--panel-edge);
  border-radius: 5px;
  padding: 1px 6px;
}

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .charts-grid { grid-template-columns: 1fr; }
  main { padding: 20px; }
  .topbar { padding: 12px 14px; }
  .stat-main { font-size: 27px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 16px; }
  .charts-grid { gap: 16px; margin-top: 24px; }
  /* sample time already lives in the brand meta row; keep controls on one line */
  .updated-chip { display: none; }
  .topbar-right { flex-wrap: nowrap; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
