:root {
  --bg: #070b14;
  --bg-2: #0c1220;
  --panel: #101828;
  --panel-2: #0b1120;
  --border: #1e293b;
  --border-2: #263449;
  --text: #e6edf7;
  --text-dim: #8b98ad;
  --text-faint: #5b6b82;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --violet: #a78bfa;
  --cyan: #22d3ee;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --radius: 16px;
}

[data-theme="light"] {
  --bg: #eef2f8;
  --bg-2: #e5ebf4;
  --panel: #ffffff;
  --panel-2: #f6f8fc;
  --border: #d9e1ee;
  --border-2: #c7d2e2;
  --text: #0f1c33;
  --text-dim: #4b5b74;
  --text-faint: #8594aa;
  --shadow: 0 10px 30px rgba(20, 40, 80, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

.app {
  max-width: 1480px;
  margin: 0 auto;
  padding: 18px 20px 8px;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; color: var(--accent); }
.brand-text h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.tagline { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.12em; }

.hostinfo { flex: 1; min-width: 220px; }
.hostname { font-size: 16px; font-weight: 600; }
.hostname .ip { color: var(--accent); font-weight: 500; margin-left: 6px; font-size: 13px; }
.meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.clock { text-align: right; }
.clock-time { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.clock-uptime { font-size: 11px; color: var(--text-faint); margin-top: 1px; }

.controls { display: flex; align-items: center; gap: 8px; }

.status { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-dim); padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 0 rgba(251,191,36,0.5); }
.status.online .dot { background: var(--green); animation: pulse 2s infinite; }
.status.offline .dot { background: var(--red); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52,211,153,0.55); }
  70% { box-shadow: 0 0 0 7px rgba(52,211,153,0); }
  100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 34px; min-width: 34px; padding: 0 10px;
  background: var(--panel-2); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 9px;
  cursor: pointer; font-size: 13px; transition: all 0.15s ease;
  font-family: inherit;
}
.btn:hover { color: var(--text); border-color: var(--border-2); }
.btn svg { width: 16px; height: 16px; }
.btn.paused { color: var(--accent); border-color: var(--accent); }
.select { appearance: none; cursor: pointer; }

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* ---------- Layout ---------- */
.grid { display: grid; gap: 18px; }

.cards {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
}

.panels-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px;
}

.charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: 0.01em; }
.panel-hint { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

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

/* ---------- Gauges ---------- */
.gauge-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 12px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.gauge-card:hover { transform: translateY(-2px); border-color: var(--border-2); }

.gauge { position: relative; width: 108px; height: 108px; }
.gauge-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--gauge-color, var(--accent)) calc(var(--p, 0) * 1%), var(--border) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 13px), #000 calc(100% - 12px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 13px), #000 calc(100% - 12px));
  transition: background 0.4s ease;
}
.gauge-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.gauge-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.gauge-label { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.12em; margin-top: 2px; }
.gauge-sub { font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; text-align: center; min-height: 15px; }

/* ---------- Cores ---------- */
.cores { display: flex; flex-direction: column; gap: 10px; }
.core-row { display: grid; grid-template-columns: 34px 1fr 40px; align-items: center; gap: 10px; }
.core-name { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.core-bar { height: 10px; background: var(--bg-2); border-radius: 6px; overflow: hidden; }
.core-fill { height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.4s ease; }
.core-val { font-size: 12px; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Net / disk lists ---------- */
.net-table { display: flex; flex-direction: column; gap: 8px; }
.net-row {
  display: grid; grid-template-columns: 1fr auto auto;
  gap: 8px; padding: 10px 12px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 10px; font-size: 13px;
}
.net-name { font-weight: 600; }
.net-rates { text-align: right; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.net-total { text-align: right; color: var(--text-faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.net-dir { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.down { color: var(--cyan); }
.up { color: var(--green); }

.disk-list { display: flex; flex-direction: column; gap: 12px; }
.disk-item { display: flex; flex-direction: column; gap: 6px; }
.disk-head { display: flex; justify-content: space-between; font-size: 12px; }
.disk-mount { font-weight: 600; }
.disk-size { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.disk-bar { height: 9px; background: var(--bg-2); border-radius: 5px; overflow: hidden; }
.disk-fill { height: 100%; width: 0; border-radius: 5px; transition: width 0.4s ease; }
.disk-foot { font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* ---------- Process tables ---------- */
.proc-table-wrap { overflow-x: auto; }
.proc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.proc-table th {
  text-align: left; font-weight: 500; color: var(--text-faint);
  padding: 6px 10px; border-bottom: 1px solid var(--border);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
}
.proc-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.proc-table tr:last-child td { border-bottom: none; }
.proc-table tbody tr { transition: background 0.12s ease; }
.proc-table tbody tr:hover { background: var(--panel-2); }
.p-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-pid { color: var(--text-faint); }
.p-pct { font-weight: 600; text-align: right; }
.p-bar-cell { width: 120px; }
.p-bar { height: 6px; background: var(--bg-2); border-radius: 3px; overflow: hidden; }
.p-bar-fill { height: 100%; border-radius: 3px; transition: width 0.4s ease; }
.p-user { color: var(--text-dim); }

/* ---------- Temperature ---------- */
.temp-row { display: flex; gap: 14px; flex-wrap: wrap; }
.temp-chip {
  padding: 12px 16px; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; display: flex; flex-direction: column; gap: 4px;
}
.temp-chip .t-val { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.temp-chip .t-label { font-size: 11px; color: var(--text-dim); }

/* ---------- Footer ---------- */
.footer {
  display: flex; justify-content: space-between;
  padding: 14px 4px; font-size: 11px; color: var(--text-faint);
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
  .panels-row, .charts { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .clock { display: none; }
}

/* ---------- Security report ---------- */
.sec-status { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.sec-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 7px 12px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel-2);
}
.sec-badge.ok { color: var(--green); border-color: rgba(52,211,153,0.35); }
.sec-badge.bad { color: var(--red); border-color: rgba(248,113,113,0.4); }
.sec-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; margin-bottom: 18px; }
#security-panel h3 { font-size: 11px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 8px; }
.sec-col h3 { margin: 0 0 10px; }
.sec-list { display: flex; flex-direction: column; gap: 6px; }
.sec-kv {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: 13px; padding: 7px 12px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 9px;
}
.sec-kv span { color: var(--text-dim); }
.sec-kv code { color: var(--text); font-variant-numeric: tabular-nums; }
.sec-bans { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.sec-ip {
  font-family: ui-monospace, monospace; font-size: 12px; color: var(--red);
  background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3);
  padding: 3px 9px; border-radius: 7px;
}
.sec-none { font-size: 12px; color: var(--text-faint); }
.sec-loglist { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.sec-log {
  display: grid; grid-template-columns: 170px 1fr auto; gap: 10px; align-items: center;
  font-size: 12px; padding: 6px 12px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 8px;
  font-variant-numeric: tabular-nums;
}
.sec-log code { color: var(--accent); }
.sec-dim { color: var(--text-faint); }
.sec-summary { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text-dim); display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 900px) { .sec-grid { grid-template-columns: 1fr; } .sec-log { grid-template-columns: 1fr; } }
