/* ============================================
   RingerIQ Design System
   Direction: Data & Analysis + Sophistication
   Foundation: Cool slate, indigo accent
   ============================================ */

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

:root {
  /* Color System */
  --bg-base: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f8fafc;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --bg-sidebar-active: rgba(99, 102, 241, 0.15);

  /* Text Hierarchy */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-faint: #cbd5e1;
  --text-inverse: #f8fafc;
  --text-sidebar: #94a3b8;
  --text-sidebar-active: #ffffff;

  /* Accent */
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: #eef2ff;
  --accent-text: #ffffff;

  /* Semantic */
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-text: #065f46;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-text: #92400e;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-text: #991b1b;
  --info: #0284c7;
  --info-bg: #f0f9ff;
  --info-text: #075985;

  /* Borders */
  --border: #e2e8f0;
  --border-subtle: #f1f5f9;
  --border-strong: #cbd5e1;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.08);

  /* Spacing (4px grid) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, ui-monospace, 'Cascadia Code', 'Fira Code', Menlo, monospace;
  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 13px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 24px;
  --text-3xl: 32px;

  /* Layout */
  --sidebar-width: 220px;
  --sidebar-collapsed: 60px;
  --header-height: 56px;

  /* Transitions */
  --ease: cubic-bezier(0.25, 1, 0.5, 1);
  --duration: 150ms;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-base);
  min-height: 100vh;
}

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

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

/* --- App Layout --- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.2s var(--ease);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand img {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
}

.sidebar-brand span {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-inverse);
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: var(--sp-3) var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  color: var(--text-sidebar);
  font-size: var(--text-base);
  font-weight: 500;
  transition: all var(--duration) var(--ease);
  text-decoration: none;
}

.sidebar-nav a:hover {
  color: var(--text-sidebar-active);
  background: var(--bg-sidebar-hover);
}

.sidebar-nav a.active {
  color: var(--text-sidebar-active);
  background: var(--bg-sidebar-active);
}

.sidebar-nav a svg,
.sidebar-nav a .nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.7;
  flex-shrink: 0;
}

.sidebar-nav a.active svg,
.sidebar-nav a.active .nav-icon {
  opacity: 1;
}

.sidebar-section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
}

.sidebar-footer {
  padding: var(--sp-4);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  color: var(--text-sidebar);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background var(--duration) var(--ease);
}

.sidebar-user:hover {
  background: var(--bg-sidebar-hover);
}

.sidebar-user .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: var(--text-xs);
  font-weight: 600;
  flex-shrink: 0;
}

.sidebar-version {
  font-size: var(--text-xs);
  color: rgba(148, 163, 184, 0.5);
  padding: var(--sp-2) var(--sp-3) 0;
}

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

.page-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: var(--sp-4) var(--sp-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-header h1 {
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.page-header h1 small {
  font-size: var(--text-base);
  font-weight: 400;
  color: var(--text-muted);
  margin-left: var(--sp-2);
}

.page-body {
  flex: 1;
  padding: var(--sp-6);
}

/* --- Cards --- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-body {
  padding: var(--sp-5);
}

.card-body.flush {
  padding: 0;
}

/* --- Stat Cards --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.stat-card .stat-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card .stat-value {
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

.stat-card .stat-detail {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Stat card accent stripe */
.stat-card.accent-indigo { border-top: 3px solid var(--accent); }
.stat-card.accent-green { border-top: 3px solid var(--success); }
.stat-card.accent-amber { border-top: 3px solid var(--warning); }
.stat-card.accent-red { border-top: 3px solid var(--danger); }

/* --- Tables --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

.data-table thead {
  position: sticky;
  top: var(--header-height);
  z-index: 10;
}

.data-table th {
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--duration) var(--ease);
}

.data-table tbody tr:hover {
  background: var(--bg-surface-hover);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* Data cells */
