/* ==========================================================================
   BeraLab WhatsApp Gateway - Modern Dark SaaS Bento Theme
   ========================================================================== */

:root {
  --bg-dark: #0a0e17;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-hover: rgba(30, 41, 59, 0.7);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(255, 255, 255, 0.16);

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

  --wa-green: #25d366;
  --wa-green-glow: rgba(37, 211, 102, 0.25);
  --wa-green-dark: #128c7e;

  --brand-indigo: #6366f1;
  --brand-cyan: #06b6d4;
  --brand-amber: #f59e0b;
  --brand-red: #ef4444;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(37, 211, 102, 0.15);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  background-image:
    radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 20%, rgba(37, 211, 102, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 50% 85%, rgba(6, 182, 212, 0.05) 0%, transparent 50%);
  background-attachment: fixed;
}

.dashboard-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
.header-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}

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

.brand-logo-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

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

.brand-info .tenant-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.tenant-pill code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--brand-cyan);
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  transition: all 0.25s ease;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-badge.connected {
  background: rgba(37, 211, 102, 0.15);
  border-color: rgba(37, 211, 102, 0.4);
  color: var(--wa-green);
}
.status-badge.connected .status-dot {
  background: var(--wa-green);
  box-shadow: 0 0 8px var(--wa-green);
  animation: pulse-dot 2s infinite ease-in-out;
}

.status-badge.qr_pending,
.status-badge.scan_qr {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--brand-amber);
}
.status-badge.qr_pending .status-dot,
.status-badge.scan_qr .status-dot {
  background: var(--brand-amber);
  animation: pulse-dot 1.5s infinite ease-in-out;
}

.status-badge.init {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  color: var(--brand-indigo);
}
.status-badge.init .status-dot {
  background: var(--brand-indigo);
  animation: pulse-dot 1s infinite ease-in-out;
}

.status-badge.logged_out {
  background: rgba(148, 163, 184, 0.15);
  border-color: rgba(148, 163, 184, 0.3);
  color: var(--text-secondary);
}
.status-badge.logged_out .status-dot {
  background: var(--text-secondary);
}

.status-badge.disconnected {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--brand-red);
}
.status-badge.disconnected .status-dot {
  background: var(--brand-red);
}

@keyframes pulse-dot {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.35);
    opacity: 0.65;
  }
}

/* ==========================================================================
   Buttons & Controls
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed !important;
  pointer-events: none;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--border-highlight);
}

.btn-primary {
  background: #10b981;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.btn-primary:hover:not(:disabled) {
  background: #059669;
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.45);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}
.btn-danger:hover:not(:disabled) {
  background: #ef4444;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

.btn-outline-danger {
  background: transparent;
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}
.btn-outline-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
}

.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.toggle-switch input[type="checkbox"] {
  accent-color: var(--wa-green);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ==========================================================================
   Bento Grid Layout
   ========================================================================== */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 20px;
}

.bento-col-12 {
  grid-column: span 12;
}

.bento-col-6 {
  grid-column: span 6;
}

.bento-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-header {
  margin-bottom: 20px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ==========================================================================
   QR Section
   ========================================================================== */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  text-align: center;
}

.qr-box {
  background: #ffffff;
  padding: 16px;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-width: 252px;
  min-height: 252px;
}

.qr-image {
  width: 220px;
  height: 220px;
  display: block;
  image-rendering: pixelated;
}

.qr-placeholder {
  color: var(--text-secondary);
  padding: 32px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.qr-placeholder svg {
  stroke: var(--text-muted);
}

.qr-instructions {
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 320px;
  text-align: center;
}

.qr-instructions ol {
  text-align: left;
  margin: 8px 0 0 20px;
}

.qr-instructions li {
  margin-bottom: 4px;
}

/* ==========================================================================
   Pairing Code Section
   ========================================================================== */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-group {
  display: flex;
  gap: 8px;
}

.form-input {
  flex: 1;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}

.form-input:focus {
  border-color: var(--wa-green);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
}

.form-input.is-invalid {
  border-color: var(--brand-red);
}

.form-input.is-valid {
  border-color: var(--wa-green);
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
}

.pairing-result-box {
  margin-top: 24px;
  padding: 20px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(37, 211, 102, 0.2);
  border-radius: var(--radius-md);
  text-align: center;
}

.pairing-result-box.hidden {
  display: none;
}

.pairing-code-display {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--wa-green);
  text-shadow: 0 0 16px rgba(37, 211, 102, 0.35);
  margin: 12px 0;
  user-select: all;
}

