:root {
  --primary: #0D9373;
  --primary-hover: #0b7d62;
  --primary-light: rgba(13, 147, 115, 0.12);
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
}

[data-theme="dark"] {
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-light: rgba(16, 185, 129, 0.15);
  --bg-main: #0b0f17;
  --bg-card: #151d2a;
  --bg-sidebar: #0f1724;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #233044;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

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

/* Sidebar */
.sidebar {
  width: 280px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

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

.lang-selector-wrapper {
  display: flex;
  align-items: center;
}

.lang-select {
  padding: 4px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.lang-select:hover {
  border-color: var(--primary);
}

.lang-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.brand-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #0D9373, #10b981);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(13, 147, 115, 0.3);
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-name span {
  color: var(--primary);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.avatar {
  width: 34px;
  height: 34px;
  background: #6366f1;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
}

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

.user-email {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-plan {
  font-size: 11px;
  color: var(--primary);
  text-transform: uppercase;
  font-weight: 700;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 12px 4px;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 20px;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.nav-item.active a,
.nav-item a:hover {
  color: var(--text-main);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.meter-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius-md);
}

.meter-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 6px;
  font-weight: 600;
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.3s;
}

.theme-logout-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* White-Label Mode UI overrides (Custom Menu Links inside GHL) */
body.whitelabel-mode #userProfileBox,
body.whitelabel-mode #logoutBtn,
body.whitelabel-mode #navLocations,
body.whitelabel-mode #btnBackSubaccounts,
body.whitelabel-mode #btnDeleteSubaccount,
body.whitelabel-mode #modalDeviceProxyGroup,
body.whitelabel-mode .meter-box {
  display: none !important;
}

body.whitelabel-mode .theme-logout-row {
  justify-content: flex-end;
}

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

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

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 32px 40px;
}

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

.title-area {
  display: flex;
  align-items: center;
  gap: 16px;
}

.back-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

.back-btn:hover {
  border-color: var(--text-muted);
  color: var(--text-main);
}

.location-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* Tabs */
.tabs-nav {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 12px 18px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
  margin-bottom: -1px;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-btn:hover:not(.active) {
  color: var(--text-main);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
}

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

.btn-danger {
  background-color: #ef4444;
  color: white;
}

.btn-danger:hover {
  background-color: #dc2626;
}

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.device-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  transition: all 0.2s;
}

.device-card.default-device {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.subaccount-card-healthy {
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.12) 0%, rgba(16, 185, 129, 0.03) 100%), var(--bg-card, #ffffff) !important;
  border: 1.8px solid #10b981 !important;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.15) !important;
}
.subaccount-card-healthy:hover {
  box-shadow: 0 6px 22px rgba(16, 185, 129, 0.28) !important;
  transform: translateY(-2px);
}

.subaccount-card-warning {
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.14) 0%, rgba(245, 158, 11, 0.03) 100%), var(--bg-card, #ffffff) !important;
  border: 1.8px solid #f59e0b !important;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.18) !important;
}
.subaccount-card-warning:hover {
  box-shadow: 0 6px 22px rgba(245, 158, 11, 0.3) !important;
  transform: translateY(-2px);
}

.subaccount-card-danger {
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.14) 0%, rgba(239, 68, 68, 0.03) 100%), var(--bg-card, #ffffff) !important;
  border: 1.8px solid #ef4444 !important;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.18) !important;
}
.subaccount-card-danger:hover {
  box-shadow: 0 6px 22px rgba(239, 68, 68, 0.3) !important;
  transform: translateY(-2px);
}

.device-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.device-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.device-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-connected {
  background: #dcfce7;
  color: #166534;
}

[data-theme="dark"] .badge-connected {
  background: rgba(22, 101, 52, 0.3);
  color: #4ade80;
}

.badge-disconnected {
  background: #f1f5f9;
  color: #475569;
}

[data-theme="dark"] .badge-disconnected {
  background: rgba(71, 85, 105, 0.3);
  color: #94a3b8;
}

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

[data-theme="dark"] .badge-default {
  background: rgba(146, 64, 14, 0.3);
  color: #fde047;
}

.device-actions {
  display: flex;
  gap: 6px;
}

.card-action-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.card-action-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.device-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.device-name {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.device-phone {
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.device-proxy {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.device-card-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* Settings View Sections */
.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

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

.section-title {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.section-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-main);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 14px;
  transition: border-color 0.15s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.toggle-row:last-child {
  border-bottom: none;
}

.toggle-info h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.toggle-info p {
  font-size: 12px;
  color: var(--text-muted);
}

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: .2s;
  border-radius: 24px;
}

[data-theme="dark"] .slider {
  background-color: #334155;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}

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

input:checked + .slider:before {
  transform: translateX(20px);
}

/* Routing Rules List */
.rules-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rule-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: grab;
}

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

.rule-index {
  width: 24px;
  height: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.rule-title {
  font-size: 13px;
  font-weight: 600;
}

.rule-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 28px;
  transform: scale(0.95);
  transition: transform 0.2s;
}

.modal-overlay.active .modal-box {
  transform: scale(1);
}

/* Standalone Auth Screen (Login / Registro independiente) */
#authModal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999999;
  background: #f8fafc;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
  opacity: 1;
}

#authModal.active {
  display: flex !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

#authModal .modal-box.auth-page-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
  max-width: 440px;
  width: 100%;
  padding: 40px 34px;
  text-align: center;
  transform: none !important;
}

[data-theme="dark"] #authModal {
  background: #0b0f17;
}

