/* ================================================================
   Phoenix CDR Platform - Design System
   Theme: Industrial Precision (Law Enforcement Command Center)
   ================================================================ */

/* ── Design Tokens ─────────────────────────────────────────────── */
:root {
  /* Core palette - Dark command center */
  --color-bg-primary: #0f1117;
  --color-bg-secondary: #161a23;
  --color-bg-tertiary: #1c2030;
  --color-bg-surface: #1e2235;
  --color-bg-elevated: #252a3a;
  --color-bg-hover: #2a3045;
  --color-bg-content: #f8f9fb;

  /* Accent */
  --color-accent: #6366f1;
  --color-accent-hover: #818cf8;
  --color-accent-muted: rgba(99, 102, 241, 0.15);

  /* Status colors - precise, high contrast */
  --color-critical: #ef4444;
  --color-warning: #f59e0b;
  --color-success: #10b981;
  --color-info: #3b82f6;
  --color-neutral: #6b7280;

  /* Text */
  --color-text-primary: #f1f5f9;
  --color-text-secondary: #94a3b8;
  --color-text-muted: #64748b;
  --color-text-dark: #1e293b;
  --color-text-on-accent: #ffffff;

  /* Borders */
  --color-border: rgba(255, 255, 255, 0.06);
  --color-border-light: #e2e8f0;
  --color-border-accent: rgba(99, 102, 241, 0.3);

  /* Sidebar */
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 64px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-display: 'Inter', sans-serif;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Google Fonts ──────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── Base Reset & Typography ───────────────────────────────────── */
body {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

/* Monospace for data identifiers */
.font-mono, .phone-number, .case-id, .nid-number, .session-id {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

/* ── Scrollbar Design ──────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.3);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.5);
}

/* ── Data Cards ────────────────────────────────────────────────── */
.data-card {
  background: white;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.data-card:hover {
  box-shadow: var(--shadow-md);
  border-color: rgba(99, 102, 241, 0.2);
}
.data-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #f1f5f9;
}
.data-card-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--color-text-dark);
  letter-spacing: -0.02em;
}

/* ── Status Badges (Law Enforcement precision) ─────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-critical { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.badge-warning  { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.badge-success  { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.badge-info     { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.badge-neutral  { background: #f9fafb; color: #6b7280; border: 1px solid #e5e7eb; }
.badge-active   { background: #eef2ff; color: #4f46e5; border: 1px solid #c7d2fe; }

/* Pulsing dot for live status */
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot-live {
  background: var(--color-success);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  50% { opacity: 0.8; box-shadow: 0 0 0 4px rgba(16, 185, 129, 0); }
}

/* ── Metric Cards ──────────────────────────────────────────────── */
.metric-card {
  background: white;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  position: relative;
  overflow: hidden;
}
.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  border-radius: 3px 0 0 3px;
}
.metric-card-blue::before    { background: #3b82f6; }
.metric-card-indigo::before  { background: #6366f1; }
.metric-card-green::before   { background: #10b981; }
.metric-card-red::before     { background: #ef4444; }
.metric-card-amber::before   { background: #f59e0b; }
.metric-card-purple::before  { background: #8b5cf6; }

.metric-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--color-text-dark);
  font-variant-numeric: tabular-nums;
}
.metric-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-neutral);
  margin-bottom: 0.25rem;
}

/* ── Navigation Bar ────────────────────────────────────────────── */
.nav-bar {
  background: var(--color-bg-primary);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 40;
}
.nav-brand {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, #818cf8, #6366f1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.nav-subtitle {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
  text-decoration: none;
}
.nav-link:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}
.nav-link-active {
  background: var(--color-accent-muted);
  color: var(--color-accent-hover);
}

/* ── Tabs ──────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--color-border-light);
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 0.625rem 1rem;
  border-bottom: 2px solid transparent;
  font-weight: 500;
  font-size: 0.8125rem;
  color: var(--color-neutral);
  transition: all var(--transition-fast);
  white-space: nowrap;
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.tab-btn:hover {
  color: var(--color-accent);
}
.tab-btn.active, .tab-btn-active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
  font-weight: 600;
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
  line-height: 1.4;
}
.btn-primary {
  background: var(--color-accent);
  color: white;
}
.btn-primary:hover {
  background: var(--color-accent-hover);
  box-shadow: var(--shadow-glow);
}
.btn-secondary {
  background: transparent;
  border: 1px solid var(--color-border-light);
  color: var(--color-text-dark);
}
.btn-secondary:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}
.btn-danger {
  background: var(--color-critical);
  color: white;
}
.btn-danger:hover {
  background: #dc2626;
}
.btn-sm {
  padding: 4px 10px;
  font-size: 0.75rem;
}
.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* ── Input Fields ──────────────────────────────────────────────── */
.input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--color-text-dark);
  background: white;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-muted);
}
.input-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-neutral);
  margin-bottom: 4px;
}

