/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0c0e14;
  --bg2:       #12151f;
  --bg3:       #191d2a;
  --border:    #232840;
  --border2:   #2e3450;
  --text:      #e2e8f0;
  --text2:     #6b7a99;
  --text3:     #3d4a68;
  --accent:    #5b6af0;
  --accent-h:  #7080f8;
  --green:     #22c55e;
  --red:       #ef4444;
  --yellow:    #f59e0b;
  --orange:    #f97316;
  --purple:    #6366f1;
  --teal:      #10b981;
  --radius:    8px;
  --sidebar:   200px;
  --font:      -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  --mono:      'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
}

html, body { height: 100%; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 13px; line-height: 1.5; }

/* ── Login ─────────────────────────────────────────────────── */
#login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% -10%, #1a1f3a 0%, var(--bg) 65%);
}

.login-box {
  width: 100%;
  max-width: 360px;
  padding: 2.25rem 2rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}

.login-logo { text-align: center; margin-bottom: 2rem; }
.login-mark { font-size: 2rem; margin-bottom: 0.6rem; }
.login-logo h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; }
.login-logo p { color: var(--text2); font-size: 0.8rem; margin-top: 0.2rem; }

.field { margin-bottom: 1.1rem; }
.field label { display: block; color: var(--text2); font-size: 0.73rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 0.4rem; }
.field input, .field textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.88rem;
  font-family: var(--font);
  transition: border-color 0.15s;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }

.err-msg { color: var(--red); font-size: 0.8rem; margin-bottom: 0.8rem; text-align: center; }

/* ── Dashboard layout ──────────────────────────────────────── */
#dashboard-page { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sb-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 1rem 1rem;
  font-weight: 700;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}
.sb-mark { font-size: 1.1rem; }

.sb-nav {
  flex: 1;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  color: var(--text2);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
}
.nav-link svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-link:hover { background: var(--bg3); color: var(--text); }
.nav-link.active { background: var(--accent); color: #fff; }

.sb-footer { padding: 1rem 0.75rem; border-top: 1px solid var(--border); }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── Top bar ────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}
.topbar h2 { font-size: 0.95rem; font-weight: 600; letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }

.nginx-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text2);
}

.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text3);
  flex-shrink: 0;
}
.dot.up { background: var(--green); box-shadow: 0 0 5px rgba(34,197,94,0.5); }
.dot.down { background: var(--red); box-shadow: 0 0 5px rgba(239,68,68,0.5); }

.muted { color: var(--text2); font-size: 0.75rem; }

/* ── Sections ───────────────────────────────────────────────── */
.section { flex: 1; overflow-y: auto; padding: 1.5rem; }
.sec-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text2);
  margin-bottom: 0.75rem;
}

/* ── Topology / Flowchart ───────────────────────────────────── */
.topo-wrap {
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.topo-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.topo-row { display: flex; align-items: center; gap: 1rem; justify-content: center; }
.topo-row-svcs { gap: 1rem; margin-top: 2.5rem; flex-wrap: wrap; justify-content: center; }
.topo-row-top { margin-bottom: 0; }

.topo-arrow { color: var(--border2); font-size: 1.1rem; user-select: none; flex-shrink: 0; }

.topo-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 0.75rem 1rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 120px;
  text-align: center;
  position: relative;
  transition: border-color 0.2s;
}
.topo-node:hover { border-color: var(--border2); }
.topo-node.node-nginx { border-color: var(--border2); }
.topo-node.node-globe { opacity: 0.7; }
.topo-node.svc-up { border-color: rgba(34,197,94,0.3); }
.topo-node.svc-down { border-color: rgba(239,68,68,0.3); }
.topo-node.skeleton { width: 140px; height: 100px; animation: pulse 1.5s infinite; }

.topo-node-icon { font-size: 1.4rem; line-height: 1; }
.topo-node-title { font-size: 0.78rem; font-weight: 600; color: var(--text); }
.topo-node-sub { font-size: 0.68rem; color: var(--text2); font-family: var(--mono); }
.topo-node-ms { font-size: 0.68rem; color: var(--green); font-family: var(--mono); }

