/* ==========================================================================
   Botanika Bharat CloudPBX & Telephony Platform - Design System
   Modern Carrier-Grade Dark Glassmorphic Aesthetic
   ========================================================================== */

:root {
  --bg-primary: #0a0f1d;
  --bg-secondary: #111827;
  --bg-tertiary: #1f293d;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(31, 41, 61, 0.85);
  --bg-glass: rgba(255, 255, 255, 0.04);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(34, 197, 94, 0.4);
  --border-active: #22c55e;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-wa: #25d366;
  --accent-wa-glow: rgba(37, 211, 102, 0.25);
  --accent-sip: #0ea5e9;
  --accent-sip-glow: rgba(14, 165, 233, 0.25);
  --accent-int: #8b5cf6;
  --accent-int-glow: rgba(139, 92, 246, 0.25);
  --accent-warn: #f59e0b;
  --accent-danger: #ef4444;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(14, 165, 233, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(37, 211, 102, 0.08) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(139, 92, 246, 0.05) 0px, transparent 60%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(10, 15, 29, 0.5);
}
::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.3);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(56, 189, 248, 0.65);
}

/* App Layout */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
  z-index: 20;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
  width: 68px !important;
}
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-item .badge,
.sidebar.collapsed .sidebar-footer {
  display: none !important;
}
.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 18px 0;
}
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 12px 0;
}

.sidebar-header {
  padding: 20px 18px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
  background: var(--bg-secondary);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #22c55e, #0ea5e9);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  box-shadow: 0 0 15px rgba(34, 197, 94, 0.3);
}

.brand-text h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #fff;
  line-height: 1.2;
}

.brand-text span {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}

.nav-links {
  list-style: none;
  padding: 14px 8px 36px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  /* Firefox: Eye-visible cyan scroller on dark track */
  scrollbar-width: thin;
  scrollbar-color: #38bdf8 rgba(10, 15, 29, 0.75);
}

/* Big, proper, eye-visible scroller for the menu across PC, laptops, tablets, and mobile */
.nav-links::-webkit-scrollbar {
  width: 9px;
  display: block;
}
.nav-links::-webkit-scrollbar-track {
  background: rgba(10, 15, 29, 0.7);
  border-radius: 999px;
  margin: 6px 2px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.nav-links::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
  border-radius: 999px;
  min-height: 48px;
  border: 2px solid rgba(15, 23, 42, 0.9);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.45);
  transition: all 0.2s ease;
}
.nav-links::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #7dd3fc 0%, #38bdf8 100%);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.85);
  border-color: rgba(15, 23, 42, 0.6);
}
.nav-links::-webkit-scrollbar-thumb:active {
  background: #0284c7;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.nav-item:hover {
  background: var(--bg-tertiary);
  color: #fff;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(37, 211, 102, 0.15), rgba(14, 165, 233, 0.1));
  color: #fff;
  border-left: 3px solid var(--accent-wa);
  font-weight: 600;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-item.active svg {
  opacity: 1;
  color: var(--accent-wa);
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(10, 15, 29, 0.95);
  flex-shrink: 0;
  position: relative;
  z-index: 5;
  box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.35);
}

.agent-presence-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
}

.presence-avatar {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
}

.status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-tertiary);
}
.status-dot.online { background: #22c55e; box-shadow: 0 0 8px #22c55e; }
.status-dot.in_call { background: #ef4444; box-shadow: 0 0 8px #ef4444; }
.status-dot.away { background: #f59e0b; }
.status-dot.offline { background: #64748b; }

.presence-info {
  flex: 1;
  min-width: 0;
}
.presence-name {
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.presence-ext {
  font-size: 11px;
  color: var(--text-muted);
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* Header */
.topbar {
  height: 64px;
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
}

.sidebar-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
  transform: translateY(-1px);
}
.sidebar-toggle-btn:active {
  transform: translateY(0);
}

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

.page-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.2px;
}

.system-badge-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Three-Dot Expandable Menu */
.topbar-more-container {
  position: relative;
  display: none;
  align-items: center;
}

.topbar-more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}
.topbar-more-btn:hover, .topbar-more-btn.active {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
  transform: translateY(-1px);
}
.topbar-more-btn:active {
  transform: translateY(0);
}

.topbar-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 260px;
  background: rgba(17, 24, 39, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(16px);
  padding: 8px;
  z-index: 1060;
  display: none;
  flex-direction: column;
  gap: 4px;
  max-height: calc(100vh - 80px);
  max-height: calc(100dvh - 80px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #38bdf8 rgba(10, 15, 29, 0.75);
  animation: dropdownIn 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}
.topbar-dropdown-menu::-webkit-scrollbar {
  width: 6px;
}
.topbar-dropdown-menu::-webkit-scrollbar-thumb {
  background: #38bdf8;
  border-radius: 999px;
}
.topbar-dropdown-menu.show {
  display: flex !important;
}

@keyframes dropdownIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.dropdown-user-header {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 4px;
}
.dropdown-user-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dropdown-user-sub {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #e2e8f0;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all 0.15s ease;
}
.dropdown-item:hover {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
}
.dropdown-item.danger {
  color: #f87171;
}
.dropdown-item.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.dropdown-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 4px 0;
}

@media (max-width: 900px) {
  .desktop-topbar-actions {
    display: none !important;
  }
  .topbar-more-container {
    display: inline-flex !important;
  }
}

.sys-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}
.sys-badge.domain {
  color: #38bdf8;
  background: rgba(14, 165, 233, 0.1);
  border-color: rgba(14, 165, 233, 0.25);
}
.sys-badge.port {
  color: #4ade80;
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.25);
}
.sys-badge.active-pulse::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}

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

.btn-open-softphone {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  transition: var(--transition);
}
.btn-open-softphone:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

