/* Google Material 3 Design System - Sender Pool Platform */
@import url('https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&family=Inter:wght@300;400;500;600;700&family=Roboto+Mono:wght@400;500;600&display=swap');

:root {
  /* Google Color Palette */
  --google-blue: #1a73e8;
  --google-blue-hover: #1557b0;
  --google-blue-light: #e8f0fe;
  --google-blue-dark: #174ea6;
  
  --google-green: #1e8e3e;
  --google-green-hover: #137333;
  --google-green-light: #e6f4ea;
  --google-green-dark: #0d652d;

  --google-red: #d93025;
  --google-red-hover: #b31412;
  --google-red-light: #fce8e6;

  --google-amber: #f9ab00;
  --google-amber-hover: #e37400;
  --google-amber-light: #fef7e0;
  --google-amber-dark: #b06000;

  --google-purple: #9334e6;
  --google-purple-light: #f3e8fd;

  /* Neutral Slate Surface & Text Colors */
  --surface-bg: #f8fafd;
  --surface-card: #ffffff;
  --surface-hover: #f1f3f4;
  --surface-active: #e8eaed;
  
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --text-tertiary: #80868b;
  --text-on-primary: #ffffff;
  
  --border-subtle: #dadce0;
  --border-light: #e8eaed;
  --border-focus: #1a73e8;

  /* Google Material Elevations */
  --elevation-1: 0 1px 2px 0 rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  --elevation-2: 0 1px 3px 0 rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15);
  --elevation-3: 0 2px 6px 2px rgba(60,64,67,.15), 0 1px 2px 0 rgba(60,64,67,.3);
  --elevation-modal: 0 8px 24px rgba(0,0,0,0.18), 0 2px 6px rgba(0,0,0,0.12);

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Modern Universal Scrollbar Variables */
  --scrollbar-thumb: rgba(60, 64, 67, 0.28);
  --scrollbar-thumb-hover: rgba(60, 64, 67, 0.52);
  --scrollbar-track: transparent;
}

/* ── Dark Theme Design Tokens ────────────────────────────────────────────── */
body.dark-mode, [data-theme="dark"] {
  --surface-bg: #0f1117;
  --surface-card: #181b22;
  --surface-hover: #222734;
  --surface-active: #2d3345;
  
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-on-primary: #ffffff;
  
  --border-subtle: #334155;
  --border-light: #232836;
  --border-focus: #3b82f6;

  --google-blue: #3b82f6;
  --google-blue-hover: #2563eb;
  --google-blue-light: rgba(59, 130, 246, 0.15);
  --google-blue-dark: #93c5fd;

  --google-green: #10b981;
  --google-green-hover: #059669;
  --google-green-light: rgba(16, 185, 129, 0.15);
  --google-green-dark: #6ee7b7;

  --google-red: #ef4444;
  --google-red-hover: #dc2626;
  --google-red-light: rgba(239, 68, 68, 0.15);

  --google-amber: #f59e0b;
  --google-amber-hover: #d97706;
  --google-amber-light: rgba(245, 158, 11, 0.15);
  --google-amber-dark: #fcd34d;

  --elevation-1: 0 1px 3px rgba(0,0,0,0.4);
  --elevation-2: 0 4px 12px rgba(0,0,0,0.5);
  --elevation-3: 0 8px 24px rgba(0,0,0,0.6);
  --elevation-modal: 0 16px 40px rgba(0,0,0,0.7);
  --scrollbar-thumb: rgba(255, 255, 255, 0.22);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.42);
  --scrollbar-track: transparent;
}

body.dark-mode .form-control {
  background: #111319;
  border-color: #334155;
  color: #f1f5f9;
}

body.dark-mode .form-control:focus {
  background: #151821;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

body.dark-mode .google-table th {
  background: #13151c;
  color: #94a3b8;
  border-bottom-color: #232836;
}

body.dark-mode .google-table td {
  border-bottom-color: #232836;
  color: #e2e8f0;
}

body.dark-mode .google-table tr:hover td {
  background: #1c202a;
}

body.dark-mode .modal-box {
  background: #181b22;
  border: 1px solid #334155;
}

body.dark-mode .modal-header,
body.dark-mode .modal-footer {
  background: #13151c;
  border-color: #232836;
}

body.dark-mode .modal-body {
  background: #181b22;
}

body.dark-mode .tenant-chip {
  background: #232836;
  border-color: #334155;
  color: #94a3b8;
}

body.dark-mode .tenant-chip strong {
  color: #f1f5f9;
}

body.dark-mode .toast {
  background: #1c202a;
  color: #f1f5f9;
  border-color: #334155;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Universal Sleek Rounded Scrollbars (Chrome, Edge, Safari, Firefox) ── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

*::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

*::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

*::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 9999px;
  border: 1px solid transparent;
  background-clip: padding-box;
  transition: background-color 0.2s ease;
}

*::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

*::-webkit-scrollbar-button {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

html, body {
  font-size: 13px;
  font-family: 'Google Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--surface-bg);
  color: var(--text-primary);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* App Bar / Top Navigation - Permanently Fixed */
.google-appbar {
  background: var(--surface-card);
  height: 48px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  box-sizing: border-box !important;
  z-index: 1000 !important;
  box-shadow: 0 1px 3px 0 rgba(0,0,0,0.08);
  gap: 8px;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #1a73e8 0%, #1557b0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 2px 4px rgba(26,115,232,0.25);
  flex-shrink: 0;
}

.brand-logo.crm {
  background: linear-gradient(135deg, #1e8e3e 0%, #137333 100%);
  box-shadow: 0 2px 4px rgba(30,142,62,0.25);
}

.brand-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 1;
}

.tenant-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 10.5px;
  font-weight: 500;
  background: var(--google-blue-light);
  color: var(--google-blue-dark);
  border: 1px solid rgba(26,115,232,0.2);
  flex-shrink: 0;
}

.tenant-chip.company {
  background: rgba(52, 168, 83, 0.15);
  color: #81c995;
  border-color: rgba(52, 168, 83, 0.3);
}

.tenant-chip.global {
  background: rgba(66, 133, 244, 0.15);
  color: #8ab4f8;
  border-color: rgba(66, 133, 244, 0.3);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Layout container */
.app-layout {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  width: 100%;
  padding-top: 48px;
  box-sizing: border-box;
}

/* Sidebar Navigation Rail - Pinned & Fixed during scroll */
.nav-sidebar {
  width: 220px;
  background: var(--surface-card);
  border-right: 1px solid var(--border-light);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
  position: fixed;
  top: 48px;
  left: 0;
  bottom: 0;
  height: calc(100vh - 48px);
  height: calc(100dvh - 48px);
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition-normal);
  z-index: 90;
  box-sizing: border-box;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.nav-item:hover {
  background-color: var(--surface-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: #e8f0fe;
  color: #1a73e8;
  font-weight: 600;
  border-left: 3.5px solid #1a73e8;
  border-radius: 4px 8px 8px 4px;
}

.nav-item.active svg,
.nav-item.active .icon-svg {
  stroke: #1a73e8;
}

.nav-item.crm-active {
  background: #e6f4ea;
  color: #137333;
  font-weight: 600;
  border-left: 3.5px solid #1e8e3e;
  border-radius: 4px var(--radius-xl) var(--radius-xl) 4px;
}

.nav-item.crm-active svg,
.nav-item.crm-active .icon-svg {
  stroke: #1e8e3e;
}

body.dark-mode .nav-item.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.22) 0%, rgba(59, 130, 246, 0.08) 100%) !important;
  color: #93c5fd !important;
  font-weight: 600 !important;
  border-left: 3.5px solid #3b82f6 !important;
  box-shadow: inset 0 0 12px rgba(59, 130, 246, 0.12);
}

body.dark-mode .nav-item.active svg,
body.dark-mode .nav-item.active .icon-svg {
  stroke: #60a5fa !important;
}

body.dark-mode .nav-item.crm-active {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.22) 0%, rgba(16, 185, 129, 0.08) 100%) !important;
  color: #6ee7b7 !important;
  font-weight: 600 !important;
  border-left: 3.5px solid #10b981 !important;
  box-shadow: inset 0 0 12px rgba(16, 185, 129, 0.12);
}