.topo-status-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text3);
}
.topo-status-dot.up { background: var(--green); box-shadow: 0 0 5px rgba(34,197,94,0.5); }
.topo-status-dot.down { background: var(--red); box-shadow: 0 0 5px rgba(239,68,68,0.5); }

.topo-svc-actions { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; justify-content: center; }

.topo-svg {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 0;
}
.topo-node { z-index: 1; }

/* ── Stat strip ─────────────────────────────────────────────── */
.stat-strip {
  display: flex;
  gap: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.stat-item {
  flex: 1;
  padding: 0.85rem 1rem;
  border-right: 1px solid var(--border);
  text-align: center;
}
.stat-item:last-child { border-right: none; }
.stat-val { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.stat-lbl { font-size: 0.68rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }

/* ── Uptime dots ────────────────────────────────────────────── */
.uptime-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
}
.uptime-row { display: flex; align-items: center; gap: 0.6rem; }
.uptime-label { width: 130px; font-size: 0.73rem; color: var(--text2); flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uptime-dots { display: flex; gap: 2px; flex: 1; }
.uptime-dot {
  width: 10px; height: 10px;
  border-radius: 2px;
  background: var(--bg3);
  cursor: default;
  transition: opacity 0.1s;
}
.uptime-dot.up { background: var(--green); opacity: 0.8; }
.uptime-dot.down { background: var(--red); opacity: 0.9; }
.uptime-dot:hover { opacity: 1; }
.uptime-pct { font-size: 0.72rem; color: var(--text2); width: 40px; text-align: right; flex-shrink: 0; font-family: var(--mono); }

/* ── Cards grid ─────────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--border2); }
.card.skeleton { animation: pulse 1.5s infinite; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

.card-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 0.65rem; }
.card-title { display: flex; align-items: center; gap: 0.4rem; font-weight: 600; font-size: 0.85rem; }
.card-icon { font-size: 1.1rem; }
.card-sub { color: var(--text2); font-size: 0.72rem; margin-bottom: 0.85rem; font-family: var(--mono); }
.card-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.badge {
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-up { background: rgba(34,197,94,0.12); color: var(--green); border: 1px solid rgba(34,197,94,0.25); }
.badge-down { background: rgba(239,68,68,0.12); color: var(--red); border: 1px solid rgba(239,68,68,0.25); }
.badge-info { background: rgba(91,106,240,0.12); color: var(--accent-h); border: 1px solid rgba(91,106,240,0.25); }

/* ── PM2 table ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.tbl {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg2);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  font-size: 0.8rem;
}
.tbl th {
  background: var(--bg3);
  padding: 0.55rem 0.9rem;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
}
.tbl td { padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--border); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--bg3); }
.tbl-empty { text-align: center; color: var(--text2); padding: 1.5rem; }

/* ── Deploy ─────────────────────────────────────────────────── */
.deploy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.git-hash { font-family: var(--mono); font-size: 0.72rem; color: var(--accent-h); }
.git-subject { font-size: 0.82rem; color: var(--text); margin: 0.3rem 0; }
.git-meta { font-size: 0.72rem; color: var(--text2); margin-bottom: 0.75rem; }
.git-branch { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.1rem 0.4rem; background: var(--bg3); border: 1px solid var(--border); border-radius: 4px; font-family: var(--mono); font-size: 0.7rem; color: var(--accent-h); margin-bottom: 0.6rem; }
.git-dirty { color: var(--yellow); font-size: 0.72rem; margin-bottom: 0.5rem; }
.git-output {
  margin-top: 0.75rem;
  padding: 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text2);
  max-height: 220px;
  overflow-y: auto;
  display: none;
}
.git-output.show { display: block; }

.deploy-line { padding: 1px 0; line-height: 1.6; white-space: pre-wrap; word-break: break-all; }
.deploy-step { color: var(--accent2); font-weight: 600; margin-top: 0.35rem; }
.deploy-ok   { color: var(--green); }
.deploy-err  { color: var(--red); }
.deploy-info { color: var(--text2); }
.deploy-out  { color: var(--text2); padding-left: 0.75rem; opacity: 0.75; }

.webhook-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.6rem; }
.webhook-row label { width: 130px; font-size: 0.78rem; color: var(--text2); flex-shrink: 0; }
.webhook-row input { flex: 1; }