/* Page Containers */
.content-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
  animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards & Glass Containers */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

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

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Stat Grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.stat-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon.green { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.stat-icon.blue { background: rgba(14, 165, 233, 0.15); color: #0ea5e9; }
.stat-icon.purple { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.stat-icon.amber { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }

.stat-val {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}
.stat-lbl {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Table Design */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: rgba(10, 15, 29, 0.4);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.data-table th {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 16px;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
}
.badge-inbound { background: rgba(34, 197, 94, 0.15); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.3); }
.badge-outbound { background: rgba(14, 165, 233, 0.15); color: #38bdf8; border: 1px solid rgba(14, 165, 233, 0.3); }
.badge-internal { background: rgba(139, 92, 246, 0.15); color: #c084fc; border: 1px solid rgba(139, 92, 246, 0.3); }

.badge-whatsapp { background: rgba(37, 211, 102, 0.15); color: #25d366; }
.badge-voice { background: rgba(14, 165, 233, 0.15); color: #38bdf8; }

.mos-badge {
  font-weight: 700;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
}
.mos-high { background: rgba(34, 197, 94, 0.2); color: #4ade80; }
.mos-med { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.mos-low { background: rgba(239, 68, 68, 0.2); color: #f87171; }

/* Audio Waveform Player Controls */
.audio-cell-player {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}

.btn-play-mini {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-wa);
  color: #000;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition);
}
.btn-play-mini:hover {
  transform: scale(1.08);
  box-shadow: 0 0 12px var(--accent-wa-glow);
}

.mini-waveform-canvas {
  width: 110px;
  height: 24px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.audio-dur {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
}
.btn-primary:hover {
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}
.btn-success {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
}
.btn-success:hover {
  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.4);
}
.btn-outline {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-muted);
}
.btn-outline:hover {
  background: var(--bg-tertiary);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}
.btn-danger-outline {
  background: transparent;
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}
.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.15);
}

/* Forms & Inputs */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-input, .form-select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: #fff;
  font-size: 13.5px;
  font-family: inherit;
  transition: var(--transition);
}
.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.form-hint {
  font-size: 11px;
  color: var(--text-dim);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #334155;
  transition: .3s;
  border-radius: 34px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--accent-wa);
}
input:checked + .slider:before {
  transform: translateX(20px);
}

/* Modals */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.active {
  display: flex !important;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}
.modal-close:hover {
  color: #fff;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* Floating WebRTC Softphone Drawer */
.softphone-dock {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 360px;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(14, 165, 233, 0.15);
  z-index: 90;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.softphone-dock.minimized {
  transform: translateY(calc(100% - 56px));
}

.softphone-header {
  padding: 14px 18px;
  background: linear-gradient(90deg, #1e293b, #0f172a);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.softphone-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
}

.softphone-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dialer-display {
  background: #0a0f1d;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  text-align: right;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 20px;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 1px;
}

.dialer-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.keypad-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}
.keypad-btn:hover {
  background: #334155;
  border-color: rgba(255, 255, 255, 0.2);
}
.keypad-btn:active {
  transform: scale(0.96);
}

.call-action-row {
  display: flex;
  gap: 10px;
}

.btn-call {
  flex: 1;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.4);
}
.btn-call:hover {
  filter: brightness(1.1);
}

.btn-hangup {
  flex: 1;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}

.active-call-overlay {
  display: none;
  background: #0f172a;
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  border: 1px solid rgba(14, 165, 233, 0.3);
}

.active-call-timer {
  font-size: 26px;
  font-weight: 800;
  color: #38bdf8;
  font-variant-numeric: tabular-nums;
  margin: 6px 0;
}

.live-audio-meter {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin: 10px 0;
}
.live-audio-bar {
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, #22c55e, #38bdf8);
  transition: width 0.1s ease;
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar { width: 70px; }
  .sidebar-header .brand-text, .nav-item span, .sidebar-footer { display: none; }
  .topbar { padding: 0 16px; }
  .content-body { padding: 16px; }
  .softphone-dock { width: 320px; right: 12px; bottom: 12px; }
}

/* --- Branded Ringback & Automated Audio Pipeline Styling --- */
.audio-hero-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.98));
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.audio-hero-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #22c55e, #38bdf8, #a855f7);
}

.soundwave-container {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 28px;
  padding: 0 8px;
}

.soundwave-bar {
  width: 4px;
  height: 30%;
  background: #38bdf8;
  border-radius: 2px;
  animation: soundwave-pulse 1.2s infinite ease-in-out alternate;
}
.soundwave-bar:nth-child(2) { animation-delay: 0.15s; height: 60%; }
.soundwave-bar:nth-child(3) { animation-delay: 0.3s; height: 90%; background: #22c55e; }
.soundwave-bar:nth-child(4) { animation-delay: 0.45s; height: 50%; }
.soundwave-bar:nth-child(5) { animation-delay: 0.6s; height: 80%; background: #a855f7; }
.soundwave-bar:nth-child(6) { animation-delay: 0.75s; height: 40%; }
.soundwave-bar:nth-child(7) { animation-delay: 0.9s; height: 100%; background: #38bdf8; }
.soundwave-bar:nth-child(8) { animation-delay: 1.05s; height: 35%; }

@keyframes soundwave-pulse {
  0% { transform: scaleY(0.3); }
  100% { transform: scaleY(1); }
}

.pipeline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin: 20px 0;
}

.pipeline-step-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  position: relative;
  transition: all var(--transition-fast);
}

.pipeline-step-card:hover {
  border-color: rgba(56, 189, 248, 0.5);
  transform: translateY(-2px);
  background: rgba(30, 41, 59, 0.8);
}

.pipeline-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 8px;
}

.upload-dropzone {
  border: 2px dashed rgba(56, 189, 248, 0.4);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  text-align: center;
  background: rgba(15, 23, 42, 0.5);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
}

.code-snippet-dark {
  background: #020617;
  border: 1px solid #1e293b;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-family: 'Fira Code', monospace;
  font-size: 12px;
  color: #38bdf8;
  overflow-x: auto;
  line-height: 1.6;
}

/* --- Authentication Gateway Overlay & Modal --- */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 15, 29, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.25s ease-out;
}

.auth-overlay.hidden {
  display: none !important;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: #0f172a;
  border: 1px solid rgba(56, 189, 248, 0.25);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 30px rgba(56, 189, 248, 0.15);
  border-radius: 18px;
  padding: 34px 30px;
  position: relative;
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-brand-logo {
  font-size: 38px;
  margin-bottom: 8px;
  display: inline-block;
  animation: pulse 2s infinite ease-in-out;
}

.auth-header h2 {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
}

.auth-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.auth-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  margin-bottom: 16px;
  text-align: center;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 12px;
  font-size: 14px;
  opacity: 0.6;
  pointer-events: none;
}

.input-with-icon .form-input {
  padding-left: 36px;
  width: 100%;
}

.btn-toggle-eye {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  opacity: 0.7;
}

.btn-auth-submit {
  width: 100%;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  margin-top: 8px;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.3);
}

