:root {
  color-scheme: dark;
  --bg: #05090c;
  --panel: #0a1519;
  --panel-2: #0c1d22;
  --line: rgba(126, 242, 255, 0.17);
  --text: #e8fcff;
  --muted: #91a9b1;
  --green: #6dfc98;
  --blue: #7ef2ff;
  --violet: #8f8cff;
  --yellow: #ffd166;
  --red: #ff6b8b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 20% 0%, rgba(126, 242, 255, 0.10), transparent 34%), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  padding: 22px;
  overflow-x: hidden;
}

a {
  color: var(--blue);
  text-decoration: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto 18px;
  max-width: 1320px;
}

.topbar h1,
.panel h2,
.login-box h1 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 28px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-weight: 800;
}

.pill.online {
  color: #04240f;
  background: var(--green);
  border-color: var(--green);
}

.layout {
  display: grid;
  gap: 18px;
  max-width: 1320px;
  margin: 0 auto;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(12, 29, 34, 0.96), rgba(5, 12, 15, 0.96));
  box-shadow: 0 0 0 1px rgba(109, 252, 152, 0.03), 0 24px 90px rgba(0, 0, 0, 0.28);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
  gap: 18px;
  padding: 20px;
  overflow: hidden;
}

.hero > *,
.stats-grid,
.stats-grid > * {
  min-width: 0;
}

.hero-main {
  display: flex;
  min-height: 154px;
  flex-direction: column;
  justify-content: center;
  padding: 18px;
  border: 1px solid rgba(109, 252, 152, 0.22);
  border-radius: 8px;
  background: rgba(109, 252, 152, 0.05);
}

.label,
.stats-grid span,
dt,
.panel-head p,
.login-box p {
  color: var(--muted);
}

.hero-main strong {
  display: block;
  margin: 4px 0;
  font-size: clamp(42px, 6vw, 92px);
  line-height: 0.95;
  color: var(--green);
  overflow-wrap: anywhere;
}

.hero-main small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stats-grid div {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.stats-grid strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(20px, 1.8vw, 30px);
  overflow-wrap: anywhere;
}

.stats-grid small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.chart-panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.panel-head h2,
.panel-head p {
  margin: 0;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button,
.login-box button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button.active,
button:hover,
.login-box button:hover {
  border-color: var(--blue);
  background: rgba(126, 242, 255, 0.13);
}

.chart-wrap {
  position: relative;
}

#trafficChart {
  display: block;
  width: 100%;
  height: 520px;
  border: 1px solid rgba(126, 242, 255, 0.12);
  border-radius: 8px;
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  width: 230px;
  padding: 10px 12px;
  border: 1px solid rgba(126, 242, 255, 0.32);
  border-radius: 8px;
  background: rgba(5, 12, 15, 0.96);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
  color: var(--text);
  pointer-events: none;
}

.chart-tooltip strong,
.chart-tooltip span {
  display: block;
}

.chart-tooltip strong {
  margin-bottom: 8px;
  font-size: 12px;
}

.chart-tooltip span {
  margin-top: 5px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.legend button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--muted);
  opacity: 0.46;
}

.legend button.active {
  color: var(--text);
  opacity: 1;
}

.legend i {
  display: inline-block;
  width: 24px;
  height: 4px;
  margin-right: 8px;
  vertical-align: middle;
  border-radius: 999px;
}

.legend .in {
  background: var(--green);
}

.legend .out {
  background: var(--violet);
}

.legend .iperf {
  background: var(--yellow);
}

.ping-panel {
  display: block;
  padding: 18px;
}

.ping-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}

.ping-head h2,
.ping-head p {
  margin: 0;
}

.ping-head p {
  margin-top: 4px;
  color: var(--muted);
}

.ping-head strong {
  color: var(--blue);
  font-size: 32px;
  white-space: nowrap;
}

#pingChart {
  display: block;
  width: 100%;
  height: 130px;
  border: 1px solid rgba(126, 242, 255, 0.12);
  border-radius: 8px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.grid .panel {
  padding: 18px;
}

dl {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 11px 16px;
  margin: 18px 0 0;
}

dt {
  font-size: 13px;
}

dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-box {
  width: min(420px, calc(100vw - 36px));
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.login-box form {
  display: grid;
  gap: 14px;
}

.login-box label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.login-box input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.22);
  font: inherit;
}

.error {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 107, 139, 0.35);
  border-radius: 8px;
  color: var(--red);
  background: rgba(255, 107, 139, 0.08);
}

@media (max-width: 1500px) {
  body {
    padding: 14px;
  }

  .topbar,
  .layout {
    max-width: 1240px;
  }

  .topbar {
    margin-bottom: 12px;
  }

  .topbar h1 {
    font-size: 24px;
  }

  .eyebrow {
    margin-bottom: 4px;
    font-size: 11px;
  }

  .layout {
    gap: 14px;
  }

  .hero {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
  }

  .hero-main {
    min-height: 126px;
    padding: 14px;
  }

  .hero-main strong {
    font-size: clamp(42px, 5.3vw, 72px);
  }

  .stats-grid {
    gap: 10px;
  }

  .stats-grid div {
    min-height: 94px;
    padding: 12px;
  }

  .stats-grid strong {
    margin-top: 6px;
    font-size: clamp(19px, 1.65vw, 25px);
  }

  .stats-grid small {
    margin-top: 6px;
    font-size: 12px;
  }

  .chart-panel,
  .ping-panel,
  .grid .panel {
    padding: 14px;
  }

  .panel-head {
    margin-bottom: 10px;
  }

  .panel h2 {
    font-size: 22px;
  }

  .panel-head p {
    font-size: 14px;
  }

  button,
  .login-box button {
    min-height: 34px;
    padding: 0 12px;
  }

  #trafficChart {
    height: 420px;
  }

  .legend {
    gap: 10px;
    margin-top: 10px;
  }

  .ping-head {
    margin-bottom: 10px;
  }

  .ping-head strong {
    font-size: 26px;
  }

  #pingChart {
    height: 118px;
  }

  .grid {
    gap: 14px;
  }

  dl {
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 9px 12px;
    margin-top: 14px;
  }
}

@media (max-width: 1250px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .stats-grid div {
    min-height: 86px;
  }

  #trafficChart {
    height: 390px;
  }
}

@media (max-width: 980px) {
  .topbar,
  .panel-head,
  .hero {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats-grid,
  .grid {
    grid-template-columns: 1fr;
  }

  .ping-head {
    flex-direction: column;
  }

  #trafficChart {
    height: 380px;
  }

  #pingChart {
    height: 150px;
  }
}
