:root {
  --primary: #3b82f6;
  --primary-dark: #1d4ed8;
  --primary-bg: #eff6ff;
  --secondary: #64748b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --purple: #8b5cf6;
  --teal: #14b8a6;
  --cyan: #06b6d4;
  --bg: #0f172a;
  --bg-light: #1e293b;
  --surface: #1e293b;
  --surface-hover: #334155;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; }

/* ===== TOP NAV ===== */
.top-nav {
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; padding: 0 20px;
  background: #020617; border-bottom: 1px solid var(--border);
  z-index: 100;
}
.nav-left { display: flex; align-items: center; gap: 12px; }
.nav-logo { height: 28px; }
.nav-title { font-weight: 700; font-size: 14px; }
.nav-env {
  background: rgba(239,68,68,0.2); color: #fca5a5;
  padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
}
.nav-center { display: flex; align-items: center; }
.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%;
  animation: pulse 2s infinite;
}
.status-dot.green { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.yellow { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.status-dot.red { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.nav-right { display: flex; align-items: center; gap: 16px; }
.nav-clock { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.agent-badge {
  background: rgba(255,255,255,0.08); color: var(--text-muted);
  padding: 4px 12px; border-radius: 14px; font-size: 12px; font-weight: 500;
  display: flex; align-items: center; gap: 5px;
}

/* ===== LAYOUT ===== */
.app-layout { display: flex; height: calc(100vh - 52px); }

.sidebar {
  width: 200px; background: #020617; border-right: 1px solid var(--border);
  padding: 12px 8px; flex-shrink: 0;
}
.sidebar-section { margin-bottom: 16px; }
.sidebar-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: #475569; padding: 6px 12px 4px;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px; border-radius: 6px;
  text-decoration: none; color: #94a3b8; font-size: 13px; font-weight: 500;
  transition: all 0.1s;
}
.nav-item:hover { background: var(--bg-light); color: var(--text); }
.nav-item.active { background: rgba(59,130,246,0.15); color: var(--primary); }
.nav-item i { width: 16px; text-align: center; font-size: 13px; }

.main-content { flex: 1; overflow-y: auto; padding: 20px 24px; }

.view { display: none; }
.view.active { display: block; }
.view-header { margin-bottom: 18px; }
.view-header h1 { font-size: 20px; font-weight: 700; }
.view-header .subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; display: block; }
.view-header-row {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px;
}
.view-header-row h1 { font-size: 20px; font-weight: 700; }
.view-header-row .subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; display: block; }

/* ===== STATS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 18px; }
.stats-grid-4 { grid-template-columns: repeat(4, 1fr); }
.stat-card {
  background: var(--surface); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); border-left: 3px solid transparent;
}
.stat-card.blue { border-left-color: var(--primary); }
.stat-card.green { border-left-color: var(--success); }
.stat-card.orange { border-left-color: var(--warning); }
.stat-card.red { border-left-color: var(--danger); }
.stat-card.purple { border-left-color: var(--purple); }
.stat-card.teal { border-left-color: var(--teal); }
.stat-value { font-size: 26px; font-weight: 800; display: block; font-variant-numeric: tabular-nums; }
.stat-value.danger { color: var(--danger); }
.stat-value.warning { color: var(--warning); }
.stat-value.success { color: var(--success); }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

/* ===== CARDS ===== */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.card-body { padding: 14px 16px; }
.card-scroll { max-height: 280px; overflow-y: auto; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dashboard-3col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ===== TABLES ===== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 8px 10px; font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: #64748b; border-bottom: 1px solid var(--border); font-weight: 600;
}
.data-table td {
  padding: 8px 10px; font-size: 13px; border-bottom: 1px solid rgba(51,65,85,0.5);
  vertical-align: middle;
}
.data-table tr:hover { background: var(--surface-hover); }
.data-table tr { cursor: pointer; }
.id-cell { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 11px; color: var(--primary); }

/* ===== BADGES ===== */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
}
.badge-green { background: rgba(16,185,129,0.15); color: #34d399; }
.badge-blue { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-orange { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-red { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-gray { background: rgba(148,163,184,0.15); color: #94a3b8; }
.badge-purple { background: rgba(139,92,246,0.15); color: #a78bfa; }
.badge-teal { background: rgba(20,184,166,0.15); color: #2dd4bf; }
.badge-cyan { background: rgba(6,182,212,0.15); color: #22d3ee; }

/* ===== PRIORITY INDICATORS ===== */
.priority-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.priority-dot.critical { background: var(--danger); }
.priority-dot.high { background: var(--warning); }
.priority-dot.medium { background: var(--primary); }
.priority-dot.low { background: var(--success); }

/* ===== QUEUE TABS ===== */
.queue-tabs { display: flex; gap: 4px; }
.queue-tab {
  padding: 6px 14px; border-radius: 6px; font-size: 12px; font-weight: 600;
  border: none; cursor: pointer; transition: all 0.12s;
  background: var(--surface); color: var(--text-muted);
}
.queue-tab:hover { background: var(--surface-hover); color: var(--text); }
.queue-tab.active { background: var(--primary); color: white; }
.queue-tab .tab-count {
  margin-left: 4px; padding: 1px 6px; border-radius: 8px;
  font-size: 10px; background: rgba(0,0,0,0.2);
}

/* ===== PIPELINE BOARD ===== */
.pipeline-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.pipeline-col {
  background: rgba(30,41,59,0.5); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 12px;
}
.pipeline-col-header {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.pipeline-col-count { font-size: 18px; font-weight: 800; }
.pipeline-item {
  background: var(--surface); border-radius: 6px; padding: 10px 12px;
  margin-bottom: 6px; border-left: 3px solid transparent;
  font-size: 12px; cursor: pointer;
}
.pipeline-item:hover { background: var(--surface-hover); }
.pipeline-item .pi-id { font-family: monospace; color: var(--primary); font-size: 11px; }
.pipeline-item .pi-desc { margin-top: 3px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pipeline-item .pi-date { margin-top: 3px; font-size: 10px; color: #475569; }

/* ===== HORIZ BAR ===== */
.hbar-container { margin-bottom: 14px; }
.hbar-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.hbar-label .hl-name { font-weight: 500; }
.hbar-label .hl-value { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.hbar-track { height: 8px; background: rgba(51,65,85,0.5); border-radius: 4px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }

/* ===== SLA GAUGE ===== */
.sla-gauge {
  text-align: center; padding: 8px 0;
}
.sla-gauge-value { font-size: 36px; font-weight: 800; }
.sla-gauge-label { font-size: 12px; color: var(--text-muted); }

/* ===== FILTERS ===== */
.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: end; }
.filter-group label { display: block; font-size: 10px; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 3px; }
.filter-group select, .filter-group input {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; background: var(--surface); color: var(--text); min-width: 140px;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 6px; font-size: 12px;
  font-weight: 500; border: none; cursor: pointer;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-hover); color: var(--text); }
.btn-sm { padding: 4px 8px; font-size: 11px; }

/* ===== MODAL ===== */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.modal-content {
  position: relative; background: var(--surface); border-radius: 12px;
  width: 90%; max-width: 650px; max-height: 80vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border);
}
.modal-content.modal-wide { max-width: 800px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-header h2 { font-size: 16px; }
.modal-close { border: none; background: none; cursor: pointer; font-size: 16px; color: var(--text-muted); }
.modal-body { padding: 16px 18px; }
.detail-row { display: flex; padding: 6px 0; border-bottom: 1px solid rgba(51,65,85,0.4); }
.detail-label { width: 130px; font-size: 11px; color: #64748b; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; flex-shrink: 0; }
.detail-value { flex: 1; font-size: 13px; }

.loading-spinner { text-align: center; padding: 24px; color: var(--text-muted); font-size: 13px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1400px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } .dashboard-3col { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .sidebar { display: none; } .pipeline-board { grid-template-columns: 1fr 1fr; } }
