/* ═══════════════════════════════════════════════════════════════════════════
   CyberBox MAF — Complete Design System
   Modern security console — calmer dark slate (default) + light theme.
   Token-driven: theme switches by overriding the same CSS custom properties.
   Light theme: <html data-theme="light">. Default (no attribute) = dark.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Variables — Dark (default) ──────────────────────────────────────────── */
:root {
  --bg-base:        #0b0f17;
  --bg-surface:     #111722;
  --bg-card:        #161d2b;
  --bg-card-hover:  #1c2433;
  --bg-input:       #0e141f;
  --bg-sidebar:     #0a0e16;
  --bg-log:         #070b12;   /* terminal/log panel — was hardcoded #050810 */

  --border:         #232c3d;
  --border-light:   #2e3a4f;

  /* Accent — calmer modern blue (replaces harsh neon cyan).
     --cyan is kept as an alias so existing rules keep working. */
  --accent:         #3b82f6;
  --accent-hover:   #60a5fa;
  --cyan:           var(--accent);
  --cyan-dim:       #2563eb;
  --cyan-glow:      rgba(59,130,246,0.10);
  --green:          #22c55e;
  --green-dim:      #16a34a;
  --green-glow:     rgba(34,197,94,0.10);
  --red:            #ef4444;
  --red-dim:        #dc2626;
  --red-glow:       rgba(239,68,68,0.10);
  --yellow:         #f59e0b;
  --yellow-dim:     #d97706;
  --yellow-glow:    rgba(245,158,11,0.10);
  --purple:         #a78bfa;
  --orange:         #fb923c;
  --info:           #38bdf8;

  --text-primary:   #e6edf6;
  --text-secondary: #9aa7bd;
  --text-muted:     #6b7a92;
  --text-accent:    var(--accent);

  --sidebar-width:  240px;
  --topbar-height:  56px;
  --radius:         12px;
  --radius-sm:      8px;
  --radius-lg:      16px;
  --transition:     0.18s ease;
  --shadow:         0 4px 16px rgba(0,0,0,0.35);
  --shadow-glow:    0 0 0 1px rgba(59,130,246,0.10), 0 2px 14px rgba(0,0,0,0.30);
}

/* ── Variables — Light theme ─────────────────────────────────────────────── */
[data-theme="light"] {
  /* Cyber/SOC light theme — cool steel-blue surfaces with a cyan accent. */
  --bg-base:        #e9f0f7;   /* cool ice-blue */
  --bg-surface:     #dbe6f1;   /* steel */
  --bg-card:        #ffffff;
  --bg-card-hover:  #e6f1fa;
  --bg-input:       #ffffff;
  --bg-sidebar:     #f2f8fd;
  --bg-log:         #0e141f;   /* keep the log panel dark for legibility */

  --border:         #cbdcec;
  --border-light:   #aec6dd;

  --accent:         #1e3a8a;   /* deep navy (blue-900) */
  --accent-hover:   #1e40af;   /* navy hover (blue-800) */
  --cyan-dim:       #1e40af;
  --cyan-glow:      rgba(30,58,138,0.12);
  --green:          #16a34a;
  --green-dim:      #15803d;
  --green-glow:     rgba(22,163,74,0.10);
  --red:            #dc2626;
  --red-dim:        #b91c1c;
  --red-glow:       rgba(220,38,38,0.10);
  --yellow:         #d97706;
  --yellow-dim:     #b45309;
  --yellow-glow:    rgba(217,119,6,0.12);
  --purple:         #7c3aed;
  --orange:         #ea580c;
  --info:           #0284c7;

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #64748b;

  --shadow:         0 4px 16px rgba(15,23,42,0.08);
  --shadow-glow:    0 0 0 1px rgba(30,58,138,0.16), 0 2px 12px rgba(15,23,42,0.06);
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color var(--transition), color var(--transition);
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.logo-title { display: block; font-size: 18px; font-weight: 700; color: var(--text-primary); }
.logo-sub   { display: block; font-size: 12px; color: var(--text-muted); letter-spacing: 1px; }

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
}
.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--cyan-glow);
  color: var(--accent);
  border: 1px solid rgba(59,130,246,0.28);
}
.nav-icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-label { flex: 1; }
.nav-badge {
  background: var(--cyan);
  color: var(--bg-base);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}