.quick-credentials {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.quick-cred-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.quick-cred-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cred-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cred-chip:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: #38bdf8;
  color: #fff;
}

.cred-chip.admin {
  border-color: rgba(234, 179, 8, 0.3);
  color: #fde047;
}

.cred-chip.admin:hover {
  background: rgba(234, 179, 8, 0.15);
  border-color: #eab308;
}

/* --- Authentication Gateway Overlay & Modal --- */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 15, 29, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.25s ease-out;
}

.auth-overlay.hidden {
  display: none !important;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: #0f172a;
  border: 1px solid rgba(56, 189, 248, 0.25);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 30px rgba(56, 189, 248, 0.15);
  border-radius: 18px;
  padding: 34px 30px;
  position: relative;
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-brand-logo {
  font-size: 38px;
  margin-bottom: 8px;
  display: inline-block;
}

.auth-header h2 {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
}

.auth-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.auth-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  margin-bottom: 16px;
  text-align: center;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 12px;
  font-size: 14px;
  opacity: 0.6;
  pointer-events: none;
}

.input-with-icon .form-input {
  padding-left: 36px;
  width: 100%;
}

.btn-toggle-eye {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  opacity: 0.7;
}

.btn-auth-submit {
  width: 100%;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  margin-top: 8px;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.3);
}

.quick-credentials {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.quick-cred-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.quick-cred-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cred-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cred-chip:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: #38bdf8;
  color: #fff;
}

.cred-chip.admin {
  border-color: rgba(234, 179, 8, 0.3);
  color: #fde047;
}

.cred-chip.admin:hover {
  background: rgba(234, 179, 8, 0.15);
  border-color: #eab308;
}

/* ==========================================================================
   Internal Team Directory - Filter Pills & Status Badges
   ========================================================================== */
.dir-pills-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dir-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.dir-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.dir-pill.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: #38bdf8;
  color: #fff;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

.dir-pill.pill-online.active {
  background: rgba(34, 197, 94, 0.15);
  border-color: #22c55e;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.25);
}

.dir-pill.pill-offline.active {
  background: rgba(148, 163, 184, 0.15);
  border-color: #94a3b8;
  box-shadow: 0 0 12px rgba(148, 163, 184, 0.25);
}

.dir-pill.pill-left.active {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.25);
}

.dir-pill-count {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 9999px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

.dir-pill.active .dir-pill-count {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* Status Badges */
.badge-status-online {
  background: rgba(34, 197, 94, 0.16);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-status-offline {
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.25);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
}

.badge-status-left {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: line-through;
}

/* Outbound Route Badges */
.badge-route-wa {
  background: rgba(37, 211, 102, 0.12);
  color: #25d366;
  border: 1px solid rgba(37, 211, 102, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-route-voice {
  background: rgba(14, 165, 233, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(14, 165, 233, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-route-inherit {
  background: rgba(168, 85, 247, 0.12);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
}

/* CDR Modal Tab Navigation */
.cdr-tabs-bar {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 16px;
  padding-bottom: 2px;
}

.cdr-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 2px solid transparent;
}

.cdr-tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.03);
}

.cdr-tab-btn.active {
  color: #38bdf8;
  border-bottom-color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
}

.cdr-log-entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  margin-bottom: 6px;
  font-family: 'Fira Code', monospace;
  font-size: 12px;
  border-left: 3px solid #38bdf8;
}

.cdr-log-entry.level-WARN { border-left-color: #fbbf24; }
.cdr-log-entry.level-ERROR { border-left-color: #f87171; }
.cdr-log-entry.level-INFO { border-left-color: #38bdf8; }

.cdr-log-time {
  color: #64748b;
  white-space: nowrap;
  font-size: 11px;
}

.cdr-log-event {
  color: #38bdf8;
  font-weight: 700;
  min-width: 140px;
}

.cdr-log-detail {
  color: #cbd5e1;
  flex: 1;
}


/* ============================================================
   ENTERPRISE RESPONSIVE CSS v9.0.0 — 100% All Screen Sizes
   ============================================================ */

/* Universal Responsive Base */
*, *::before, *::after {
  box-sizing: border-box;
}

.table-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

/* Overview Hero Banner */
.overview-hero-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.85) 0%, rgba(15, 23, 42, 0.95) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 20px 24px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(12px);
}
.overview-hero-content {
  flex: 1;
  min-width: 260px;
}
.overview-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #38bdf8;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.overview-hero-title {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  margin: 0 0 6px 0;
}
.overview-hero-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}
.overview-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.btn-hero-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  text-decoration: none;
}
.btn-hero-action:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(56, 189, 248, 0.4);
  transform: translateY(-1px);
  color: #38bdf8;
}
.btn-hero-action.primary {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.3);
}
.btn-hero-action.primary:hover {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.45);
  color: #fff;
}

