/* ============================================
   MJ DigitalFactory — Design System v4.0
   ============================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* ── Custom Properties ── */
:root {
  --bg: #f0f1f6;
  --surface: #ffffff;
  --surface2: #e8eaf2;
  --border: #d0d3e0;
  --accent: #6944e0;
  --accent2: #00a882;
  --accent3: #e85a20;
  --text: #1a1d2e;
  --muted: #9196ad;
  --muted2: #636a88;
  --danger: #e0334f;
  --warning: #d99400;
  --gold: #c8a020;

  --font-heading: 'IBM Plex Sans', -apple-system, sans-serif;
  --font-body: 'IBM Plex Sans', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Consolas', monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 260px;
  --topbar-h: 60px;

  --transition: 0.2s ease;
}

/* ── Dark Theme ── */
[data-theme="dark"] {
  --bg: #1a1c28;
  --surface: #222432;
  --surface2: #2a2d3e;
  --border: #363a50;
  --accent: #8b6ff0;
  --accent2: #2ee8b0;
  --accent3: #ff7b4a;
  --text: #e2e4ee;
  --muted: #5c6280;
  --muted2: #8890b0;
  --danger: #ff5570;
  --warning: #ffb830;
  --gold: #f0c840;
}

[data-theme="dark"] body::before {
  background-image:
    linear-gradient(rgba(139,111,240,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(139,111,240,0.025) 1px, transparent 1px);
}

[data-theme="dark"] body::after {
  background: radial-gradient(ellipse, rgba(139,111,240,0.06) 0%, transparent 70%);
}

[data-theme="dark"] .card,
[data-theme="dark"] .kpi-card {
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

[data-theme="dark"] .toast {
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

[data-theme="dark"] .toast.toast-success {
  background: rgba(46,232,176,0.12);
  border-color: rgba(46,232,176,0.25);
}

[data-theme="dark"] .toast.toast-error {
  background: rgba(255,85,112,0.12);
  border-color: rgba(255,85,112,0.25);
}

[data-theme="dark"] .toast.toast-warning {
  background: rgba(255,184,48,0.12);
  border-color: rgba(255,184,48,0.25);
}

[data-theme="dark"] .toast.toast-info {
  background: rgba(139,111,240,0.12);
  border-color: rgba(139,111,240,0.25);
}

[data-theme="dark"] .modal-overlay {
  background: rgba(10,12,20,0.6);
}

[data-theme="dark"] .banner-warning {
  background: rgba(255,184,48,0.08);
  border-color: rgba(255,184,48,0.2);
}

[data-theme="dark"] .banner-info {
  background: rgba(139,111,240,0.08);
  border-color: rgba(139,111,240,0.2);
}

[data-theme="dark"] .banner-success {
  background: rgba(46,232,176,0.08);
  border-color: rgba(46,232,176,0.2);
}

[data-theme="dark"] .sidebar-nav a:hover {
  background: rgba(139,111,240,0.08);
}

[data-theme="dark"] .sidebar-nav a.active {
  background: rgba(139,111,240,0.12);
}

[data-theme="dark"] tbody tr:hover {
  background: rgba(139,111,240,0.05);
}

[data-theme="dark"] .btn-success,
[data-theme="dark"] .btn-warning {
  color: #1a1c28;
}

[data-theme="dark"] select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238890b0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

/* ── Theme Toggle Button ── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted2);
  cursor: pointer;
  padding: 6px 10px;
  font-size: 1rem;
  line-height: 1;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--muted);
  background: var(--surface2);
}

/* ── Reset ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ── Background Effects ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(105,68,224,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(105,68,224,0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 600px;
  background: radial-gradient(ellipse, rgba(105,68,224,0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ── Typography ── */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.3;
}

h1 { font-size: 1.8rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent2);
}

/* ── Layout: Sidebar + Main ── */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo h1 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.sidebar-logo .system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted2);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent2);
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.offline {
  background: var(--danger);
  animation: none;
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--muted2);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  position: relative;
}

.sidebar-nav a:hover {
  color: var(--text);
  background: rgba(105,68,224,0.07);
}

.sidebar-nav a.active {
  color: var(--text);
  background: rgba(105,68,224,0.1);
  border-left-color: var(--accent);
}

.sidebar-nav a .nav-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.sidebar-nav .badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
}

/* ── Main Content ── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-time {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted2);
}

.topbar-connection {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted2);
}

.topbar-connection .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent2);
}

.topbar-connection .dot.offline {
  background: var(--danger);
}

/* ── Page Content ── */
.page-content {
  padding: 32px;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  animation: fadeUp 0.4s ease both;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-header h3 {
  font-family: var(--font-heading);
  font-weight: 700;
}

/* ── KPI Cards ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  animation: fadeUp 0.4s ease both;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.kpi-card .kpi-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.kpi-card .kpi-value {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
}

.kpi-card .kpi-sub {
  font-size: 0.8rem;
  color: var(--muted2);
  margin-top: 4px;
}

.kpi-card.accent .kpi-value { color: var(--accent); }
.kpi-card.accent2 .kpi-value { color: var(--accent2); }
.kpi-card.accent3 .kpi-value { color: var(--accent3); }
.kpi-card.gold .kpi-value { color: var(--gold); }
.kpi-card.danger .kpi-value { color: var(--danger); }

/* ── Grids ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }

/* ── Agent Status Cards ── */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.agent-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  animation: fadeUp 0.4s ease both;
}

