/* ==========================================================================
   DataVista — CSS Stylesheet
   Modern, Sleek, Responsive SaaS Design System
   ========================================================================== */

:root {
  /* Color Palette - Light Mode */
  --bg-app: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f1f5f9;
  --bg-hover: #f1f5f9;
  --bg-active: #e2e8f0;
  
  --border-color: #e2e8f0;
  --border-subtle: #edf2f7;
  --border-focus: #6366f1;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-text: #4338ca;

  --accent: #0ea5e9;
  --accent-light: #e0f2fe;

  --success: #10b981;
  --success-light: #ecfdf5;
  --success-text: #047857;

  --whatsapp: #25d366;
  --whatsapp-hover: #1eb956;
  --whatsapp-light: #e8fbee;

  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --warning-text: #b45309;

  --danger: #ef4444;
  --danger-light: #fef2f2;
  --danger-text: #b91c1c;

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

  /* Dimensions & Radius */
  --sidebar-width: 320px;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  /* Typography */
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* Dark Mode Theme */
body.theme-dark {
  --bg-app: #090d16;
  --bg-sidebar: #0f172a;
  --bg-card: #131d31;
  --bg-input: #1e293b;
  --bg-hover: #1e293b;
  --bg-active: #334155;

  --border-color: #1e293b;
  --border-subtle: #172339;
  --border-focus: #818cf8;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-light: #1e1b4b;
  --primary-text: #c7d2fe;

  --accent: #38bdf8;
  --accent-light: #082f49;

  --success: #34d399;
  --success-light: #064e3b;
  --success-text: #a7f3d0;

  --whatsapp: #25d366;
  --whatsapp-hover: #1eb956;
  --whatsapp-light: #0b381e;

  --warning: #fbbf24;
  --warning-light: #451a03;
  --warning-text: #fde68a;

  --danger: #f87171;
  --danger-light: #450a0a;
  --danger-text: #fecaca;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

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

html, body {
  height: 100%;
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ==========================================================================
   LEFT SIDEBAR
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform var(--transition-normal);
  z-index: 50;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.brand-icon svg {
  width: 22px;
  height: 22px;
}

.brand-info h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.2;
}

.badge-accent {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--primary-light);
  color: var(--primary-text);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  display: inline-block;
}

.badge-file-type {
  font-size: 0.68rem;
  font-weight: 700;
  font-family: var(--font-mono);
  background: var(--accent-light);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.sidebar-close-btn {
  display: none;
}

/* Sidebar Content */
.sidebar-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar-scrollable::-webkit-scrollbar {
  width: 6px;
}

.sidebar-scrollable::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.sidebar-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-xs);
}

.section-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.section-title svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
}

.section-title h3 {
  font-size: 0.88rem;
  font-weight: 600;
}

.counter-badge {
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-mono);
  background: var(--bg-input);
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.section-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Column Actions Bar */
.column-actions-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.search-mini {
  position: relative;
  margin-bottom: 10px;
}

.search-mini .mini-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

.search-mini input {
  width: 100%;
  padding: 6px 10px 6px 30px;
  font-size: 0.78rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
  transition: border var(--transition-fast);
}

.search-mini input:focus {
  border-color: var(--border-focus);
}

/* Column Checklist */
.column-checkboxes-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

.column-checkboxes-list::-webkit-scrollbar {
  width: 4px;
}

.column-checkboxes-list::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.col-checkbox-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  font-size: 0.8rem;
  color: var(--text-secondary);
  transition: background var(--transition-fast);
}

.col-checkbox-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.col-checkbox-item.checked {
  color: var(--text-primary);
  font-weight: 500;
}