.copy-btn-wrapper {
  margin-top: 10px;
}

/* ==========================================================================
   Connected Session Overview
   ========================================================================== */
.connected-card {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(6, 182, 212, 0.05) 100%), var(--bg-card);
  border-color: rgba(37, 211, 102, 0.25);
}

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

.stat-item {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
}

.stat-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  word-break: break-all;
}

.stat-value.highlight {
  color: var(--wa-green);
}

.session-actions-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

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

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  background: #1e293b;
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text-primary);
  animation: slide-up 0.25s ease-out;
  transition: opacity 0.3s ease;
}

.toast.toast-success {
  border-left: 4px solid var(--wa-green);
}

.toast.toast-error {
  border-left: 4px solid var(--brand-red);
}

.toast.toast-info {
  border-left: 4px solid var(--brand-cyan);
}

@keyframes slide-up {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ==========================================================================
   Utilities & Animations
   ========================================================================== */
.spinner {
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top: 2px solid #ffffff;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 900px) {
  .bento-col-6 {
    grid-column: span 12;
  }
}

@media (max-width: 600px) {
  .header-card {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-actions {
    width: 100%;
    justify-content: space-between;
  }
  .session-actions-bar {
    flex-direction: column;
    width: 100%;
  }
  .session-actions-bar .btn {
    width: 100%;
  }
}


/* ==========================================================================
   Broadcast & Campaign Monitor Styles
   ========================================================================== */
.broadcast-section {
  margin-top: 24px;
}

.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.form-label-row .form-label {
  margin-bottom: 0;
}

.btn-link {
  background: none;
  border: none;
  color: var(--brand-cyan);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s;
}

.btn-link:hover {
  color: #38bdf8;
}

.btn-link-danger {
  color: var(--brand-red) !important;
}

.btn-link-danger:hover {
  color: #f87171 !important;
}

/* Pacing configuration box */
.pacing-box {
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 14px;
}

.pacing-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand-indigo);
  margin-bottom: 12px;
}

.pacing-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.pacing-grid .form-group {
  margin-bottom: 0;
}

.pacing-grid .form-label {
  font-size: 0.75rem;
  margin-bottom: 4px;
}

.pacing-grid .form-input {
  padding: 6px 10px;
  font-size: 0.85rem;
}

/* Monitor Header & Selectors */
.monitor-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.campaign-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-input-sm {
  padding: 6px 10px;
  font-size: 0.82rem;
  min-width: 170px;
  background: rgba(15, 23, 42, 0.7);
}

.btn-icon-only {
  padding: 6px 10px;
  font-size: 0.95rem;
  line-height: 1;
}

/* Campaign Info Bar */
.campaign-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
  gap: 12px;
}

.campaign-name-block {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.campaign-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.campaign-active-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Campaign Badges */
.campaign-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.badge-running {
  background: rgba(37, 211, 102, 0.15);
  border: 1px solid rgba(37, 211, 102, 0.4);
  color: var(--wa-green);
}
.badge-running .status-dot {
  background: var(--wa-green);
  box-shadow: 0 0 6px var(--wa-green);
  animation: pulse-dot 1.2s infinite ease-in-out;
}

.badge-paused {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: var(--brand-amber);
}
.badge-paused .status-dot {
  background: var(--brand-amber);
}

.badge-completed {
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.4);
  color: var(--brand-cyan);
}
.badge-completed .status-dot {
  background: var(--brand-cyan);
}

.badge-aborted {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: var(--brand-red);
}
.badge-aborted .status-dot {
  background: var(--brand-red);
}

.badge-pending {
  background: rgba(148, 163, 184, 0.15);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--text-secondary);
}
.badge-pending .status-dot {
  background: var(--text-secondary);
}

/* Progress Bar */
.progress-section {
  margin-bottom: 20px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

#campaign-progress-percent {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
  color: var(--text-primary);
}

.progress-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981 0%, #06b6d4 100%);
  border-radius: 9999px;
  transition: width 0.4s ease;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

/* Campaign Stat Counters Grid */
.campaign-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.camp-stat-box {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  text-align: center;
}

.camp-stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.camp-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text-primary);
}

.camp-stat-value.val-green {
  color: var(--wa-green);
}

.camp-stat-value.val-red {
  color: var(--brand-red);
}

.camp-stat-value.val-amber {
  color: var(--brand-amber);
}

/* Campaign Action Controls Bar */
.campaign-controls-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.campaign-controls-bar .btn {
  flex: 1;
}