/* ── Traffic ────────────────────────────────────────────────── */
.traffic-controls { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; align-items: center; }

.traffic-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.traffic-stat {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}
.traffic-stat .ts-val { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
.traffic-stat .ts-lbl { font-size: 0.68rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }

.bar-chart {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
}
.bar-chart-title { font-size: 0.72rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 0.75rem; font-weight: 700; }
.bc-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 3px; }
.bc-label { width: 28px; font-size: 0.68rem; color: var(--text2); text-align: right; flex-shrink: 0; font-family: var(--mono); }
.bc-wrap { flex: 1; height: 14px; background: var(--bg3); border-radius: 2px; overflow: hidden; }
.bc-bar { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.4s; min-width: 2px; }
.bc-count { width: 36px; font-size: 0.68rem; color: var(--text2); font-family: var(--mono); }

.status-breakdown { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.sb-pill {
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: var(--mono);
  font-weight: 600;
}
.sb-2xx { background: rgba(34,197,94,0.12); color: var(--green); border: 1px solid rgba(34,197,94,0.2); }
.sb-3xx { background: rgba(91,106,240,0.12); color: var(--accent-h); border: 1px solid rgba(91,106,240,0.2); }
.sb-4xx { background: rgba(245,158,11,0.12); color: var(--yellow); border: 1px solid rgba(245,158,11,0.2); }
.sb-5xx { background: rgba(239,68,68,0.12); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }

/* ── Database ───────────────────────────────────────────────── */
.db-type { font-size: 0.68rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 0.4rem; }
.db-size { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 0.25rem; }
.db-note { font-size: 0.75rem; color: var(--text2); }
.db-stripe { width: 4px; border-radius: 2px; align-self: stretch; flex-shrink: 0; }

/* ── File manager ───────────────────────────────────────────── */
.files-bar { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.breadcrumb { display: flex; align-items: center; gap: 0.25rem; font-size: 0.75rem; color: var(--text2); font-family: var(--mono); }
.breadcrumb span { cursor: pointer; }
.breadcrumb span:hover { color: var(--text); }
.bc-sep { color: var(--text3); }

.files-layout { display: flex; gap: 1rem; height: calc(100vh - 200px); }
.file-list {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-y: auto;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  transition: background 0.1s;
}
.file-item:last-child { border-bottom: none; }
.file-item:hover { background: var(--bg3); }
.file-item.active { background: var(--bg3); color: var(--accent-h); }
.file-item-ico { font-size: 0.9rem; flex-shrink: 0; }
.file-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item-size { color: var(--text2); font-size: 0.68rem; font-family: var(--mono); }

.file-editor { flex: 1; display: flex; flex-direction: column; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.file-editor-header { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); background: var(--bg3); font-family: var(--mono); font-size: 0.78rem; color: var(--text2); }

.code-area {
  flex: 1;
  width: 100%;
  padding: 0.85rem;
  background: var(--bg);
  border: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.6;
  resize: none;
  tab-size: 2;
}
.code-area:focus { outline: none; }

/* ── ENV editor ─────────────────────────────────────────────── */
.env-bar { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.env-area { height: calc(100vh - 180px); width: 100%; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); }

/* ── Logs ───────────────────────────────────────────────────── */
.logs-bar { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.search-input {
  padding: 0.4rem 0.7rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.8rem;
  width: 180px;
}
.search-input:focus { outline: none; border-color: var(--accent); }

.log-viewer {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  height: calc(100vh - 210px);
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.65;
}
.log-line { color: var(--text2); padding: 1px 0; white-space: pre-wrap; word-break: break-all; font-family: monospace; font-size: 0.75rem; }
.log-line.err { color: #fca5a5; }
.log-line.warn { color: #fde68a; }
.log-line.hidden { display: none; }

/* ── Human-readable log rows ─────────────────────────────────── */
.log-table-header {
  display: grid;
  grid-template-columns: 90px 60px 1fr 56px 60px 90px 110px;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg2);
  z-index: 1;
}
.log-row {
  display: grid;
  grid-template-columns: 90px 60px 1fr 56px 60px 90px 110px;
  gap: 0.5rem;
  align-items: center;
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  font-size: 0.78rem;
  transition: background 0.1s;
}
.log-row:hover { background: var(--bg3); }
.log-row.hidden { display: none; }
.log-err-row { grid-template-columns: 160px 80px 1fr; }
.log-time { color: var(--text2); font-size: 0.72rem; white-space: nowrap; }
.log-path { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: monospace; font-size: 0.75rem; }
.log-size { color: var(--text2); font-size: 0.72rem; text-align: right; }
.log-ip   { color: var(--text2); font-size: 0.72rem; font-family: monospace; overflow: hidden; text-overflow: ellipsis; }
.log-device { font-size: 0.78rem; white-space: nowrap; }
.log-err-msg { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Method badges */
.log-method-get    { background: rgba(99,102,241,0.15); color: #818cf8; border-color: rgba(99,102,241,0.3); }
.log-method-post   { background: rgba(16,185,129,0.15); color: #34d399; border-color: rgba(16,185,129,0.3); }
.log-method-delete { background: rgba(239,68,68,0.15);  color: #fca5a5; border-color: rgba(239,68,68,0.3); }
.log-method-other  { background: rgba(245,158,11,0.15); color: #fcd34d; border-color: rgba(245,158,11,0.3); }

/* Status code badges */
.log-status-2 { background: rgba(34,197,94,0.12);  color: #4ade80; border-color: rgba(34,197,94,0.3); }
.log-status-3 { background: rgba(99,102,241,0.12); color: #818cf8; border-color: rgba(99,102,241,0.3); }
.log-status-4 { background: rgba(245,158,11,0.12); color: #fcd34d; border-color: rgba(245,158,11,0.3); }
.log-status-5 { background: rgba(239,68,68,0.12);  color: #fca5a5; border-color: rgba(239,68,68,0.3); }

.log-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
  letter-spacing: 0.03em;
}

/* Raw toggle */
.log-raw-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text2);
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}

/* ── Alerts ─────────────────────────────────────────────────── */
.field-row { margin-bottom: 1rem; }
.field-row.twin { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.toggle-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 0.82rem; }
.toggle-label input[type=checkbox] { accent-color: var(--accent); width: 14px; height: 14px; }

/* ── System metrics ─────────────────────────────────────────── */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.metric-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
}
.metric-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text2); margin-bottom: 0.4rem; }
.metric-val { font-size: 1.8rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 0.6rem; }
.metric-bar { height: 4px; background: var(--bg3); border-radius: 2px; overflow: hidden; margin-bottom: 0.4rem; }
.metric-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.5s; }
.metric-fill.warn { background: var(--yellow); }
.metric-fill.danger { background: var(--red); }
.metric-sub { font-size: 0.72rem; color: var(--text2); font-family: var(--mono); }

.action-row { display: flex; align-items: center; gap: 0.75rem; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  font-family: var(--font);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg3); color: var(--text); }
.btn-danger { background: rgba(239,68,68,0.12); color: var(--red); border: 1px solid rgba(239,68,68,0.25); }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.22); }
.btn-success { background: rgba(34,197,94,0.12); color: var(--green); border: 1px solid rgba(34,197,94,0.25); }
.btn-success:hover:not(:disabled) { background: rgba(34,197,94,0.22); }
.btn-warning { background: rgba(245,158,11,0.12); color: var(--yellow); border: 1px solid rgba(245,158,11,0.25); }
.btn-warning:hover:not(:disabled) { background: rgba(245,158,11,0.22); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.75rem; }

/* ── Selects ─────────────────────────────────────────────────── */
.sel {
  padding: 0.4rem 0.7rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
  font-family: var(--font);
}
.sel:focus { outline: none; border-color: var(--accent); }

/* ── Inputs (general) ────────────────────────────────────────── */
input[type=text], input[type=url], input[type=number] {
  padding: 0.4rem 0.7rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.8rem;
  font-family: var(--font);
  transition: border-color 0.15s;
  width: 100%;
}
input[type=text]:focus, input[type=url]:focus, input[type=number]:focus { outline: none; border-color: var(--accent); }

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 1.1rem;
  font-size: 0.8rem;
  z-index: 9999;
  max-width: 320px;
  animation: slideUp 0.2s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }

@keyframes slideUp { from{transform:translateY(16px);opacity:0} to{transform:translateY(0);opacity:1} }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--border2); }