/* ── Tool Status Animations (MCP) ──────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.tool-status-card {
  animation: fadeInUp 0.3s ease-out;
  border-radius: var(--radius-lg);
  padding: 0.875rem 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid;
  position: relative;
  overflow: hidden;
}
.tool-status-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, currentColor, transparent);
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
  opacity: 0.3;
}

/* ── Chat Messages ─────────────────────────────────────────────── */
.chat-bubble-user {
  background: var(--color-accent);
  color: white;
  border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
  padding: 0.625rem 1rem;
  max-width: 85%;
  font-size: 0.875rem;
  line-height: 1.5;
}
.chat-bubble-assistant {
  background: white;
  color: var(--color-text-dark);
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
  padding: 0.625rem 1rem;
  max-width: 85%;
  font-size: 0.875rem;
  line-height: 1.5;
}
.chat-bubble-assistant code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  background: #f1f5f9;
  padding: 1px 4px;
  border-radius: 3px;
}

/* ── Section Dividers ──────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 1rem;
}
.section-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-text-dark);
  letter-spacing: -0.02em;
}
.section-line {
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}
.section-badge {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 4px;
  background: #f1f5f9;
  color: var(--color-neutral);
}

/* ── Tables ────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  font-size: 0.8125rem;
  border-collapse: separate;
  border-spacing: 0;
}
.data-table thead th {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-neutral);
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}
.data-table tbody td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  color: var(--color-text-dark);
}
.data-table tbody tr:hover {
  background: #f8fafc;
}

/* ── Workflow Progress ─────────────────────────────────────────── */
.workflow-step {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.5rem 0;
}
.workflow-step-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 700;
  flex-shrink: 0;
}
.workflow-step-active .workflow-step-dot {
  background: var(--color-accent);
  color: white;
  box-shadow: 0 0 0 4px var(--color-accent-muted);
}
.workflow-step-complete .workflow-step-dot {
  background: var(--color-success);
  color: white;
}
.workflow-step-pending .workflow-step-dot {
  background: #e2e8f0;
  color: var(--color-neutral);
}

/* ── Utility Classes ───────────────────────────────────────────── */
.text-mono { font-family: var(--font-mono); }
.text-2xs { font-size: 0.625rem; }
.gap-tight { gap: 4px; }
.truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ================================================================
   cmd-main Global Overrides — Transform old Tailwind cards to dense style
   These override the scattered bg-white/rounded-lg/shadow-md/p-6 patterns
   inside the main content area without touching element IDs.
   ================================================================ */

/* Compact ALL cards inside main content */
.cmd-main-inner .bg-white.rounded-lg.shadow-md,
.cmd-main-inner .bg-white.rounded-lg.shadow-sm,
.cmd-main-inner .bg-white.border.border-gray-200.rounded-lg {
  border-radius: var(--radius-sm) !important;
  box-shadow: none !important;
  border: 1px solid var(--color-border-light) !important;
  padding: 10px !important;
  margin-bottom: 8px !important;
}
/* Remove excessive padding from p-6, p-4 cards */
.cmd-main-inner .p-6 { padding: 10px !important; }
.cmd-main-inner .p-4 { padding: 8px !important; }
.cmd-main-inner .mb-6 { margin-bottom: 8px !important; }
.cmd-main-inner .mb-4 { margin-bottom: 6px !important; }
.cmd-main-inner .gap-6 { gap: 8px !important; }
.cmd-main-inner .gap-4 { gap: 6px !important; }
.cmd-main-inner .space-y-6 > * + * { margin-top: 8px !important; }
.cmd-main-inner .space-y-3 > * + * { margin-top: 4px !important; }