/* Empty State */
.campaign-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  color: var(--text-muted);
  text-align: center;
  gap: 12px;
}

.campaign-empty-state svg {
  stroke: var(--text-muted);
  opacity: 0.6;
}

/* Error Log Drawer */
.campaign-error-box {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-top: 14px;
}

.error-box-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fca5a5;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.error-log-list {
  list-style: none;
  max-height: 120px;
  overflow-y: auto;
  font-size: 0.78rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: #f87171;
  padding-left: 0;
}

.error-log-list li {
  padding: 2px 0;
  border-bottom: 1px solid rgba(239, 68, 68, 0.1);
}

.error-log-list li:last-child {
  border-bottom: none;
}

@media (max-width: 600px) {
  .campaign-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .campaign-controls-bar {
    flex-direction: column;
  }
  .pacing-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Tenant Provisioning & Onboarding Modal / Credentials Styles
   ========================================================================== */

.badge-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.credentials-box, .snippet-box {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: calc(100% - 60px);
}

.code-snippet-wrapper {
  background: #06090e;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  overflow-x: auto;
  position: relative;
}

.code-snippet {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  color: #38bdf8;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-card {
  background: #111827;
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 40px rgba(37, 211, 102, 0.1);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

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

.modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  transition: color 0.15s ease;
}

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

.modal-body {
  padding: 24px;
}

.auth-feedback {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  line-height: 1.4;
}

.auth-feedback.success {
  background: rgba(37, 211, 102, 0.12);
  color: var(--wa-green);
  border: 1px solid rgba(37, 211, 102, 0.3);
}

.auth-feedback.error {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* OTP Modal Enhancements (OBJ-18) */
.btn-resend {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-resend:hover:not(:disabled) {
  color: var(--wa-green);
}

.btn-resend:disabled {
  color: var(--text-muted);
  opacity: 0.6;
  cursor: not-allowed;
  text-decoration: none;
}

.auth-input-valid {
  border-color: var(--wa-green) !important;
  box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.2) !important;
}

.auth-input-error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2) !important;
}

/* ==========================================================================
   Modular 4-Tab Navigation (OBJ-18 Step 2)
   ========================================================================== */
.tabs-navigation-wrapper {
  margin-bottom: 24px;
}

.tabs-navigation {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 6px;
  box-shadow: var(--shadow-card);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs-navigation::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  user-select: none;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  color: #ffffff;
  background: rgba(37, 211, 102, 0.15);
  border-color: rgba(37, 211, 102, 0.35);
  box-shadow: 0 2px 10px rgba(37, 211, 102, 0.2);
}

.tab-btn.active svg {
  color: var(--wa-green);
}

.tab-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

.tab-btn.active .tab-badge {
  background: rgba(37, 211, 102, 0.25);
  color: var(--wa-green);
}

.tab-content-panel {
  display: none;
  animation: fadeInTab 0.25s ease forwards;
}

.tab-content-panel.active {
  display: block;
}

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

/* User Account & Logout in Top Bar */
.user-account-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  padding: 4px 12px;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.user-account-phone {
  font-weight: 600;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace, monospace;
}

/* Placeholder Bento Grid for In-Progress Modules */
.placeholder-bento-hero {
  padding: 48px 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px dashed var(--border-highlight);
  border-radius: var(--radius-xl);
}

.placeholder-icon-circle {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-indigo);
  margin-bottom: 18px;
}

.placeholder-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.placeholder-desc {
  max-width: 580px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 24px;
}

/* ==========================================================================
   Step 3: Advanced Message Composer, Media Uploader & Live WhatsApp Preview
   ========================================================================== */

.bento-col-7 {
  grid-column: span 7;
}

.bento-col-5 {
  grid-column: span 5;
}

@media (max-width: 992px) {
  .bento-col-7,
  .bento-col-5 {
    grid-column: span 12;
  }
}

.preview-and-monitor-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* WhatsApp Connection Status Alert Banner */
.conn-alert-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  transition: all 0.25s ease;
}