.nav-badge.urgent { background: var(--red); color: #fff; }
.nav-badge.pulse  { background: var(--green); animation: pulse-badge 1.5s infinite; }
.nav-badge:empty  { display: none; }
@keyframes pulse-badge {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.green  { background: var(--green);  box-shadow: 0 0 6px var(--green); }
.status-dot.red    { background: var(--red);    box-shadow: 0 0 6px var(--red); }
.status-dot.yellow { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }

/* ── Main Wrapper ────────────────────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  padding: 4px;
  display: none;
}
.topbar-breadcrumb {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-time  { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ── Live Alerts toggle (topbar) — background new-incident poller ─────────── */
.live-alerts-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.live-alerts-toggle input { display: none; }
.lat-track {
  width: 34px; height: 19px; border-radius: 999px; background: var(--border);
  position: relative; flex-shrink: 0; transition: background var(--transition);
}
.lat-thumb {
  position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35); transition: transform var(--transition);
}
.live-alerts-toggle input:checked + .lat-track { background: var(--green, #22c55e); }
.live-alerts-toggle input:checked + .lat-track .lat-thumb { transform: translateX(15px); }
.lat-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.live-alerts-toggle input:disabled + .lat-track { opacity: .5; cursor: not-allowed; }
.topbar-theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.topbar-theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Page Container ──────────────────────────────────────────────────────── */
.page-container {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  overflow-x: hidden;
}
.page-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  gap: 16px;
  color: var(--text-muted);
}

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-sm {
  width: 16px; height: 16px;
  border-width: 2px;
  display: inline-block;
}

/* ── Page Header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-title span { color: var(--cyan); }
.page-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card:hover { border-color: var(--border-light); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.1px;
}

/* ── Stat Cards ──────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}
.stat-card:hover { border-color: var(--border-light); transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card.cyan::before   { background: linear-gradient(90deg, var(--cyan), var(--purple)); }
.stat-card.green::before  { background: linear-gradient(90deg, var(--green), var(--cyan)); }
.stat-card.red::before    { background: linear-gradient(90deg, var(--red), var(--orange)); }
.stat-card.yellow::before { background: linear-gradient(90deg, var(--yellow), var(--orange)); }
.stat-card.purple::before { background: linear-gradient(90deg, var(--purple), var(--cyan)); }

.stat-icon   { font-size: 24px; margin-bottom: 10px; }
.stat-value  { font-size: 28px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-label  { font-size: 11px; color: var(--text-muted); margin-top: 4px; letter-spacing: 0.2px; }
.stat-change { font-size: 11px; margin-top: 6px; }
.stat-change.up   { color: var(--green); }
.stat-change.down { color: var(--red); }

/* ── Grid Layouts ────────────────────────────────────────────────────────── */
.grid-2   { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3   { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.col-span-2 { grid-column: span 2; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: var(--shadow);
}
.btn-success {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.btn-success:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: var(--shadow);
}
.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.btn-danger:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: var(--shadow);
}
.btn-warning {
  background: var(--yellow);
  color: #1a1205;
  border-color: var(--yellow);
}
.btn-warning:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: var(--shadow);
}
.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-light);
}
.btn-outline:hover:not(:disabled) {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { color: var(--text-primary); background: var(--bg-card); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.badge-critical { background: rgba(255,23,68,0.2);    color: var(--red);    border: 1px solid rgba(255,23,68,0.3); }
.badge-high     { background: rgba(255,109,0,0.2);    color: var(--orange); border: 1px solid rgba(255,109,0,0.3); }
.badge-medium   { background: rgba(255,214,0,0.2);    color: var(--yellow); border: 1px solid rgba(255,214,0,0.3); }
.badge-low      { background: rgba(0,230,118,0.2);    color: var(--green);  border: 1px solid rgba(0,230,118,0.3); }
.badge-info     { background: rgba(0,212,255,0.15);   color: var(--cyan);   border: 1px solid rgba(0,212,255,0.25); }
.badge-purple   { background: rgba(179,136,255,0.15); color: var(--purple); border: 1px solid rgba(179,136,255,0.25); }
.badge-gray     { background: rgba(74,96,128,0.3);    color: var(--text-muted); border: 1px solid var(--border); }
.badge-approved { background: rgba(0,230,118,0.2);    color: var(--green);  border: 1px solid rgba(0,230,118,0.3); }
.badge-rejected { background: rgba(255,23,68,0.2);    color: var(--red);    border: 1px solid rgba(255,23,68,0.3); }
.badge-deferred { background: rgba(255,214,0,0.2);    color: var(--yellow); border: 1px solid rgba(255,214,0,0.3); }
.badge-pending  { background: rgba(0,212,255,0.15);   color: var(--cyan);   border: 1px solid rgba(0,212,255,0.25); }
.badge-tp       { background: rgba(255,23,68,0.2);    color: var(--red);    border: 1px solid rgba(255,23,68,0.3); }
.badge-fp       { background: rgba(0,230,118,0.2);    color: var(--green);  border: 1px solid rgba(0,230,118,0.3); }
.badge-benign   { background: rgba(74,96,128,0.3);    color: var(--text-muted); border: 1px solid var(--border); }

/* ── Table ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead tr { background: var(--bg-surface); }
thead th {
  padding: 12px 14px;
  text-align: left;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-card-hover); cursor: pointer; }
tbody td {
  padding: 12px 14px;
  color: var(--text-primary);
  vertical-align: middle;
}
.td-muted { color: var(--text-muted); font-size: 12px; }

/* ── Resizable table columns (see shared.js's makeColumnsResizable) ────────── */
.col-resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 3;
  touch-action: none;
}
.col-resize-handle::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 2px;
  width: 2px;
  background: transparent;
  border-radius: 2px;
  transition: background var(--transition);
}
.col-resize-handle:hover::after,
.col-resize-handle.resizing::after { background: var(--cyan); }
.td-mono  { font-family: 'Cascadia Code', 'Fira Code', monospace; font-size: 12px; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 600;
  letter-spacing: 0.1px;
}
.form-control {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.18);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
select.form-control option { background: var(--bg-card); }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}
.search-input { padding-left: 32px; }

