:root {
  --bg: #0b1220;
  --surface: #111c30;
  --surface-2: #1c2942;
  --border: #2a3a55;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-dim: #64748b;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius-sm: 6px;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
#app { min-height: 100vh; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-brand {
  padding: 0 24px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sidebar-brand h1 { font-size: 18px; margin: 0; }
.sidebar-brand .small { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.sidebar a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 24px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
}
.nav-notif-badge {
  display: inline-block;
  min-width: 20px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  border-radius: 10px;
  background: var(--primary, #3b82f6);
  color: #fff;
}
.nav-notif-badge[hidden] { display: none; }
.sidebar a:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.sidebar a.active { color: var(--text); background: rgba(59,130,246,0.10); border-left-color: var(--primary); }
.sidebar-footer { margin-top: auto; padding: 12px 24px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-dim); }
.sidebar-footer button {
  background: none; border: 0; color: var(--text-secondary); padding: 0; cursor: pointer;
  font-size: 12px; text-decoration: underline;
}
.sidebar-footer button:hover { color: var(--text); }

.main { padding: 24px 32px; max-width: 1400px; }
.main h1 { font-size: 26px; margin: 0 0 4px; }
.main .subtitle { color: var(--text-secondary); margin: 0 0 24px; }

/* ── Typography ──────────────────────────────────────────────────────────── */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.2; }
h2 { font-size: 18px; margin: 24px 0 12px; }
h3 { font-size: 15px; margin: 16px 0 8px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; }
p { margin: 0 0 12px; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
.muted { color: var(--text-secondary); }
.dim { color: var(--text-dim); }
code { background: rgba(255,255,255,0.06); padding: 1px 6px; border-radius: 4px; font-size: 0.92em; font-family: 'SF Mono', Consolas, Menlo, monospace; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); cursor: pointer;
  font-size: 14px; font-weight: 500; font-family: inherit; text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--border); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(255,255,255,0.05); }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 { margin-top: 0; }
.card-row { display: flex; gap: 16px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.card-row:last-child { border-bottom: 0; }
.card-row-label { color: var(--text-secondary); font-size: 13px; min-width: 140px; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0;
}
tbody td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody tr.clickable { cursor: pointer; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table-wrap-scroll { max-height: 70vh; overflow: auto; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], textarea, select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 10px;
  font-size: 14px;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); }
textarea { min-height: 80px; resize: vertical; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-primary { background: rgba(59,130,246,0.20); color: var(--primary); }
.badge-success { background: rgba(34,197,94,0.20); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.20); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.20); color: var(--danger); }
.badge-muted { background: rgba(148,163,184,0.15); color: var(--text-secondary); }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 24px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
}
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card { width: 100%; max-width: 400px; }

/* ── Utilities ───────────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; top: 20px; right: 20px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px; font-size: 14px;
  z-index: 200; max-width: 420px; box-shadow: 0 8px 30px rgba(0,0,0,0.35);
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.15); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
}

/* ── Test dashboard ───────────────────────────────────────────────────────── */
.badge-pass { background: rgba(34,197,94,0.20); color: var(--success); }
.badge-fail { background: rgba(239,68,68,0.20); color: var(--danger); }
.badge-skip { background: rgba(245,158,11,0.18); color: var(--warning); }
.badge-gap  { background: rgba(148,163,184,0.15); color: var(--text-secondary); }
.badge-none { background: rgba(148,163,184,0.12); color: var(--text-dim); }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; color: var(--text-secondary); font-weight: 600; padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table tr:last-child td { border-bottom: 0; }

.area-h { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-secondary); margin: 18px 0 8px; }
.journey-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 6px; }
.journey-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: inherit; }
.journey-row:hover { border-color: var(--primary); background: rgba(59,130,246,0.06); }
.journey-id { font-family: ui-monospace, monospace; font-size: 12px; font-weight: 600; }
.journey-title { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: 5px 0; }

.mermaid-wrap { overflow-x: auto; background: var(--bg-elevated, #0b1220); border-radius: 8px; padding: 14px; }
.mermaid-wrap svg { max-width: 100%; height: auto; }
.mermaid-src { white-space: pre-wrap; font-size: 12px; color: var(--text-secondary); }
.err-line { color: var(--danger); font-size: 12px; margin-top: 3px; max-width: 60ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