/* Compact text sizes inside main */
.cmd-main-inner h3 { font-size: 13px !important; font-weight: 700 !important; margin-bottom: 6px !important; }
.cmd-main-inner .text-xl { font-size: 14px !important; }
.cmd-main-inner .text-lg { font-size: 13px !important; }
.cmd-main-inner .text-3xl { font-size: 22px !important; }
.cmd-main-inner .text-2xl { font-size: 18px !important; }

/* Compact buttons inside main */
.cmd-main-inner button.bg-red-600,
.cmd-main-inner button.bg-green-600,
.cmd-main-inner button.bg-blue-600,
.cmd-main-inner button.bg-indigo-600,
.cmd-main-inner button.bg-purple-600,
.cmd-main-inner button.bg-orange-500,
.cmd-main-inner button.bg-emerald-600,
.cmd-main-inner button.bg-cyan-600 {
  padding: 6px 14px !important;
  font-size: 12px !important;
  border-radius: var(--radius-sm) !important;
}

/* Compact form elements */
.cmd-main-inner input[type="text"],
.cmd-main-inner input[type="date"],
.cmd-main-inner input[type="file"],
.cmd-main-inner select,
.cmd-main-inner textarea {
  font-size: 12px !important;
  padding: 5px 8px !important;
  border-radius: var(--radius-sm) !important;
}

/* Gradient headers → flat dense headers */
.cmd-main-inner [class*="bg-gradient-to"] {
  background: #f8fafc !important;
  border: 1px solid var(--color-border-light) !important;
  border-radius: var(--radius-sm) !important;
  padding: 10px !important;
}

/* Tab content panel — remove old shadow/border patterns */
.cmd-main-inner .tab-content { padding: 0 !important; }
.cmd-main-inner .bg-white.rounded-lg.shadow-md.mb-6 > .border-b { display: none !important; } /* hide old tab bar */
.cmd-main-inner .bg-white.rounded-lg.shadow-sm.mb-4 { border: none !important; box-shadow: none !important; padding: 0 !important; }

/* Metric cards — already styled, just ensure spacing */
.cmd-main-inner .metric-card {
  padding: 8px 12px !important;
  margin-bottom: 0 !important;
}
.cmd-main-inner .metric-value { font-size: 20px !important; }
.cmd-main-inner .metric-label { font-size: 9px !important; }

/* Map containers — ensure they fill width */
.cmd-main-inner [id*="map"], .cmd-main-inner [id*="Map"] {
  border-radius: var(--radius-sm) !important;
}

/* Collapsible details — compact */
.cmd-main-inner details > summary {
  padding: 8px 10px !important;
  font-size: 12px !important;
}
.cmd-main-inner details > summary .data-card-title { font-size: 12px !important; }

/* ================================================================
   Dense Command Center Components
   Compact, data-dense UI for law enforcement forensic analysis
   ================================================================ */