.conn-alert-disconnected {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

.conn-alert-disconnected .conn-alert-icon {
  color: #f59e0b;
}

.conn-alert-connected {
  background: rgba(37, 211, 102, 0.1);
  border: 1px solid rgba(37, 211, 102, 0.3);
  color: #86efac;
}

.conn-alert-connected .conn-alert-icon {
  color: var(--wa-green);
}

.conn-alert-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.conn-alert-content {
  flex: 1;
  font-size: 0.84rem;
  line-height: 1.35;
}

.conn-alert-content strong {
  display: block;
  font-size: 0.88rem;
  margin-bottom: 2px;
}

.conn-alert-content p {
  margin: 0;
  opacity: 0.9;
}

/* Form Row 2-col Grid */
.form-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 640px) {
  .form-row-2col {
    grid-template-columns: 1fr;
  }
}

/* Rich Message Composer Container */
.composer-container {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 14px;
  margin-bottom: 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.composer-container:focus-within {
  border-color: var(--brand-indigo);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.35);
}

.composer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 8px;
  background: rgba(30, 41, 59, 0.4);
  border-bottom: 1px solid var(--border-subtle);
}

.composer-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.composer-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.35);
  border-bottom: 1px solid var(--border-subtle);
}

.composer-toolbar.formatting-toolbar {
  padding-top: 6px;
  padding-bottom: 6px;
  background: rgba(15, 23, 42, 0.2);
}

.composer-toolbar-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.toolbar-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
  margin-right: 3px;
}

.tag-chip-btn {
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 0.78rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tag-chip-btn:hover {
  background: #6366f1;
  color: #ffffff;
  border-color: #6366f1;
  transform: translateY(-1px);
}

.fmt-btn {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.8rem;
  cursor: pointer;
  min-width: 28px;
  transition: all 0.15s ease;
}

.fmt-btn:hover {
  border-color: var(--brand-indigo);
  background: rgba(99, 102, 241, 0.2);
  color: #c7d2fe;
}

.composer-toolbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border-subtle);
  margin: 0 4px;
}

.emoji-group {
  display: flex;
  align-items: center;
  gap: 3px;
}

.emoji-btn {
  background: transparent;
  border: none;
  font-size: 1.05rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: transform 0.12s ease, background 0.12s ease;
}

.emoji-btn:hover {
  transform: scale(1.25);
  background: rgba(255, 255, 255, 0.1);
}

.composer-textarea-wrap {
  position: relative;
}

.composer-textarea {
  width: 100%;
  border: none;
  background: transparent;
  padding: 12px 14px;
  color: var(--text-primary);
  font-size: 0.92rem;
  line-height: 1.5;
  resize: vertical;
  min-height: 130px;
  font-family: inherit;
  outline: none;
}

.composer-textarea::placeholder {
  color: var(--text-muted);
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(15, 23, 42, 0.4);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.char-counter span {
  font-weight: 600;
  color: var(--text-secondary);
}

/* Media Uploader Drag-and-Drop */
.media-upload-group {
  margin-top: 14px;
}

.media-dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.45);
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.media-dropzone:hover,
.media-dropzone.drag-active {
  border-color: var(--wa-green);
  background: rgba(37, 211, 102, 0.06);
  box-shadow: 0 0 20px rgba(37, 211, 102, 0.12);
}

.dropzone-idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.dropzone-icon {
  color: var(--brand-cyan);
  margin-bottom: 2px;
}

.dropzone-text {
  font-size: 0.88rem;
  color: var(--text-primary);
}

.dropzone-browse {
  color: var(--brand-cyan);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.dropzone-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.media-preview-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-sm);
}

.preview-thumb-box {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

.preview-thumb-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-thumb-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-info-box {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.preview-name {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-meta {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Warm-Up Advisory */
.warmup-advisory {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.22);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 12px;
  font-size: 0.78rem;
  color: #fbbf24;
  line-height: 1.45;
}

.warmup-advisory svg {
  flex-shrink: 0;
  margin-top: 1px;
}

/* ==========================================================================
   Live WhatsApp Chat Mockup & Bubble
   ========================================================================== */
.wa-preview-card {
  padding: 18px;
}

.preview-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--wa-green);
  background: rgba(37, 211, 102, 0.1);
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.preview-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--wa-green);
  animation: pulse-wa 2s infinite ease-in-out;
}

@keyframes pulse-wa {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.wa-mockup-frame {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  background: #0b141a;
  margin-top: 12px;
}

.wa-appbar {
  background: #202c33;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #e9edef;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.wa-appbar-back {
  color: #aebac1;
  display: flex;
  align-items: center;
}

.wa-appbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #00a884;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.5px;
}

.wa-appbar-user {
  flex: 1;
  min-width: 0;
}

.wa-appbar-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #e9edef;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-appbar-status {
  font-size: 0.72rem;
  color: #8696a0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.wa-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #25d366;
}