body.dark-mode .nav-item.crm-active svg,
body.dark-mode .nav-item.crm-active .icon-svg {
  stroke: #34d399 !important;
}

/* Scalable Vector Icons */
.icon-svg {
  width: 17px;
  height: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  flex-shrink: 0;
}

.icon-svg svg {
  width: 100%;
  height: 100%;
  display: block;
}

.icon-svg.sm {
  width: 13px;
  height: 13px;
}

.icon-svg.lg {
  width: 22px;
  height: 22px;
}

.icon-svg.xl {
  width: 32px;
  height: 32px;
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 16px 24px;
  margin-left: 220px;
  width: calc(100% - 220px);
  max-width: calc(100vw - 220px);
  min-width: 0;
  box-sizing: border-box;
}

/* Section Header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.section-subtitle {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 1px;
}

/* Google Cards */
.google-card {
  background: var(--surface-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  box-shadow: var(--elevation-1);
  padding: 14px 18px;
  margin-bottom: 14px;
  transition: box-shadow var(--transition-fast);
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.google-card:hover {
  box-shadow: var(--elevation-2);
}

.card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: break-word;
}

.card-title span {
  min-width: 0;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Stat Metric Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card {
  background: var(--surface-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  box-shadow: var(--elevation-1);
  padding: 10px 14px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 3.5px;
  background: var(--text-tertiary);
}

.stat-card.green::before { background: var(--google-green); }
.stat-card.blue::before { background: var(--google-blue); }
.stat-card.amber::before { background: var(--google-amber); }
.stat-card.red::before { background: var(--google-red); }
.stat-card.purple::before { background: var(--google-purple); }

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-card.green .stat-value { color: var(--google-green-dark); }
.stat-card.blue .stat-value { color: var(--google-blue-dark); }
.stat-card.amber .stat-value { color: var(--google-amber-dark); }
.stat-card.red .stat-value { color: var(--google-red); }

.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 2px;
}

/* Tables */
.table-container {
  background: var(--surface-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  box-shadow: var(--elevation-1);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

.google-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12px;
}

.google-table thead {
  background-color: var(--surface-bg);
  border-bottom: 1px solid var(--border-subtle);
}

.google-table th {
  padding: 8px 12px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: var(--surface-bg);
}

.google-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
  line-height: 1.4;
}

.google-table tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.03);
}

body.dark-mode .google-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.05) !important;
}

body.dark-mode .google-table tbody tr:hover td {
  background-color: transparent !important;
}

/* Accordion Drawer Background: adapts cleanly to active light/dark theme */
.google-table tbody tr.tpl-accordion-drawer,
.google-table tbody tr.tpl-accordion-drawer td,
.google-table tbody tr.tpl-accordion-drawer:hover,
.google-table tbody tr.tpl-accordion-drawer:hover td {
  background-color: #ffffff !important;
}

body.dark-mode .google-table tbody tr.tpl-accordion-drawer,
body.dark-mode .google-table tbody tr.tpl-accordion-drawer td,
body.dark-mode .google-table tbody tr.tpl-accordion-drawer:hover,
body.dark-mode .google-table tbody tr.tpl-accordion-drawer:hover td {
  background-color: #111827 !important;
}

/* Template summary row dark theme hover guarantee */
body.dark-mode .google-table tbody tr[id^="tpl-summary-row-"]:hover,
body.dark-mode .google-table tbody tr[id^="tpl-summary-row-"]:hover td {
  background-color: rgba(255, 255, 255, 0.04) !important;
  color: #f8fafc !important;
}

.google-table tbody tr:last-child td {
  border-bottom: none;
}

