:root {
  --bg-0: #070b12;
  --bg-1: #0c1320;
  --bg-2: #121b2c;
  --bg-3: #182338;
  --bg-4: #1e2b44;
  --line: rgba(154, 184, 220, 0.14);
  --line-strong: rgba(174, 204, 240, 0.28);
  --text: #eef3fb;
  --muted: #8ea2c0;
  --faint: #6b7d99;
  --cyan: #2ee6d6;
  --cyan-dim: rgba(46, 230, 214, 0.16);
  --blue: #5b8cff;
  --green: #3ee0a0;
  --green-dim: rgba(62, 224, 160, 0.16);
  --amber: #f5c14a;
  --amber-dim: rgba(245, 193, 74, 0.16);
  --red: #ff6b7a;
  --red-dim: rgba(255, 107, 122, 0.16);
  --violet: #b08cff;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", ui-monospace, monospace;
  --sidebar: 268px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(46, 230, 214, 0.08), transparent 50%),
    radial-gradient(900px 500px at 110% 0%, rgba(91, 140, 255, 0.1), transparent 46%),
    var(--bg-0);
  color: var(--text);
  font-family: var(--font);
  letter-spacing: 0.01em;
}

body {
  min-height: 100vh;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #2a3b58;
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: #3a5074;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.05em 0.4em;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(130, 160, 200, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(130, 160, 200, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 30%, black, transparent 78%);
  z-index: 0;
}

.login-screen,
.app-shell,
.toast-stack,
.modal {
  position: relative;
  z-index: 1;
}

.login-screen {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  min-height: 100vh;
}

.login-art {
  display: flex;
  align-items: center;
  padding: 64px;
}

.login-art-inner {
  position: relative;
  max-width: 560px;
}

.login-kicker {
  color: var(--cyan);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 120px 0 12px;
}

.login-art h1 {
  font-size: clamp(36px, 5vw, 58px);
  line-height: 1.05;
  margin: 0 0 18px;
  letter-spacing: -0.04em;
}

.login-copy {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
  max-width: 46ch;
}

.orbit {
  position: absolute;
  border: 1px dashed rgba(46, 230, 214, 0.28);
  border-radius: 50%;
  top: 0;
  left: 0;
}

.orbit-a {
  width: 180px;
  height: 180px;
}

.orbit-b {
  width: 260px;
  height: 260px;
  top: -40px;
  left: -40px;
  border-color: rgba(91, 140, 255, 0.22);
}

.node {
  position: absolute;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #1b2942, #121c30);
  box-shadow: var(--shadow);
}