/* Agent Workspace Launchpad */
.agent-workspace-card {
  background: linear-gradient(145deg, rgba(22, 30, 49, 0.8), rgba(15, 23, 42, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
.workspace-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.workspace-tile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
.workspace-tile:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.35);
  transform: translateY(-2px);
}
.workspace-tile-ico {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 20px;
  flex-shrink: 0;
}
.workspace-tile-text strong {
  display: block;
  font-size: 13.5px;
  color: #fff;
  margin-bottom: 3px;
}
.workspace-tile-text span {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Sidebar Backdrop for Mobile */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1040;
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

/* ── Mobile & Tablet: max-width 900px ── */
@media (max-width: 900px) {
  .sidebar {
    position: fixed !important;
    top: 0;
    bottom: 0;
    left: 0;
    width: 285px !important;
    max-width: 86vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }
  .sidebar.mobile-open {
    transform: translateX(0) !important;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.9);
  }
  .sidebar.mobile-open .brand-text,
  .sidebar.mobile-open .nav-item span,
  .sidebar.mobile-open .sidebar-footer {
    display: flex !important;
  }
  .sidebar .nav-links {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain;
    padding-bottom: max(60px, env(safe-area-inset-bottom, 32px));
  }
  .sidebar .nav-links::-webkit-scrollbar {
    width: 9px !important;
    display: block !important;
  }
  .sidebar .nav-links::-webkit-scrollbar-track {
    background: rgba(10, 15, 29, 0.85) !important;
    margin: 8px 2px;
  }
  .sidebar .nav-links::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%) !important;
    border-radius: 999px !important;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.6) !important;
  }
  .main-wrapper {
    width: 100% !important;
    margin-left: 0 !important;
  }
  .topbar {
    padding: 8px 14px;
    height: auto;
    min-height: 56px;
  }
  .topbar-left {
    gap: 10px;
  }
  .page-title {
    font-size: 15px;
    max-width: 240px;
  }
  .system-badge-group #hdrPortBadge,
  .system-badge-group #hdrTlsBadge {
    display: none !important;
  }
  .content-body {
    padding: 14px;
  }
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .softphone-dock {
    width: 320px;
    right: 12px;
    bottom: 12px;
  }
}

/* ── Small Mobile: max-width 640px ── */
@media (max-width: 640px) {
  .topbar {
    padding: 8px 10px;
  }
  .page-title {
    font-size: 13.5px;
    max-width: 160px;
  }
  .system-badge-group {
    display: none !important;
  }
  .topbar-right {
    gap: 6px !important;
  }
  #topUserName {
    display: none;
  }
  #topUserRole {
    display: none;
  }
  #topUserBadge {
    padding: 4px 8px !important;
  }
  #btnTopPermissions span:not(#hdrPermDot) {
    display: none;
  }
  #btnOpenSoftphoneHeader span:last-child {
    display: none;
  }
  .content-body {
    padding: 10px;
  }
  .overview-hero-card {
    padding: 16px;
    flex-direction: column;
    align-items: flex-start;
  }
  .overview-hero-actions {
    width: 100%;
  }
  .btn-hero-action {
    flex: 1;
    justify-content: center;
  }
  .stat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .stat-card {
    padding: 10px 12px;
  }
  .stat-val {
    font-size: 18px;
  }
  .stat-lbl {
    font-size: 10.5px;
  }
  .stat-icon {
    width: 32px;
    height: 32px;
    font-size: 15px;
  }
  .card-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 10px !important;
  }
  .card-header > div:last-child {
    width: 100%;
    justify-content: flex-start;
  }
  .softphone-dock {
    width: calc(100vw - 16px);
    right: 8px;
    left: 8px;
    bottom: 8px;
  }
  .form-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

/* ── Wide Screens: min-width 1200px ── */
@media (min-width: 1200px) {
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Summary stats in performance tab: responsive */
#perfSummaryGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 18px;
}
@media (max-width: 640px) {
  #perfSummaryGrid {
    grid-template-columns: repeat(2, 1fr);
    padding: 12px;
    gap: 8px;
  }
}

/* Deepgram keys grid */
#deepgramKeysGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

/* Active call overlay: always on top, mobile-safe */
#spActiveCallOverlay {
  z-index: 9999;
}