.wa-appbar-icons {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #aebac1;
}

.wa-chat-canvas {
  background-color: #0b141a;
  background-image:
    radial-gradient(circle at 10px 10px, rgba(255, 255, 255, 0.025) 1.5px, transparent 1.5px),
    radial-gradient(circle at 26px 26px, rgba(37, 211, 102, 0.015) 1.5px, transparent 1.5px);
  background-size: 32px 32px;
  padding: 16px 14px;
  min-height: 270px;
  display: flex;
  flex-direction: column;
}

.wa-date-chip {
  align-self: center;
  background: #182229;
  color: #8696a0;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 6px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.wa-bubble-wrapper {
  display: flex;
  justify-content: flex-end;
  width: 100%;
}

.wa-bubble-outgoing {
  position: relative;
  background: #005c4b;
  color: #e9edef;
  border-radius: 8px 8px 0px 8px;
  padding: 8px 10px 6px;
  max-width: 88%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  word-break: break-word;
}

.wa-bubble-tail {
  position: absolute;
  right: -7px;
  top: 0;
  width: 0;
  height: 0;
  border-top: 8px solid #005c4b;
  border-right: 8px solid transparent;
}

.wa-bubble-media {
  margin-bottom: 6px;
  border-radius: 6px;
  overflow: hidden;
  max-width: 100%;
}

.wa-bubble-media img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  display: block;
  border-radius: 6px;
}

.wa-bubble-media video {
  width: 100%;
  max-height: 220px;
  display: block;
  border-radius: 6px;
}

.wa-doc-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #025144;
  border-radius: 6px;
  padding: 8px 10px;
}

.wa-doc-icon {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
}

.wa-doc-details {
  flex: 1;
  min-width: 0;
}

.wa-doc-filename {
  font-size: 0.82rem;
  font-weight: 600;
  color: #e9edef;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-doc-size {
  font-size: 0.7rem;
  color: rgba(241, 241, 242, 0.65);
}

.wa-bubble-text {
  font-size: 0.88rem;
  line-height: 1.45;
  color: #e9edef;
}

.wa-bubble-text strong {
  font-weight: 700;
}

.wa-bubble-text em {
  font-style: italic;
}

.wa-bubble-text del {
  text-decoration: line-through;
}

.wa-bubble-text code {
  background: rgba(0, 0, 0, 0.25);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
}

.wa-var-pill {
  background: rgba(6, 182, 212, 0.25);
  color: #67e8f9;
  border: 1px solid rgba(6, 182, 212, 0.45);
  border-radius: 4px;
  padding: 1px 5px;
  font-weight: 500;
}

.wa-bubble-meta {
  float: right;
  margin-top: 4px;
  margin-left: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.wa-bubble-time {
  font-size: 0.68rem;
  color: rgba(241, 241, 242, 0.65);
}

.wa-bubble-ticks {
  display: inline-flex;
  align-items: center;
}

/* ==========================================================================
   Section 3: Gestione Contatti, Import CSV & Analytics Rubrica (OBJ-18)
   ========================================================================== */

.contacts-top-bar {
  padding: 20px 24px;
}

.contacts-top-bar-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

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

/* Import Mode Toggle Tabs */
.import-mode-toggle {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 4px;
}

.import-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.import-toggle-btn:hover {
  color: var(--text-primary);
}

.import-toggle-btn.active {
  background: rgba(37, 211, 102, 0.2);
  color: #86efac;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.import-mode-panel {
  margin-top: 14px;
}

.contacts-dropzone {
  min-height: 140px;
  padding: 24px 16px;
}

/* Live Import Metrics Box */
.contacts-metrics-box {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(37, 211, 102, 0.3);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 16px;
  animation: slide-up 0.25s ease-out;
}

.metrics-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.metrics-box-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #86efac;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.metric-pill {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
}

.metric-pill.metric-imported {
  border-color: rgba(37, 211, 102, 0.4);
  background: rgba(37, 211, 102, 0.08);
}
.metric-pill.metric-imported .metric-num {
  color: var(--wa-green);
}

.metric-pill.metric-updated {
  border-color: rgba(6, 182, 212, 0.4);
  background: rgba(6, 182, 212, 0.08);
}
.metric-pill.metric-updated .metric-num {
  color: var(--brand-cyan);
}

.metric-pill.metric-skipped {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}
.metric-pill.metric-skipped .metric-num {
  color: var(--brand-red);
}

.metric-num {
  font-size: 1.35rem;
  font-weight: 800;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.1;
}