/* Badges & Chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-free     { background: var(--google-green-light); color: var(--google-green-dark); }
.badge-assigned { background: var(--google-blue-light); color: var(--google-blue-dark); }
.badge-warming  { background: var(--google-amber-light); color: var(--google-amber-dark); }
.badge-cooldown { background: var(--google-red-light); color: var(--google-red); }
.badge-unlinked { background: var(--surface-hover); color: var(--text-secondary); border: 1px solid var(--border-subtle); }

.badge-waba     { background: var(--google-blue-light); color: var(--google-blue-dark); border: 1px solid var(--border-subtle); }
.badge-baileys  { background: var(--google-purple-light); color: var(--google-purple); border: 1px solid var(--border-subtle); }

/* Badges in Dark Mode */
body.dark-mode .badge-free     { background: rgba(16, 185, 129, 0.18); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.35); }
body.dark-mode .badge-assigned { background: rgba(59, 130, 246, 0.18); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.35); }
body.dark-mode .badge-warming  { background: rgba(245, 158, 11, 0.18); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.35); }
body.dark-mode .badge-cooldown { background: rgba(239, 68, 68, 0.18); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.35); }
body.dark-mode .badge-unlinked { background: #20242e; color: #94a3b8; border: 1px solid #334155; }

body.dark-mode .badge-waba     { background: rgba(59, 130, 246, 0.18); color: #93c5fd; border: 1px solid rgba(59, 130, 246, 0.35); }
body.dark-mode .badge-baileys  { background: rgba(168, 85, 247, 0.18); color: #d8b4fe; border: 1px solid rgba(168, 85, 247, 0.35); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 30px;
  padding: 0 11px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  box-sizing: border-box;
  line-height: 1;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  border-color: #2563eb;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.38);
  color: #ffffff;
}

.btn-success {
  background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
  color: #ffffff;
  border-color: #16a34a;
  box-shadow: 0 2px 6px rgba(34, 197, 94, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.btn-success:hover {
  background: linear-gradient(180deg, #4ade80 0%, #22c55e 100%);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.38);
  color: #ffffff;
}

.btn-danger {
  background: #fef2f2;
  border: 1.5px solid #fca5a5;
  color: #dc2626;
  font-weight: 500;
}
.btn-danger:hover {
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  border-color: #dc2626;
  box-shadow: 0 3px 12px rgba(220, 38, 38, 0.35);
}

body.dark-mode .btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
}
body.dark-mode .btn-danger:hover {
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  border-color: #dc2626;
  box-shadow: 0 3px 12px rgba(239, 68, 68, 0.45);
}

.btn-outline {
  background: var(--surface-card);
  border: 1.5px solid var(--border-subtle);
  color: var(--text-primary);
  font-weight: 500;
}
.btn-outline:hover {
  background: var(--google-blue-light);
  border-color: var(--google-blue);
  color: var(--google-blue);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.18);
}

.btn-secondary {
  background: var(--surface-hover);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-weight: 500;
}
.btn-secondary:hover {
  background: var(--surface-active);
  border-color: var(--border-subtle);
  color: var(--text-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Dark Mode Outline & Secondary Buttons */
body.dark-mode .btn-outline {
  background: #181d28;
  border-color: #2d4a77;
  color: #93c5fd;
}
body.dark-mode .btn-outline:hover {
  background: #1e293b;
  border-color: #3b82f6;
  color: #bfdbfe;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.25);
}

body.dark-mode .btn-secondary {
  background: #1e222d;
  border-color: #334155;
  color: #cbd5e1;
}
body.dark-mode .btn-secondary:hover {
  background: #282f3d;
  border-color: #475569;
  color: #f1f5f9;
}

.btn-text {
  background: transparent;
  color: var(--google-blue);
  padding: 0 12px;
  font-weight: 500;
  box-shadow: none;
  height: auto;
}
.btn-text:hover {
  background: var(--google-blue-light);
  color: var(--google-blue-hover);
  transform: none;
}

.btn-sm {
  height: 26px !important;
  padding: 0 8px !important;
  font-size: 10.5px !important;
  border-radius: 5px !important;
}

.btn-lg {
  height: 38px !important;
  padding: 0 16px !important;
  font-size: 13px !important;
  border-radius: 8px !important;
}

.btn-pill {
  border-radius: 9999px !important;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Pagination Component */
.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.pagination-btn:hover:not(:disabled):not(.active) {
  background: var(--google-blue-light);
  border-color: var(--google-blue);
  color: var(--google-blue);
}

.pagination-btn.active {
  background: var(--google-blue);
  border-color: var(--google-blue);
  color: #ffffff;
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 11px;
}

.form-label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.35px;
}

.form-control,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
select.form-control {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  color: var(--text-primary);
  background: var(--surface-card);
  box-sizing: border-box;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color 0.2s ease, color 0.2s ease;
}

.form-control:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select.form-control:focus {
  outline: none;
  border-color: var(--google-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

textarea.form-control {
  height: auto !important;
  min-height: 64px;
  padding: 8px 10px;
  border-radius: 6px;
  line-height: 1.4;
  font-size: 12px;
  resize: vertical;
}

.font-mono {
  font-family: 'Roboto Mono', monospace !important;
}

/* Explicit Dark Mode Input Overrides (Guaranteed High Contrast) */
body.dark-mode input,
body.dark-mode textarea,
body.dark-mode select,
body.dark-mode .form-control {
  background-color: #141720 !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

body.dark-mode input[type="date"]::-webkit-calendar-picker-indicator,
body.dark-mode input[type="time"]::-webkit-calendar-picker-indicator,
body.dark-mode input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(1.2);
  cursor: pointer;
  opacity: 0.9;
}

body.dark-mode input:focus,
body.dark-mode textarea:focus,
body.dark-mode select:focus,
body.dark-mode .form-control:focus {
  background-color: #181c26 !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3) !important;
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
  color: #64748b !important;
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 14px;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: var(--surface-card);
  border-radius: var(--radius-md);
  box-shadow: var(--elevation-modal);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  transform: translateY(12px) scale(0.98);
  transition: transform var(--transition-normal);
  overflow: hidden;
}

.modal-overlay.open .modal-box {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 18px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  line-height: 1;
}

.modal-close:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  font-size: 12.5px;
}

.modal-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--surface-bg);
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #323232;
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--elevation-2);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  animation: slideUp 200ms ease-out forwards;
}

.toast.success { background: #137333; }
.toast.error   { background: #c5221f; }
.toast.info    { background: #1a73e8; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(15px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Progress bar */
.progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: #f1f3f4;
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--google-amber);
  border-radius: 3px;
  transition: width var(--transition-normal);
}

/* QR Code Display Container */
.qr-scanner-card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  padding: 24px 20px;
  text-align: center;
  max-width: 380px;
  margin: 0 auto;
  box-shadow: var(--elevation-1);
}

.qr-frame {
  position: relative;
  display: inline-block;
  padding: 12px;
  background: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  border: 2px dashed var(--google-blue);
  margin: 16px 0;
  overflow: hidden;
  width: 244px;
  height: 244px;
  box-sizing: border-box;
}

.qr-frame img {
  display: block;
  border-radius: var(--radius-sm);
  width: 216px;
  height: 216px;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  filter: contrast(120%) brightness(92%);
  opacity: 1;
}

.qr-frame-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(4px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  padding: 14px;
  text-align: center;
  z-index: 10;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.qr-frame-overlay:hover {
  background: rgba(15, 23, 42, 0.95);
}

.qr-frame-overlay .reload-btn-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #10b981;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
  transition: transform 0.2s ease;
}

.qr-frame-overlay:hover .reload-btn-circle {
  transform: scale(1.08) rotate(45deg);
}

.qr-frame-overlay .overlay-title {
  color: #f8fafc;
  font-weight: 600;
  font-size: 13px;
}

.qr-frame-overlay .overlay-sub {
  color: #94a3b8;
  font-size: 11px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

.spinner.dark {
  border-color: rgba(0,0,0,0.2);
  border-top-color: var(--google-blue);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Variable Pills */
.var-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 500;
  font-family: inherit;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  background: #e8f0fe;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  transition: all 0.15s ease;
}
.var-pill:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
  transform: translateY(-1px);
}
body.dark-mode .var-pill {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.35);
}
body.dark-mode .var-pill:hover {
  background: #3b82f6;
  color: #ffffff;
  border-color: #3b82f6;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

/* WhatsApp Live Preview & Chat Viewer */
.wa-preview-wrap {
  background: #efeae2;
  border: 1px solid #dcd7ce;
  border-radius: 12px;
  padding: 18px 16px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.wa-bubble-preview {
  max-width: 82%;
  margin-left: auto;
  background: #d9fdd3;
  color: #111b21;
  border: 1px solid #c4e9be;
  border-radius: 10px 10px 2px 10px;
  padding: 12px 16px 8px 16px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
  transition: all 0.2s ease;
}

.chat-window {
  background: #efeae2;
  border-radius: var(--radius-md);
  padding: 16px;
  height: 480px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 1px 1px rgba(0,0,0,0.1);
  position: relative;
  word-break: break-word;
}

.chat-bubble.inbound {
  align-self: flex-start;
  background: #ffffff;
  color: #111b21;
  border-top-left-radius: 2px;
}

.chat-bubble.outbound {
  align-self: flex-end;
  background: #d9fdd3;
  color: #111b21;
  border-top-right-radius: 2px;
}

.chat-bubble-meta {
  font-size: 10px;
  color: #667781;
  text-align: right;
  margin-top: 4px;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* Dark Mode Chat & Preview Overrides */
body.dark-mode .wa-preview-wrap {
  background: #0b141a;
  border: 1px solid #1f2c34;
}

body.dark-mode .wa-bubble-preview {
  background: linear-gradient(180deg, #005c4b 0%, #004d3e 100%);
  color: #e9edef;
  border: 1px solid rgba(0, 168, 132, 0.35);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

body.dark-mode .wa-bubble-preview strong {
  color: #ffffff;
}

body.dark-mode .chat-window {
  background: #0b141a;
}

body.dark-mode .chat-bubble.inbound {
  background: #202c33;
  color: #e9edef;
}

body.dark-mode .chat-bubble.outbound {
  background: linear-gradient(180deg, #005c4b 0%, #004d3e 100%);
  color: #e9edef;
  border: 1px solid rgba(0, 168, 132, 0.3);
}

body.dark-mode .chat-bubble-meta {
  color: #8696a0;
}

/* Responsive Hamburger & Drawer */

/* ── Usage & Billing Summary Card ────────────────────────────────────────── */
.usage-summary-box {
  background: var(--surface-hover);
  border-left: 4px solid var(--google-green);
  margin: 10px 14px;
  padding: 10px 14px;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.usage-summary-box.admin-blue {
  border-left-color: var(--google-blue);
}

.usage-summary-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.usage-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface-card);
  padding: 4px 9px;
  border-radius: 5px;
  border: 1px solid var(--border-subtle);
  line-height: 1.3;
}

.usage-stat-pill strong {
  color: var(--text-primary);
  font-weight: 600;
}

.usage-stat-pill strong.cost-val {
  color: var(--google-blue);
  font-weight: 700;
}

.usage-summary-badge {
  font-size: 11px;
  color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

@media (max-width: 768px) {
  .usage-summary-box {
    margin: 8px 8px !important;
    padding: 8px 10px !important;
    gap: 8px !important;
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .usage-summary-stats {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px 10px !important;
    width: 100% !important;
  }

  .usage-stat-pill {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 5px 8px !important;
    font-size: 11px !important;
  }

  .usage-summary-badge {
    justify-content: center !important;
    font-size: 10.5px !important;
    margin-top: 2px !important;
  }
}

@media (max-width: 420px) {
  .usage-summary-stats {
    grid-template-columns: 1fr !important;
  }
}

/* ── Universal Table Pagination System ───────────────────────────────────── */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--surface-card);
  border-top: 1px solid var(--border-light);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11.5px;
}

body.dark-mode .pagination-bar {
  background: #151820;
  border-top-color: #232836;
}

.pagination-info {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  flex-wrap: wrap;
  font-size: 11.5px;
}

.pagination-count {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.pagination-count strong {
  color: var(--text-primary);
  font-weight: 600;
}

.pagination-size-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
}

.pagination-size-select {
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  background: var(--surface-bg);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  height: 24px;
  transition: border-color var(--transition-fast);
}

.pagination-size-select:focus {
  border-color: var(--google-blue);
}

body.dark-mode .pagination-size-select {
  background: #111319;
  border-color: #334155;
  color: #f1f5f9;
}

.pagination-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pagination-btn {
  min-width: 24px;
  height: 24px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  background: var(--surface-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  user-select: none;
}

.pagination-btn:hover:not(.disabled):not(.active) {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.pagination-btn.active {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%) !important;
  color: #ffffff !important;
  border-color: #2563eb !important;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(37,99,235,0.3);
}

.pagination-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.pagination-ellipsis {
  padding: 0 3px;
  color: var(--text-tertiary);
  font-size: 11px;
  user-select: none;
}

body.dark-mode .pagination-btn {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

body.dark-mode .pagination-btn:hover:not(.disabled):not(.active) {
  background: #283347;
  color: #f1f5f9;
}

@media (max-width: 640px) {
  .pagination-bar {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
  }
  .pagination-info {
    justify-content: space-between;
    width: 100%;
  }
  .pagination-controls {
    justify-content: center;
    width: 100%;
    overflow-x: auto;
    padding: 2px 0;
  }
}

@media (max-width: 360px) {
  .pagination-bar {
    padding: 5px 6px !important;
    gap: 4px !important;
  }
  .pagination-info {
    font-size: 10.5px !important;
  }
  .pagination-btn {
    min-width: 22px !important;
    height: 22px !important;
    font-size: 10.5px !important;
    padding: 0 3px !important;
  }
  .pagination-size-select {
    height: 22px !important;
    font-size: 10px !important;
    padding: 1px 4px !important;
  }
}

/* ── Live Search & Filter Box Component ──────────────────────────────────── */
.search-box-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 100%;
  max-width: 320px;
}

.search-box-wrap input {
  width: 100%;
  padding-left: 32px !important;
  padding-right: 28px !important;
  font-size: 12.5px !important;
}

.search-box-icon {
  position: absolute;
  left: 10px;
  pointer-events: none;
  color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.search-box-clear {
  position: absolute;
  right: 8px;
  cursor: pointer;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  padding: 0;
  transition: all var(--transition-fast);
}

.search-box-clear:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

body.dark-mode .search-box-clear:hover {
  background: #334155;
}

/* ── Interactive Info Tip (i) Component ───────────────────────────────────── */
.info-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  color: var(--text-tertiary);
  margin-left: 4px;
  vertical-align: middle;
  transition: color var(--transition-fast);
}

.info-tip:hover {
  color: var(--google-blue);
}

.info-tip .tip-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  pointer-events: none;
}

.info-tip .tip-box {
  display: none; /* Handled by global floating tooltip to prevent container clipping */
}

/* Global Floating Tooltip (renders at document.body level) */
.global-floating-tooltip {
  position: fixed;
  z-index: 999999;
  background: #202124;
  color: #ffffff;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  padding: 8px 12px;
  border-radius: 6px;
  max-width: 280px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  white-space: normal;
  text-align: left;
}

.global-floating-tooltip.arrow-down::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: #202124 transparent transparent transparent;
}

.global-floating-tooltip.arrow-up::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: transparent transparent #202124 transparent;
}

/* ── Google Material Modal System ─────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 16px;
  animation: modalFadeIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop[style*="display: flex"],
.modal-backdrop.active {
  display: flex !important;
}

.modal-card {
  background: var(--surface-card, #ffffff);
  border: 1px solid var(--border-subtle, #dadce0);
  border-radius: var(--radius-lg, 16px);
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.05);
  color: var(--text-primary, #202124);
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
  animation: modalSlideUp 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] .modal-card {
  background: #1e293b;
  border-color: #334155;
  color: #f8fafc;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary, #202124);
  margin: 0;
}

[data-theme="dark"] .modal-title {
  color: #f8fafc;
}

.modal-body {
  margin-bottom: 20px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light, #e8eaed);
}

[data-theme="dark"] .modal-footer {
  border-top-color: #334155;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Base Mobile & Drawer Nav Tokens ──────────────────────────────────────── */
.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast);
}

.menu-toggle:hover {
  background: var(--surface-hover);
}

.sidebar-drawer-header {
  display: none;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1040;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-overlay.open {
  display: block !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* ── Responsive Media Queries: Tablet & Mobile (<= 1024px) ────────────────── */
@media (max-width: 1024px) {
  .menu-toggle {
    display: inline-flex;
  }

  .sidebar-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 4px 12px 4px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 8px;
  }

  .sidebar-drawer-header .brand-title {
    font-size: 14px !important;
    font-weight: 700;
  }

  .sidebar-close-btn {
    background: transparent;
    border: none;
    font-size: 16px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background-color var(--transition-fast), color var(--transition-fast);
  }

  .sidebar-close-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
  }

  .nav-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 270px !important;
    max-width: 82vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 1050 !important;
    transform: translateX(-100%) !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.45) !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
    background: #ffffff !important;
    padding: 16px 12px !important;
  }

  body.dark-mode .nav-sidebar {
    background: #0e121a !important;
    border-right: 1px solid #1e293b !important;
  }

  .nav-sidebar.open {
    transform: translateX(0) !important;
  }

  .main-content {
    margin-left: 0 !important;
    padding: 16px 14px 48px 14px;
    max-width: 100vw;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }
}

/* ── Responsive Media Queries: Mobile Devices (<= 768px) ──────────────────── */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    width: 100% !important;
  }

  .google-appbar {
    padding: 0 10px !important;
    height: 44px !important;
    gap: 6px !important;
  }

  .brand-wrapper {
    gap: 6px !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
    overflow: hidden !important;
  }

  .brand-logo {
    width: 24px !important;
    height: 24px !important;
    font-size: 12px !important;
    flex-shrink: 0 !important;
  }

  .brand-title {
    font-size: 12.5px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    min-width: 0 !important;
    flex-shrink: 0 !important;
    max-width: none !important;
  }

  .brand-title .brand-sub {
    display: none !important;
  }

  .tenant-chip {
    display: none !important;
  }

  .header-actions {
    gap: 5px !important;
    flex-shrink: 0 !important;
  }

  .header-actions .btn {
    font-size: 0 !important; /* Collapses any raw text nodes like 'Sign Out' */
    padding: 0 !important;
    min-width: 28px !important;
    width: 28px !important;
    height: 28px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 6px !important;
  }

  .header-actions .btn svg,
  .header-actions .btn #theme-icon,
  .header-actions .btn #theme-icon svg {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 14px !important;
    height: 14px !important;
    font-size: 14px !important;
    margin: 0 !important;
  }

  .header-actions .btn span:not(#theme-icon),
  .header-actions .btn #theme-label,
  .header-actions .btn #serp-btn-label {
    display: none !important;
  }

  .app-layout {
    display: block !important;
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
    padding-top: 44px !important;
  }

  .main-content {
    padding: 10px 8px 56px 8px !important;
    max-width: 100vw !important;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  .section-header {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 8px !important;
    margin-bottom: 10px !important;
    flex-wrap: nowrap !important;
  }

  .section-header > div:first-child {
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }

  .section-header > button,
  .section-header > div > button,
  .section-header .btn {
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: fit-content !important;
    height: 28px !important;
    padding: 0 8px !important;
    font-size: 11px !important;
    white-space: nowrap !important;
    justify-content: center !important;
  }

  /* When toolbar search is inside section-header, fill remaining space */
  .section-header > .table-toolbar-scroll-wrapper {
    flex: 0 1 auto !important;
    max-width: none !important;
    min-width: 0 !important;
    width: auto !important;
  }

  .section-title {
    font-size: 14.5px !important;
  }

  .section-subtitle {
    font-size: 10.5px !important;
    color: var(--text-tertiary) !important;
    margin-top: 1px !important;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px !important;
    margin-bottom: 10px !important;
  }

  .stat-card {
    padding: 8px 10px !important;
  }

  .stat-card:last-child:nth-child(odd) {
    grid-column: 1 / -1 !important;
  }

  .stat-value {
    font-size: 17px !important;
  }

  .stat-label {
    font-size: 10px !important;
  }

  .google-card {
    padding: 12px 10px !important;
    margin-bottom: 10px !important;
    border-radius: 7px !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
    width: 100% !important;
    overflow: hidden !important;
  }

  .google-card[style*="padding: 0"] {
    padding: 0 !important;
  }

  .card-title {
    font-size: 12.5px !important;
    margin-bottom: 6px !important;
    justify-content: flex-start !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  .form-label {
    font-size: 10px !important;
    margin-bottom: 3px !important;
    letter-spacing: 0.3px !important;
  }

  .info-tip .tip-icon {
    width: 12px !important;
    height: 12px !important;
  }

  /* Force responsive collapsing of wide multi-column grids */
  [style*="grid-template-columns"],
  [style*="display: grid"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    max-width: 100% !important;
  }

  /* Table Toolbars on Mobile: Single Line with Scroll Slider for Multiple Controls */
  .table-toolbar {
    padding: 10px 12px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  .table-toolbar .card-title,
  .table-toolbar h2 {
    width: 100% !important;
    margin-bottom: 0 !important;
    font-size: 13.5px !important;
  }

  .table-toolbar-scroll-wrapper {
    width: 100% !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    position: relative !important;
    min-width: 0 !important;
  }

  .table-toolbar-group {
    width: 100% !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 6px !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    scroll-behavior: smooth;
    padding: 1px 0 !important;
    min-width: 0 !important;
  }

  .table-toolbar-group::-webkit-scrollbar {
    display: none !important;
  }

  .table-toolbar-group > * {
    flex-shrink: 0 !important;
  }

  /* Two-item toolbars (Search + Refresh): fill 100% on one line without scroll */
  .table-toolbar-group > .search-box-wrap:only-child,
  .table-toolbar-group > .search-box-wrap:first-child:nth-last-child(2) {
    flex: 1 1 auto !important;
    min-width: 140px !important;
    max-width: none !important;
  }

  .table-toolbar-scroll-wrapper .table-toolbar-group .search-box-wrap {
    flex: 0 0 160px !important;
    width: 160px !important;
    min-width: 160px !important;
  }

  .table-toolbar-scroll-wrapper .table-toolbar-group select.form-control {
    flex: 0 0 110px !important;
    width: 110px !important;
    min-width: 110px !important;
  }

  .table-toolbar-group .search-box-wrap input {
    width: 100% !important;
    height: 28px !important;
    font-size: 11.5px !important;
    padding: 0 8px 0 26px !important;
  }

  .table-toolbar-group select.form-control {
    height: 28px !important;
    font-size: 11px !important;
    padding: 0 4px !important;
    flex-shrink: 0 !important;
  }

  .table-toolbar-group .btn {
    height: 28px !important;
    padding: 0 8px !important;
    font-size: 11px !important;
    flex: 0 0 auto !important;
    width: auto !important;
    white-space: nowrap !important;
  }

  /* Horizontal Table Scroll & Container */
  .table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 7px;
  }

  .google-table {
    min-width: 480px;
  }

  .google-table th,
  .google-table td {
    padding: 7px 9px;
    font-size: 11.5px;
  }

  /* Pagination Bar on Mobile */
  .pagination-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 6px 10px !important;
    gap: 6px !important;
    box-sizing: border-box !important;
  }

  .pagination-info {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
    font-size: 11px !important;
    gap: 6px !important;
  }

  .pagination-size-wrap {
    font-size: 11px !important;
    gap: 4px !important;
  }

  .pagination-size-select {
    height: 24px !important;
    font-size: 11px !important;
    padding: 1px 4px !important;
  }

  .pagination-controls {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    overflow-x: auto !important;
    gap: 4px !important;
    padding: 2px 0 !important;
  }

  .pagination-btn {
    min-width: 24px !important;
    height: 24px !important;
    font-size: 11px !important;
    padding: 0 4px !important;
  }

  /* Modals on Mobile */
  .modal-backdrop,
  .modal-overlay {
    padding: 6px !important;
    align-items: flex-end !important;
  }

  .modal-card,
  .modal-box {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    border-radius: 14px 14px 0 0 !important;
    max-height: 90vh !important;
    max-height: 90dvh !important;
    padding: 14px 12px !important;
    box-sizing: border-box !important;
  }

  .modal-header {
    padding: 0 0 10px 0;
  }

  .modal-body {
    max-height: calc(90vh - 100px) !important;
    max-height: calc(90dvh - 100px) !important;
    overflow-y: auto !important;
    font-size: 12px !important;
  }

  .modal-footer {
    padding: 10px 0 0 0;
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  .modal-footer .btn {
    flex: 1 1 calc(50% - 4px) !important;
    height: 30px !important;
    font-size: 11.5px !important;
  }

  /* Toast positioning on mobile */
  #toast-container {
    left: 10px;
    right: 10px;
    bottom: 14px;
    width: auto;
  }

  .toast {
    min-width: unset;
    width: 100%;
    font-size: 11.5px;
    padding: 8px 12px;
  }

  /* Forms on Mobile */
  .form-control {
    font-size: 12px !important;
    padding: 0 8px !important;
    height: 30px !important;
    max-width: 100%;
    box-sizing: border-box;
  }

  .btn {
    font-size: 11.5px !important;
    padding: 0 9px !important;
    height: 28px !important;
  }

  /* Flex containers in form groups wrap cleanly on mobile */
  .form-group > div[style*="display: flex"],
  .form-row {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  #login-overlay .google-card {
    padding: 24px 16px !important;
    margin: 8px;
    max-width: 100% !important;
  }
}

