:root {
  --bg: #0b0f17;
  --bg2: #111726;
  --card: #141b2b;
  --card-bd: #223049;
  --txt: #e6edf6;
  --muted: #8497b0;
  --accent: #4f9cf9;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --rx: #34d399;
  --tx: #4f9cf9;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 20% -10%, #16203a 0%, var(--bg) 55%) fixed;
  color: var(--txt);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- Login ---------- */
.login {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg); padding: 20px; z-index: 10;
}
.login-card {
  width: 100%; max-width: 340px; background: var(--card);
  border: 1px solid var(--card-bd); border-radius: var(--radius);
  padding: 28px 24px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.login-logo { font-size: 34px; text-align: center; color: var(--accent); }
.login-card h1 { margin: 0; text-align: center; font-size: 20px; }
.login-sub { margin: 0 0 6px; text-align: center; color: var(--muted); font-size: 13px; }
.login-card input {
  background: var(--bg2); border: 1px solid var(--card-bd); color: var(--txt);
  border-radius: 10px; padding: 12px 14px; font-size: 15px; outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  background: var(--accent); color: #07101f; border: 0; border-radius: 10px;
  padding: 12px; font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 4px;
}
.login-card button:disabled { opacity: .6; cursor: default; }
.login-error { color: var(--red); font-size: 13px; min-height: 16px; text-align: center; }

/* ---------- Topbar ---------- */
.app { max-width: 1200px; margin: 0 auto; padding: 16px clamp(12px, 3vw, 24px) 40px; }
.topbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 6px 2px 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-size: 22px; color: var(--accent);
  background: var(--card); border: 1px solid var(--card-bd);
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
}
.host { font-size: 17px; font-weight: 650; line-height: 1.1; }
.osline { font-size: 12px; color: var(--muted); margin-top: 2px; }
.topstats { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.topstat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.topstat-val { font-family: var(--mono); font-size: 15px; font-weight: 600; }
.topstat-lbl { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.conn { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 0 rgba(52,211,153,.5); }
.dot.live { background: var(--green); animation: pulse 2s infinite; }
.dot.down { background: var(--red); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52,211,153,.45); }
  70% { box-shadow: 0 0 0 7px rgba(52,211,153,0); }
  100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); }
}
.logout {
  background: var(--card); color: var(--muted); border: 1px solid var(--card-bd);
  border-radius: 9px; padding: 7px 12px; font-size: 12.5px; cursor: pointer;
}
.logout:hover { color: var(--txt); border-color: var(--accent); }

/* ---------- Grid + cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.card {
  background: linear-gradient(180deg, var(--card) 0%, #121a29 100%);
  border: 1px solid var(--card-bd); border-radius: var(--radius); padding: 16px;
}
.card.wide { grid-column: 1 / -1; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.card-head h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.big { font-family: var(--mono); font-size: 26px; font-weight: 700; }
.big-sm { font-family: var(--mono); font-size: 14px; }
.card-foot { margin-top: 10px; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart { width: 100%; height: 90px; display: block; }

/* CPU cores */
.cores { display: grid; grid-template-columns: repeat(auto-fill, minmax(28px, 1fr)); gap: 5px; margin-top: 12px; }
.core {
  height: 30px; background: var(--bg2); border-radius: 5px; position: relative; overflow: hidden;
  display: flex; align-items: flex-end;
}
.core-fill { width: 100%; background: linear-gradient(180deg, var(--accent), #2563eb); transition: height .3s ease; }
.core span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 9px; font-family: var(--mono); color: var(--txt); opacity: .85; }

/* Bars */
.bar { height: 12px; background: var(--bg2); border-radius: 6px; overflow: hidden; display: flex; margin: 10px 0 8px; }
.bar.bar-sm { height: 8px; margin: 4px 0; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #2563eb); transition: width .3s ease; }
.bar-cache { background: #2a3a57; }
.swapfill { background: linear-gradient(90deg, var(--amber), #d97706); }
.kv { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 13px; }
.kv-sm { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.legend { display: flex; gap: 14px; margin-top: 10px; font-size: 11px; color: var(--muted); }
.legend i.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.sw.used { background: var(--accent); } .sw.cache { background: #2a3a57; } .sw.free { background: var(--bg2); }
.swap { margin-top: 12px; }

/* Network */
.net-sum { font-family: var(--mono); }
.netlist { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.netrow { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; }
.netrow .ifn { font-family: var(--mono); color: var(--muted); }
.netrow .rates { display: flex; gap: 14px; font-family: var(--mono); }
.rx { color: var(--rx); } .tx { color: var(--tx); }

/* Disk */
.disklist { display: flex; flex-direction: column; gap: 14px; }
.disk .kv { margin-bottom: 4px; }
.disk .mount { font-family: var(--mono); font-size: 12.5px; }
.disk .pct { font-size: 12px; color: var(--muted); }
.disk .bar { margin: 6px 0 0; }
.disk .bar-fill.warn { background: linear-gradient(90deg, var(--amber), #d97706); }
.disk .bar-fill.crit { background: linear-gradient(90deg, var(--red), #b91c1c); }

/* Processes */
table.proc { width: 100%; border-collapse: collapse; font-size: 13px; }
table.proc th { text-align: left; color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 6px 8px; border-bottom: 1px solid var(--card-bd); }
table.proc td { padding: 7px 8px; border-bottom: 1px solid rgba(34,48,73,.4); font-family: var(--mono); }
table.proc td.name { font-family: system-ui, sans-serif; }
table.proc .num { text-align: right; }
table.proc tr:last-child td { border-bottom: 0; }

.foot { text-align: center; color: var(--muted); font-size: 11.5px; margin-top: 22px; }

@media (max-width: 560px) {
  .topbar { gap: 8px; }
  .topstats { gap: 12px; width: 100%; justify-content: space-between; }
  .big { font-size: 22px; }
}