.cell-mono {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.cell-primary {
  color: var(--text-primary);
  font-weight: 500;
}

.cell-link {
  color: var(--accent);
  font-weight: 500;
}

.cell-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.cell-truncate {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-nowrap {
  white-space: nowrap;
}

.cell-caller {
  white-space: nowrap;
}

.cell-contact-name {
  display: block;
  font-weight: 500;
}

.cell-phone-sub {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.cell-phone-only {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-positive {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge-negative {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.badge-neutral {
  background: var(--bg-base);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info-text);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.badge-accent {
  background: var(--accent-light);
  color: var(--accent);
}

/* Call type badges */
.badge-type {
  background: var(--bg-base);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  font-weight: 500;
  text-transform: capitalize;
}

/* Direction badges */
.badge-inbound {
  background: var(--info-bg);
  color: var(--info-text);
}

.badge-outbound {
  background: var(--accent-light);
  color: var(--accent);
}

/* Status badges */
.badge-answered {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge-missed {
  background: var(--danger-bg);
  color: var(--danger-text);
}

/* --- Forms --- */
.form-group {
  margin-bottom: var(--sp-4);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--sp-1);
}

.form-input,
.form-select {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-md);
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--duration) var(--ease);
}

.form-input:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-input::placeholder {
  color: var(--text-faint);
}

/* Inline filters */
.filter-bar {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}

.filter-bar .form-input,
.filter-bar .form-select {
  width: auto;
  min-width: 160px;
}

.filter-bar .form-input[type="search"] {
  min-width: 240px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-base);
  font-weight: 500;
  font-family: var(--font-sans);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
  line-height: 1.5;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.btn-sm {
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--text-sm);
}

/* --- Detail Page --- */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.detail-section {
  margin-bottom: var(--sp-6);
}

.detail-dl {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: var(--sp-2) var(--sp-4);
  font-size: var(--text-base);
}

.detail-dl dt {
  font-weight: 500;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.detail-dl dd {
  color: var(--text-primary);
}

.detail-dl dd.mono {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

/* Transcript */
.transcript-block {
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 500px;
  overflow-y: auto;
  padding: var(--sp-4);
  background: var(--bg-base);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
}

/* --- Pagination Bar --- */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: var(--sp-3);
}

.pagination-bar .page-info {
  color: var(--text-muted);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.pagination-bar .page-numbers {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 var(--sp-2);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: all var(--duration) var(--ease);
  cursor: pointer;
}

.page-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.page-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.page-ellipsis {
  padding: 0 var(--sp-1);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.per-page {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.per-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 var(--sp-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  text-decoration: none;
  transition: all var(--duration) var(--ease);
}

.per-page-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.per-page-btn.active {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

/* Legacy pagination (keep for partials) */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4);
  justify-content: center;
}

.pagination a,
.pagination span {
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
}

/* --- Breadcrumbs --- */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--sp-5);
}

.breadcrumbs a {
  color: var(--text-muted);
}

.breadcrumbs a:hover {
  color: var(--accent);
}

.breadcrumbs .separator {
  color: var(--text-faint);
}

/* --- Login Page --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  padding: var(--sp-4);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.login-header {
  padding: var(--sp-8) var(--sp-6) var(--sp-6);
  text-align: center;
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-surface-hover) 100%);
}

.login-header img {
  width: 48px;
  height: 48px;
  margin-bottom: var(--sp-3);
}

.login-header h1 {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: var(--sp-1);
}

.login-header p {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.login-body {
  padding: var(--sp-6);
}

.login-body .form-group {
  margin-bottom: var(--sp-4);
}

.login-body .btn-primary {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-md);
  margin-top: var(--sp-2);
}

/* --- Alerts --- */
.alert {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-bottom: var(--sp-4);
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid rgba(220, 38, 38, 0.15);
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid rgba(5, 150, 105, 0.15);
}

/* --- Empty States --- */
.empty-state {
  text-align: center;
  padding: var(--sp-12) var(--sp-6);
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: var(--sp-4);
  opacity: 0.3;
}

.empty-state p {
  font-size: var(--text-md);
}

/* --- Utility --- */
.text-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--text-primary); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }

.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }

/* --- Mobile Hamburger --- */
.mobile-toggle {
  display: none;
  position: fixed;
  top: var(--sp-3);
  left: var(--sp-3);
  z-index: 200;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--bg-sidebar);
  color: var(--text-inverse);
  border: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .mobile-toggle {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
  }

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

  .mobile-overlay.open {
    display: block;
  }

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

  .page-header {
    padding-left: 56px;
  }

  .page-body {
    padding: var(--sp-4);
  }

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

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

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar .form-input,
  .filter-bar .form-select {
    width: 100%;
    min-width: unset;
  }

  .data-table {
    font-size: var(--text-sm);
  }

  .data-table th,
  .data-table td {
    padding: var(--sp-2) var(--sp-3);
  }

  .cell-truncate {
    max-width: 150px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .pagination-bar {
    flex-direction: column;
    align-items: center;
  }
}

/* --- Charts Grid --- */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.chart-container {
  position: relative;
  height: 260px;
  padding: var(--sp-4);
}

@media (max-width: 768px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Enhanced Filter Bar --- */
.filter-row {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
}

.filter-row .form-input,
.filter-row .form-select {
  width: auto;
  min-width: 140px;
}

.filter-row .form-input[type="search"] {
  min-width: 240px;
  flex: 1;
}

.filter-row .form-input[type="date"] {
  min-width: 140px;
}

.filter-row-more {
  display: none;
  margin-top: var(--sp-2);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-subtle);
}

.filter-row-more.show {
  display: flex;
}

@media (max-width: 768px) {
  .filter-row {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-row .form-input,
  .filter-row .form-select {
    width: 100%;
    min-width: unset;
  }
}

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  top: var(--sp-4);
  right: var(--sp-4);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  max-width: 360px;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-3) var(--sp-4);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  animation: toastIn 200ms ease-out;
  transition: all 300ms var(--ease);
}