.agent-card .agent-name {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.agent-card .agent-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.agent-card .agent-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.agent-card .agent-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 8px;
  font-family: var(--font-mono);
}

/* Agent status colors */
.status-run .dot { background: var(--accent2); animation: pulse 2s ease-in-out infinite; }
.status-run { color: var(--accent2); }
.status-idle .dot { background: var(--muted); }
.status-idle { color: var(--muted); }
.status-queue .dot { background: var(--warning); animation: pulse 2s ease-in-out infinite; }
.status-queue { color: var(--warning); }
.status-error .dot { background: var(--danger); }
.status-error { color: var(--danger); }
.status-done .dot { background: var(--accent2); }
.status-done { color: var(--accent2); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: #5a38cc;
  box-shadow: 0 0 20px rgba(105,68,224,0.25);
}

.btn-success {
  background: var(--accent2);
  color: #fff;
}

.btn-success:hover {
  background: #009070;
  box-shadow: 0 0 20px rgba(0,168,130,0.25);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #c42a44;
  box-shadow: 0 0 20px rgba(224,51,79,0.25);
}

.btn-warning {
  background: var(--warning);
  color: #fff;
}

.btn-warning:hover {
  background: #bb8000;
  box-shadow: 0 0 20px rgba(217,148,0,0.25);
}

.btn-ghost {
  background: transparent;
  color: var(--muted2);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--muted);
  background: var(--surface2);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.btn .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ── Quick Actions ── */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* ── Activity Feed ── */
.activity-feed {
  max-height: 300px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.activity-item .activity-time {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
}

.activity-item .activity-msg {
  flex: 1;
  color: var(--muted2);
}

/* Activity colors */
.dot-sale { background: var(--accent2); }
.dot-agent { background: var(--accent); }
.dot-system { background: var(--muted2); }
.dot-error { background: var(--danger); }

/* ── Progress Bar ── */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar .progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
  background: var(--accent);
}

.progress-bar .progress-fill.warning { background: var(--warning); }
.progress-bar .progress-fill.danger { background: var(--danger); }

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

tbody tr:hover {
  background: rgba(105,68,224,0.05);
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.3px;
}

.badge-accent { background: rgba(105,68,224,0.12); color: var(--accent); }
.badge-success { background: rgba(0,168,130,0.12); color: var(--accent2); }
.badge-warning { background: rgba(217,148,0,0.12); color: var(--warning); }
.badge-danger { background: rgba(224,51,79,0.12); color: var(--danger); }
.badge-muted { background: rgba(99,106,136,0.12); color: var(--muted2); }

/* ── Forms ── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: border-color var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(105,68,224,0.12);
}

.form-control::placeholder {
  color: var(--muted);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23636a88' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.input-group {
  display: flex;
  gap: 8px;
}

.input-group .form-control {
  flex: 1;
}

/* Password toggle */
.password-wrap {
  position: relative;
}

.password-wrap .form-control {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
}

.password-toggle:hover {
  color: var(--text);
}

/* ── Toast Notifications ── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  animation: slideIn 0.3s ease;
  min-width: 280px;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.toast.toast-success {
  background: #ecfdf5;
  border: 1px solid rgba(0,168,130,0.3);
  color: var(--accent2);
}

.toast.toast-error {
  background: #fef2f4;
  border: 1px solid rgba(224,51,79,0.3);
  color: var(--danger);
}

.toast.toast-warning {
  background: #fefbec;
  border: 1px solid rgba(217,148,0,0.3);
  color: var(--warning);
}

.toast.toast-info {
  background: #f3effc;
  border: 1px solid rgba(105,68,224,0.3);
  color: var(--accent);
}

.toast.removing {
  animation: slideOut 0.3s ease forwards;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,29,46,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  animation: fadeIn 0.2s ease;
  backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  min-width: 400px;
  max-width: 560px;
  width: 90%;
  animation: scaleIn 0.2s ease;
}

.modal h3 {
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ── Console / Log ── */
.console-log {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  max-height: 400px;
  overflow-y: auto;
  line-height: 1.8;
}

.console-log .log-line {
  display: flex;
  gap: 12px;
}

.console-log .log-time {
  color: var(--muted);
  white-space: nowrap;
}

.console-log .log-success { color: var(--accent2); }
.console-log .log-error { color: var(--danger); }
.console-log .log-warning { color: var(--warning); }
.console-log .log-info { color: var(--muted2); }

/* ── Pipeline Visual ── */
.pipeline-flow {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 20px 0;
}

