* { box-sizing: border-box; }
:root {
  --bg: #0b0d11;
  --panel: #12151b;
  --panel-2: #171b22;
  --border: #242933;
  --text: #eef0f3;
  --muted: #8a8f9a;
  --accent: #4caf7d;
  --accent-soft: rgba(76, 175, 125, 0.12);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.12);
  --warn: #e0c25f;
  --warn-soft: rgba(224, 194, 95, 0.12);
  --info: #5fa8e0;
  --info-soft: rgba(95, 168, 224, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
}
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
#app { min-height: 100vh; }
a { color: var(--accent); }

/* ---------- Toasts ---------- */
#toasts { position: fixed; top: 16px; right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 260px; max-width: 420px; padding: 12px 14px; border-radius: var(--radius-sm);
  font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,0.35); border: 1px solid var(--border);
  background: var(--panel-2); animation: toast-in 0.18s ease-out;
}
.toast.error { border-color: rgba(255,107,107,0.4); background: #201516; color: #ffb4b4; }
.toast.success { border-color: rgba(76,175,125,0.4); background: #12201a; color: #9fe0bf; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Login ---------- */
.login-screen {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: radial-gradient(circle at 30% 20%, rgba(76,175,125,0.08), transparent 40%), var(--bg);
}
.login-box { width: 340px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; }
.login-box .brand-mark { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.login-box h1 { font-size: 18px; margin: 0 0 4px; }
.login-box .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.login-box input { width: 100%; padding: 11px 13px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg); color: var(--text); margin-bottom: 14px; font-size: 14px; }
.login-box input:focus { outline: none; border-color: var(--accent); }
.login-box .error { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 16px; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 216px; background: var(--panel); border-right: 1px solid var(--border); padding: 20px 12px; flex-shrink: 0; display: flex; flex-direction: column; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; }
.sidebar .brand .mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.sidebar .brand .name { font-weight: 700; font-size: 15px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-size: 13.5px; cursor: pointer; transition: background .12s, color .12s;
}
.sidebar a .ic { width: 16px; text-align: center; opacity: .85; }
.sidebar a.active { color: var(--text); background: var(--panel-2); }
.sidebar a:hover { color: var(--text); background: var(--panel-2); }
.sidebar .spacer { flex: 1; }
.sidebar .logout { color: var(--danger); opacity: .8; }
.sidebar .logout:hover { opacity: 1; background: var(--danger-soft); }

.main { flex: 1; padding: 28px 36px 60px; overflow-x: auto; max-width: 1100px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-head h2 { margin: 0; font-size: 20px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 28px 0 10px; font-weight: 600; }
.section-title:first-child { margin-top: 0; }

/* ---------- Stat tiles ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 8px; }
.stat-tile { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-tile .label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.stat-tile .value { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat-tile .value .unit { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.stat-tile .foot { margin-top: 6px; font-size: 12px; color: var(--muted); }

/* ---------- Cards / forms ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; max-width: 540px; }
.card.wide { max-width: none; }
.card h3 { margin: 0 0 4px; font-size: 15px; }
.card .card-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 16px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-family: inherit; font-size: 13.5px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 96px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; resize: vertical; }
.card .actions { margin-top: 18px; display: flex; gap: 10px; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 10px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--accent); color: #06130d; font-weight: 600; font-size: 13px;
  cursor: pointer; transition: filter .12s, background .12s; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--panel-2); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { border-color: #39404d; }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(255,107,107,0.3); }
.btn.danger:hover { background: rgba(255,107,107,0.2); }
.btn.sm { padding: 6px 11px; font-size: 12px; }
.icon-btn {
  width: 30px; height: 30px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--panel-2);
  color: var(--muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 13px;
}
.icon-btn:hover { color: var(--text); border-color: #39404d; }
.icon-btn.danger:hover { color: var(--danger); border-color: rgba(255,107,107,0.4); background: var(--danger-soft); }
.row-actions { display: flex; gap: 6px; }

/* ---------- Tables ---------- */
.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; background: var(--panel-2); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.015); }
td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted); }
.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.running { background: var(--info-soft); color: var(--info); }
.badge.done { background: var(--accent-soft); color: var(--accent); }
.badge.failed { background: var(--danger-soft); color: var(--danger); }

.muted { color: var(--muted); font-size: 12.5px; }
.link-action { color: var(--accent); cursor: pointer; font-size: 12.5px; }
.link-action:hover { text-decoration: underline; }

/* ---------- Job steps ---------- */
.steps-list { display: flex; flex-direction: column; gap: 0; margin: 18px 0; }
.step-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
.step-row:last-child { border-bottom: none; }
.step-row .dot { width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; flex-shrink: 0; }
.step-row .dot.ok { background: var(--accent-soft); color: var(--accent); }
.step-row .dot.cur { background: var(--info-soft); color: var(--info); }
.step-row .dot.pending { background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); }
.step-row .label { color: var(--text); }
.step-row.inactive .label { color: var(--muted); }
.job-steps { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; white-space: pre-wrap; color: var(--muted); max-height: 260px; overflow: auto; }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; }
  .sidebar nav { flex-direction: row; }
  .main { padding: 20px; }
}
