:root {
  --bg: #0b0f19;
  --bg-elev: #111827;
  --bg-card: #151e30;
  --bg-hover: #1c2840;
  --border: #24324d;
  --text: #e6edf7;
  --text-muted: #8fa3c4;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html[data-theme="light"] {
  --bg: #f3f6fb;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #eef3fa;
  --border: #d8e1ee;
  --text: #0f172a;
  --text-muted: #475569;
  --accent: #0284c7;
  --accent-strong: #0369a1;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14px; line-height: 1.45;
}

.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  height: 56px; padding: 0 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--bg-elev); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-left, .topbar-right, .vps-switcher, .auth-bar {
  display: flex; align-items: center; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px;
}

.workspace { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: 224px; flex-shrink: 0;
  background: var(--bg-elev); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 14px 10px;
}
.nav-list { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  width: 100%; border: 0; background: transparent; color: var(--text-muted);
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 9px; cursor: pointer; font: inherit; text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: rgba(56, 189, 248, 0.14); color: var(--accent); font-weight: 600; }
.nav-divider { height: 1px; background: var(--border); margin: 8px 6px; }
.nav-tag {
  margin-left: auto; font-size: 10px; padding: 1px 6px; border-radius: 99px;
  background: var(--bg-hover); color: var(--text-muted); border: 1px solid var(--border);
}
.sidebar-footer {
  padding: 10px 12px; border-radius: 10px; background: var(--bg-card); border: 1px solid var(--border);
}
.security-chip { font-weight: 600; font-size: 12px; color: var(--green); }
.security-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.main-view { flex: 1; padding: 20px 24px; overflow-y: auto; max-width: 1440px; }

.page-header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 12px; margin-bottom: 18px;
}
.page-title { margin: 0; font-size: 20px; font-weight: 700; }
.page-sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { display: none; }
}

.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.card-title {
  margin: 0 0 10px; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}

/* Circular Gauge (aaPanel-style) */
.gauge-card { display: flex; align-items: center; gap: 14px; }
.gauge-wrap { position: relative; width: 72px; height: 72px; flex-shrink: 0; }
.gauge-svg { width: 72px; height: 72px; transform: rotate(-90deg); }
.gauge-track { fill: none; stroke: var(--border); stroke-width: 7; }
.gauge-fill { fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round; transition: stroke-dashoffset 0.35s ease; }
.gauge-fill.warn { stroke: var(--amber); }
.gauge-fill.danger { stroke: var(--red); }
.gauge-fill.ok { stroke: var(--green); }
.gauge-val {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.gauge-meta h4 { margin: 0 0 4px; font-size: 13px; color: var(--text-muted); font-weight: 600; }
.gauge-meta .big { font-size: 16px; font-weight: 700; }
.gauge-meta .sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Progress Bar */
.bar { height: 7px; border-radius: 99px; background: var(--border); overflow: hidden; margin: 6px 0; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 99px; }
.bar-fill.ok { background: var(--green); }
.bar-fill.warn { background: var(--amber); }

/* Sparkline */
.sparkline-svg { width: 100%; height: 84px; display: block; }
.spark-rx { fill: none; stroke: #38bdf8; stroke-width: 2; }
.spark-tx { fill: none; stroke: #22c55e; stroke-width: 2; }

/* Badges, Buttons & Inputs */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600;
}
.badge-accent { background: rgba(56, 189, 248, 0.16); color: var(--accent); }
.badge-green { background: rgba(34, 197, 94, 0.16); color: var(--green); }
.badge-amber { background: rgba(245, 158, 11, 0.16); color: var(--amber); }
.badge-red { background: rgba(239, 68, 68, 0.16); color: var(--red); }
.badge-muted { background: var(--bg-hover); color: var(--text-muted); border: 1px solid var(--border); }

.status-pill {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 99px;
}
.status-pill.online { background: rgba(34, 197, 94, 0.16); color: var(--green); }
.status-pill.offline { background: rgba(245, 158, 11, 0.16); color: var(--amber); }

.btn {
  border: 1px solid var(--border); background: var(--bg-hover); color: var(--text);
  padding: 7px 13px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500;
}
.btn:hover { border-color: var(--accent); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-danger { background: rgba(239, 68, 68, 0.15); border-color: var(--red); color: var(--red); }
.btn-ghost { background: transparent; }

input, select, textarea {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font: inherit;
}
textarea.code-box { width: 100%; min-height: 120px; font-family: var(--mono); font-size: 12px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; }

.pre-box {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-family: var(--mono); font-size: 12px;
  white-space: pre-wrap; max-height: 260px; overflow: auto;
}

.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.form-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }

.toast-container {
  position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50;
}
.toast {
  background: var(--bg-card); border: 1px solid var(--border); padding: 10px 14px;
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); max-width: 360px;
}
.toast.err { border-color: var(--red); color: var(--red); }
.toast.ok { border-color: var(--green); }

