:root {
  --bg: #0f0f1a;
  --card: #1e1e32;
  --line: #2e2e48;
  --text: #e8e6f5;
  --muted: #8b86a8;
  --accent: #8b5cf6;
  --accent2: #a78bfa;
  --ok: #34d399;
  --danger: #f472b6;
  --radius: 14px;
  --font: ui-sans-serif, system-ui, sans-serif;
  --mono: ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; }
a { color: var(--accent2); text-decoration: none; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.lede { color: var(--muted); margin: 0.25rem 0 0; font-size: 0.92rem; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 220px;
  background: #141428; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 1.2rem 0.9rem;
}
.brand { display: flex; gap: 0.7rem; align-items: center; }
.brand strong { display: block; }
.brand small { color: var(--muted); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
}
.sidebar nav { margin-top: 1.6rem; display: flex; flex-direction: column; gap: 0.2rem; }
.sidebar nav a {
  color: var(--muted); padding: 0.55rem 0.75rem; border-radius: 10px;
}
.sidebar nav a:hover, .sidebar nav a.active { background: var(--card); color: var(--text); }
.sidebar-foot { margin-top: auto; font-size: 0.8rem; color: var(--muted); display: flex; flex-direction: column; gap: 0.4rem; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); margin-right: 0.3rem; }
.dot.live { background: var(--ok); }

.shell { margin-left: 220px; padding: 1.6rem 2rem 3rem; max-width: 1180px; }
body.auth .shell { margin: 0; max-width: none; padding: 0; }
body.auth .sidebar { display: none; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background:
  radial-gradient(900px 500px at 20% -10%, rgba(139,92,246,0.18), transparent), var(--bg); }
.auth-card {
  width: min(400px, 92vw); background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 2rem;
}

.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.4rem; }
.top h1 { margin: 0; font-size: 1.45rem; letter-spacing: -0.03em; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin-bottom: 1.1rem; }
.stat, .card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.stat-k { display: block; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-v { font-size: 1.35rem; font-weight: 650; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; margin-bottom: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; }
.card h2 { margin: 0 0 0.6rem; font-size: 1.02rem; }
.card-head { display: flex; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.6rem; }
.card-head h2 { margin: 0; }

.pill { font-size: 0.7rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.22rem 0.5rem; border-radius: 999px; border: 1px solid var(--line); }
.pill.on { background: rgba(52,211,153,0.12); color: var(--ok); border-color: transparent; }
.pill.off { background: rgba(244,114,182,0.12); color: var(--danger); border-color: transparent; }
.pill.busy { opacity: 0.55; }
.machine.busy { opacity: 0.45; pointer-events: none; filter: grayscale(0.4); }
.machine.busy.allow-stop { pointer-events: auto; opacity: 0.7; }

.progress-row { display: flex; align-items: center; gap: 0.6rem; }
.bar { flex: 1; height: 6px; background: #12122a; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #6366f1); }
.pct { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }
.log {
  margin: 0; max-height: 180px; overflow: auto; background: #12122a; border: 1px solid var(--line);
  border-radius: 10px; padding: 0.65rem; color: #c4c1dc; font-family: var(--mono); font-size: 11px;
  white-space: pre-wrap; word-break: break-all;
}

.stack { display: flex; flex-direction: column; gap: 0.7rem; }
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }
input, select, textarea {
  background: #12122a; color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 0.5rem 0.7rem; font-family: inherit;
}
.chk { flex-direction: row; align-items: center; gap: 0.45rem; color: var(--text); }
.checks { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: #2a2a44; color: var(--text);
  border-radius: 10px; padding: 0.48rem 0.9rem; cursor: pointer; font-weight: 550;
}
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.danger { color: var(--danger); background: transparent; border-color: rgba(244,114,182,0.4); }
.btn.full { width: 100%; }
.btn:disabled, button:disabled { opacity: 0.4; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th, td { text-align: left; padding: 0.45rem 0.55rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 0.7rem; text-transform: uppercase; }
.toast { background: rgba(139,92,246,0.15); border: 1px solid rgba(139,92,246,0.35);
  color: var(--accent2); padding: 0.7rem 1rem; border-radius: 12px; margin-bottom: 1rem; }
.filters { display: flex; gap: 0.4rem; margin-bottom: 1rem; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 0.28rem 0.7rem; color: var(--muted); }
.chip.on { border-color: var(--accent); color: var(--accent2); }
.secret { font-family: var(--mono); letter-spacing: 0.02em; }
.tree a { display: block; padding: 0.25rem 0; color: var(--muted); }
.tree a:hover { color: var(--text); }
@media (max-width: 960px) {
  .sidebar { display: none; }
  .shell { margin: 0; padding: 1rem; }
  .grid-2, .stats, .grid-4 { grid-template-columns: 1fr; }
}