[data-theme="dark"] #authModal .modal-box.auth-page-box {
  background: #111827;
  border-color: #1f2937;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.6);
}

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

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
}

/* Connection Method Options */
.connection-methods {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.method-option {
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.15s;
}

.method-option.suggested {
  border-color: var(--primary);
  background: var(--primary-light);
}

.method-option:hover {
  border-color: var(--primary);
}

.method-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.method-icon {
  font-size: 24px;
}

.method-texts h4 {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.method-texts p {
  font-size: 12px;
  color: var(--text-muted);
}

/* Metrics Row */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.metric-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.metric-value {
  font-size: 28px;
  font-weight: 800;
  margin-top: 4px;
  color: var(--primary);
}

/* Code Snippet Box */
.code-box {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: 12px;
  position: relative;
  overflow-x: auto;
  white-space: pre-wrap;
}

.copy-code-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}

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

/* ==========================================================================
   🔘 BUTTON BUILDER & WHATSAPP PHONE MOCKUP
   ========================================================================== */
.builder-layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 960px) {
  .builder-layout {
    grid-template-columns: 1fr;
  }
}

.builder-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.builder-preview-col {
  position: sticky;
  top: 20px;
}

.wa-mockup-card {
  background: #efeae2;
  border: 1px solid #d1d7db;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 12px 30px -8px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .wa-mockup-card {
  background: #0b141a;
  border-color: #222e35;
}