/* ── Filters ─────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar .form-control { width: auto; min-width: 130px; }

/* ── Progress / Confidence Bar ───────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}
.progress-fill.cyan   { background: linear-gradient(90deg, var(--cyan-dim), var(--cyan)); }
.progress-fill.green  { background: linear-gradient(90deg, var(--green-dim), var(--green)); }
.progress-fill.red    { background: linear-gradient(90deg, var(--red-dim), var(--red)); }
.progress-fill.yellow { background: linear-gradient(90deg, var(--yellow-dim), var(--yellow)); }

/* ── Pipeline Stepper ────────────────────────────────────────────────────── */
.pipeline-stages {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 20px 0;
  overflow-x: auto;
  padding-bottom: 4px;
}
.pipeline-stage {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}
.stage-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.stage-circle {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  background: var(--bg-card);
  transition: all var(--transition);
}
.stage-circle.done    { border-color: var(--green); background: var(--green-glow); }
.stage-circle.active  { border-color: var(--cyan);  background: var(--cyan-glow); animation: pulse-stage 1s infinite; }
.stage-circle.failed  { border-color: var(--red);   background: var(--red-glow); }
.stage-circle.pending { border-color: var(--border); opacity: 0.5; }
@keyframes pulse-stage {
  0%,100% { box-shadow: 0 0 0 0 rgba(59,130,246,0.35); }
  50%      { box-shadow: 0 0 0 6px rgba(59,130,246,0); }
}
.stage-label { font-size: 10px; color: var(--text-muted); text-align: center; max-width: 60px; }
.stage-label.active { color: var(--cyan); font-weight: 600; }
.stage-label.done   { color: var(--green); }
.stage-connector {
  width: 40px; height: 2px;
  background: var(--border);
  margin-bottom: 22px;
}
.stage-connector.done { background: var(--green); }
.stage-connector.active { background: linear-gradient(90deg, var(--green), var(--cyan)); }

/* ── Log Panel ───────────────────────────────────────────────────────────── */
.log-panel {
  background: var(--bg-log);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: 'Cascadia Code', 'Fira Code', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.6;
  height: 320px;
  overflow-y: auto;
  color: #a8c7fa;
}
.log-line { padding: 1px 0; }
.log-line.success { color: var(--green); }
.log-line.error   { color: var(--red); }
.log-line.warning { color: var(--yellow); }
.log-line.info    { color: var(--cyan); }