.toast-call {
  border-left: 3px solid var(--accent);
}

.toast-exit {
  opacity: 0;
  transform: translateX(100%);
}

.toast-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.toast-header strong {
  flex: 1;
  font-size: var(--text-base);
  color: var(--text-primary);
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-lg);
  padding: 0;
  line-height: 1;
}

.toast-close:hover {
  color: var(--text-primary);
}

.toast-dir {
  font-size: var(--text-sm);
}

.toast-body {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* --- WebSocket Status Indicator --- */
.ws-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: var(--sp-2);
  background: var(--text-muted);
  vertical-align: middle;
}

.ws-connected {
  background: var(--success);
}

.ws-reconnecting {
  background: var(--warning);
  animation: wsPulse 1.5s ease-in-out infinite;
}

.ws-disconnected {
  background: var(--danger);
}

@keyframes wsPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* --- Call Detail Enhancements --- */

/* PCI Banner */
.alert-pci {
  background: #fef3cd;
  border: 1px solid #ffc107;
  border-radius: var(--radius-lg);
  padding: var(--sp-3) var(--sp-4);
  color: #856404;
  margin-bottom: var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.alert-pci::before {
  content: "\00AB\00BB";
  color: #dc3545;
  font-weight: 700;
}

/* Warning alert */
.alert-warning {
  background: #fff3cd;
  border-left: 3px solid #ffc107;
  border-radius: var(--radius-md);
  padding: var(--sp-3);
  color: #664d03;
}
.alert-warning strong {
  color: #dc3545;
  text-transform: uppercase;
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
}

/* Two-column detail layout */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.detail-left, .detail-right {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
}

/* Caller History */
.history-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
  text-align: center;
  margin-bottom: var(--sp-4);
}
.history-stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.history-stat-value {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
}
.history-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--sp-2);
}
.history-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 300px;
  overflow-y: auto;
}
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-2) var(--sp-3);
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--border);
  transition: background 150ms;
}
.history-item:hover {
  background: var(--bg-surface-hover);
}
.history-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: var(--text-sm);
}

/* Analysis section */
.analysis-section { margin-bottom: var(--sp-3); }
.analysis-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--sp-2);
}
.analysis-content {
  background: var(--bg-base);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
}

/* Products table header */
.products-header {
  color: var(--danger);
  text-transform: uppercase;
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
}

/* Fraud Detection Card */
.fraud-card {
  border: none;
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.fraud-high {
  background: #dc3545;
  color: white;
}
.fraud-medium {
  background: #fd7e14;
  color: white;
}
.fraud-header {
  background: rgba(0,0,0,0.15) !important;
  color: white !important;
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.fraud-header::before { content: "\26A0"; }
.fraud-display {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}
.fraud-score {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
}
.fraud-bar-container {
  flex: 1;
  background: rgba(255,255,255,0.25);
  border-radius: var(--radius-full);
  height: 24px;
  overflow: hidden;
}
.fraud-bar {
  height: 100%;
  background: rgba(255,255,255,0.5);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: var(--sp-2);
  font-size: var(--text-sm);
  font-weight: 600;
}
.fraud-label {
  text-align: center;
  margin-top: var(--sp-2);
  font-size: var(--text-sm);
  opacity: 0.8;
}

/* Badge for extension number */
.badge-ext {
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

/* --- Products Table --- */
.products-table-wrap {
  padding: 0;
  overflow-x: auto;
}
.products-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.products-table th,
.products-table td {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}
.products-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-base);
}
.products-table tbody tr:last-child td {
  border-bottom: none;
}

/* --- Messenger-style Transcript --- */
.chat-transcript {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4);
  max-height: 600px;
  overflow-y: auto;
  background: var(--bg-base);
}
.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}
.chat-msg.chat-staff {
  align-self: flex-start;
}
.chat-msg.chat-customer {
  align-self: flex-end;
}
.chat-msg.chat-unknown {
  align-self: flex-start;
}
.chat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 2px;
  padding: 0 var(--sp-2);
}
.chat-customer .chat-label {
  text-align: right;
}
.chat-bubble {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  line-height: 1.6;
  word-wrap: break-word;
}
.chat-staff .chat-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--radius-sm);
}
.chat-customer .chat-bubble {
  background: var(--accent);
  color: var(--accent-text);
  border-bottom-right-radius: var(--radius-sm);
}
.chat-unknown .chat-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--radius-sm);
}

/* Analysis sections */
.analysis-section {
  margin-bottom: var(--sp-4);
}
.analysis-section:last-child {
  margin-bottom: 0;
}
.analysis-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  margin-bottom: var(--sp-1);
}
.analysis-content p {
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-secondary);
}