/* sidebar profile card: click opens profile + sign out */
.agent-presence-wrap { position: relative; }
.agent-presence-card { cursor: pointer; transition: border-color .15s, background .15s; }
.agent-presence-card:hover, .agent-presence-card:focus-visible { border-color: #38bdf8; outline: none; }
.presence-caret { color: var(--text-muted); font-size: 14px; transition: transform .15s; }
.agent-presence-wrap.open .presence-caret { transform: rotate(180deg); }
.agent-profile-pop { position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); background: var(--bg-secondary, #0f172a); border: 1px solid var(--border-subtle); border-radius: 12px; padding: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 50; min-width: 230px; }
.app-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.app-avatar { width: 42px; height: 42px; flex: none; font-size: 15px; }
.app-name { font-weight: 700; font-size: 14px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-sub { font-size: 11px; color: #38bdf8; font-weight: 700; letter-spacing: .04em; }
.app-rows { display: grid; gap: 6px; margin-bottom: 12px; font-size: 12px; }
.app-row { display: flex; justify-content: space-between; gap: 10px; }
.app-row span:first-child { color: var(--text-muted); }
.app-row span:last-child { color: #e2e8f0; text-align: right; overflow-wrap: anywhere; }
.app-logout { width: 100%; padding: 9px; border-radius: 8px; border: 1px solid rgba(239,68,68,.4); background: rgba(239,68,68,.1); color: #f87171; font-weight: 700; cursor: pointer; }
.app-logout:hover { background: rgba(239,68,68,.2); }

/* Instant Anti-Flicker Gate: Never render dashboard until session is verified */
html:not(.authed) .app-container,
html:not(.authed) .softphone-dock,
html:not(.authed) #softphoneDock,
body:not(.authed) .app-container,
body:not(.authed) .softphone-dock,
body:not(.authed) #softphoneDock {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

/* The login screen must always be visible and clickable when not authenticated */
html:not(.authed) .auth-overlay,
body:not(.authed) .auth-overlay {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Synchronous Role-based Navigation - prevents unauthorized menu flicker */
.nav-item[data-admin-only="true"] {
  display: none !important;
}
body.is-admin .nav-item[data-admin-only="true"] {
  display: flex !important;
}

/* Responsive Single-Line CDR Filter Bar */
.cdr-filter-bar {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 8px !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  scrollbar-width: thin;
  max-width: 100%;
}
.cdr-filter-bar::-webkit-scrollbar {
  height: 4px;
}
.cdr-filter-bar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}
.cdr-filter-bar > * {
  flex-shrink: 0 !important;
}
@media (max-width: 900px) {
  .cdr-card-header {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .cdr-filter-bar {
    width: 100% !important;
    padding-bottom: 6px !important;
  }
}




/* ==========================================================================
   Black Points & Performance
   ========================================================================== */
.nav-group { list-style: none; }
.nav-group-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--radius-md); color: var(--text-muted); font-size: 13.5px; font-weight: 500; cursor: pointer; user-select: none; transition: var(--transition); }
.nav-group-head:hover { background: var(--bg-tertiary); color: #fff; }
.nav-group-head svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav-group-head .nav-chev { margin-left: auto; width: 14px; height: 14px; transition: transform .2s; }
.nav-group.open .nav-chev { transform: rotate(180deg); }
.nav-group.has-active .nav-group-head { color: #fff; }
.nav-sub { display: none; list-style: none; margin: 2px 0 6px 18px; padding-left: 10px; border-left: 1px solid var(--border-subtle); }
.nav-group.open .nav-sub { display: block; }
.nav-sub .nav-item { padding: 8px 12px; font-size: 13px; }
.nav-badge { margin-left: auto; min-width: 18px; padding: 1px 6px; border-radius: 9px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
.nav-badge[hidden] { display: none; }
.sidebar.collapsed .nav-group-head span, .sidebar.collapsed .nav-sub { display: none; }

.bp-wrap { display: flex; flex-direction: column; gap: 14px; }
.bp-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; justify-content: space-between; padding: 16px 18px; border-radius: var(--radius-lg); background: linear-gradient(120deg, rgba(14,165,233,.14), rgba(139,92,246,.12)); border: 1px solid var(--border-subtle); }
.bp-hero h3 { font-size: 18px; margin-bottom: 2px; }
.bp-hero p { color: var(--text-muted); font-size: 12.5px; }
.bp-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(255,255,255,.07); border: 1px solid var(--border-subtle); white-space: nowrap; }
.bp-chip.ok { background: rgba(34,197,94,.15); color: #4ade80; border-color: rgba(34,197,94,.35); }
.bp-chip.warn { background: rgba(245,158,11,.15); color: #fbbf24; border-color: rgba(245,158,11,.35); }
.bp-chip.bad { background: rgba(239,68,68,.15); color: #f87171; border-color: rgba(239,68,68,.35); }
.bp-chip.info { background: rgba(14,165,233,.15); color: #38bdf8; border-color: rgba(14,165,233,.35); }
.bp-chip.dim { color: var(--text-muted); }
.bp-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.bp-kpi { padding: 14px 16px; border-radius: var(--radius-md); background: var(--bg-card); border: 1px solid var(--border-subtle); }
.bp-kpi small { color: var(--text-muted); font-size: 12px; display: block; }
.bp-kpi b { font-size: 28px; line-height: 1.2; }
.bp-kpi b i { font-style: normal; font-size: 15px; color: var(--text-muted); font-weight: 500; }
.bp-bar { height: 7px; border-radius: 4px; background: rgba(255,255,255,.08); overflow: hidden; margin-top: 8px; }
.bp-bar > span { display: block; height: 100%; border-radius: 4px; background: #22c55e; transition: width .5s; }
.bp-bar.warn > span { background: #f59e0b; } .bp-bar.bad > span { background: #ef4444; } .bp-bar.info > span { background: #0ea5e9; }
.bp-cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.bp-cat { padding: 14px; border-radius: var(--radius-md); background: var(--bg-card); border: 1px solid var(--border-subtle); cursor: pointer; transition: var(--transition); }
.bp-cat:hover { border-color: var(--border-focus); background: var(--bg-card-hover); }
.bp-cat.ex { border-color: rgba(239,68,68,.55); box-shadow: 0 0 0 1px rgba(239,68,68,.25) inset; }
.bp-cat-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.bp-code { font-weight: 800; font-size: 12px; padding: 2px 8px; border-radius: 6px; background: rgba(139,92,246,.2); color: #c4b5fd; }
.bp-cat h4 { font-size: 14px; }
.bp-cat .big { font-size: 26px; font-weight: 800; }
.bp-cat .big i { font-style: normal; font-size: 14px; color: var(--text-muted); font-weight: 500; }
.bp-cat p { color: var(--text-muted); font-size: 12px; margin-top: 8px; line-height: 1.45; }
.bp-alert { padding: 12px 14px; border-radius: var(--radius-md); background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.45); color: #fecaca; font-size: 13px; }
.bp-alert b { color: #fff; }
.bp-info { padding: 12px 14px; border-radius: var(--radius-md); background: rgba(14,165,233,.1); border: 1px solid rgba(14,165,233,.35); color: #bae6fd; font-size: 13px; }
.bp-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.bp-row > * { flex: 0 0 auto; }
.bp-row .grow { flex: 1 1 200px; }
.bp-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.bp-tabs button { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border-subtle); background: transparent; color: var(--text-muted); cursor: pointer; font-size: 12.5px; font-weight: 600; }
.bp-tabs button.on { background: rgba(34,197,94,.18); color: #4ade80; border-color: rgba(34,197,94,.45); }
.bp-st { padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; text-transform: capitalize; }
.bp-st.proposed { background: rgba(245,158,11,.18); color: #fbbf24; } .bp-st.approved { background: rgba(239,68,68,.18); color: #f87171; }
.bp-st.rejected, .bp-st.waived, .bp-st.voided, .bp-st.revoked { background: rgba(148,163,184,.18); color: #cbd5e1; } .bp-st.pending { background: rgba(245,158,11,.18); color: #fbbf24; }
.bp-st.active { background: rgba(34,197,94,.18); color: #4ade80; } .bp-st.leave-approved { background: rgba(34,197,94,.18); color: #4ade80; }
.bp-tbl .why { max-width: 680px; color: #e2e8f0; font-size: 12.5px; line-height: 1.45; }
.bp-tbl .why small { color: var(--text-muted); display: block; margin-top: 3px; }
.bp-v-table-wrap { margin-top: 8px; border-radius: 6px; overflow: hidden; border: 1px solid rgba(148, 163, 184, 0.2); }
.bp-v-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.bp-v-table th { background: rgba(30, 41, 59, 0.7); color: #94a3b8; font-weight: 600; padding: 5px 8px; border-bottom: 1px solid rgba(148, 163, 184, 0.2); text-align: left; }
.bp-v-table td { padding: 5px 8px; border-bottom: 1px solid rgba(148, 163, 184, 0.1); vertical-align: top; }
.bp-v-table tr:last-child td { border-bottom: none; }
.bp-v-table tr:hover { background: rgba(255, 255, 255, 0.03); }
.bp-note { margin-top: 5px; padding: 6px 8px; border-radius: 6px; background: rgba(14,165,233,.12); color: #bae6fd; font-size: 12px; }
.bp-acts { display: flex; flex-wrap: wrap; gap: 5px; }
.bp-acts button { padding: 4px 9px; font-size: 12px; }
.bp-medal { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; font-weight: 700; font-size: 13px; border: 1px solid transparent; }
.bp-medal.silver { background: linear-gradient(135deg, #cbd5e1, #94a3b8); color: #0f172a; }
.bp-medal.gold { background: linear-gradient(135deg, #fde68a, #f59e0b); color: #422006; }
.bp-medal.diamond { background: linear-gradient(135deg, #a5f3fc, #818cf8); color: #1e1b4b; }
.bp-medal small { font-weight: 600; opacity: .8; }
.bp-tiers { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.bp-tier { padding: 16px; border-radius: var(--radius-md); background: var(--bg-card); border: 1px solid var(--border-subtle); text-align: center; }
.bp-tier .bp-medal { font-size: 15px; padding: 10px 16px; }
.bp-tier p { margin-top: 8px; color: var(--text-muted); font-size: 12.5px; }
.bp-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.bp-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; align-items: end; }
.bp-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); }
.bp-form label.wide { grid-column: 1 / -1; }
.bp-form textarea { min-height: 70px; resize: vertical; }
.bp-spark { width: 100%; height: 90px; }
.bp-ov { position: fixed; inset: 0; background: rgba(2,6,23,.7); display: flex; align-items: center; justify-content: center; z-index: 3000; padding: 14px; }
.bp-box { width: min(760px, 100%); max-height: 90vh; overflow: auto; background: var(--bg-secondary); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.bp-box h3 { margin-bottom: 10px; }
.bp-box textarea { width: 100%; min-height: 90px; }
.bp-time { position: relative; margin-left: 10px; padding-left: 16px; border-left: 2px solid var(--border-subtle); }
.bp-time > div { margin-bottom: 12px; position: relative; font-size: 13px; }
.bp-time > div::before { content: ""; position: absolute; left: -22px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: #22c55e; }
.bp-time small { color: var(--text-muted); display: block; }
.bp-ok { color: #4ade80; } .bp-bad { color: #f87171; } .bp-warn { color: #fbbf24; }
.bp-cell { text-align: center; font-weight: 700; border-radius: 6px; padding: 3px 6px; }
.bp-cell.ok { background: rgba(34,197,94,.14); color: #4ade80; } .bp-cell.warn { background: rgba(245,158,11,.16); color: #fbbf24; } .bp-cell.bad { background: rgba(239,68,68,.2); color: #f87171; } .bp-cell.zero { color: var(--text-dim); }
.bp-live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.bp-live i { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 0 rgba(34,197,94,.7); animation: bpPulse 2s infinite; }
@keyframes bpPulse { 70% { box-shadow: 0 0 0 7px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }
@media (max-width: 760px) { .bp-tbl .why { max-width: none; } .bp-kpi b { font-size: 24px; } }

/* grouped sidebar: groups made only of admin pages are hidden for everyone else */
.nav-group[data-admin-only="true"] { display: none; }
body.is-admin .nav-group[data-admin-only="true"] { display: block; }
.nav-group + .nav-group, .nav-item + .nav-group, .nav-group + .nav-item { margin-top: 2px; }

/* filters and toolbars: always ONE line (scroll sideways on a phone), controls at their natural width */
.kb-toolbar, .rp-control-bar, .bp-filters { display: flex; flex-wrap: nowrap !important; gap: 8px; align-items: center; overflow-x: auto; scrollbar-width: none; }
.kb-toolbar::-webkit-scrollbar, .rp-control-bar::-webkit-scrollbar, .bp-filters::-webkit-scrollbar { display: none; }
.kb-toolbar > *, .rp-control-bar > *, .bp-filters > * { flex: 0 0 auto; }
.kb-toolbar .form-select, .kb-toolbar .form-input, .rp-control-bar .form-select, .rp-control-bar .form-input, .bp-filters .form-select, .bp-filters .form-input { width: auto; min-width: 120px; }
.kb-toolbar .kb-spacer, .bp-filters .grow { flex: 1 1 auto; min-width: 8px; }
.rp-control-bar > div { min-width: 0 !important; }
.bp-row .form-input, .bp-row .form-select { width: auto; }
.card-header > .bp-row { flex-wrap: nowrap; flex: 0 0 auto; }
.card-header > .bp-row .form-input { min-width: 130px; }
.bp-ev { margin-top: 3px; font-size: 12px; color: #cbd5e1; } .bp-ev s { color: #94a3b8; }

/* Black Points category cards: all six on ONE row on desktop, then 3 / 2 / 1 per row as the screen narrows */
.bp-cats { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.bp-cat { padding: 12px; min-width: 0; }
.bp-cat-top { flex-wrap: wrap; gap: 6px; align-items: flex-start; }
.bp-cat-top > span:first-child { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.bp-cat h4 { font-size: 12.5px; line-height: 1.25; margin: 0 !important; }
.bp-cat .big { font-size: 22px; }
.bp-cat .big i { font-size: 11.5px; display: block; }
.bp-cat p { font-size: 11.5px; }
.bp-cat .bp-chip { font-size: 11px; padding: 2px 8px; }
.bp-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1400px) { .bp-cats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .bp-cats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .bp-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .bp-cats, .bp-kpis { grid-template-columns: minmax(0, 1fr); } }

/* ---- responsive safety net (all pages) ---- */
html, body { max-width: 100%; overflow-x: hidden; }
.main-wrapper, .tab-pane, .card, .content-area { min-width: 0; max-width: 100%; }
img, video, canvas, svg { max-width: 100%; }
.table-wrapper, .rp-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.data-table { min-width: 560px; }
.card { box-sizing: border-box; }
.card-header { flex-wrap: wrap; gap: 10px; }
.bp-grid2, .bp-tiers { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.bp-box { width: min(760px, 100%); }
@media (max-width: 900px) {
  .card { padding: 14px; }
  .page-title { font-size: 16px; }
  .system-badge-group { display: none; }
  .bp-form { grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
  .bp-hero { padding: 12px; }
  .bp-ov { padding: 8px; }
  .bp-box { padding: 14px; max-height: 94vh; }
}
@media (max-width: 480px) {
  .data-table { font-size: 12px; }
  .btn { padding: 8px 10px; }
  .bp-acts button { padding: 6px 8px; }
}

/* shared date filter: one line */
.df { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; white-space: nowrap; }
.df .form-select, .df .form-input { width: auto; min-width: 0; }
.df .df-dates { display: none; align-items: center; gap: 6px; }
.df.df-range .df-dates { display: inline-flex; }
.df .df-to { color: var(--text-muted); font-size: 12px; }
.bp-pager-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 12px 4px 0; }
.data-table tfoot td { font-weight: 700; border-top: 1px solid var(--border-subtle); background: rgba(255,255,255,.03); }
.bp-rules { margin: 8px 0 0 18px; padding: 0; font-size: 13px; line-height: 1.55; color: #e2e8f0; } .bp-rules li { margin-bottom: 6px; }
.bp-tip { display: block; margin-top: 4px; max-width: 360px; white-space: normal; color: var(--text-muted); font-size: 11.5px; line-height: 1.4; }
.bp-chip.dim { color: var(--text-muted); }

/* KPI / summary cards: ONE row at every screen size - the cards share the width, and on a narrow screen the row scrolls sideways instead of wrapping */
#perfSummaryGrid, .rp-cards {
  display: grid !important;
  grid-auto-flow: column !important;
  grid-template-columns: none !important;
  grid-auto-columns: minmax(104px, 1fr) !important;
  gap: 10px !important;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 6px;
}
#perfSummaryGrid { padding: 14px 16px !important; }
#perfSummaryGrid > div { padding: 10px 8px !important; min-width: 0; }
#perfSummaryGrid > div > div:first-child { font-size: 18px !important; margin-bottom: 4px !important; }
#perfSummaryGrid > div > div:nth-child(2) { font-size: 17px !important; white-space: nowrap; }
#perfSummaryGrid > div > div:nth-child(3) { font-size: 10px !important; line-height: 1.25; }
@media (max-width: 640px) { #perfSummaryGrid, .rp-cards { grid-auto-columns: minmax(96px, 38vw) !important; } }
.bp-logid { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 4px; background: rgba(148,163,184,.18); color: #cbd5e1; font-size: 11px; }
.wb-say { margin: 8px 0; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,.04); font-size: 12px; line-height: 1.45; max-height: 150px; overflow-y: auto; }
.wb-say .wb-u { color: #fde68a; } .wb-say .wb-a { color: #bae6fd; }

/* ── No overlap: floating phone, follow-up badge and health banner each get their own place ── */
.softphone-dock { max-height: calc(100vh - 24px); overflow-y: auto; overscroll-behavior: contain; }
.softphone-dock.minimized { overflow: hidden; }
#fuBadge { right: 24px !important; bottom: 92px !important; z-index: 80 !important; max-width: min(360px, calc(100vw - 32px)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body:has(.softphone-dock:not(.minimized)) #fuBadge { display: none !important; }
#sysHealthBanner { top: auto !important; left: 16px !important; right: auto !important; bottom: 16px !important; z-index: 80 !important; max-width: min(420px, calc(100vw - 32px)); border-radius: 12px; text-align: left !important; line-height: 1.35; box-shadow: 0 6px 20px rgba(0,0,0,.4); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 1100px) { #fuBadge { right: 12px !important; bottom: 80px !important; } }
@media (max-width: 640px) {
  #fuBadge { right: 8px !important; bottom: 72px !important; max-width: calc(100vw - 16px); }
  #sysHealthBanner { left: 8px !important; right: 8px !important; bottom: 124px !important; max-width: none; }
  body:has(.softphone-dock:not(.minimized)) #sysHealthBanner { display: none !important; }
  .softphone-dock { max-height: calc(100vh - 16px); }
}
.pg-b.on { background: #38bdf8; color: #06202e; border-color: transparent; }

/* ── Call Detail Records: phone / tablet view = one card per call (no sideways scrolling) ── */
#tab-cdrs .table-wrapper { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 1100px) {
  #tab-cdrs .data-table, #tab-cdrs .data-table tbody { display: block; width: 100%; }
  #tab-cdrs .data-table thead { display: none; }
  #tab-cdrs .data-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 0 0 12px; padding: 12px; border: 1px solid var(--border-subtle); border-radius: 12px; background: var(--bg-secondary, rgba(255,255,255,.03)); }
  #tab-cdrs .data-table td { display: block; border: 0 !important; padding: 0 !important; min-width: 0; overflow-wrap: anywhere; word-break: break-word; font-size: 13px; }
  #tab-cdrs .data-table td::before { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 2px; }
  #tab-cdrs .data-table td:nth-child(1)::before { content: "Time & Call UUID"; }
  #tab-cdrs .data-table td:nth-child(2)::before { content: "Direction"; }
  #tab-cdrs .data-table td:nth-child(3)::before { content: "Customer"; }
  #tab-cdrs .data-table td:nth-child(4)::before { content: "Handled By"; }
  #tab-cdrs .data-table td:nth-child(5)::before { content: "Picked Up & Wait"; }
  #tab-cdrs .data-table td:nth-child(6)::before { content: "Talk Time & Audio"; }
  #tab-cdrs .data-table td:nth-child(7)::before { content: "Transcript"; }
  #tab-cdrs .data-table td:nth-child(8)::before { content: "WhatsApp Feedback"; }
  #tab-cdrs .data-table td:nth-child(9)::before { content: "Actions"; }
  #tab-cdrs .data-table td:nth-child(1), #tab-cdrs .data-table td:nth-child(3), #tab-cdrs .data-table td:nth-child(7), #tab-cdrs .data-table td:nth-child(9) { grid-column: 1 / -1; }
  #tab-cdrs .data-table td[colspan] { grid-column: 1 / -1; }
  #tab-cdrs .data-table td[colspan]::before { content: none; }
  #tab-cdrs audio { width: 100%; max-width: 100%; }
}
@media (max-width: 480px) { #tab-cdrs .data-table tr { grid-template-columns: 1fr; } }

/* ── CDR table on desktop: fits the screen, no sideways scrolling ── */
@media (min-width: 1101px) {
  #tab-cdrs .table-wrapper { overflow-x: hidden; }
  #tab-cdrs .data-table { table-layout: fixed; width: 100%; min-width: 0 !important; font-size: 12px; }
  #tab-cdrs .data-table th, #tab-cdrs .data-table td { padding: 8px 6px !important; white-space: normal !important; overflow-wrap: anywhere; word-break: break-word; vertical-align: top; }
  #tab-cdrs .data-table td [style*="nowrap"] { white-space: normal !important; }
  #tab-cdrs .data-table td [style*="max-width"] { max-width: 100% !important; }
  #tab-cdrs .data-table th:nth-child(1) { width: 13%; }
  #tab-cdrs .data-table th:nth-child(2) { width: 8%; }
  #tab-cdrs .data-table th:nth-child(3) { width: 15%; }
  #tab-cdrs .data-table th:nth-child(4) { width: 12%; }
  #tab-cdrs .data-table th:nth-child(5) { width: 10%; }
  #tab-cdrs .data-table th:nth-child(6) { width: 12%; }
  #tab-cdrs .data-table th:nth-child(7) { width: 14%; }
  #tab-cdrs .data-table th:nth-child(8) { width: 8%; }
  #tab-cdrs .data-table th:nth-child(9) { width: 8%; }
  #tab-cdrs .data-table td:nth-child(7) > div > div { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; }
  #tab-cdrs .data-table audio { width: 100%; min-width: 0; height: 30px; }
  #tab-cdrs .data-table .btn { padding: 3px 7px; font-size: 11px; }
}

/* Tag-your-calls badge lives bottom-left (health banner sits just above it), never over the phone */
#fuBadge { left: 16px !important; right: auto !important; bottom: 16px !important; }
#sysHealthBanner { bottom: 62px !important; }
body:has(.softphone-dock:not(.minimized)) #fuBadge { display: inline-block !important; }
@media (max-width: 1100px) { #fuBadge { left: 12px !important; right: auto !important; bottom: 16px !important; } }
@media (max-width: 640px) { #fuBadge { left: 8px !important; right: auto !important; bottom: 72px !important; } #sysHealthBanner { bottom: 118px !important; } }

#tab-cdrs .audio-cell-player { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; max-width: 100%; min-width: 0; }
#tab-cdrs .mini-waveform-canvas { flex: 1 1 44px; min-width: 36px; max-width: 100%; width: auto !important; height: 22px; }
#tab-cdrs .data-table td .badge, #tab-cdrs .data-table td .btn { max-width: 100%; white-space: normal; }
@media (min-width: 1101px) and (max-width: 1500px) { #tab-cdrs .mini-waveform-canvas { display: none; } }