.pipeline-node {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  text-align: center;
  min-width: 130px;
  position: relative;
  transition: all var(--transition);
}

.pipeline-node:hover {
  border-color: var(--accent);
}

.pipeline-node .node-name {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.pipeline-node .node-status {
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.pipeline-node .node-time {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 6px;
}

.pipeline-node .node-btn {
  margin-top: 10px;
}

.pipeline-arrow {
  color: var(--muted);
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* ── HITL Product Card ── */
.hitl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  animation: fadeUp 0.4s ease both;
  transition: all 0.4s ease;
}

.hitl-card.collapsing {
  opacity: 0;
  transform: translateY(-20px);
  max-height: 0;
  padding: 0 24px;
  margin-bottom: 0;
  overflow: hidden;
}

.hitl-card .hitl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.hitl-card .hitl-score {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  background: rgba(105,68,224,0.1);
  color: var(--accent);
  font-weight: 600;
}

.hitl-card .hitl-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
}

.hitl-card .hitl-meta {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 0.8rem;
  color: var(--muted2);
}

.hitl-card .hitl-preview {
  font-size: 0.85rem;
  color: var(--muted2);
  padding: 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  line-height: 1.5;
}

.hitl-card .hitl-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted2);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 1rem;
}

/* ── Skeleton Loader ── */
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 40%, var(--surface2) 65%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  width: 80%;
}

.skeleton-text.short {
  width: 50%;
}

.skeleton-card {
  height: 120px;
}

/* ── Score Bar ── */
.score-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-bar .bar {
  flex: 1;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
  max-width: 60px;
}

.score-bar .bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
}

.score-bar .score-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted2);
}

/* ── Filters Row ── */
.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
  align-items: center;
}

.filters-row .form-control {
  width: auto;
  min-width: 160px;
}

.search-input {
  position: relative;
}

.search-input .form-control {
  padding-left: 36px;
}

.search-input .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.9rem;
}

/* ── Newsletter Status ── */
.newsletter-status-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.newsletter-status-card .ns-item {
  text-align: center;
}

.newsletter-status-card .ns-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted2);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.newsletter-status-card .ns-value {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
}

/* ── Config Sections ── */
.config-section {
  margin-bottom: 32px;
}

.config-section h3 {
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Login Page ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.login-box {
  text-align: center;
  width: 100%;
  max-width: 380px;
  padding: 40px;
}

.login-box .login-logo {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.login-box .login-subtitle {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted2);
  margin-bottom: 32px;
}

.login-box .login-form {
  margin-bottom: 24px;
}

.login-box .login-version {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
}

/* ── Wizard (first config) ── */
.wizard-steps {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.wizard-step {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}

.wizard-step.active {
  background: var(--accent);
}

.wizard-step.done {
  background: var(--accent2);
}

/* ── Warning Banner ── */
.banner {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.banner-warning {
  background: #fefbec;
  border: 1px solid rgba(217,148,0,0.25);
  color: var(--warning);
}

.banner-info {
  background: #f3effc;
  border: 1px solid rgba(105,68,224,0.2);
  color: var(--accent);
}

.banner-success {
  background: #ecfdf5;
  border: 1px solid rgba(0,168,130,0.2);
  color: var(--accent2);
}

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Animation delays for staggered cards */
.kpi-card:nth-child(1), .agent-card:nth-child(1), .hitl-card:nth-child(1) { animation-delay: 0s; }
.kpi-card:nth-child(2), .agent-card:nth-child(2), .hitl-card:nth-child(2) { animation-delay: 0.05s; }
.kpi-card:nth-child(3), .agent-card:nth-child(3), .hitl-card:nth-child(3) { animation-delay: 0.1s; }
.kpi-card:nth-child(4), .agent-card:nth-child(4), .hitl-card:nth-child(4) { animation-delay: 0.15s; }
.kpi-card:nth-child(5), .agent-card:nth-child(5) { animation-delay: 0.2s; }
.kpi-card:nth-child(6), .agent-card:nth-child(6) { animation-delay: 0.25s; }

/* ── Hamburger (mobile) ── */
.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .hamburger {
    display: block;
  }

  .page-content {
    padding: 20px 16px;
  }

  .grid-2, .grid-3, .grid-2-1 {
    grid-template-columns: 1fr;
  }

  .config-grid {
    grid-template-columns: 1fr;
  }

  .pipeline-flow {
    flex-direction: column;
  }

  .pipeline-arrow {
    transform: rotate(90deg);
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .modal {
    min-width: auto;
    width: 95%;
  }

  .topbar {
    padding: 0 16px;
  }

  .filters-row {
    flex-direction: column;
    align-items: stretch;
  }

  .filters-row .form-control {
    width: 100%;
  }
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ── Utility ── */
.text-accent { color: var(--accent); }
.text-accent2 { color: var(--accent2); }
.text-accent3 { color: var(--accent3); }
.text-muted { color: var(--muted2); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