.metric-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 4px;
}

.import-errors-drawer {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 12px;
}

.errors-drawer-title {
  font-size: 0.76rem;
  font-weight: 700;
  color: #fca5a5;
  margin-bottom: 6px;
}

/* Contacts Table Controls & Search */
.contacts-table-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.contacts-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  flex: 1;
  max-width: 420px;
  transition: border-color 0.2s ease;
}

.contacts-search-wrap:focus-within {
  border-color: var(--wa-green);
  box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.15);
}

.contacts-search-wrap svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.contacts-search-input {
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
  width: 100%;
}

.contacts-search-input::placeholder {
  color: var(--text-muted);
}

/* Dynamic Tag Filter Pills */
.contacts-tags-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.tags-bar-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-right: 4px;
}

.contacts-tag-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-pill-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  padding: 3px 10px;
  font-size: 0.76rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tag-pill-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.tag-pill-btn.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.5);
  color: #c7d2fe;
  font-weight: 600;
}

/* Glass Table Styles */
.table-glass-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.35);
}

.contacts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  text-align: left;
}

.contacts-table thead th {
  background: rgba(30, 41, 59, 0.6);
  padding: 12px 14px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.contacts-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.15s ease;
}

.contacts-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

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

.contacts-table td {
  padding: 12px 14px;
  vertical-align: middle;
}

/* Cell Elements */
.contact-name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.contact-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

.contact-name-title {
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.contact-phone-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  color: #86efac;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.contact-phone-cell svg {
  color: var(--wa-green);
  flex-shrink: 0;
}

.contact-tags-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.contact-tag-badge {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.contact-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.contact-status-badge.badge-active {
  background: rgba(37, 211, 102, 0.12);
  border: 1px solid rgba(37, 211, 102, 0.35);
  color: var(--wa-green);
}
.contact-status-badge.badge-active .status-dot {
  background: var(--wa-green);
}

.contact-status-badge.badge-optout {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: var(--brand-red);
}
.contact-status-badge.badge-optout .status-dot {
  background: var(--brand-red);
}

.contact-date-cell {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Action buttons inside table row */
.table-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.contact-action-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
}

.contact-action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.contact-action-btn.btn-action-del:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.contact-action-btn.btn-action-optout:hover {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

@media (max-width: 768px) {
  .contacts-top-bar-content {
    flex-direction: column;
    align-items: flex-start;
  }
  .contacts-top-actions {
    width: 100%;
  }
  .contacts-top-actions .btn {
    flex: 1;
  }
  .metrics-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Section 4: Developer REST API v1 & Token Management Styles (Step 5)
   ========================================================================== */

.doc-code-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
}

.doc-tabs-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.doc-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.doc-tab-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.doc-tab-btn.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.5);
  color: #c7d2fe;
}

.doc-tab-btn svg {
  color: inherit;
}

/* API Endpoints Reference Table */
.api-endpoints-table {
  width: 100%;
}

.endpoint-route {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 3px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.84rem;
  color: #38bdf8;
  white-space: nowrap;
}

.endpoint-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-top: 4px;
}

/* Method Badges */
.badge-method {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.badge-method.badge-post {
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: var(--wa-green);
}

.badge-method.badge-get {
  background: rgba(6, 182, 212, 0.18);
  border: 1px solid rgba(6, 182, 212, 0.4);
  color: var(--brand-cyan);
}

.badge-method.badge-delete {
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
}

/* Payload Preview Box */
.payload-box {
  background: #06090e;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 10px;
  overflow-x: auto;
  max-width: 320px;
}

.payload-box pre {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.74rem;
  color: #94a3b8;
  line-height: 1.35;
}

/* HTTP Codes List */
.http-codes-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.badge-http-code {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  width: fit-content;
}

.badge-http-code.http-200 {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #86efac;
}

.badge-http-code.http-400 {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

.badge-http-code.http-401 {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.badge-http-code.http-429 {
  background: rgba(168, 85, 247, 0.12);
  border: 1px solid rgba(168, 85, 247, 0.3);
  color: #d8b4fe;
}

.badge-http-code.http-500 {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #f87171;
}

/* Language Selector */
.lang-switcher {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  line-height: 1;
}

.lang-btn:hover {
  color: #fff;
}

.lang-btn.active {
  background: rgba(37, 211, 102, 0.2);
  color: var(--wa-green, #25D366);
  border: 1px solid rgba(37, 211, 102, 0.35);
}