.wa-mockup-header {
  background: #008069;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

[data-theme="dark"] .wa-mockup-header {
  background: #202c33;
}

.wa-mockup-body {
  padding: 16px;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background-image: radial-gradient(#d1d7db 0.75px, transparent 0.75px);
  background-size: 14px 14px;
}

[data-theme="dark"] .wa-mockup-body {
  background-image: radial-gradient(#222e35 0.75px, transparent 0.75px);
}

.wa-bubble {
  background: #ffffff;
  border-radius: 12px 12px 12px 2px;
  padding: 10px 12px 6px 12px;
  max-width: 88%;
  box-shadow: 0 1px 1.5px rgba(0,0,0,0.13);
  align-self: flex-start;
}

[data-theme="dark"] .wa-bubble {
  background: #202c33;
}

[data-theme="dark"] .wa-bubble div {
  color: #e9edef !important;
}

.wa-bubble-buttons {
  margin-top: 4px;
  max-width: 88%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-self: flex-start;
  width: 100%;
}

.wa-btn-preview {
  background: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #00a884;
  box-shadow: 0 1px 1.5px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

[data-theme="dark"] .wa-btn-preview {
  background: #202c33;
  color: #00a884;
}

.builder-item-card {
  background: var(--bg-body, #f8fafc);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ==========================================================================
   📊 ADS ANALYTICS & UNIFIED ADS CARDS
   ========================================================================== */
.unified-ads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 20px;
  margin-top: 10px;
}

@media (max-width: 900px) {
  #adsDistributionRow, #adsTimeDistributionRow {
    grid-template-columns: 1fr !important;
  }
}

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

.ad-unified-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.ad-unified-card:hover {
  box-shadow: var(--shadow-md, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
  border-color: rgba(13, 147, 115, 0.4);
  transform: translateY(-2px);
}

.ad-card-top {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.ad-creative-box {
  width: 95px;
  height: 95px;
  min-width: 95px;
  border-radius: 12px;
  background: #0f172a;
  overflow: hidden;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.ad-creative-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.ad-unified-card:hover .ad-creative-img {
  transform: scale(1.05);
}

.ad-creative-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #94a3b8;
  text-align: center;
  padding: 6px;
}

.ad-card-main-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ad-card-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
  line-height: 1.3;
  word-break: break-word;
}

.ad-card-body {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ad-origin-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  background: rgba(13, 147, 115, 0.08);
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  transition: background 0.2s;
}

.ad-origin-link:hover {
  background: rgba(13, 147, 115, 0.18);
}

/* Leads Counter Highlight */
.ad-leads-metric-badge {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-body, #f8fafc);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  margin-top: 4px;
}

.ad-leads-count-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ad-leads-icon {
  font-size: 20px;
}

.ad-leads-count {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
}

.ad-leads-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ad-share-pct {
  font-size: 11.5px;
  font-weight: 700;
  color: #64748b;
  background: rgba(100, 116, 139, 0.1);
  padding: 3px 7px;
  border-radius: 6px;
}

/* Placements summary block */
.ad-placements-summary {
  background: var(--bg-body, #f8fafc);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.ad-summary-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.plc-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}

.plc-reels {
  background: #f5f3ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.plc-feed {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.plc-stories {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.plc-watch {
  background: #f0f9ff;
  color: #0284c7;
  border: 1px solid #bae6fd;
}

.plc-other {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.plc-net-tag {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  margin-left: auto;
}

.plc-net-fb {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.plc-net-ig {
  background: #fdf2f8;
  color: #be185d;
  border: 1px solid #fbcfe8;
}

.plc-net-both {
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
}

/* Toggle Leads Details */
.ad-card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  gap: 8px;
}

.btn-toggle-leads {
  background: var(--bg-body, #f1f5f9);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

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

.ad-date-range-sub {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Leads Drawer Table */
.ad-leads-drawer {
  background: var(--bg-body, #f8fafc);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-top: 6px;
}

.ad-leads-drawer-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.ad-leads-table-wrap {
  max-height: 240px;
  overflow-y: auto;
  overflow-x: auto;
}

.ad-leads-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.ad-leads-table th {
  text-align: left;
  padding: 6px 8px;
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--text-muted);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}

.ad-leads-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.ad-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 700;
}

.ad-badge-fb {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.ad-badge-ig {
  background: #fdf2f8;
  color: #be185d;
  border: 1px solid #fbcfe8;
}

.ad-badge-reels {
  background: #f5f3ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.ad-badge-feed {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.ad-badge-stories {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.ad-badge-watch {
  background: #f0f9ff;
  color: #0284c7;
  border: 1px solid #bae6fd;
}

.ad-badge-other {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--border, #e2e8f0);
  border-radius: 9999px;
  overflow: hidden;
  margin-top: 4px;
}

.progress-bar-indigo {
  background: #6366f1;
  height: 100%;
  border-radius: 9999px;
  transition: width 0.4s ease;
}

.progress-bar-pink {
  background: #ec4899;
  height: 100%;
  border-radius: 9999px;
  transition: width 0.4s ease;
}

.progress-bar-emerald {
  background: #10b981;
  height: 100%;
  border-radius: 9999px;
  transition: width 0.4s ease;
}