/* ── Section Header (Dense) ──────────────────────────────────── */
.sec-header {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 0; margin-bottom: 8px;
  border-bottom: 1px solid var(--color-border-light);
}
.sec-header-icon {
  width: 22px; height: 22px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: white; background: var(--color-accent); flex-shrink: 0;
}
.sec-header-title { font-size: 12px; font-weight: 700; color: var(--color-text-dark); letter-spacing: -0.02em; white-space: nowrap; }
.sec-header-count {
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px;
  background: var(--color-accent-muted); color: var(--color-accent);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
.sec-header-spacer { flex: 1; }
.sec-header-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

/* ── Dense Data Table ─────────────────────────────────────────── */
.dense-table-wrap { border: 1px solid var(--color-border-light); border-radius: var(--radius-sm); overflow: hidden; background: white; }
.dense-table-scroll { overflow-x: auto; overflow-y: auto; max-height: 480px; }
.dense-table { width: 100%; font-size: 12px; border-collapse: collapse; line-height: 1.3; }
.dense-table thead th {
  position: sticky; top: 0; z-index: 2; background: #f1f5f9;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--color-neutral); padding: 5px 8px; text-align: left;
  border-bottom: 2px solid #e2e8f0; white-space: nowrap; cursor: pointer; user-select: none;
}
.dense-table thead th:hover { background: #e2e8f0; color: var(--color-text-dark); }
.dense-table thead th .sort-icon { font-size: 8px; margin-left: 3px; opacity: 0.4; }
.dense-table thead th.sorted-asc .sort-icon,
.dense-table thead th.sorted-desc .sort-icon { opacity: 1; color: var(--color-accent); }
.dense-table tbody td {
  padding: 4px 8px; border-bottom: 1px solid #f1f5f9; color: var(--color-text-dark);
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dense-table tbody tr:nth-child(even) { background: #fafbfc; }
.dense-table tbody tr:hover { background: #eef2ff; }
.dense-table .cell-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 11px; }
.dense-table-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px; border-top: 1px solid var(--color-border-light); background: #f8fafc;
  font-size: 11px; color: var(--color-neutral); flex-wrap: wrap; gap: 6px;
}
.dense-table-footer .pagination { display: flex; align-items: center; gap: 2px; }
.dense-table-footer .pagination button {
  min-width: 24px; height: 24px; padding: 0 4px;
  border: 1px solid #e2e8f0; border-radius: 4px; background: white;
  font-size: 11px; font-weight: 500; color: var(--color-text-dark);
  cursor: pointer; transition: all var(--transition-fast);
}
.dense-table-footer .pagination button:hover { background: #eef2ff; border-color: var(--color-accent); }
.dense-table-footer .pagination button.active { background: var(--color-accent); color: white; border-color: var(--color-accent); }
.dense-table-footer .pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Stat Pill Row ────────────────────────────────────────────── */
.stat-pill-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px 0; }
.stat-pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 600; background: #f1f5f9; color: var(--color-text-dark);
  border: 1px solid #e2e8f0; white-space: nowrap;
}
.stat-pill-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--color-accent); font-weight: 700; }
.stat-pill-divider { width: 1px; height: 14px; background: #e2e8f0; flex-shrink: 0; }
.stat-pill-accent { background: var(--color-accent-muted); border-color: rgba(99,102,241,0.2); }
.stat-pill-red { background: #fef2f2; border-color: #fecaca; }
.stat-pill-green { background: #f0fdf4; border-color: #bbf7d0; }

/* ── Alert Card (Anomaly) ─────────────────────────────────────── */
.alert-card { display: flex; align-items: stretch; background: white; border: 1px solid var(--color-border-light); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 6px; transition: box-shadow var(--transition-fast); }
.alert-card:hover { box-shadow: var(--shadow-md); }
.alert-card-severity { width: 4px; flex-shrink: 0; }
.alert-card-severity-critical { background: var(--color-critical); }
.alert-card-severity-warning { background: var(--color-warning); }
.alert-card-severity-info { background: var(--color-info); }
.alert-card-severity-low { background: var(--color-success); }
.alert-card-body { flex: 1; padding: 6px 10px; min-width: 0; }
.alert-card-header { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.alert-card-type { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.alert-card-type-critical { color: var(--color-critical); }
.alert-card-type-warning { color: var(--color-warning); }
.alert-card-type-info { color: var(--color-info); }
.alert-card-title { font-size: 12px; font-weight: 600; color: var(--color-text-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-card-desc { font-size: 11px; color: var(--color-neutral); line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-card-meta { display: flex; align-items: center; gap: 8px; margin-top: 3px; font-size: 10px; color: var(--color-text-muted); font-family: var(--font-mono); }

/* ── Chart Container ──────────────────────────────────────────── */
.chart-wrap { background: white; border: 1px solid var(--color-border-light); border-radius: var(--radius-sm); overflow: hidden; display: flex; flex-direction: column; }
.chart-wrap-header { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; border-bottom: 1px solid #f1f5f9; background: #fafbfc; }
.chart-wrap-title { font-size: 11px; font-weight: 700; color: var(--color-text-dark); display: flex; align-items: center; gap: 5px; }
.chart-wrap-body { flex: 1; padding: 8px; min-height: 180px; position: relative; }
.chart-wrap-body canvas { width: 100% !important; max-height: 240px; }

/* ── Map Container ────────────────────────────────────────────── */
.map-wrap { background: white; border: 1px solid var(--color-border-light); border-radius: var(--radius-sm); overflow: hidden; position: relative; }
.map-wrap-header { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; border-bottom: 1px solid #f1f5f9; background: #fafbfc; position: relative; z-index: 5; }
.map-wrap-title { font-size: 11px; font-weight: 700; color: var(--color-text-dark); display: flex; align-items: center; gap: 5px; }
.map-wrap-body { height: 400px; position: relative; }
.map-wrap-legend { position: absolute; bottom: 8px; left: 8px; z-index: 10; display: flex; gap: 8px; padding: 4px 8px; background: rgba(255,255,255,0.92); border-radius: 4px; font-size: 10px; font-weight: 500; backdrop-filter: blur(4px); }

/* ── Contact Card (Compact Row) ───────────────────────────────── */
.contact-row { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-bottom: 1px solid #f1f5f9; transition: background var(--transition-fast); cursor: pointer; }
.contact-row:hover { background: #eef2ff; }
.contact-row:last-child { border-bottom: none; }
.contact-row-avatar { width: 28px; height: 28px; border-radius: 50%; background: #e2e8f0; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; color: var(--color-neutral); flex-shrink: 0; overflow: hidden; }
.contact-row-avatar img { width: 100%; height: 100%; object-fit: cover; }
.contact-row-info { flex: 1; min-width: 0; }
.contact-row-name { font-size: 12px; font-weight: 600; color: var(--color-text-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-row-phone { font-size: 11px; font-family: var(--font-mono); color: var(--color-text-muted); }
.contact-row-stats { display: flex; align-items: center; gap: 6px; flex-shrink: 0; font-size: 10px; font-weight: 600; color: var(--color-neutral); }
.contact-row-stat { display: flex; align-items: center; gap: 2px; }

/* ── Action Toolbar ───────────────────────────────────────────── */
.action-toolbar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: white; border: 1px solid var(--color-border-light); border-radius: var(--radius-sm); margin-bottom: 8px; flex-wrap: wrap; }
.action-toolbar-group { display: flex; align-items: center; gap: 4px; }
.action-toolbar-divider { width: 1px; height: 20px; background: #e2e8f0; margin: 0 4px; flex-shrink: 0; }
.action-toolbar-search { padding: 4px 8px; border: 1px solid #e2e8f0; border-radius: 4px; font-size: 11px; background: #f8fafc; min-width: 140px; color: var(--color-text-dark); }
.action-toolbar-search:focus { outline: none; border-color: var(--color-accent); background: white; }
.action-toolbar-select { padding: 4px 22px 4px 8px; border: 1px solid #e2e8f0; border-radius: 4px; font-size: 11px; font-weight: 500; background: white; appearance: none; color: var(--color-text-dark); cursor: pointer; }

/* ── Empty State ──────────────────────────────────────────────── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; text-align: center; }
.empty-state-icon { width: 48px; height: 48px; border-radius: 50%; background: #f1f5f9; display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--color-text-muted); margin-bottom: 10px; }
.empty-state-title { font-size: 13px; font-weight: 600; color: var(--color-text-dark); margin-bottom: 4px; }
.empty-state-desc { font-size: 11px; color: var(--color-neutral); max-width: 280px; line-height: 1.5; }
.empty-state-action { margin-top: 12px; }

/* ── Sidebar Badge ────────────────────────────────────────────── */
.sidebar-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  font-size: 9px; font-weight: 700; font-family: var(--font-mono);
  font-variant-numeric: tabular-nums; line-height: 1;
  background: var(--color-accent); color: white; margin-left: auto; flex-shrink: 0;
}
.sidebar-badge-critical { background: var(--color-critical); }
.sidebar-badge-warning { background: var(--color-warning); color: var(--color-text-dark); }
.sidebar-badge-muted { background: var(--color-bg-hover); color: var(--color-text-secondary); }
.cmd-sidebar:not(.expanded) .sidebar-badge {
  min-width: 6px; height: 6px; padding: 0; font-size: 0; border-radius: 50%;
  margin-left: 0; position: absolute; top: 6px; right: 10px;
}
.cmd-sidebar:not(.expanded) .cmd-sidebar-item { position: relative; }

/* ── Skeleton Structures ──────────────────────────────────────── */
.skel-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.skel-line { height: 10px; border-radius: 4px; }
.skel-circle { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; }

/* ── Loading Skeleton ──────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

/* ================================================================
   3-Panel Command Center Layout
   ================================================================ */

/* Container: fills viewport below navbar */
.cmd-layout {
  display: flex;
  height: calc(100vh - 56px); /* 56px = nav-bar height (h-14) */
  overflow: hidden;
}

/* ── Left Sidebar (collapsed: icons only, expanded: icons + labels) ── */
.cmd-sidebar {
  width: 56px;
  background: var(--color-bg-primary);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-normal);
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  z-index: 20;
  scrollbar-width: none;
}
.cmd-sidebar::-webkit-scrollbar { display: none; }
.cmd-sidebar.expanded { width: 220px; }

/* Sidebar toggle button */
.cmd-sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px 0;
  color: var(--color-text-muted);
  cursor: pointer;
  border: none;
  background: none;
  transition: color var(--transition-fast);
}
.cmd-sidebar-toggle:hover { color: var(--color-text-primary); }

/* Sidebar category header */
.cmd-sidebar-category {
  padding: 10px 16px 4px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
}
.cmd-sidebar:not(.expanded) .cmd-sidebar-category {
  font-size: 0;
  padding: 6px 0;
  text-align: center;
}
.cmd-sidebar:not(.expanded) .cmd-sidebar-category::after {
  content: '';
  display: block;
  width: 20px;
  height: 1px;
  background: var(--color-border);
  margin: 0 auto;
}

/* Sidebar nav item */
.cmd-sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: var(--color-text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 12.5px;
  font-weight: 500;
  transition: all var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  border-left: 3px solid transparent;
}
.cmd-sidebar:not(.expanded) .cmd-sidebar-item {
  justify-content: center;
  padding: 10px 0;
}
.cmd-sidebar:not(.expanded) .cmd-sidebar-item span { display: none; }
.cmd-sidebar-item:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}
.cmd-sidebar-item.active {
  background: var(--color-accent-muted);
  color: var(--color-accent-hover);
  border-left-color: var(--color-accent);
}
.cmd-sidebar-item i {
  width: 18px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
}

/* ── Main Content Area ─────────────────────────────────────────── */
.cmd-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: #f8f9fb;
  min-width: 0; /* prevent flex overflow */
}
.cmd-main-inner {
  padding: 12px 16px;
  max-width: 1400px;
}
/* Dense spacing for all grid layouts inside main */
.cmd-main-inner .grid { gap: 6px; }

/* ── Right Panel (AI Copilot) ──────────────────────────────────── */
.cmd-copilot {
  width: 420px;
  min-width: 420px;
  max-width: 420px;
  flex: 0 0 420px;
  background: white;
  border-left: 1px solid var(--color-border-light);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-normal), opacity var(--transition-normal);
  overflow: hidden;
}
.cmd-copilot.collapsed {
  width: 0;
  min-width: 0;
  max-width: 0;
  flex-basis: 0;
  opacity: 0;
  border: none;
}
.cmd-copilot-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.cmd-copilot-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
/* Chat panel layout fix — input always pinned at bottom */
#copilotPanelChat {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 !important;
  overflow: hidden !important;
  min-height: 0 !important;
}
#chatMessages {
  flex: 1 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
}
#chatMessages .ai-response {
  width: 100% !important;
  max-width: 100% !important;
  white-space: normal !important;
  overflow-wrap: anywhere;
  word-break: normal;
  font-size: 13px;
  line-height: 1.65;
}
#chatMessages .ai-response p {
  margin: 0.45rem 0;
}
#chatMessages .ai-response h2,
#chatMessages .ai-response h3,
#chatMessages .ai-response h4 {
  margin: 0.35rem 0 0.55rem;
  color: #111827;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
}
#chatMessages .ai-response h2 { font-size: 1rem; }
#chatMessages .ai-response h3 { font-size: 0.95rem; }
#chatMessages .ai-response h4 { font-size: 0.9rem; }
#chatMessages .ai-response strong {
  font-weight: 800;
  color: #111827;
}
#chatMessages .ai-response ul,
#chatMessages .ai-response ol {
  margin: 0.45rem 0 0.65rem 1.1rem;
  padding-left: 0.6rem;
}
#chatMessages .ai-response ul { list-style: disc; }
#chatMessages .ai-response ol { list-style: decimal; }
#chatMessages .ai-response li {
  margin: 0.22rem 0;
  padding-left: 0.1rem;
}
#chatMessages .ai-response code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: #eef2ff;
  color: #3730a3;
  padding: 1px 5px;
  border-radius: 5px;
}
#chatMessages .ai-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  margin: 0.65rem 0;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.08);
}
#chatMessages .ai-md-table {
  width: 100%;
  min-width: 520px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  line-height: 1.45;
}
#chatMessages .ai-md-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(135deg, #eef2ff, #f5f3ff);
  color: #312e81;
  font-weight: 800;
  padding: 9px 10px;
  border-bottom: 1px solid #c7d2fe;
  white-space: nowrap;
}
#chatMessages .ai-md-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #eef2ff;
  color: #1f2937;
  vertical-align: top;
  white-space: nowrap;
}
#chatMessages .ai-md-table tbody tr:nth-child(even) td {
  background: #f8fafc;
}
#chatMessages .ai-md-table tbody tr:hover td {
  background: #eef2ff;
}
.cmd-copilot-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--color-border-light);
  flex-shrink: 0;
}