.node-core {
  width: 70px;
  height: 70px;
  border-radius: 22px;
  background: linear-gradient(160deg, #2ee6d6, #4c8dff);
  color: #06201c;
  top: 28px;
  left: 54px;
}

.node-a { top: 8px; left: 168px; }
.node-b { top: 118px; left: 168px; }
.node-c { top: 86px; left: -8px; }

.login-panel {
  display: grid;
  place-items: center;
  padding: 32px;
  background: linear-gradient(180deg, rgba(18, 27, 44, 0.72), rgba(12, 19, 32, 0.9));
  border-left: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.login-card {
  width: min(100%, 400px);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 32px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.login-card h2 {
  margin: 8px 0 0;
  font-size: 26px;
  letter-spacing: -0.03em;
}

.muted {
  color: var(--muted);
  margin: 0;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input,
select {
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px var(--cyan-dim);
}

.form-error {
  margin: 0;
  color: var(--red);
  background: var(--red-dim);
  border: 1px solid rgba(255, 107, 122, 0.3);
  border-radius: 10px;
  padding: 10px 12px;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(180deg, #40f0df, #1fc9bb);
  color: #06241f;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border-color: rgba(255, 107, 122, 0.3);
}

.btn-block {
  width: 100%;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: rgba(8, 13, 22, 0.86);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px;
}

.brand strong {
  display: block;
  font-size: 14px;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.side-nav {
  display: grid;
  gap: 4px;
}

.side-nav a {
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  position: relative;
}

.side-nav a:hover,
.side-nav a.active {
  background: var(--bg-3);
  color: var(--text);
}

.side-nav a.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 99px;
  background: var(--cyan);
}

.side-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.side-user {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

.workspace {
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-end;
  padding: 28px 32px 12px;
}

.crumb {
  margin: 0;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 11px;
  font-weight: 600;
}

.topbar h1 {
  margin: 6px 0 0;
  font-size: 30px;
  letter-spacing: -0.04em;
}

.topbar-actions {
  display: flex;
  gap: 12px;
  align-items: end;
}

.router-select span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.router-select select {
  min-width: 220px;
}

.live-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(62, 224, 160, 0.28);
  font-size: 13px;
  font-weight: 600;
}

.live-pill.paused {
  background: var(--amber-dim);
  color: var(--amber);
  border-color: rgba(245, 193, 74, 0.3);
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 8px transparent; }
}

.view {
  padding: 12px 32px 40px;
  display: grid;
  gap: 18px;
}

.stat-grid,
.card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.card {
  background: linear-gradient(180deg, rgba(24, 35, 56, 0.92), rgba(16, 25, 41, 0.92));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  min-width: 0;
}

.card h3,
.card h4 {
  margin: 0;
  font-size: 15px;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 10px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  margin: 8px 0 0;
  color: var(--faint);
  font-size: 13px;
}

.trend-up { color: var(--green); }
.trend-down { color: var(--red); }

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

.router-card {
  display: grid;
  gap: 14px;
}

.router-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.identity {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}

.badge-ok { background: var(--green-dim); color: var(--green); }
.badge-warn { background: var(--amber-dim); color: var(--amber); }
.badge-off { background: var(--red-dim); color: var(--red); }
.badge-info { background: var(--cyan-dim); color: var(--cyan); }

.meter {
  height: 8px;
  background: var(--bg-1);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.meter > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--blue));
  border-radius: inherit;
}

.meter.hot > span {
  background: linear-gradient(90deg, var(--amber), var(--red));
}

.kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  font-size: 13px;
}

.kv span {
  color: var(--muted);
  display: block;
  font-size: 11px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(12, 19, 32, 0.7);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.02);
  position: sticky;
  top: 0;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: rgba(46, 230, 214, 0.04);
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
}

.toolbar {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.search {
  min-width: min(100%, 280px);
}

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

.chart-box {
  height: 240px;
  position: relative;
}

.chart-box canvas,
.gauge canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.gauge-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
  align-items: center;
}

.gauge {
  width: 140px;
  height: 140px;
}

.split {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 14px;
}

.alert-list {
  display: grid;
  gap: 8px;
}

.alert {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-1);
  font-size: 13px;
}

.alert strong {
  display: block;
  margin-bottom: 4px;
}

.alert.danger { border-color: rgba(255, 107, 122, 0.35); }
.alert.warning { border-color: rgba(245, 193, 74, 0.35); }

.log-row .topics {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 11px;
}

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

.spark {
  width: 92px;
  height: 28px;
  display: block;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid .check,
.form-grid .modal-actions {
  grid-column: 1 / -1;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.check input {
  width: auto;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.72);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(100%, 560px);
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-head h3 {
  margin: 0;
}

.icon-btn {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 8px;
  z-index: 30;
}

.toast {
  min-width: 240px;
  max-width: 360px;
  background: var(--bg-3);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.row-actions {
  display: flex;
  gap: 8px;
}

.iface-up { color: var(--green); }
.iface-down { color: var(--red); }

.legend {
  display: flex;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  display: inline-block;
  margin-right: 6px;
}

.swatch.rx { background: var(--cyan); }
.swatch.tx { background: var(--blue); }

[hidden] {
  display: none !important;
}

@media (max-width: 1100px) {
  .stat-grid,
  .card-grid,
  .router-cards,
  .split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .login-screen,
  .app-shell {
    grid-template-columns: 1fr;
  }

  .login-art {
    display: none;
  }

  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .view,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

.ip-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.alarm-banner {
  margin: 0 32px 8px;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
}

.alarm-banner.down {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(255, 107, 122, 0.45);
  animation: alarmflash 1s infinite;
}

.alarm-banner.up {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(62, 224, 160, 0.45);
}

@keyframes alarmflash {
  50% { filter: brightness(1.35); }
}

#sound-btn {
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