/* ── Responsive Media Queries: Small Phones (<= 480px) ────────────────────── */
@media (max-width: 480px) {
  .google-appbar {
    padding: 0 6px !important;
    height: 42px !important;
  }

  .app-layout {
    padding-top: 42px !important;
  }

  .brand-title {
    font-size: 12px !important;
  }

  .section-title {
    font-size: 13.5px !important;
  }

  .card-title {
    font-size: 12px !important;
    justify-content: flex-start !important;
  }

  .form-label {
    font-size: 9.5px !important;
  }

  .form-control {
    font-size: 11.5px !important;
    height: 28px !important;
    padding: 0 6px !important;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 5px !important;
  }

  .stat-card {
    padding: 7px 8px !important;
  }

  .stat-card:last-child:nth-child(odd) {
    grid-column: 1 / -1 !important;
  }

  .stat-value {
    font-size: 16px !important;
  }

  .stat-label {
    font-size: 9px !important;
  }

  .google-card {
    padding: 10px 8px !important;
    border-radius: 6px !important;
  }

  .btn {
    font-size: 11px !important;
    height: 26px !important;
    padding: 0 7px !important;
  }

  .btn-sm {
    font-size: 10px !important;
    height: 24px !important;
    padding: 0 5px !important;
  }

  #b-admin-pairing-code-text {
    font-size: 16px !important;
    letter-spacing: 2px !important;
    padding: 5px 6px !important;
  }

  #login-overlay .google-card {
    padding: 18px 12px !important;
  }
}

