:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3354;
  --accent: #6366f1;
  --accent-hover: #4f52d6;
  --text: #e2e4f0;
  --text-muted: #7b80a0;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #38bdf8;
  --radius: 8px;
  --sidebar-w: 220px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout ─── */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 18px; letter-spacing: 0.02em;
}
.sidebar-logo svg { flex-shrink: 0; }
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  cursor: pointer; color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  font-size: 14px; border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(99,102,241,0.18); color: var(--accent); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-bottom { padding: 12px 8px; border-top: 1px solid var(--border); }
.sidebar-user { display: flex; align-items: center; gap: 8px; padding: 6px 10px; color: var(--text-muted); font-size: 13px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; color: white; font-weight: 600; font-size: 12px; flex-shrink: 0; }

.main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.topbar {
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); flex-shrink: 0;
}
.topbar h1 { font-size: 18px; font-weight: 600; }
.content { padding: 24px; flex: 1; }

/* ─── Cards / widgets ─── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-weight: 600; font-size: 15px; }
.card-body { padding: 0; }

/* ─── Tables ─── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 16px; text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }
.empty-row td { text-align: center; color: var(--text-muted); padding: 32px; }

/* ─── Badges / status ─── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 500; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.badge-online  { color: var(--success); background: rgba(34,197,94,.12); }
.badge-online::before { background: var(--success); }
.badge-offline { color: var(--text-muted); background: rgba(123,128,160,.12); }
.badge-offline::before { background: var(--text-muted); }
.badge-error   { color: var(--danger); background: rgba(239,68,68,.12); }
.badge-error::before { background: var(--danger); }
.badge-pending { color: var(--warning); background: rgba(245,158,11,.12); }
.badge-pending::before { background: var(--warning); }
.badge-running { color: var(--info); background: rgba(56,189,248,.12); }
.badge-running::before { background: var(--info); animation: pulse 1.5s infinite; }
.badge-success { color: var(--success); background: rgba(34,197,94,.12); }
.badge-success::before { background: var(--success); }
.badge-failed  { color: var(--danger); background: rgba(239,68,68,.12); }
.badge-failed::before { background: var(--danger); }
.badge-queued  { color: var(--info); background: rgba(56,189,248,.12); }
.badge-queued::before { background: var(--info); }
.badge-skipped { color: var(--text-muted); background: rgba(123,128,160,.12); }
.badge-skipped::before { background: var(--text-muted); }
.badge-completed { color: var(--success); background: rgba(34,197,94,.12); }
.badge-completed::before { background: var(--success); }
.badge-cancelled { color: var(--text-muted); background: rgba(123,128,160,.12); }
.badge-cancelled::before { background: var(--text-muted); }

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

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-danger { background: rgba(239,68,68,.12); color: var(--danger); border-color: rgba(239,68,68,.3); }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,.2); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; padding: 10px; }

/* ─── Forms ─── */
.field { margin-bottom: 16px; }
label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-muted); }
input[type=text], input[type=password], input[type=email], select, textarea {
  width: 100%; padding: 8px 12px; border-radius: var(--radius);
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 14px; outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }
select option { background: var(--surface2); }
.error-msg { color: var(--danger); font-size: 13px; margin-bottom: 12px; }

/* ─── Modal ─── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; backdrop-filter: blur(2px);
}
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 480px; max-width: 95vw; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 20px; line-height: 1; padding: 0 4px; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ─── Toast ─── */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  min-width: 260px; max-width: 380px;
  display: flex; align-items: center; gap: 10px;
  animation: slideIn 0.2s ease; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-info    { border-left: 3px solid var(--info); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── Progress bar ─── */
.progress-bar { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.4s; }
.progress-fill.success { background: var(--success); }
.progress-fill.failed { background: var(--danger); }

/* ─── Login page ─── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 36px; width: 380px; max-width: 95vw; }
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; font-size: 20px; font-weight: 700; }
.login-card h2 { margin-bottom: 20px; font-size: 18px; }

/* ─── Misc ─── */
.flex { display: flex; }
.gap-2 { gap: 8px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.mt-4 { margin-top: 16px; }
.log-output {
  background: #0a0c12; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; font-family: 'Fira Mono', 'Consolas', monospace; font-size: 12px;
  max-height: 320px; overflow-y: auto; white-space: pre-wrap; color: #c8d0e8;
}
.section-title { font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 12px; }
.inline-badge { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 11px; background: var(--surface2); border: 1px solid var(--border); color: var(--text-muted); font-family: monospace; }