.col-check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.custom-checkbox {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.col-checkbox-item.checked .custom-checkbox {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.custom-checkbox svg {
  width: 11px;
  height: 11px;
  opacity: 0;
  stroke-width: 3px;
  transform: scale(0.6);
  transition: all var(--transition-fast);
}

.col-checkbox-item.checked .custom-checkbox svg {
  opacity: 1;
  transform: scale(1);
}

.col-index-num {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* Faceted Filters */
.filter-controls-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-field label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-field select {
  width: 100%;
  padding: 6px 10px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
}

.filter-field select:focus {
  border-color: var(--border-focus);
}

/* Quick Toggles */
.quick-toggle-group {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px dashed var(--border-color);
  padding-top: 12px;
}

.toggle-control {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.toggle-control input {
  display: none;
}

.toggle-slider {
  width: 32px;
  height: 18px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  position: relative;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  height: 12px;
  width: 12px;
  left: 2px;
  top: 2px;
  background-color: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition-fast);
}

.toggle-control input:checked + .toggle-slider {
  background-color: var(--primary);
  border-color: var(--primary);
}

.toggle-control input:checked + .toggle-slider::before {
  transform: translateX(14px);
  background-color: #ffffff;
}

.toggle-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* File Upload Card */
.file-upload-card {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  text-align: center;
  background: var(--bg-input);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 10px;
}

.file-upload-card:hover, .file-upload-card.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.file-input-hidden {
  display: none;
}

.upload-drop-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.upload-icon-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.upload-icon {
  width: 24px;
  height: 24px;
  color: var(--primary);
}

.upload-format-tags {
  display: flex;
  gap: 4px;
}

.fmt-tag {
  font-size: 0.65rem;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 2px 5px;
  border-radius: 4px;
}

.fmt-csv {
  background: #ede9fe;
  color: #6d28d9;
}

.fmt-xlsx, .fmt-xls {
  background: #dcfce7;
  color: #15803d;
}

.upload-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.upload-desc {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Sheet Selector */
.sheet-selector-wrap {
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sheet-select-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.sheet-select-label svg {
  width: 14px;
  height: 14px;
  color: var(--primary);
}

/* WhatsApp Template Settings */
.wa-template-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-textarea-sm {
  width: 100%;
  min-height: 56px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-family: var(--font-main);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
  resize: vertical;
}

.form-textarea-sm:focus {
  border-color: var(--border-focus);
}

.wa-tag-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.wa-tag-hint code {
  font-family: var(--font-mono);
  background: var(--bg-input);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--primary);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
}

.data-file-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  overflow: hidden;
  max-width: 200px;
}

.data-file-tag svg {
  width: 14px;
  height: 14px;
  color: var(--primary);
  flex-shrink: 0;
}

.data-file-tag span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   MAIN CONTENT AREA
   ========================================================================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--bg-app);
}

/* Top Bar */
.top-bar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

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

.mobile-menu-btn {
  display: none;
}

.header-title-group {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.page-heading {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.stats-pills {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.stat-pill svg {
  width: 13px;
  height: 13px;
  color: var(--primary);
}

.pill-highlight {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-text);
}

.pill-highlight svg {
  color: var(--primary);
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Dropdown */
.dropdown-wrap {
  position: relative;
}

.dropdown-caret {
  width: 14px;
  height: 14px;
  margin-left: 2px;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 100;
}

.dropdown-menu.show {
  display: flex;
  animation: fadeIn 0.15s ease;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.dropdown-item svg {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
}

/* Toolbar */
.toolbar {
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.search-box-wrap {
  position: relative;
  flex: 1;
  max-width: 520px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 9px 90px 9px 40px;
  font-size: 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-fast);
}

.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.search-clear-btn {
  position: absolute;
  right: 70px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: 50%;
}

.search-clear-btn:hover {
  color: var(--text-primary);
}

.search-clear-btn svg {
  width: 14px;
  height: 14px;
}

.keyboard-shortcut {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  font-family: var(--font-mono);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-muted);
  pointer-events: none;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.selection-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-light);
  border: 1px solid var(--primary);
  padding: 4px 10px;
  border-radius: var(--radius-md);
}

.selection-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary-text);
}

.page-size-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.form-select-sm {
  padding: 6px 10px;
  font-size: 0.8rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
}

/* Active Tags Bar */
.active-tags-bar {
  padding: 0 24px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.active-tags-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.active-tags-label svg {
  width: 14px;
  height: 14px;
}

.tags-container {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--primary-text);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.filter-tag .tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary-text);
  display: flex;
  align-items: center;
  padding: 0;
  opacity: 0.7;
}

.filter-tag .tag-remove:hover {
  opacity: 1;
}

.filter-tag .tag-remove svg {
  width: 12px;
  height: 12px;
}

.btn-clear-all-tags {
  font-size: 0.72rem;
  color: var(--danger-text);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  margin-left: 4px;
}

/* ==========================================================================
   TABLE CARD & GRID
   ========================================================================== */
.table-card {
  flex: 1;
  margin: 0 24px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.table-responsive {
  flex: 1;
  overflow: auto;
  position: relative;
}

.table-responsive::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
  text-align: left;
}

/* Table Header */
.data-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-card);
}

.data-table th {
  padding: 12px 14px;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
  white-space: nowrap;
  user-select: none;
  position: relative;
}