/* ── Responsive Media Queries: Extra Small Phones (<= 360px) ──────────────── */
@media (max-width: 360px) {
  .google-appbar {
    padding: 0 4px !important;
    height: 40px !important;
  }

  .app-layout {
    padding-top: 40px !important;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 4px !important;
  }

  .stat-card {
    padding: 6px 6px !important;
  }

  .stat-card:last-child:nth-child(odd) {
    grid-column: 1 / -1 !important;
  }

  .brand-title {
    font-size: 11px !important;
  }

  .section-title {
    font-size: 12.5px !important;
  }

  .card-title {
    font-size: 11.5px !important;
    justify-content: flex-start !important;
  }

  .form-label {
    font-size: 9px !important;
  }

  .form-control {
    font-size: 11px !important;
    height: 26px !important;
    padding: 0 5px !important;
  }

  .main-content {
    padding: 8px 4px 50px 4px !important;
  }

  .google-card {
    padding: 8px 6px !important;
  }

  .modal-footer .btn {
    flex: 1 1 100% !important;
  }

  .qr-scanner-card {
    max-width: 100% !important;
    padding: 10px 6px !important;
  }

  .qr-frame {
    width: 180px !important;
    height: 180px !important;
    max-width: 100% !important;
  }

  .qr-frame img {
    width: 160px !important;
    height: 160px !important;
  }
}

