:root {
  --bg: #1e1e1e;
  --panel: #2d2d2d;
  --panel-2: #3a3a3a;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f5f5f7;
  --dim: #98989d;
  --blue: #0a84ff;
  --green: #30d58d;
  --orange: #ff9f0a;
  --red: #ff453a;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(10, 132, 255, 0.12), transparent),
    radial-gradient(ellipse 50% 40% at 100% 100%, rgba(48, 213, 141, 0.06), transparent);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* Login */
.login-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 800px at 20% 10%, #3b1d6e 0%, transparent 55%),
    radial-gradient(1000px 700px at 90% 30%, #0b4f6c 0%, transparent 50%),
    linear-gradient(160deg, #1a1530 0%, #0d1220 60%, #060810 100%);
}
.login-clock {
  font-size: 48px;
  font-weight: 600;
  margin-bottom: 24px;
  color: #fff;
}
.login-card {
  width: min(360px, 100%);
  padding: 28px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}
.login-icon { font-size: 42px; margin-bottom: 8px; }
.login-card h1 { margin: 0 0 4px; font-size: 18px; }
.login-sub { color: rgba(255,255,255,0.55); font-size: 12px; margin: 0 0 20px; }
.login-card input {
  width: 100%;
  padding: 12px;
  margin-bottom: 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.3);
  color: #fff;
  font-size: 15px;
  outline: none;
}
.login-card input:focus { border-color: rgba(10,132,255,0.7); }
.login-card button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}
.login-error {
  background: rgba(255,69,58,0.15);
  color: #ffb4b0;
  font-size: 12px;
  padding: 8px;
  border-radius: 8px;
  margin-bottom: 10px;
}

/* Menubar */
.menubar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.menubar-left, .menubar-right { display: flex; align-items: center; gap: 10px; }
.menubar-title { font-weight: 600; }
.menubar-sub { color: var(--dim); font-size: 11px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menubar-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
  opacity: 0.85;
}
.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }

.desktop { max-width: 1280px; margin: 0 auto; padding: 12px 16px 32px; }

/* Hero */
.hero {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 16px;
}
.hero-traffic {
  display: flex; gap: 7px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.25);
  border-bottom: 1px solid var(--border);
}
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.red { background: #ff5f57; }
.dot.yellow { background: #febc2e; }
.dot.green { background: #28c840; }
.hero-body {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 22px;
  gap: 16px;
  flex-wrap: wrap;
}
.hero-eyebrow { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 6px; }
.hero-title { margin: 0; font-size: 26px; font-weight: 700; }
.hero-meta { color: var(--dim); font-size: 13px; margin: 8px 0 0; }
.hero-badge {
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.hero-badge.healthy { background: rgba(48,213,141,0.15); color: var(--green); border: 1px solid rgba(48,213,141,0.35); }
.hero-badge.warning { background: rgba(255,159,10,0.15); color: var(--orange); border: 1px solid rgba(255,159,10,0.35); }
.hero-badge.critical { background: rgba(255,69,58,0.15); color: var(--red); border: 1px solid rgba(255,69,58,0.35); }

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--green);
}
.kpi-card.warning::before { background: var(--orange); }
.kpi-card.critical::before { background: var(--red); }
.kpi-label { color: var(--dim); font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-value { font-size: 22px; font-weight: 700; margin: 4px 0 2px; line-height: 1.15; word-break: break-word; }
.kpi-sub { color: var(--dim); font-size: 11px; }

.panels {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
@media (max-width: 900px) { .panels { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.panel-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.panel-tag {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--dim);
}

.gauge-row { display: grid; gap: 14px; margin-bottom: 12px; }
.gauge-label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; color: var(--dim); }
.gauge-label strong { color: var(--text); font-size: 16px; }
.gauge-track {
  height: 10px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  overflow: hidden;
}
.gauge-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), #5ac8fa);
  transition: width 0.5s ease;
}
.gauge-fill.swap { background: linear-gradient(90deg, var(--orange), #ffd60a); }
.gauge-fill.critical { background: linear-gradient(90deg, var(--red), var(--orange)); }
.gauge-sub { font-size: 11px; color: var(--dim); margin-top: 4px; }

#chart-ram { width: 100%; margin-top: 8px; opacity: 0.9; }

.gemma-box {
  padding: 14px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 12px;
}
.gemma-box.loaded { border-color: rgba(255,159,10,0.4); background: rgba(255,159,10,0.08); }
.gemma-box.on-demand { border-color: rgba(10,132,255,0.45); background: rgba(10,132,255,0.08); }
.gemma-detail {
  margin: -4px 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.55;
  color: var(--dim);
}
.gemma-detail strong { color: var(--text); }
.gemma-detail .row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.gemma-detail .row span:last-child { text-align: right; color: var(--text); }

.consumer-list { list-style: none; padding: 0; margin: 0; }
.consumer-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.consumer-list li:last-child { border-bottom: none; }
.consumer-list span { color: var(--dim); }

.btn-sm {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
}
.btn-sm:hover { background: rgba(255,69,58,0.15); border-color: rgba(255,69,58,0.4); color: var(--red); }

.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.svc-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.svc-icon { font-size: 20px; }
.svc-info { flex: 1; min-width: 0; }
.svc-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.svc-meta { font-size: 10px; color: var(--dim); }
.status-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}
.status-pill.active { background: rgba(48,213,141,0.15); color: var(--green); }
.status-pill.inactive { background: rgba(255,69,58,0.15); color: var(--red); }
.status-pill.other { background: rgba(255,159,10,0.15); color: var(--orange); }

.table-wrap { overflow-x: auto; }
.proc-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.proc-table th {
  text-align: left;
  color: var(--dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.proc-table td { padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.proc-table tr:hover td { background: rgba(255,255,255,0.03); }

.win-in { animation: winIn 0.18s ease-out; }
@keyframes winIn {
  from { opacity: 0; transform: scale(0.98) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.25);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
