:root {
  --bg: #0b1015;
  --bg-raise: #121920;
  --bg-card: #161e26;
  --line: #25303b;
  --ink: #e8edf2;
  --muted: #8b97a4;
  --brass: #c4a46a;
  --brass-dim: #8a7344;
  --teal: #3dba9a;
  --teal-dim: #1f6d5b;
  --rust: #d46a5a;
  --amber: #d9a441;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --sans: "Segoe UI", "IBM Plex Sans", system-ui, sans-serif;
  --mono: "Cascadia Mono", "Consolas", "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(196, 164, 106, 0.08), transparent 50%),
    var(--bg);
  color: var(--ink);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100%;
}

.rail {
  background: #0e141b;
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1.5px solid var(--brass);
  background:
    linear-gradient(#0c1116, #0c1116) padding-box,
    linear-gradient(160deg, var(--brass), #5c4a28) border-box;
  position: relative;
}
.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
.brand-mark::before {
  top: 7px;
  width: 12px;
  height: 8px;
  border: 1.5px solid var(--brass);
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
}
.brand-mark::after {
  top: 14px;
  width: 16px;
  height: 12px;
  border: 1.5px solid var(--brass);
  border-radius: 2px;
}
.brand strong { display: block; letter-spacing: 0.04em; }
.brand small { color: var(--muted); }

.rail nav { display: flex; flex-direction: column; gap: 4px; }
.rail nav a {
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
}
.rail nav a:hover,
.rail nav a.active {
  background: #18222c;
  color: var(--ink);
}
.rail nav a.active { box-shadow: inset 2px 0 0 var(--brass); }

.rail-foot {
  margin-top: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
}
.dot.ok { background: var(--teal); }
.dot.bad { background: var(--rust); }

main { padding: 28px 36px 48px; min-width: 0; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 24px;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--brass);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
}
h1 { margin: 0; font-size: 28px; font-weight: 600; }
.top-actions { display: flex; gap: 8px; }

.btn {
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--ink);
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover { border-color: #3a4754; }
.btn.primary {
  background: var(--brass);
  border-color: var(--brass);
  color: #1a1408;
  font-weight: 600;
}
.btn.danger { border-color: #6b3530; color: #f0b2aa; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.grid {
  display: grid;
  gap: 16px;
}
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cards-2 { grid-template-columns: 1.4fr 1fr; }
.cards-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}
.card h2, .card h3 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.stat-value { font-size: 26px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--muted); font-size: 12px; margin-top: 6px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #1b252e; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  text-transform: lowercase;
}
.badge.running, .badge.queued { color: #f0d39a; border-color: #6b5426; }
.badge.success, .badge.done { color: #9ee4d0; border-color: var(--teal-dim); }
.badge.failed, .badge.canceled { color: #f0b2aa; border-color: #6b3530; }

.form { display: grid; gap: 14px; max-width: 640px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
label.check {
  grid-template-columns: 18px 1fr;
  align-items: center;
  color: var(--ink);
}
label.check input { width: auto; margin: 0; }
.sched {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 8px;
}
input, select, textarea {
  background: #0f151b;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 12px;
}
textarea { min-height: 88px; resize: vertical; }
.help { font-size: 12px; color: #6f7b87; }

.progress-hero {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 24px;
  align-items: center;
}
.ring {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: conic-gradient(var(--teal) var(--pct, 0%), #24303a 0);
  display: grid;
  place-items: center;
}
.ring-inner {
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: var(--bg-card);
  display: grid;
  place-items: center;
  text-align: center;
}
.ring-inner strong { font-size: 28px; }
.ring-inner span { color: var(--muted); font-size: 12px; }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.metric {
  background: #10171e;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
.metric b { display: block; font-size: 18px; margin-top: 4px; font-variant-numeric: tabular-nums; }

.log {
  font-family: var(--mono);
  font-size: 12px;
  background: #0b1015;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  min-height: 180px;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  color: #c5d0da;
}

.empty {
  color: var(--muted);
  padding: 28px 8px;
  text-align: center;
}

.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.split { display: flex; justify-content: space-between; gap: 12px; align-items: center; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #1d2731;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-width: 360px;
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .rail { flex-direction: row; align-items: center; gap: 16px; overflow-x: auto; }
  .rail nav { flex-direction: row; }
  .rail-foot { margin: 0 0 0 auto; }
  .stats, .cards-2, .cards-3, .metrics, .progress-hero { grid-template-columns: 1fr; }
  main { padding: 20px; }
}