/* ── Responsive Template Drawer & Variable Mapping ───────────────────────── */
.tpl-responsive-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 22px;
  align-items: start;
}

.tpl-preview-sticky {
  position: sticky;
  top: 20px;
}

.tpl-var-grid-header {
  display: grid;
  grid-template-columns: minmax(160px, auto) minmax(180px, 1.2fr) minmax(140px, 1fr);
  gap: 12px;
  padding: 0 10px 8px 10px;
  border-bottom: 1px solid var(--border-light);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tpl-var-grid-row {
  display: grid;
  grid-template-columns: minmax(160px, auto) minmax(180px, 1.2fr) minmax(140px, 1fr);
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface-bg);
  margin-bottom: 8px;
  border: 1px solid var(--border-light);
}

@media (max-width: 820px) {
  .tpl-responsive-grid {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
  .tpl-preview-sticky {
    position: static !important;
    max-width: 480px;
    margin: 16px auto 0 auto;
    width: 100%;
  }
}

@media (max-width: 768px) {
  .tpl-var-grid-header {
    display: none !important;
  }
  .tpl-var-grid-row {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    padding: 12px !important;
  }
  .tpl-var-grid-row > div:first-child {
    max-width: 100% !important;
    width: 100% !important;
  }
  .tpl-var-tag-badge {
    width: 100% !important;
    text-align: left !important;
    padding: 6px 10px !important;
  }
}

/* ── Outreach Templates Table & Mobile Responsiveness ────────────────────── */
.tpl-table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
}

.tpl-outreach-table {
  width: 100%;
  min-width: 660px;
  border-collapse: collapse;
}

.tpl-outreach-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  color: var(--text-secondary);
}

.tpl-outreach-table th.col-purpose { width: 30%; min-width: 170px; }
.tpl-outreach-table th.col-meta { width: 22%; min-width: 130px; }
.tpl-outreach-table th.col-comps { width: 20%; min-width: 120px; }
.tpl-outreach-table th.col-status { width: 12%; min-width: 90px; text-align: center; }
.tpl-outreach-table th.col-actions { width: 16%; min-width: 150px; text-align: right; }