.data-table th.sortable {
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.data-table th.sortable:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.th-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sort-icon {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.sort-icon svg {
  width: 14px;
  height: 14px;
}

.data-table th.sorted-asc,
.data-table th.sorted-desc {
  color: var(--primary);
  background: var(--primary-light);
}

.data-table th.sorted-asc .sort-icon,
.data-table th.sorted-desc .sort-icon {
  color: var(--primary);
}

/* Table Rows & Cells */
.data-table tbody tr {
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--border-subtle);
}

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

.data-table tbody tr.row-selected {
  background: var(--primary-light) !important;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
  white-space: nowrap;
}

/* Cell Types & Badges */
.cell-dim {
  color: var(--text-muted);
  font-style: italic;
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 500;
}

.badge-source {
  background: #ede9fe;
  color: #6d28d9;
}

.badge-channel {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-stage {
  background: #fef3c7;
  color: #92400e;
}

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

.phone-link, .email-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-primary);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  transition: color var(--transition-fast);
}

.phone-link:hover, .email-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* ==========================================================================
   DIRECT CALL & WHATSAPP ACTION BUTTONS
   ========================================================================== */
.phone-cell-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.phone-digits {
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.phone-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-call {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary-text);
  border: 1px solid rgba(99, 102, 241, 0.2);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.btn-call:hover {
  background: var(--primary);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(79, 70, 229, 0.25);
}

.btn-call svg {
  width: 12px;
  height: 12px;
}

.btn-whatsapp {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--whatsapp);
  color: #ffffff;
  border: none;
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(37, 211, 102, 0.25);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.btn-whatsapp:hover {
  background: var(--whatsapp-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(37, 211, 102, 0.35);
}

.btn-whatsapp svg {
  width: 13px;
  height: 13px;
}

/* Highlight search matches */
mark.highlight {
  background: #fef08a;
  color: #854d0e;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}

body.theme-dark mark.highlight {
  background: #854d0e;
  color: #fef08a;
}

/* Checkbox Column */
.th-checkbox, .td-checkbox {
  width: 38px;
  text-align: center;
  padding: 11px 10px !important;
}

.row-check {
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* Empty State */
.empty-state {
  padding: 60px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
}

.empty-state-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.empty-state-icon svg {
  width: 30px;
  height: 30px;
}

.empty-state h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.empty-state p {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 400px;
}

/* Table Footer / Pagination */
.table-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-info {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.page-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
}

.page-btn svg {
  width: 15px;
  height: 15px;
}

.page-numbers {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ==========================================================================
   WHATSAPP DIRECT SHARE & BROADCAST MODAL
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.25s ease;
}

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

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wa-modal-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--whatsapp);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(37, 211, 102, 0.3);
}

.wa-modal-icon svg {
  width: 22px;
  height: 22px;
}

.modal-title-wrap h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-label svg {
  width: 14px;
  height: 14px;
  color: var(--primary);
}

.form-textarea-numbers {
  width: 100%;
  min-height: 60px;
  padding: 8px 10px;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
  resize: vertical;
}

.form-textarea-msg {
  width: 100%;
  min-height: 70px;
  padding: 8px 10px;
  font-size: 0.8rem;
  font-family: var(--font-main);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
  resize: vertical;
}

.form-textarea-msg:focus {
  border-color: var(--border-focus);
}

.wa-recipients-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 190px;
  overflow-y: auto;
  padding-right: 4px;
}

.wa-recipient-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.wa-recipient-card:hover {
  background: var(--bg-hover);
}

.wa-recipient-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wa-recipient-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.wa-recipient-num {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ==========================================================================
   BUTTONS & UI COMPONENTS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn svg {
  width: 15px;
  height: 15px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

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

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

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

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

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

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

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

.btn-link {
  background: none;
  border: none;
  padding: 0;
  text-decoration: underline;
  cursor: pointer;
}

.btn-xs {
  font-size: 0.72rem;
  padding: 4px 8px;
}

.btn-sm {
  font-size: 0.78rem;
  padding: 6px 12px;
}

.w-full {
  width: 100%;
}

.cursor-pointer {
  cursor: pointer;
}

.text-danger {
  color: var(--danger-text) !important;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1100;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.82rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp 0.25s ease forwards;
  pointer-events: auto;
}

.toast-success svg {
  color: var(--success);
}

.toast-info svg {
  color: var(--primary);
}

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

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

/* ==========================================================================
   RESPONSIVE DESIGN & MEDIA QUERIES
   ========================================================================== */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 290px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

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

  .sidebar-close-btn {
    display: flex;
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .table-card {
    margin: 0 12px 12px;
  }

  .toolbar {
    padding: 12px;
    flex-direction: column;
    align-items: stretch;
  }

  .search-box-wrap {
    max-width: 100%;
  }

  .top-bar {
    padding: 12px 16px;
  }

  .modal-card {
    max-height: 95vh;
  }
}

@media print {
  .sidebar, .top-bar, .toolbar, .table-footer, .active-tags-bar, .modal-backdrop {
    display: none !important;
  }
  .app-layout {
    display: block;
    height: auto;
  }
  .table-card {
    margin: 0;
    border: none;
    box-shadow: none;
  }
}