/* Copilot toggle button (shown when collapsed) */
.cmd-copilot-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  color: white;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(99,102,241,0.4);
  z-index: 50;
  border: none;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.cmd-copilot-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(99,102,241,0.5);
}
.cmd-copilot.collapsed ~ .cmd-copilot-fab { display: flex; }

/* ── Case Context Bar (compact header inside main) ─────────────── */
.cmd-case-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: white;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.cmd-case-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--color-text-dark);
  letter-spacing: -0.02em;
}

/* ── Ingest Modal ──────────────────────────────────────────────── */
.cmd-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 23, 0.6);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cmd-modal {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 50px rgba(0,0,0,0.2);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}
.cmd-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

/* ── Tab Content (fills available space) ───────────────────────── */
.tab-content-panel {
  min-height: calc(100vh - 180px);
}

/* ── Responsive: collapse sidebar + copilot on small screens ──── */
@media (max-width: 1024px) {
  .cmd-sidebar { width: 0; overflow: hidden; }
  .cmd-copilot { width: 0; min-width: 0; max-width: 0; flex-basis: 0; opacity: 0; border: none; }
  .cmd-copilot-fab { display: flex !important; }
  .cmd-main-inner { padding: 12px 16px; }
}
@media (max-width: 768px) {
  .cmd-case-bar { flex-direction: column; align-items: flex-start; }
}

/* ── Print Styles (for reports) ────────────────────────────────── */
@media print {
  .nav-bar, .tab-bar, .btn, button, .cmd-sidebar, .cmd-copilot, .cmd-copilot-fab { display: none !important; }
  .cmd-main { overflow: visible; height: auto; }
  .data-card { break-inside: avoid; border: 1px solid #ccc; box-shadow: none; }
  body { background: white; font-size: 10pt; }
}