/* ── HITL Cards ──────────────────────────────────────────────────────────── */
.hitl-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  transition: all var(--transition);
}
.hitl-card:hover { border-color: var(--cyan); box-shadow: var(--shadow-glow); }
.hitl-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 12px;
}
.hitl-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.hitl-actions-list { margin-bottom: 16px; }
.hitl-action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 12px;
}
.hitl-action-icon { font-size: 16px; flex-shrink: 0; }
.hitl-action-info { flex: 1; }
.hitl-action-name { font-weight: 600; color: var(--text-primary); }
.hitl-action-target { color: var(--text-muted); font-size: 11px; font-family: monospace; }
.hitl-decision-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.confidence-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}
.confidence-row .progress-bar { flex: 1; }

/* ── Connection Test Cards ───────────────────────────────────────────────── */
.conn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.conn-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.conn-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.conn-icon { font-size: 24px; }
.conn-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.conn-sub   { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.conn-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; margin-bottom: 10px;
}
.conn-detail { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.conn-detail span { color: var(--text-primary); }

/* ── Empty State ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
  gap: 12px;
}
.empty-state-icon { font-size: 48px; opacity: 0.4; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); }
.empty-state-sub   { font-size: 13px; max-width: 300px; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 700px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.modal-close {
  background: none; border: none;
  color: var(--text-muted); font-size: 18px;
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Detail rows ─────────────────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
.detail-item { min-width: 0; }
.detail-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
/* overflow-wrap:anywhere is the safety net — without it, a long value with no
   natural break point (a raw JSON string, a token, a long ID) overflows its
   grid cell horizontally instead of wrapping, visually overlapping whatever
   sits below/beside it. min-width:0 above is required for a grid item to
   actually shrink instead of growing to fit unbreakable content. */
.detail-value { font-size: 13px; color: var(--text-primary); font-weight: 500; overflow-wrap: anywhere; }
.detail-value.mono { font-family: monospace; font-size: 12px; }
.detail-section { margin-bottom: 20px; }
.detail-section-title {
  font-size: 12px; color: var(--cyan); text-transform: uppercase;
  letter-spacing: 0.5px; font-weight: 600; margin-bottom: 10px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 999;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-width: 260px;
  max-width: 380px;
  display: flex; align-items: flex-start; gap: 12px;
  box-shadow: var(--shadow);
  animation: toast-in 0.3s ease;
}
@keyframes toast-in { from { opacity:0; transform: translateY(20px); } }
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--cyan); }
.toast.warning { border-left: 3px solid var(--yellow); }
.toast-icon  { font-size: 18px; flex-shrink: 0; }
.toast-body  { flex: 1; }
.toast-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.toast-msg   { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Chart Container ─────────────────────────────────────────────────────── */
.chart-wrap { position: relative; height: 220px; }
.chart-wrap-lg { position: relative; height: 280px; }

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 18px;
  background: none; border: none;
  color: var(--text-muted); font-size: 13px; font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--cyan); border-bottom-color: var(--cyan); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Countdown Timer ─────────────────────────────────────────────────────── */
.countdown {
  font-size: 20px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.countdown.urgent { color: var(--red); animation: pulse-badge 0.8s infinite; }
.countdown.warning { color: var(--yellow); }
.countdown.ok      { color: var(--green); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-2 { grid-template-columns: 1fr; }
  .col-span-2 { grid-column: span 1; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .topbar-toggle { display: flex; }
  .page-container { padding: 16px; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Utilities ───────────────────────────────────────────────────────────── */
.text-cyan    { color: var(--cyan); }
.text-green   { color: var(--green); }
.text-red     { color: var(--red); }
.text-yellow  { color: var(--yellow); }
.text-muted   { color: var(--text-muted); }
.text-sm      { font-size: 12px; }
.text-xs      { font-size: 11px; }
.fw-600       { font-weight: 600; }
.fw-700       { font-weight: 700; }
.mono         { font-family: monospace; }
.mt-4         { margin-top: 4px; }
.mt-8         { margin-top: 8px; }
.mt-12        { margin-top: 12px; }
.mt-16        { margin-top: 16px; }
.mt-20        { margin-top: 20px; }
.mb-8         { margin-bottom: 8px; }
.mb-12        { margin-bottom: 12px; }
.mb-16        { margin-bottom: 16px; }
.mb-20        { margin-bottom: 20px; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.gap-16       { gap: 16px; }
.flex-1       { flex: 1; }
.hidden       { display: none !important; }
.w-full       { width: 100%; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