.tpl-outreach-table td {
  padding: 10px 12px;
  vertical-align: middle;
}

/* On mobile / tablet (<= 820px), transform table rows into 100% width responsive cards */
@media (max-width: 820px) {
  .tpl-table-wrapper {
    overflow-x: visible !important;
    padding: 10px !important;
  }
  .tpl-outreach-table {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    border-collapse: separate !important;
  }
  .tpl-outreach-table thead {
    display: none !important;
  }
  .tpl-outreach-table tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    width: 100% !important;
  }
  .tpl-outreach-table tr.tpl-summary-row {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    box-sizing: border-box !important;
    background: var(--surface-card) !important;
    border: 1px solid var(--border-light) !important;
    border-radius: 10px !important;
    padding: 14px !important;
    gap: 10px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06) !important;
  }
  .tpl-outreach-table tr.tpl-summary-row > td {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    text-align: left !important;
  }
  .tpl-outreach-table tr.tpl-summary-row > td.col-actions {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    border-top: 1px solid var(--border-light) !important;
    padding-top: 10px !important;
    margin-top: 4px !important;
  }
  .tpl-outreach-table tr.tpl-accordion-drawer {
    display: block !important;
    width: 100% !important;
    margin-top: -6px !important;
    margin-bottom: 8px !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    border: 1.5px solid var(--google-blue) !important;
  }
  .tpl-outreach-table tr.tpl-accordion-drawer[style*="display: none"] {
    display: none !important;
  }
  .tpl-outreach-table tr.tpl-accordion-drawer > td {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
  }
  .tpl-drawer-inner {
    padding: 14px 12px !important;
  }
}

/* ── Viewport Height Adaptability (Landscape / Short Screens) ─────────────── */
@media (max-height: 640px) {
  .modal-card, .modal-box {
    max-height: 94vh !important;
    max-height: 94dvh !important;
    padding: 12px 16px !important;
  }
  .modal-body {
    max-height: calc(94vh - 100px) !important;
    overflow-y: auto !important;
  }
  .google-appbar {
    height: 48px !important;
  }
  @media (min-width: 1025px) {
    .nav-sidebar {
      top: 48px !important;
      height: calc(100vh - 48px) !important;
      height: calc(100dvh - 48px) !important;
    }
  }
}

/* ── Table Toolbar & Single-Line Action Headers ──────────────────────────── */
.table-toolbar {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--surface-card);
}

.table-toolbar-scroll-wrapper {
  display: flex;
  align-items: center;
  position: relative;
  max-width: 100%;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

/* Constrain scroll-wrapper when placed directly inside section-header (e.g., RAG search) */
.section-header > .table-toolbar-scroll-wrapper {
  max-width: 320px;
  flex: 0 1 320px;
}

.table-toolbar-group {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  flex-wrap: nowrap !important;
  width: 100% !important;
  min-width: 0 !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  scrollbar-width: none !important;
  scroll-behavior: smooth;
}

.table-toolbar-group::-webkit-scrollbar {
  display: none !important;
}

.table-toolbar-group > * {
  flex-shrink: 0 !important;
}

.toolbar-scroll-arrow {
  display: none;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 32px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  z-index: 5;
  flex-shrink: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  transition: all 0.15s ease;
  user-select: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.toolbar-scroll-arrow:hover {
  background: var(--surface-hover);
  color: var(--google-blue);
  border-color: var(--google-blue);
}

.toolbar-scroll-arrow.left {
  margin-right: 6px;
}

.toolbar-scroll-arrow.right {
  margin-left: 6px;
}

.table-toolbar .search-box-wrap,
.table-toolbar-scroll-wrapper .search-box-wrap {
  width: 210px;
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0 !important;
}

.table-toolbar .search-box-wrap input,
.table-toolbar-scroll-wrapper .search-box-wrap input {
  width: 100% !important;
  height: 30px !important;
  padding: 0 8px 0 28px !important;
  font-size: 12px !important;
}

.table-toolbar select.form-control,
.table-toolbar-scroll-wrapper select.form-control {
  height: 30px !important;
  font-size: 11.5px !important;
  max-width: 150px;
  flex-shrink: 0 !important;
}

.table-toolbar .btn,
.table-toolbar-scroll-wrapper .btn {
  height: 30px !important;
  padding: 0 10px !important;
  font-size: 11.5px !important;
  flex-shrink: 0 !important;
  white-space: nowrap !important;
}

/* ── Filter Toolbar & Responsive Input Form Layouts ──────────────────────── */
.filter-toolbar {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  background: var(--surface-card);
}

.filter-toolbar .filter-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 150px;
  min-width: 0;
}

.filter-toolbar .filter-field .form-label {
  margin-bottom: 0 !important;
  font-size: 10.5px;
}

.filter-toolbar .filter-field .form-control {
  width: 100% !important;
  max-width: 100% !important;
  height: 30px !important;
  font-size: 12px !important;
}

.filter-toolbar .btn {
  height: 30px !important;
  align-self: flex-end;
  margin-bottom: 0 !important;
  padding: 0 10px !important;
  font-size: 11.5px !important;
  white-space: nowrap;
}

/* Input gap and form-group spacing refinements */
.form-group {
  margin-bottom: 11px;
}

.form-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  .filter-toolbar {
    padding: 10px 12px !important;
    gap: 8px 10px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: flex-end !important;
  }

  .filter-toolbar .filter-field {
    flex: 1 1 140px !important;
    width: auto !important;
    max-width: none !important;
    min-width: 120px !important;
  }

  .filter-toolbar .btn {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: auto !important;
    height: 32px !important;
    padding: 0 14px !important;
    font-size: 11.5px !important;
    align-self: flex-end !important;
    white-space: nowrap !important;
    justify-content: center !important;
  }

  .form-group {
    margin-bottom: 9px !important;
  }

  .form-row {
    gap: 6px !important;
  }
}

@media (max-width: 520px) {
  .filter-toolbar {
    padding: 8px 10px !important;
    gap: 8px !important;
  }

  .filter-toolbar .filter-field {
    flex: 1 1 calc(50% - 5px) !important;
    min-width: 110px !important;
  }

  .filter-toolbar .btn {
    flex: 1 1 100% !important;
    width: 100% !important;
    height: 32px !important;
  }
}

@media (max-width: 360px) {
  .form-group {
    margin-bottom: 7px !important;
  }

  .filter-toolbar {
    padding: 6px 8px !important;
    gap: 6px !important;
  }

  .filter-toolbar .filter-field {
    flex: 1 1 100% !important;
    width: 100% !important;
  }

  .filter-toolbar .btn {
    flex: 1 1 100% !important;
    width: 100% !important;
  }
}

.rag-split-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 24px;
}

@media (max-width: 1024px) {
  .rag-split-grid {
    grid-template-columns: 1fr !important;
    gap: 18px !important;
  }
}

/* ── Mobile Responsive Table Accordion System ──────────────────────────────── */
.mobile-card-cell {
  display: none;
}

@media (max-width: 768px) {
  .google-table.responsive-accordion-table {
    min-width: 100% !important;
    width: 100% !important;
    display: table !important;
  }

  .google-table.responsive-accordion-table thead {
    display: none !important;
  }

  .google-table.responsive-accordion-table tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .google-table.responsive-accordion-table tbody tr {
    display: block !important;
    background: var(--surface-card) !important;
    border: 1px solid var(--border-light) !important;
    border-radius: var(--radius-md, 10px) !important;
    padding: 0 !important;
    overflow: hidden !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
    transition: box-shadow 0.2s ease, border-color 0.2s ease !important;
  }

  body.dark-mode .google-table.responsive-accordion-table tbody tr {
    background: #11151f !important;
    border-color: #232836 !important;
  }

  .google-table.responsive-accordion-table tbody tr td.desktop-cell {
    display: none !important;
  }

  .google-table.responsive-accordion-table tbody tr td.mobile-card-cell {
    display: block !important;
    padding: 0 !important;
    border-bottom: none !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .mobile-card-header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 11px 13px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    background: transparent;
    transition: background-color 0.15s ease;
  }

  .mobile-card-header:hover,
  .mobile-card-header:active {
    background: var(--surface-hover);
  }

  .mobile-card-summary {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
  }

  .mobile-card-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    word-break: break-word;
  }

  .mobile-card-subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }

  .mobile-card-chevron {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 8px;
    background: var(--surface-hover);
    color: var(--text-secondary);
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.15s ease;
  }

  .mobile-card-chevron svg {
    width: 12px;
    height: 12px;
    transition: transform 0.22s ease;
  }

  .mobile-card-row.expanded .mobile-card-chevron {
    transform: rotate(180deg);
    background: var(--google-blue-light, rgba(26, 115, 232, 0.15));
    color: var(--google-blue);
  }

  .mobile-card-details {
    display: none;
    padding: 11px 13px 13px 13px;
    border-top: 1px solid var(--border-light);
    background: rgba(0, 0, 0, 0.015);
  }

  body.dark-mode .mobile-card-details {
    background: rgba(0, 0, 0, 0.2);
    border-top-color: #1e2433;
  }

  .mobile-card-row.expanded .mobile-card-details {
    display: block !important;
    animation: mobileCardExpand 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .mobile-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
    margin-bottom: 8px;
  }

  .mobile-detail-grid.single-col {
    grid-template-columns: 1fr;
  }

  .mobile-detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .mobile-detail-item.full-width {
    grid-column: 1 / -1;
  }

  .mobile-detail-label {
    font-size: 9.5px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
  }

  .mobile-detail-value {
    font-size: 11.5px;
    color: var(--text-primary);
    word-break: break-word;
  }

  .mobile-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border-light);
    flex-wrap: wrap;
  }

  .mobile-card-actions .btn {
    flex: 1 1 calc(50% - 3px);
    justify-content: center;
    font-size: 11px !important;
    padding: 5px 8px !important;
  }
}

@keyframes mobileCardExpand {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── WhatsApp Text & Media Styles for CRM Chat Modals ── */
.chat-bubble strong { font-weight: 700; color: inherit; }
.chat-bubble em { font-style: italic; }
.chat-bubble del { text-decoration: line-through; opacity: 0.75; }
.chat-bubble a.wa-link { color: #1a73e8; text-decoration: underline; word-break: break-all; }
body.dark-mode .chat-bubble a.wa-link { color: #60a5fa; }
.wa-code-block {
  background: rgba(0, 0, 0, 0.06);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  margin: 4px 0;
  overflow-x: auto;
  white-space: pre-wrap;
}
body.dark-mode .wa-code-block { background: rgba(0, 0, 0, 0.25); }
.wa-inline-code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 4px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
body.dark-mode .wa-inline-code { background: rgba(0, 0, 0, 0.25); }

@media (max-width: 600px) {
  .chat-bubble { max-width: 90% !important; font-size: 12.5px !important; }
  .chat-bubble img { max-width: 100% !important; height: auto !important; max-height: 220px !important; border-radius: 8px !important; object-fit: cover !important; }
}

/* ── Shared WhatsApp Emoji Picker ────────────────────────────── */
.wa-emoji-picker-popover {
  position: fixed;
  z-index: 10050;
  width: 320px;
  background: var(--surface-card, #ffffff);
  border: 1px solid var(--border-light, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  animation: wa-ep-appear 0.16s ease-out;
}
body.dark-mode .wa-emoji-picker-popover {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.55);
}
@keyframes wa-ep-appear {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.wa-ep-header {
  padding: 8px 10px 6px;
  border-bottom: 1px solid var(--border-subtle, #f1f5f9);
}
body.dark-mode .wa-ep-header {
  border-bottom-color: #334155;
}
.wa-ep-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-hover, #f8fafc);
  border: 1px solid var(--border-light, #e2e8f0);
  border-radius: 8px;
  padding: 4px 8px;
}
body.dark-mode .wa-ep-search-wrap {
  background: #0f172a;
  border-color: #475569;
}
.wa-ep-search-icon {
  font-size: 12px;
  opacity: 0.6;
}
.wa-ep-search-input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 12px;
  color: var(--text-primary, #0f172a);
  flex: 1;
}
body.dark-mode .wa-ep-search-input {
  color: #f8fafc;
}
.wa-ep-search-clear {
  border: none;
  background: transparent;
  color: var(--text-tertiary, #94a3b8);
  font-size: 11px;
  cursor: pointer;
  padding: 0 2px;
}
.wa-ep-categories {
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-subtle, #f1f5f9);
  background: var(--surface-hover, #f8fafc);
  overflow-x: auto;
}
body.dark-mode .wa-ep-categories {
  background: #0f172a;
  border-bottom-color: #334155;
}
.wa-ep-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: transparent;
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary, #64748b);
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}
body.dark-mode .wa-ep-tab {
  color: #94a3b8;
}
.wa-ep-tab:hover {
  background: rgba(0, 128, 105, 0.1);
  color: #008069;
}
body.dark-mode .wa-ep-tab:hover {
  background: rgba(37, 211, 102, 0.15);
  color: #25d366;
}
.wa-ep-tab.is-active {
  background: #008069;
  color: #ffffff;
}
body.dark-mode .wa-ep-tab.is-active {
  background: #00a884;
  color: #ffffff;
}
.wa-ep-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 8px;
  max-height: 200px;
  overflow-y: auto;
}
.wa-ep-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-size: 20px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.12s ease;
}
.wa-ep-btn:hover {
  background: rgba(0, 128, 105, 0.12);
  transform: scale(1.2);
}
body.dark-mode .wa-ep-btn:hover {
  background: rgba(37, 211, 102, 0.18);
}
.wa-ep-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 24px 10px;
  font-size: 12px;
  color: var(--text-tertiary, #94a3b8);
}
.wa-ep-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: var(--surface-hover, #f8fafc);
  border-top: 1px solid var(--border-subtle, #f1f5f9);
  font-size: 11px;
  color: var(--text-tertiary, #94a3b8);
}
body.dark-mode .wa-ep-footer {
  background: #0f172a;
  border-top-color: #334155;
}
.wa-ep-footer-preview {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #0f172a);
}
body.dark-mode .wa-ep-footer-preview {
  color: #f8fafc;
}




