* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Paleta Hercules: solo azul oscuro y claro */
  --primary-color: #2e79b7;
  --primary-light: #60c1ee;
  --primary-dark: #286aa2;
  --secondary-color: #60c1ee;
  --secondary-dark: #1e5f8a;
  --success-color: #10b981;
  --danger-color: #286aa2;
  --warning-color: #f59e0b;
  --dark-bg: #ffffff !important;
  --light-bg: #ffffff !important;
  --border-color: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-lg:
    0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --sidebar-width: 280px;
  --sidebar-icon-size: 18px;
  --sidebar-font-size: 14px;
  --sidebar-logo-size: 36px;
}
.fff{
  color: #000;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  background-color: var(--light-bg);
  color: var(--text-primary);
  line-height: 1.6;
}

.brand-title-menu {
  color: var(--text-primary);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand-title-collapsed {
  display: none;
}

/* Login Page - Split layout (brand + form) */
.login-page {
  font-family: "Outfit", system-ui, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--dark-bg, #0f172a);
  color: var(--text-primary);
}

/* Skip link accesibilidad */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.5rem;
  background: var(--primary-color);
  color: white;
  border-radius: 8px;
  font-weight: 600;
  z-index: 1000;
  transition: top 0.3s;
}
.skip-link:focus {
  top: 1rem;
}

/* Layout: dos columnas */
.login-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
  width: 100%;
}
@media (max-width: 1024px) {
  .login-layout {
    grid-template-columns: 1fr;
  }
}

/* Panel izquierdo: branding */
.brand-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 3rem;
  background: #ffffff;
  overflow: hidden;
}
@media (max-width: 1024px) {
  .brand-panel {
    min-height: 35vh;
    padding: 2rem;
  }
}

.brand-panel::before,
.mesh-grid,
.floating-orb {
  display: none !important;
}

.brand-content {
  position: relative;
  z-index: 10;
  text-align: center;
  max-width: 500px;
}

.brand-panel .brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 200px;
  height: 200px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 36px;
  margin-bottom: 2rem;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.05);
  animation: logoEntrance 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  transform: translateY(30px);
  opacity: 0;
}
.brand-panel .brand-logo-img {
  width: 190px;
  height: auto;
  max-height: 190px;
  object-fit: contain;
}
@keyframes logoEntrance {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.brand-title {
  font-size: clamp(2rem, 1.5rem + 2.5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
  color: var(--primary-color);
  animation: textReveal 0.8s ease-out 0.2s forwards;
  transform: translateY(20px);
  opacity: 0;
}
.brand-subtitle {
  font-size: clamp(1.125rem, 1rem + 0.6vw, 1.25rem);
  font-weight: 400;
  color: var(--text-secondary);
  margin-bottom: 2.5rem;
  animation: textReveal 0.8s ease-out 0.4s forwards;
  transform: translateY(20px);
  opacity: 0;
}
@keyframes textReveal {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.feature-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  animation: textReveal 0.8s ease-out 0.6s forwards;
  transform: translateY(20px);
  opacity: 0;
}
.feature-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 100px;
  font-size: 0.875rem;
  font-weight: 500;
  color: white;
  transition: 0.25s ease;
}
.feature-pill:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}
.feature-pill i {
  font-size: 0.875rem;
  opacity: 0.9;
}
@media (max-width: 1024px) {
  .brand-panel .brand-logo {
    width: 160px;
    height: 160px;
    margin-bottom: 1.5rem;
  }
  .brand-panel .brand-logo-img {
    max-height: 100px;
    width: 100px;
  }
  .brand-title {
    font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2rem);
  }
  .feature-pills {
    display: none;
  }
}

/* Panel derecho: formulario */
.form-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  background: #ffffff;
  position: relative;
  overflow: hidden;
}
/* No gradients on login panels */
.form-panel::before,
.form-panel::after {
  display: none !important;
}

.form-container {
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 10;
}

.form-header {
  text-align: center;
  margin-bottom: 2.5rem;
}
.form-header-brand {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--primary-light);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}
.form-header h2 {
  font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2rem);
  font-weight: 700;
  color: var(--light-bg);
  margin-bottom: 0.5rem;
}
.form-header p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.login-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 32px;
  padding: 2.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 1.5rem;
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  border-radius: 14px;
  padding: 6px;
}

.auth-tab {
  flex: 1;
  padding: 0.65rem 0.85rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

.auth-tab.active {
  background: #ffffff;
  color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.auth-panel {
  display: none;
}

.auth-panel.active {
  display: block;
}

.form-hint {
  margin-top: 6px;
  font-size: 0.8rem;
  color: rgba(226, 232, 240, 0.7);
}

.login-card .form-group {
  margin-bottom: 1.5rem;
}
.login-card .form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
}

.login-card .input-wrapper {
  position: relative;
}
.login-card .form-input {
  width: 100%;
  padding: 1rem 1rem 1rem 1rem;
  background-color: #f8fafc !important;
  border: 1.5px solid #f1f5f9;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text-primary);
  transition: 0.25s;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  caret-color: var(--primary-color);
}
.login-card .form-input::placeholder {
  color: var(--text-secondary);
}
/* Sin hover en inputs del login */
.login-card .form-input:focus {
  border-color: var(--primary-color);
  background-color: #ffffff !important;
  box-shadow: 0 0 0 4px var(--primary-light);
}

/* Evitar blanco por autofill del navegador */
.login-card .form-input:-webkit-autofill,
.login-card .form-input:-webkit-autofill:hover,
.login-card .form-input:-webkit-autofill:focus,
.login-card .form-input:autofill {
  -webkit-text-fill-color: var(--light-bg);
  transition: background-color 9999s ease-in-out 0s;
  box-shadow: 0 0 0 1000px rgba(15, 23, 42, 0.6) inset;
}

.login-card .input-wrapper:has(.password-toggle) .form-input {
  padding-right: 3rem;
}
.password-toggle {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  transition: 0.15s;
}
.password-toggle:hover {
  color: var(--slate-200, #e2e8f0);
}

/* Error container (login) */
.login-card .error-container {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 12px;
  margin-bottom: 1.5rem;
  animation: shakeError 0.5s ease-in-out;
}
.login-card .error-container.show {
  display: flex;
}
.login-card .error-container i {
  color: #ef4444;
  font-size: 1.25rem;
}
.login-card .error-container span {
  font-size: 0.875rem;
  color: #fca5a5;
}
@keyframes shakeError {
  0%,
  100% {
    transform: translateX(0);
  }
  20%,
  60% {
    transform: translateX(-8px);
  }
  40%,
  80% {
    transform: translateX(8px);
  }
}

/* Botón submit (login) */
.login-card .btn-submit {
  width: 100%;
  padding: 1rem 1.5rem;
  background: var(--primary-color);
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: 0.25s;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 4px 20px rgba(46, 121, 183, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.login-card .btn-submit .btn-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.login-card .btn-submit:hover {
  transform: translateY(-2px);
  box-shadow:
    0 8px 30px rgba(46, 121, 183, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.login-card .btn-submit:active {
  transform: translateY(0);
}
.login-card .btn-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}
.login-card .btn-submit:hover i {
  transform: translateX(4px);
}
.login-card .btn-submit i {
  transition: transform 0.3s;
}

.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 2rem 0;
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(0, 0, 0, 0.05);
}

/* Settings */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.settings-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.settings-card h3 {
  margin-bottom: 16px;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.settings-actions-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.settings-color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.color-dot {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--border-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.color-input {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: transparent;
}

.settings-upload-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.settings-upload-row .form-control {
  flex: 1;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--text-primary);
}

.range-value {
  display: inline-flex;
  margin-left: 8px;
  font-weight: 600;
  color: var(--text-secondary);
}

.settings-note {
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.menu-icons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 12px;
  margin-bottom: 12px;
}

.menu-icon-select {
  appearance: none;
  background: #fff;
}

/* Facturas */
.invoices-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.invoice-stat {
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
}

.invoice-stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  background: var(--primary-color);
  box-shadow: 0 4px 10px rgba(255, 0, 132, 0.1);
}

.invoice-stat.pending .invoice-stat-icon {
  background: #f59e0b;
}

.invoice-stat.paid .invoice-stat-icon {
  background: #10b981;
}

.invoice-stat.cancelled .invoice-stat-icon {
  background: #ef4444;
}

.invoice-dashboard-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.invoice-editor {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 24px;
}

@media (max-width: 1024px) {
  .invoice-editor {
    grid-template-columns: 1fr;
  }
}

.invoice-editor-form,
.invoice-editor-preview {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
}

.invoice-items-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.invoice-item-row {
  display: grid;
  grid-template-columns: 2fr 0.6fr 0.8fr 0.8fr 40px;
  gap: 10px;
  margin-bottom: 10px;
}

.invoice-item-row input {
  min-width: 0;
}

.invoice-totals {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.invoice-total-box {
  background: var(--light-bg);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.invoice-rate {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(37, 99, 235, 0.08);
  color: #1e40af;
  font-weight: 600;
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.invoice-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.invoice-editor-preview {
  background: #ffffff;
  color: #111111;
  border: 1px solid #e5e7eb;
}

.invoice-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.invoice-preview-brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.invoice-preview-brand img {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
}

#invoice-preview-control {
  color: #dc2626;
  font-weight: 700;
}

.invoice-preview-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #6b7280;
}

.invoice-preview-status {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
  font-weight: 600;
  font-size: 0.85rem;
}

.invoice-preview-customer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.invoice-preview-items {
  margin-top: 16px;
}

.invoice-preview-row {
  display: grid;
  grid-template-columns: 2fr 0.6fr 0.8fr 0.8fr;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}

.invoice-preview-row.header {
  font-weight: 700;
  color: #6b7280;
}

.invoice-preview-footer {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.invoice-preview-rate {
  margin-top: 12px;
  font-size: 0.9rem;
  color: #6b7280;
}

.invoice-preview-total-bs {
  margin-top: 6px;
  font-size: 0.95rem;
  color: #111111;
  font-weight: 700;
}
.invoice-preview-total {
  text-align: right;
  font-size: 1.1rem;
  min-width: 200px;
}

.invoice-preview-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.95rem;
  color: #111111;
  margin-bottom: 6px;
}

.invoice-preview-summary-row.total {
  border-top: 1px solid #e5e7eb;
  padding-top: 8px;
  font-size: 1.05rem;
  font-weight: 700;
}

.invoice-vat-toggle {
  margin-bottom: 8px;
}

.invoice-preview-signature {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: #111111;
}

.invoice-preview-signature strong {
  border-top: 1px solid #111111;
  padding-top: 6px;
  max-width: 220px;
}

.invoice-preview-legal {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px dashed #d1d5db;
  border-radius: 10px;
  background: #f9fafb;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.invoice-legal-text {
  font-size: 0.85rem;
  color: #111111;
  line-height: 1.4;
  margin: 0;
}

.invoice-legal-stamps {
  display: flex;
  gap: 12px;
  align-items: center;
}

.invoice-seal {
  width: 86px;
  height: 86px;
  border: 2px solid #111111;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: #111111;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.invoice-qr img {
  width: 86px;
  height: 86px;
  object-fit: cover;
  border: 1px solid #111111;
  border-radius: 6px;
}

@media print {
  @page {
    size: A4;
    margin: 12mm 10mm;
  }
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .invoice-editor-preview {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
  }
}

.invoice-filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.invoice-view-toggle {
  display: flex;
  gap: 8px;
}

.invoice-table-wrap {
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  padding: 12px;
  box-shadow: var(--shadow);
}

.invoice-send-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.invoice-send-panels {
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  padding: 16px;
  box-shadow: var(--shadow);
}

.invoice-send-panel {
  display: none;
}

.invoice-send-panel.active {
  display: block;
}

.invoice-search-results {
  margin-top: 8px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  max-height: 180px;
  overflow-y: auto;
}

.invoice-search-item {
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
}

.invoice-search-item:hover {
  background: var(--light-bg);
}

.invoice-send-progress {
  margin-top: 16px;
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  padding: 16px;
  box-shadow: var(--shadow);
}

.invoice-progress-bar {
  height: 10px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.invoice-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary-color);
  transition: width 0.2s ease;
}

.invoice-progress-meta {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.invoice-progress-logs {
  margin-top: 8px;
  max-height: 160px;
  overflow-y: auto;
  font-size: 12px;
  background: var(--light-bg);
  border-radius: 10px;
  padding: 8px;
}

.invoice-kanban {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.invoice-column {
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  padding: 12px;
  min-height: 320px;
  box-shadow: var(--shadow);
}

.invoice-column h4 {
  margin-bottom: 12px;
}

.invoice-column h4 .badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 6px;
}

.badge.draft {
  background: rgba(100, 116, 139, 0.12);
  color: #475569;
}
.badge.pending {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
}
.badge.paid {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}
.badge.cancelled {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.invoice-card {
  background: var(--light-bg);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  margin-bottom: 12px;
  cursor: grab;
}

.invoice-card:active {
  cursor: grabbing;
  opacity: 0.9;
}

.invoice-card .invoice-status-pill {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 6px;
}

.invoice-status-pill.draft {
  background: rgba(100, 116, 139, 0.12);
  color: #475569;
}
.invoice-status-pill.pending {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
}
.invoice-status-pill.paid {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}
.invoice-status-pill.cancelled {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.invoice-card strong {
  display: block;
  margin-bottom: 6px;
}
.divider span {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.security-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.15);
  border-radius: 100px;
  font-size: 0.75rem;
  color: #86efac;
}
.security-badge i {
  font-size: 0.75rem;
}

.form-footer {
  text-align: center;
  margin-top: 2rem;
}
.form-footer p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

@media (max-width: 640px) {
  .login-card {
    padding: 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-layout *,
  .login-layout *::before,
  .login-layout *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
.login-page :focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: 2px;
}

/* Forms - Estilo profesional */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.875rem;
  letter-spacing: 0.01em;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="file"],
.form-group input[type="tel"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="datetime-local"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  font-size: 0.9375rem;
  background: #fff;
  transition:
    border-color 0.2s,
    box-shadow 0.2s,
    background 0.2s;
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
  border-color: #94a3b8;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(46, 121, 183, 0.12);
}

.form-group textarea {
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
}

.form-group small {
  display: block;
  margin-top: 0.375rem;
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-block;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background-color: #6b7280;
  color: white;
}

.btn-secondary:hover {
  background-color: #4b5563;
}

.btn-danger {
  background-color: var(--danger-color);
  color: white;
}

.btn-danger:hover {
  background-color: var(--primary-dark);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 12px;
}

/* App Layout + Sidebar */
.app-layout {
  display: flex;
  min-height: 100vh;
  background: #ffffff;
}

.navbar {
  background: #ffffff;
  color: var(--text-primary);
  padding: 0;
  box-shadow: 1px 0 0 rgba(0, 0, 0, 0.05);
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  align-self: flex-start;
  z-index: 1000;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease;
}

.nav-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 14px 0 12px 0;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.nav-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 12px 14px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 10px;
  flex-shrink: 0;
}

.nav-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.nav-brand {
  min-width: 0;
}

.nav-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Usuario logueado + puntico verde */
.nav-user-wrap {
  position: relative;
}
.nav-user-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.95);
  padding: 5px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.15s ease;
  max-width: 100%;
  min-width: 0;
}
.nav-user-trigger:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}
.nav-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.nav-user-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.4);
  flex-shrink: 0;
  animation: nav-dot-pulse 2s ease-in-out infinite;
}
@keyframes nav-dot-pulse {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.4);
  }
  50% {
    opacity: 0.85;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
  }
}
.nav-user-name {
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-user-chevron {
  font-size: 10px;
  opacity: 0.7;
  transition: transform 0.2s ease;
}
.nav-user-wrap.open .nav-user-chevron {
  transform: rotate(180deg);
}
.nav-user-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 6px;
  top: auto;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  min-width: 180px;
  z-index: 1100;
  overflow: hidden;
}
.nav-user-dropdown[hidden] {
  display: none !important;
}
.nav-user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
}
.nav-user-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}
.nav-user-dropdown-item i {
  width: 18px;
  opacity: 0.9;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.brand-logo-menu {
  width: var(--sidebar-logo-size);
  height: var(--sidebar-logo-size);
  border-radius: 30px;
  object-fit: cover;
  background: #f8fafc;
  border: 1px solid rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: var(--primary-color);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(46, 121, 183, 0.4);
  flex-shrink: 0;
}

.brand-icon.brand-logo-img {
  width: 80px;
  height: 56px;
  padding: 6px;
  background: transparent;
  box-shadow: none;
}

.brand-logo-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 10px;
  font-weight: 500;
  opacity: 0.65;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar-toggle.sidebar-hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  border: none;
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  transition:
    background 0.2s ease,
    transform 0.15s ease;
  flex-shrink: 0;
}

.sidebar-toggle.sidebar-hamburger:hover {
  background: #e2e8f0;
  transform: scale(1.05);
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}
.nav-menu::-webkit-scrollbar {
  width: 6px;
}
.nav-menu::-webkit-scrollbar-track {
  background: transparent;
}
.nav-menu::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}

.nav-section {
  margin-bottom: 16px;
}

.nav-section:last-child {
  margin-bottom: 0;
}

.nav-section-bottom {
  margin-top: auto;
  padding-top: 12px;
  margin-bottom: 12px;
  padding-bottom: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.nav-logout-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  transition:
    background 0.2s ease,
    color 0.2s ease;
  width: 100%;
  justify-content: center;
}

.nav-logout-link:hover {
  background: transparent;
  color: #dc2626;
}

.nav-logout-link i {
  font-size: 14px;
  opacity: 0.9;
}

.nav-section-bottom .nav-user-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 8px;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  cursor: default;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  padding: 12px 12px 6px 12px;
  margin-bottom: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 12px;
  transition:
    color 0.2s ease,
    background 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
  font-size: var(--sidebar-font-size);
  font-weight: 500;
  min-width: 0;
  position: relative;
  margin-bottom: 2px;
}

.nav-link::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: var(--primary-color);
  border-radius: 0 3px 3px 0;
  transition: height 0.2s ease;
}

.nav-link-icon {
  width: var(--sidebar-icon-size);
  height: var(--sidebar-icon-size);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--sidebar-icon-size);
  flex-shrink: 0;
  color: var(--primary-color);
  transition:
    transform 0.2s ease,
    color 0.2s ease;
}

.nav-link-toggle {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
}

.nav-link-chevron {
  font-size: 12px;
  opacity: 0.7;
  transition: transform 0.2s ease;
}

.nav-section.open .nav-link-chevron {
  transform: rotate(180deg);
}

.nav-submenu {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 4px 6px 8px 6px;
}

.nav-section.open .nav-submenu {
  display: flex;
}

.nav-sublink {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 32px;
  border-radius: 8px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: calc(var(--sidebar-font-size) * 0.95);
  transition:
    background 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
}

.nav-sublink i {
  font-size: calc(var(--sidebar-icon-size) * 0.9);
  width: calc(var(--sidebar-icon-size) * 0.9);
  text-align: center;
}

.nav-sublink:hover {
  color: var(--primary-color);
  background: transparent;
  transform: translateX(4px);
}

.nav-sublink.active {
  color: var(--primary-color);
  background: var(--primary-light);
  box-shadow: none;
}

.nav-link-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}

.nav-link:hover {
  color: var(--primary-color);
  background: var(--primary-light);
  transform: translateX(4px);
}

.nav-link:hover .nav-link-icon {
  transform: scale(1.12);
}

.nav-link:active {
  transform: translateX(4px);
}

.nav-link.active {
  color: var(--primary-color);
  background: var(--primary-light);
}

.nav-link.active::before {
  height: 60%;
}

.nav-link.active .nav-link-icon {
  color: var(--primary-color);
  transform: scale(1.15);
}

.nav-link-danger {
  color: rgba(40, 106, 162, 0.95);
}

.nav-link-danger:hover {
  background: rgba(40, 106, 162, 0.12);
  color: var(--primary-dark);
}

.nav-link-danger.active {
  background: rgba(40, 106, 162, 0.15);
  border-color: rgba(40, 106, 162, 0.3);
}

.nav-link-danger.active::before {
  background: var(--primary-dark);
}

body.sidebar-collapsed .navbar {
  width: 80px;
  min-width: 80px;
  overflow-x: hidden;
}

body.sidebar-collapsed .brand-logo-menu {
  width: 32px;
  height: 32px;
}

body.sidebar-collapsed .nav-container {
  padding: 16px 0;
}

body.sidebar-collapsed .nav-header {
  padding: 0 12px 14px 12px;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 0;
}

body.sidebar-collapsed .nav-header-row {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
  width: 100%;
}

body.sidebar-collapsed .nav-user-wrap {
  padding: 6px;
}
body.sidebar-collapsed .nav-user-name {
  display: none;
}
body.sidebar-collapsed .nav-logout-text {
  display: none;
}

body.sidebar-collapsed .nav-brand {
  justify-content: center;
  flex-direction: column;
  gap: 2px;
}
body.sidebar-collapsed .brand-title-menu {
  display: none;
}
body.sidebar-collapsed .brand-title-collapsed {
  display: block;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

body.sidebar-collapsed .nav-section-title {
  display: none;
}

body.sidebar-collapsed .nav-submenu {
  display: none !important;
}

body.sidebar-collapsed .nav-link-chevron {
  display: none;
}

body.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: 12px;
  margin: 0 8px;
  border-radius: 8px;
}

body.sidebar-collapsed .nav-link-text {
  display: none;
}

body.sidebar-collapsed .nav-link-icon {
  margin: 0;
  width: 24px;
  height: 24px;
  font-size: 18px;
}

body.sidebar-collapsed .nav-menu {
  padding: 0 8px;
  overflow-x: hidden;
}

body.sidebar-collapsed .nav-section {
  margin-bottom: 12px;
}

body.sidebar-collapsed .nav-section-bottom {
  margin-top: auto;
  padding-top: 16px;
  justify-content: center;
}

body.sidebar-collapsed .nav-section-bottom .nav-user-wrap {
  justify-content: center;
}

body.sidebar-collapsed .sidebar-toggle.sidebar-hamburger {
  display: flex !important;
  flex-shrink: 0;
}

/* Estilos para botones de iconos en historial */
.action-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s ease;
  background: transparent;
}

.btn-icon-primary {
  color: var(--primary-color);
  background: rgba(46, 121, 183, 0.1);
}

.btn-icon-primary:hover {
  background: var(--primary-color);
  color: white;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(46, 121, 183, 0.3);
}

.btn-icon-danger {
  color: var(--danger-color);
  background: rgba(40, 106, 162, 0.1);
}

.btn-icon-danger:hover {
  background: var(--danger-color);
  color: white;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(40, 106, 162, 0.3);
}

/* Versión flotante en esquina inferior derecha */
/* Chatbot Toggle Button */
.chatbot-toggle {
  position: fixed;
  right: 16px;
  bottom: 60px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-color);
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(46, 121, 183, 0.4);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  animation: pulse 2s infinite;
}

.chatbot-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(46, 121, 183, 0.6);
}

.chatbot-toggle:active {
  transform: scale(0.95);
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 4px 12px rgba(46, 121, 183, 0.4);
  }
  50% {
    box-shadow: 0 4px 20px rgba(46, 121, 183, 0.7);
  }
}

/* Chatbot Modal */
.chatbot-modal {
  position: fixed;
  right: 16px;
  bottom: 130px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 150px);
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  z-index: 999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}

.chatbot-modal.active {
  display: flex;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chatbot-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chatbot-header {
  background: var(--primary-color);
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chatbot-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.chatbot-header-info h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.chatbot-header-info p {
  margin: 0;
  font-size: 12px;
  opacity: 0.9;
}

.chatbot-clear,
.chatbot-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  font-size: 14px;
}

.chatbot-clear:hover,
.chatbot-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.chatbot-message {
  display: flex;
  gap: 10px;
  animation: fadeIn 0.3s ease;
}

.chatbot-message-user {
  flex-direction: row-reverse;
}

.chatbot-avatar-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.chatbot-message-user .chatbot-avatar-small {
  background: var(--text-secondary);
}

.chatbot-message-content {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 12px;
  background: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chatbot-message-user .chatbot-message-content {
  background: var(--primary-color);
  color: white;
}

.chatbot-message-content p {
  margin: 0 0 8px 0;
  font-size: 14px;
  line-height: 1.5;
}

.chatbot-message-content p:last-child {
  margin-bottom: 0;
}

.chatbot-message-content ul {
  margin: 8px 0;
  padding-left: 20px;
}

.chatbot-message-content li {
  margin: 4px 0;
  font-size: 13px;
}

.chatbot-input-container {
  padding: 16px;
  background: white;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
}

.chatbot-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.chatbot-input:focus {
  border-color: var(--primary-color);
}

.chatbot-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-color);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.chatbot-send:hover {
  transform: scale(1.1);
}

.chatbot-send:active {
  transform: scale(0.95);
}

.app-version {
  position: fixed;
  right: 16px;
  bottom: 12px;
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.7;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 50;
}

.app-version i {
  font-size: 10px;
}

/* Main Content */
.main-content {
  flex: 1;
  min-width: 0;
  max-width: none;
  margin: 0;
  padding: 32px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 32px;
  font-weight: 700;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: white;
  padding: 24px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-card-clickable {
  cursor: pointer;
}
.stat-card-clickable:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.stat-icon-warning {
  background: #f59e0b !important;
}

.stat-icon {
  font-size: 40px;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-color);
  color: white;
  border-radius: 12px;
  flex-shrink: 0;
}

.stat-icon i {
  font-size: 28px;
}

.stat-info h3 {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.stat-info p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Dashboard profesional */
.dashboard-header {
  margin-bottom: 28px;
}
.dashboard-subtitle {
  margin: 8px 0 0;
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 400;
}

.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}
@media (min-width: 900px) {
  .dashboard-cards {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (min-width: 1200px) {
  .dashboard-cards {
    grid-template-columns: repeat(6, 1fr);
  }
}

.dashboard-charts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
@media (min-width: 768px) {
  .dashboard-charts {
    grid-template-columns: 1fr 1fr;
  }
}
.dashboard-chart-wide {
  grid-column: 1 / -1;
  padding-left: 0;
  padding-right: 0;
}
.dashboard-chart-wide .dashboard-chart-title {
  padding-left: 24px;
  padding-right: 24px;
}
.dashboard-chart-wide .dashboard-chart-wrap {
  width: 100%;
  max-width: 100%;
  padding: 0 8px 16px;
}
.dashboard-chart-kpi {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.dashboard-chart-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.2s;
}
.dashboard-chart-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dashboard-chart-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dashboard-chart-title i {
  color: var(--primary-color);
}

.dashboard-chart-wrap {
  position: relative;
  height: 280px;
}
.dashboard-no-data {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  z-index: 1;
  background: rgba(255, 255, 255, 0.8);
}
.dashboard-chart-wrap.dashboard-chart-mini {
  height: 120px;
  max-width: 160px;
  margin: 0 auto;
}

.dashboard-kpi-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1.2;
}
.dashboard-kpi-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 8px 0 16px;
}

/* Templates */
.templates-list {
  display: grid;
  gap: 20px;
}

.template-card {
  background: white;
  padding: 24px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.template-info h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.template-info p {
  color: var(--text-secondary);
  font-size: 14px;
}

.template-badge {
  display: inline-block;
  padding: 4px 12px;
  background-color: var(--success-color);
  color: white;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  margin-left: 8px;
}

.template-actions {
  display: flex;
  gap: 8px;
}

/* Vista Editor de Plantilla (página completa) */
.template-editor-view {
  max-width: 100%;
  padding-bottom: 2rem;
}

.template-editor-header {
  margin-bottom: 1.5rem;
}

.template-editor-back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary-color);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  margin-bottom: 1rem;
  transition:
    color 0.2s,
    transform 0.2s;
}

.template-editor-back:hover {
  color: var(--primary-dark);
  transform: translateX(-2px);
}

.template-editor-back i {
  font-size: 1rem;
}

.template-editor-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
}

.template-editor-subtitle {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin: 0;
}

.template-editor-card {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.template-editor-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.template-editor-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.template-editor-section-content {
  gap: 0.75rem;
}

.template-editor-label {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.template-editor-input {
  width: 100%;
  max-width: 480px;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  font-size: 1rem;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.template-editor-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(46, 121, 183, 0.12);
}

.template-editor-section-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.template-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.template-editor-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .template-editor-layout {
    grid-template-columns: 1fr;
  }
  .template-widgets-panel {
    order: -1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem;
  }
  .template-widgets-list {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .template-widgets-title,
  .template-widgets-hint {
    width: 100%;
  }
}

.template-widgets-panel {
  background: var(--light-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  position: sticky;
  top: 1rem;
}

.template-widgets-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.template-widgets-title i {
  color: var(--primary-color);
}

.template-widgets-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0 0 0.75rem;
}

.template-widgets-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.template-widget-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--text-primary);
  cursor: grab;
  transition:
    background 0.2s,
    border-color 0.2s,
    box-shadow 0.2s;
}

.template-widget-item:hover {
  background: rgba(46, 121, 183, 0.06);
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(46, 121, 183, 0.15);
}

.template-widget-item:active {
  cursor: grabbing;
}

.template-widget-item i {
  color: var(--primary-color);
  width: 1.25rem;
  text-align: center;
}

.template-editor-main {
  min-width: 0;
}

.template-editor-dropzone.drag-over {
  outline: 2px dashed var(--primary-color);
  outline-offset: -2px;
  background: rgba(46, 121, 183, 0.04);
}

.template-editor-preview-wrap {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  background: var(--light-bg);
  min-height: 420px;
  max-height: 70vh;
  overflow-y: auto;
}

.template-editor-preview-inner {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  min-height: 360px;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.template-editor-editor-wrap {
  height: 480px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: white;
  overflow: hidden;
}

.template-editor-quill {
  height: 100%;
}

.template-editor-html-wrap {
  height: 480px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
}

.template-editor-help {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.template-editor-help code {
  background: rgba(46, 121, 183, 0.1);
  color: var(--primary-color);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.8125rem;
}

.template-editor-section-options {
  padding-top: 0.5rem;
}

.template-editor-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
  color: var(--text-primary);
  cursor: pointer;
}

.template-editor-checkbox-label input {
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--primary-color);
}

.template-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
  padding-top: 1.5rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--border-color);
}

.template-editor-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

@media (max-width: 768px) {
  .template-editor-card {
    padding: 1.25rem;
  }
  .template-editor-title {
    font-size: 1.5rem;
  }
  .template-editor-editor-wrap,
  .template-editor-html-wrap {
    height: 380px;
  }
}

/* ========== Agregar clientes nuevos (vista espectacular) ========== */
#add-clients-page {
  padding-bottom: 2rem;
  background: #f1f5f9;
  margin-left: -32px;
  margin-right: -32px;
  margin-top: -32px;
  padding: 32px;
  min-height: 100%;
}
@media (max-width: 1024px) {
  #add-clients-page {
    margin: -20px -16px 0;
    padding: 20px 16px 2rem;
  }
}
@media (max-width: 768px) {
  #add-clients-page {
    margin: -12px -10px 0;
    padding: 12px 10px 2rem;
  }
}
@media (max-width: 480px) {
  #add-clients-page {
    margin: -8px -6px 0;
    padding: 8px 6px 1.5rem;
  }
}

.add-clients-hero {
  position: relative;
  padding: clamp(2rem, 5vw, 3.5rem) 1.5rem;
  margin: -1rem -1.5rem 2rem -1.5rem;
  border-radius: 0 0 24px 24px;
  overflow: hidden;
  isolation: isolate;
}
.add-clients-hero-compact {
  padding: clamp(0.875rem, 2vw, 1.25rem) 1.5rem;
  margin: -1rem -1.5rem 1.25rem -1.5rem;
  border-radius: 0 0 16px 16px;
}
.add-clients-hero-compact .add-clients-hero-icon-wrap {
  width: 44px;
  height: 44px;
  margin: 0 auto 0.5rem;
  border-radius: 12px;
}
.add-clients-hero-compact .add-clients-hero-icon-wrap i {
  font-size: 1.2rem;
}
.add-clients-hero-compact .add-clients-hero-title {
  font-size: clamp(1.15rem, 2.5vw, 1.4rem);
  font-weight: 700;
  margin: 0 0 0.25rem;
}
.add-clients-hero-compact .add-clients-hero-subtitle {
  font-size: 0.8125rem;
  opacity: 0.92;
}
.add-clients-hero-compact .add-clients-orb-1 {
  width: 160px;
  height: 160px;
  top: -40px;
  right: -40px;
}
.add-clients-hero-compact .add-clients-orb-2 {
  width: 120px;
  height: 120px;
  bottom: -30px;
  left: -30px;
}

.add-clients-hero-bg {
  position: absolute;
  inset: 0;
  background: var(--primary-color);
  z-index: 0;
}

.add-clients-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.4;
  animation: addClientsOrb 10s ease-in-out infinite;
}
.add-clients-orb-1 {
  width: 320px;
  height: 320px;
  background: rgba(255, 255, 255, 0.2);
  top: -80px;
  right: -80px;
}
.add-clients-orb-2 {
  width: 240px;
  height: 240px;
  background: var(--primary-light);
  bottom: -60px;
  left: -60px;
  animation-delay: -4s;
  opacity: 0.3;
}
@keyframes addClientsOrb {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(20px, -20px) scale(1.05);
  }
}

/* No mesh background */
.add-clients-mesh {
  display: none !important;
}
@keyframes addClientsMesh {
  0% {
    transform: translate(0, 0);
  }
  100% {
    transform: translate(48px, 48px);
  }
}

.add-clients-hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 560px;
  margin: 0 auto;
}

.add-clients-hero-icon-wrap {
  width: 72px;
  height: 72px;
  margin: 0 auto 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  animation: addClientsIconIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.add-clients-hero-icon-wrap i {
  font-size: 2rem;
  color: #fff;
}
@keyframes addClientsIconIn {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.add-clients-hero-title {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 800;
  color: #fff;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
  animation: addClientsTextIn 0.5s ease-out 0.15s both;
}
.add-clients-hero-subtitle {
  font-size: clamp(0.9375rem, 1.5vw, 1.0625rem);
  color: rgba(255, 255, 255, 0.9);
  margin: 0;
  line-height: 1.5;
  animation: addClientsTextIn 0.5s ease-out 0.25s both;
}
@keyframes addClientsTextIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Add Clients - Diseño profesional */
.add-clients-card {
  max-width: 720px;
  margin: 0 auto;
}

.add-clients-card-inner {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 20px;
  padding: clamp(1.75rem, 4vw, 2.5rem);
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.05),
    0 10px 20px -10px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.3s ease;
}
.add-clients-card-inner:hover {
  box-shadow:
    0 8px 12px -2px rgba(0, 0, 0, 0.06),
    0 16px 32px -12px rgba(0, 0, 0, 0.1);
}

.add-clients-step {
  margin-bottom: 1.5rem;
}

.add-clients-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}
.add-clients-label i {
  color: var(--primary-color);
  font-size: 1rem;
}

.add-clients-select {
  width: 100%;
  padding: 0.875rem 1rem 0.875rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.9);
  border: 1.5px solid var(--border-color);
  border-radius: 12px;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.75rem;
}
.add-clients-select:hover {
  border-color: var(--primary-light);
}
.add-clients-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(46, 121, 183, 0.15);
}

.add-clients-hint {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0.5rem 0 0;
}

.add-clients-form-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.add-clients-form-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.25rem;
  letter-spacing: -0.01em;
}
.add-clients-form-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.4;
}

.add-clients-form-fields {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.add-clients-form-fields-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem 1.75rem;
  align-items: start;
}
@media (max-width: 640px) {
  .add-clients-form-fields-cols {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
}
.add-clients-form-fields-cols .add-clients-field-full {
  grid-column: 1 / -1;
}

.add-clients-form-fields .form-group {
  margin-bottom: 0;
}
.add-clients-form-fields label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  letter-spacing: 0.01em;
}
.add-clients-form-fields .form-control {
  width: 100%;
  padding: 0.8125rem 1rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  color: var(--text-primary);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}
.add-clients-form-fields .form-control::placeholder {
  color: #94a3b8;
}
.add-clients-form-fields .form-control:hover {
  border-color: #cbd5e1;
}
.add-clients-form-fields .form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(46, 121, 183, 0.15);
}
.add-clients-form-fields textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.add-clients-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.add-clients-btn-cancel {
  padding: 0.625rem 1.25rem;
  font-weight: 600;
  border-radius: 10px;
}
.add-clients-btn-submit {
  min-width: 180px;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  border-radius: 10px;
}
.add-clients-btn-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.add-clients-empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}
.add-clients-empty-state.hidden {
  display: none;
}
.add-clients-empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(46, 121, 183, 0.08);
  border-radius: 16px;
  color: var(--primary-color);
  font-size: 1.5rem;
}

.add-clients-form-wrap[hidden] {
  display: none !important;
}
.add-clients-form-wrap:not([hidden]) {
  display: block;
  animation: addClientsFormIn 0.4s ease-out;
}
@keyframes addClientsFormIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Formulario clientes: grupos, hints y errores */
.add-clients-field-group {
  margin-bottom: 0;
}
.add-clients-field-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
  margin-bottom: 0.5rem;
}
.add-clients-field-hint {
  font-size: 0.75rem;
  color: var(--text-secondary, #64748b);
  margin-top: 0.25rem;
  margin-bottom: 0;
}
.add-clients-field-error {
  display: block;
  font-size: 0.8125rem;
  color: #dc2626;
  margin-top: 0.375rem;
  min-height: 1.25em;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.add-clients-field-error.visible {
  opacity: 1;
}
.add-clients-input.is-invalid,
.add-clients-tel-prefix.is-invalid,
.add-clients-tel-numero.is-invalid {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12) !important;
}
.add-clients-input.is-valid,
.add-clients-tel-prefix.is-valid,
.add-clients-tel-numero.is-valid {
  border-color: #22c55e !important;
}
.add-clients-input:focus.is-invalid {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
  outline: none;
}

/* Fila teléfono Venezuela: prefijo + 7 dígitos */
.add-clients-tel-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 0.75rem;
  align-items: start;
}
@media (max-width: 480px) {
  .add-clients-tel-row {
    grid-template-columns: 1fr;
  }
}
.add-clients-tel-prefix,
.add-clients-tel-numero {
  width: 100%;
}

/* Send Container - Diseño profesional */
.send-container {
  background: #ffffff;
  padding: 2rem;
  border-radius: 16px;
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.06),
    0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 2rem;
  background: #f1f5f9;
  padding: 6px;
  border-radius: 12px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

.tab-btn {
  padding: 0.875rem 1.5rem;
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #64748b;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.tab-btn i {
  font-size: 1rem;
  opacity: 0.9;
}

.tab-btn:hover {
  color: var(--primary-color);
  background: rgba(255, 255, 255, 0.8);
  transform: translateY(-1px);
}

.tab-btn.active {
  color: white;
  background: var(--primary-color);
  box-shadow: 0 4px 14px rgba(46, 121, 183, 0.4);
}

.tab-content {
  display: none;
  animation: fadeInContent 0.3s ease;
}

@keyframes fadeInContent {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tab-content.active {
  display: block;
}

.send-form {
  max-width: 640px;
  margin: 0 auto;
}

.send-form .form-group {
  margin-bottom: 1.5rem;
}

.send-form label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.send-form input[type="text"],
.send-form input[type="email"],
.send-form input[type="tel"],
.send-form select,
.send-form textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  font-size: 0.9375rem;
  transition: all 0.2s ease;
  background: #fff;
}

.send-form input:focus,
.send-form select:focus,
.send-form textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(46, 121, 183, 0.12);
}

.send-form small {
  display: block;
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 13px;
}

.send-form input[type="file"] {
  width: 100%;
  padding: 12px;
  border: 2px dashed var(--border-color);
  border-radius: 10px;
  background: var(--light-bg);
  cursor: pointer;
  transition: all 0.3s ease;
}

.send-form input[type="file"]:hover {
  border-color: var(--primary-color);
  background: rgba(46, 121, 183, 0.05);
}

/* User selection (tabla pruebas) */
.user-selection-wrap label {
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.user-selection-box {
  max-height: 320px;
  overflow-y: auto;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  background: #ffffff;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}
.user-selection-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}
.user-selection-buttons {
  display: flex;
  gap: 0.5rem;
}
.user-selection-count {
  font-weight: 600;
  color: var(--primary-color);
  font-size: 0.875rem;
}
.users-list {
  display: grid;
  gap: 0.5rem;
}
.user-selection-item,
.users-list label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: #fff;
  cursor: pointer;
  transition: all 0.2s;
}
.user-selection-item:hover,
.users-list label:hover {
  border-color: var(--primary-color);
  background: rgba(46, 121, 183, 0.04);
}
.users-list .user-checkbox,
.user-selection-item .user-checkbox {
  accent-color: var(--primary-color);
  flex-shrink: 0;
}

/* Table */
.table-container {
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead {
  background: var(--primary-color);
  color: white;
}

.data-table th {
  padding: 18px 20px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: none;
}

.data-table td {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
  background: white;
}

.data-table tbody tr {
  transition: all 0.2s ease;
}

.data-table tbody tr:hover {
  background: var(--light-bg);
  transform: scale(1.01);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Estilos específicos para tabla de actividades */
.activity-table {
  border-radius: 12px;
  overflow: hidden;
}

.activity-row {
  border-left: 4px solid transparent;
}

.activity-row:hover {
  border-left-color: var(--primary-color);
}

.activity-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.activity-badge-create {
  background: #d1fae5;
  color: #065f46;
}

.activity-badge-update {
  background: #dbeafe;
  color: #1e40af;
}

.activity-badge-delete {
  background: #dbeafe;
  color: #1e40af;
}

.activity-badge-send {
  background: #fef3c7;
  color: #92400e;
}

.activity-badge-default {
  background: #e5e7eb;
  color: #374151;
}

.data-table tbody tr:hover {
  background-color: var(--light-bg);
}

/* Tabla "Gestionar clientes": celdas largas con ellipsis y tooltip al pasar el cursor */
#users-table-container .data-table {
  table-layout: fixed;
}
#users-table-container .data-table .cell-text-ellipsis {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#users-table-container .data-table th {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Tabla Historial de Envíos: una línea con ellipsis y tooltip */
#history-table-container .data-table {
  table-layout: fixed;
}
#history-table-container .data-table .cell-text-ellipsis {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#history-table-container .data-table th {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  text-transform: capitalize;
}

.badge-warning {
  background-color: #fef3c7;
  color: #92400e;
}

.badge-info {
  background-color: #dbeafe;
  color: #1e40af;
}

.badge-success {
  background-color: #d1fae5;
  color: #065f46;
}

.badge-danger {
  background-color: #dbeafe;
  color: #1e40af;
}

.badge-secondary {
  background-color: #f3f4f6;
  color: #374151;
}

/* Modal correos no entregados */
.no-entregados-intro {
  margin-bottom: 1.25rem;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}
.motivo-no-entrega {
  max-width: 280px;
  word-break: break-word;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.4;
}
.no-entregados-count {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}
#no-entregados-pagination button {
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--border-color);
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  transition: all 0.2s;
}
#no-entregados-pagination button:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.status-enviado {
  background-color: #d1fae5;
  color: #065f46;
}

.status-rebotado {
  background-color: #dbeafe;
  color: #1e40af;
}

.status-error {
  background-color: #dbeafe;
  color: #1e40af;
}

.status-pendiente {
  background-color: #fef3c7;
  color: #92400e;
}

.history-filters-toggle {
  display: none;
}
.history-filters {
  margin-bottom: 20px;
  padding: 16px;
  border-radius: 12px;
  background: var(--light-bg, #f5f7fa);
  border: 1px solid var(--border-color);
}

.history-filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-end;
}

.history-filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}

.history-filter-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.history-filter-group .form-control {
  min-width: 0;
}

.history-filter-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.history-filter-actions .btn {
  white-space: nowrap;
}

@media (max-width: 768px) {
  .history-filters-row {
    flex-direction: column;
    align-items: stretch;
  }
  .history-filter-group {
    min-width: 0;
  }
  .history-filter-actions {
    justify-content: flex-start;
  }
}

.history-controls {
  margin-bottom: 0;
}

.history-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

/* Modal previsualización Excel */
.excel-preview-header {
  margin-bottom: 20px;
}
.excel-preview-stats {
  background: var(--primary-color);
  color: white;
  padding: 16px 20px;
  border-radius: 12px;
  margin-bottom: 12px;
}
.excel-preview-stats h3 {
  margin: 0;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.excel-preview-note {
  margin: 8px 0 0 0;
  opacity: 0.95;
  font-size: 0.9rem;
}
.excel-preview-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}
.excel-preview-columns span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.excel-preview-columns i {
  color: var(--primary-color);
}
.excel-preview-table-wrap {
  max-height: 420px;
  overflow: auto;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: #fff;
}
.excel-preview-table {
  width: 100%;
  border-collapse: collapse;
}
.excel-preview-table thead {
  position: sticky;
  top: 0;
  background: var(--light-bg);
  z-index: 1;
  box-shadow: 0 1px 0 var(--border-color);
}
.excel-preview-table th {
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}
.excel-preview-table td {
  padding: 10px 14px;
  border-top: 1px solid var(--border-color);
  font-size: 14px;
}
.excel-preview-table tbody tr:hover {
  background: var(--light-bg);
}
.excel-preview-col-num {
  width: 56px;
  text-align: center;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* Zona de carga de archivo Excel (custom, sin "Elegir archivo") */
.excel-upload-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 24px;
  border: 2px dashed var(--primary-color);
  border-radius: 12px;
  background: rgba(46, 121, 183, 0.06);
  cursor: pointer;
  transition:
    border-color 0.2s,
    background 0.2s,
    color 0.2s;
}
.excel-upload-zone:hover {
  border-color: var(--primary-dark);
  background: rgba(46, 121, 183, 0.1);
}
.excel-upload-zone:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(46, 121, 183, 0.25);
}
.excel-upload-zone.has-file {
  border-style: solid;
  border-color: var(--success-color);
  background: rgba(16, 185, 129, 0.08);
}
.excel-upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.excel-upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--primary-color);
  pointer-events: none;
}
.excel-upload-zone.has-file .excel-upload-placeholder {
  display: none;
}
.excel-upload-icon {
  font-size: 28px;
  opacity: 0.9;
}
.excel-upload-text {
  font-size: 15px;
  font-weight: 600;
}
.excel-upload-filename {
  display: none;
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.excel-upload-zone.has-file .excel-upload-filename {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.excel-upload-zone.has-file .excel-upload-filename i {
  color: var(--success-color);
  font-size: 20px;
}

/* Página Programar Envíos: estructura y estilos */
.schedule-page .send-container.schedule-container {
  background: transparent;
  box-shadow: none;
  border: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 32px;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

.schedule-form-card,
.schedule-list-section {
  background: white;
  padding: 24px 28px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.schedule-section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 20px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.schedule-section-title i {
  color: var(--primary-color);
  font-size: 20px;
}

.schedule-form-block {
  margin-bottom: 24px;
}

.schedule-form-block:last-of-type {
  margin-bottom: 0;
}

.schedule-block-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 12px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

.schedule-form .form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.schedule-datetime-label {
  display: flex !important;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px !important;
  font-weight: 500;
  color: var(--text-primary);
}

.schedule-datetime-label i {
  color: var(--primary-color);
}

.schedule-datetime-input {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.schedule-datetime-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.form-hint {
  display: block;
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 12px;
}

.form-hint i {
  margin-right: 4px;
}

.schedule-form-actions {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.schedule-origin-section {
  margin-top: 20px;
  padding: 16px 18px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--light-bg);
}

.schedule-origin-section .form-group {
  margin-bottom: 12px;
}

.schedule-origin-section .form-group:last-child {
  margin-bottom: 0;
}

.schedule-list-section .schedule-section-title {
  margin-bottom: 16px;
}

.schedule-table-wrap {
  margin-bottom: 16px;
  border-radius: 10px;
  overflow: hidden;
}

.history-controls label,
#users-management-container label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

#history-items-per-page,
#users-items-per-page {
  padding: 8px 12px;
  font-size: 14px;
}

.form-control {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  min-width: 200px;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-large {
  max-width: 1000px;
  width: 95%;
}

/* Modal de consola con tamaño fijo */
#consoleModal .modal-content {
  height: 85vh;
  max-height: 85vh;
}

.modal-header {
  padding: 28px 32px;
  border-bottom: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--primary-color);
  color: white;
}

.modal-header h2 {
  font-size: 24px;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-header h2 i {
  font-size: 28px;
}

.modal-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: white;
  line-height: 1;
  padding: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.modal-body {
  padding: 32px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  background: white;
}

/* Modal Agregar/Editar Usuario - formulario de registro */
#userModal .modal-body {
  padding: 1.5rem 2rem;
}
#user-form-fields {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
#user-form .form-group {
  margin-bottom: 0;
}
#user-form label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.375rem;
}
#user-form .form-control {
  padding: 0.625rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  font-size: 0.9375rem;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
#user-form .form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(46, 121, 183, 0.12);
}
.form-control-readonly {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
  color: #475569;
  cursor: default;
}
.form-control-readonly:focus {
  box-shadow: none !important;
}
#user-form .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color);
  margin-top: 0.5rem;
}

/* Enviar correo individual: botón Buscar clientes */
.send-single-dest-wrap .send-single-dest-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.send-single-dest-wrap .send-single-dest-header label {
  margin-bottom: 0;
}
.send-single-dest-wrap .btn-outline.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.send-single-dest-wrap .btn-outline.btn-sm:hover {
  background: rgba(46, 121, 183, 0.08);
}

/* Modal Buscar clientes */
.search-clients-hint {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}
.search-clients-input-wrap {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.search-clients-input-wrap .search-clients-input {
  flex: 1;
  padding: 0.625rem 1rem;
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  font-size: 1rem;
}
.search-clients-input-wrap .search-clients-input:focus {
  outline: none;
  border-color: var(--primary-color);
}
.search-clients-input-wrap .search-clients-btn {
  padding: 0.625rem 1rem;
  flex-shrink: 0;
}
.search-clients-results {
  min-height: 120px;
}
.search-clients-empty,
.search-clients-loading {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}
.search-clients-empty i,
.search-clients-loading i {
  display: block;
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  color: var(--primary-light);
}
.search-clients-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 280px;
  overflow-y: auto;
}
.search-clients-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition:
    background 0.2s,
    border-color 0.2s;
}
.search-clients-item:hover {
  background: rgba(46, 121, 183, 0.06);
  border-color: var(--primary-light);
}
.search-clients-item-name {
  font-weight: 600;
  color: var(--text-primary);
}
.search-clients-item-detail {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}
.search-clients-no-results,
.search-clients-error {
  text-align: center;
  padding: 1rem;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}
.search-clients-error {
  color: var(--danger-color, #dc2626);
}

/* Modal body de consola con scroll */
#consoleModal .modal-body {
  display: flex;
  flex-direction: column;
  overflow: hidden; /* El scroll estará en el console-output */
  padding: 24px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.error-message {
  background-color: #dbeafe;
  color: #1e40af;
  padding: 12px;
  border-radius: 8px;
  margin-top: 16px;
  font-size: 14px;
}

.success-message {
  background-color: #d1fae5;
  color: #065f46;
  padding: 12px;
  border-radius: 8px;
  margin-top: 16px;
  font-size: 14px;
}

.pagination {
  display: flex;
  gap: 4px;
  justify-content: center;
  align-items: center;
  margin-top: 24px;
  flex-wrap: wrap;
}

.pagination button {
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pagination button:hover:not(:disabled) {
  background-color: var(--light-bg);
  border-color: var(--primary-color);
  color: var(--primary-color);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background-color: #f3f4f6;
}

.pagination button.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(46, 121, 183, 0.3);
  font-weight: 600;
}

.pagination button.active:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(46, 121, 183, 0.4);
}

/* Mejoras adicionales para el paginador */
.pagination button:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(46, 121, 183, 0.1);
}

.pagination button:active:not(:disabled) {
  transform: translateY(0);
}

/* Responsive para paginador */
@media (max-width: 768px) {
  .pagination {
    gap: 2px;
  }

  .pagination button {
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    font-size: 13px;
  }

  .pagination span {
    padding: 0 4px;
    min-width: 24px;
    height: 36px;
  }
}

/* Responsive */
/* Consola de envío */
.console-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  margin-bottom: 20px;
}

.console-stats > div {
  background: #f0f0f0;
  padding: 15px;
  border-radius: 8px;
  text-align: center;
}

#console-output {
  background: #1a1a1a;
  color: #00ff00;
  padding: 15px;
  border-radius: 8px;
  font-family: "Courier New", monospace;
  font-size: 12px;
  white-space: pre-wrap;
  line-height: 1.6;
  word-wrap: break-word;
}

/* Editor WYSIWYG Styles */
#editor-container-wrapper {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: white;
  resize: vertical;
  min-height: 380px;
  overflow: auto;
}

#editor-container {
  height: 100%;
}

#editor-container .ql-container {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  font-size: 14px;
  height: 100%;
  border: none;
  border-top: 1px solid var(--border-color);
}

#editor-container .ql-toolbar {
  border: none;
  border-bottom: 1px solid var(--border-color);
  padding: 12px;
  background: var(--light-bg);
  border-radius: 8px 8px 0 0;
}

#editor-container .ql-toolbar .ql-custom {
  border: none;
  cursor: pointer;
  display: inline-block;
  padding: 4px 8px;
  margin: 0 2px;
}

#editor-container .ql-toolbar .ql-custom:hover {
  background-color: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
}

/* Fuentes en el editor (claves en minúsculas con guiones = whitelist Quill) */
#editor-container .ql-editor .ql-font-arial {
  font-family: Arial, sans-serif;
}
#editor-container .ql-editor .ql-font-georgia {
  font-family: Georgia, serif;
}
#editor-container .ql-editor .ql-font-verdana {
  font-family: Verdana, sans-serif;
}
#editor-container .ql-editor .ql-font-tahoma {
  font-family: Tahoma, sans-serif;
}
#editor-container .ql-editor .ql-font-trebuchet-ms {
  font-family: "Trebuchet MS", sans-serif;
}
#editor-container .ql-editor .ql-font-times-new-roman {
  font-family: "Times New Roman", serif;
}
#editor-container .ql-editor .ql-font-courier-new {
  font-family: "Courier New", monospace;
}
#editor-container .ql-editor .ql-font-lucida-console {
  font-family: "Lucida Console", monospace;
}
#editor-container .ql-editor .ql-font-palatino-linotype {
  font-family: "Palatino Linotype", serif;
}
#editor-container .ql-editor .ql-font-comic-sans-ms {
  font-family: "Comic Sans MS", cursive;
}
#editor-container .ql-editor .ql-font-impact {
  font-family: Impact, sans-serif;
}
#editor-container .ql-editor .ql-font-segoe-ui {
  font-family: "Segoe UI", sans-serif;
}
#editor-container .ql-editor .ql-font-open-sans {
  font-family: "Open Sans", sans-serif;
}
#editor-container .ql-editor .ql-font-roboto {
  font-family: Roboto, sans-serif;
}
#editor-container .ql-editor .ql-font-lato {
  font-family: Lato, sans-serif;
}
#editor-container .ql-editor .ql-font-montserrat {
  font-family: Montserrat, sans-serif;
}
#editor-container .ql-editor .ql-font-oswald {
  font-family: Oswald, sans-serif;
}
#editor-container .ql-editor .ql-font-source-sans-pro {
  font-family: "Source Sans Pro", sans-serif;
}
/* Desplegable fuentes: quitar el "Sans Serif" que Quill pone por defecto en cada opción */
#editor-container .ql-toolbar .ql-font .ql-picker-item::before {
  content: none !important;
  font-family: inherit !important;
}
#editor-container .ql-toolbar .ql-font .ql-picker-label::before {
  font-family: inherit !important;
}
#editor-container .ql-toolbar .ql-font .ql-picker-label[data-value=""]::before {
  content: "Predeterminado" !important;
}
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-item[data-value="arial"]::before,
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-label[data-value="arial"]::before {
  content: "Arial" !important;
  font-family: Arial, sans-serif;
}
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-label[data-value="georgia"]::before,
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-item[data-value="georgia"]::before {
  content: "Georgia" !important;
  font-family: Georgia, serif;
}
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-label[data-value="verdana"]::before,
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-item[data-value="verdana"]::before {
  content: "Verdana" !important;
  font-family: Verdana, sans-serif;
}
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-label[data-value="tahoma"]::before,
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-item[data-value="tahoma"]::before {
  content: "Tahoma" !important;
  font-family: Tahoma, sans-serif;
}
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-label[data-value="trebuchet-ms"]::before,
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-item[data-value="trebuchet-ms"]::before {
  content: "Trebuchet MS" !important;
  font-family: "Trebuchet MS", sans-serif;
}
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-label[data-value="times-new-roman"]::before,
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-item[data-value="times-new-roman"]::before {
  content: "Times New Roman" !important;
  font-family: "Times New Roman", serif;
}
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-label[data-value="courier-new"]::before,
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-item[data-value="courier-new"]::before {
  content: "Courier New" !important;
  font-family: "Courier New", monospace;
}
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-label[data-value="lucida-console"]::before,
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-item[data-value="lucida-console"]::before {
  content: "Lucida Console" !important;
  font-family: "Lucida Console", monospace;
}
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-label[data-value="palatino-linotype"]::before,
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-item[data-value="palatino-linotype"]::before {
  content: "Palatino Linotype" !important;
  font-family: "Palatino Linotype", serif;
}
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-label[data-value="comic-sans-ms"]::before,
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-item[data-value="comic-sans-ms"]::before {
  content: "Comic Sans MS" !important;
  font-family: "Comic Sans MS", cursive;
}
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-label[data-value="impact"]::before,
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-item[data-value="impact"]::before {
  content: "Impact" !important;
  font-family: Impact, sans-serif;
}
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-label[data-value="segoe-ui"]::before,
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-item[data-value="segoe-ui"]::before {
  content: "Segoe UI" !important;
  font-family: "Segoe UI", sans-serif;
}
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-label[data-value="open-sans"]::before,
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-item[data-value="open-sans"]::before {
  content: "Open Sans" !important;
  font-family: "Open Sans", sans-serif;
}
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-label[data-value="roboto"]::before,
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-item[data-value="roboto"]::before {
  content: "Roboto" !important;
  font-family: Roboto, sans-serif;
}
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-label[data-value="lato"]::before,
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-item[data-value="lato"]::before {
  content: "Lato" !important;
  font-family: Lato, sans-serif;
}
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-label[data-value="montserrat"]::before,
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-item[data-value="montserrat"]::before {
  content: "Montserrat" !important;
  font-family: Montserrat, sans-serif;
}
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-label[data-value="oswald"]::before,
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-item[data-value="oswald"]::before {
  content: "Oswald" !important;
  font-family: Oswald, sans-serif;
}
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-label[data-value="source-sans-pro"]::before,
#editor-container
  .ql-toolbar
  .ql-font
  .ql-picker-item[data-value="source-sans-pro"]::before {
  content: "Source Sans Pro" !important;
  font-family: "Source Sans Pro", sans-serif;
}
/* Tamaño: una sola opción "Normal" (false) y el resto en px */
#editor-container .ql-toolbar .ql-size .ql-picker-item[data-value="12px"] {
  font-size: 12px;
}
#editor-container .ql-toolbar .ql-size .ql-picker-item[data-value="14px"] {
  font-size: 14px;
}
#editor-container .ql-toolbar .ql-size .ql-picker-item[data-value="16px"] {
  font-size: 16px;
}
#editor-container .ql-toolbar .ql-size .ql-picker-item[data-value="18px"] {
  font-size: 18px;
}
#editor-container .ql-toolbar .ql-size .ql-picker-item[data-value="20px"] {
  font-size: 20px;
}
#editor-container .ql-toolbar .ql-size .ql-picker-item[data-value="24px"] {
  font-size: 24px;
}
#editor-container .ql-toolbar .ql-size .ql-picker-item[data-value="28px"] {
  font-size: 28px;
}
#editor-container .ql-toolbar .ql-size .ql-picker-item[data-value="32px"] {
  font-size: 32px;
}

#editor-container .ql-editor {
  min-height: 450px;
  padding: 20px;
}

#editor-container .ql-editor.ql-blank::before {
  font-style: normal;
  color: var(--text-secondary);
}

#template-content {
  font-family: "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
}

/* Estilos para el editor de imágenes */
#image-editor-container {
  max-width: 100%;
  max-height: 500px;
  overflow: auto;
}

#image-editor-container img {
  max-width: 100%;
  display: block;
}

/* Estilos para Cropper */
.cropper-container {
  max-width: 100%;
}

.cropper-view-box {
  outline: 2px solid var(--primary-color);
  outline-offset: -1px;
}

.cropper-face {
  background-color: rgba(46, 121, 183, 0.1);
}

.cropper-line {
  background-color: var(--primary-color);
}

/* Modal Sesión Expirada - Diseño profesional */
#sessionExpiredModal .session-expired-content {
  max-width: 420px;
  width: 90%;
  text-align: center;
  padding: 48px 40px;
  border-radius: 20px;
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.18),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  background: #ffffff;
  animation: sessionExpiredIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes sessionExpiredIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(-16px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.session-expired-icon-wrap {
  width: 72px;
  height: 72px;
  margin: 0 auto 24px;
  border-radius: 50%;
  background: #f1f5f9;
  color: var(--text-secondary);
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.8),
    0 2px 8px rgba(0, 0, 0, 0.06);
}

.session-expired-title {
  margin: 0 0 12px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.session-expired-text {
  margin: 0 0 28px;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text-secondary);
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

.session-expired-actions {
  display: flex;
  justify-content: center;
}

.session-expired-actions .btn-lg {
  min-width: 200px;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* Modal Configurar Botón (plantilla) */
.modal-content-sm {
  max-width: 440px;
}

.input-with-color {
  display: flex;
  align-items: center;
  gap: 12px;
}

.input-with-color input[type="color"] {
  width: 44px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}

.input-with-color .form-control {
  flex: 1;
}

.form-row {
  display: flex;
  gap: 16px;
}
.form-row-2 {
  flex-wrap: wrap;
}
.form-row-2 .form-group {
  flex: 1;
  min-width: 120px;
}
.checkbox-group {
  margin-bottom: 4px;
}
.checkbox-group .checkbox-label {
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Botón de plantilla en editor: clicable para editar */
a.template-editor-btn {
  cursor: pointer;
  outline-offset: 2px;
}
a.template-editor-btn:hover {
  filter: brightness(1.05);
}
a.template-editor-btn:focus-visible {
  outline: 2px solid var(--primary-color);
}

/* Elementos arrastrables en el editor */
.editor-draggable {
  cursor: grab;
}
.editor-draggable:active {
  cursor: grabbing;
}
.template-button-embed {
  display: block;
  margin: 8px 0;
}
.template-button-embed .template-btn-drag-handle {
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
  padding: 4px 6px;
  cursor: grab;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1;
  user-select: none;
  border-radius: 4px;
}
.template-button-embed .template-btn-drag-handle:hover {
  color: var(--primary-color);
  background: rgba(46, 121, 183, 0.1);
}
.template-button-embed .template-editor-btn {
  vertical-align: middle;
}

/* Estilos para la consola de envío */
#consoleModal .console-stats {
  flex-shrink: 0; /* No se encoge */
  margin-bottom: 20px;
}

#consoleModal #console-output {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #4a5568 #1a1a1a;
}

#consoleModal #console-output::-webkit-scrollbar {
  width: 8px;
}

#consoleModal #console-output::-webkit-scrollbar-track {
  background: #1a1a1a;
}

#consoleModal #console-output::-webkit-scrollbar-thumb {
  background: #4a5568;
  border-radius: 4px;
}

#consoleModal #console-output::-webkit-scrollbar-thumb:hover {
  background: #718096;
}

/* Estilos para imágenes interactivas en el editor */
.image-wrapper {
  display: inline-block;
  position: relative;
  margin: 5px;
}

.image-wrapper:hover {
  outline: 2px dashed var(--primary-color);
  outline-offset: 2px;
}

.image-delete-btn {
  position: absolute;
  top: -10px;
  right: -10px;
  background: var(--primary-dark);
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition:
    transform 0.2s,
    background-color 0.2s;
}

.image-delete-btn:hover {
  transform: scale(1.1);
  background: var(--secondary-dark);
}

.image-resize-handle {
  position: absolute;
  bottom: -5px;
  right: -5px;
  width: 16px;
  height: 16px;
  background: var(--primary-color);
  border: 2px solid white;
  border-radius: 50%;
  cursor: nwse-resize;
  z-index: 1000;
  transition:
    transform 0.2s,
    background-color 0.2s;
}

.image-resize-handle:hover {
  transform: scale(1.2);
  background: var(--primary-dark);
}

.interactive-image {
  cursor: move;
  position: relative;
  max-width: 100%;
  height: auto;
}

/* Permitir que el editor muestre HTML con estilos inline */
#editor-container .ql-editor {
  overflow: visible;
}

#editor-container .ql-editor * {
  max-width: 100%;
}

#editor-container .ql-editor img {
  display: inline-block;
  vertical-align: middle;
}

/* Overlay para móvil */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.sidebar-open .sidebar-overlay {
  display: block;
  opacity: 1;
}

.main-content-header-mobile {
  display: none;
}

.sidebar-toggle-mobile {
  display: none;
}

@media (max-width: 1024px) {
  .app-layout {
    position: relative;
  }

  .navbar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.3);
  }

  body.sidebar-open .navbar {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .main-content-header-mobile {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .sidebar-toggle-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: var(--light-bg);
    color: var(--text-primary);
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    transition:
      background 0.2s ease,
      transform 0.15s ease;
  }
  .sidebar-toggle-mobile:hover {
    background: var(--border-color);
    transform: scale(1.05);
  }

  .main-content {
    padding: 20px 16px;
  }

  .nav-header {
    padding: 20px 16px 20px 16px;
  }

  .nav-menu {
    padding: 0 8px;
  }
}

@media (max-width: 768px) {
  .navbar {
    width: 260px;
  }

  .brand-icon {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  .brand-icon.brand-logo-img {
    width: 56px;
    height: 44px;
  }

  .brand-title {
    font-size: 16px;
  }

  .brand-subtitle {
    font-size: 10px;
  }

  .nav-link {
    padding: 10px 14px;
    font-size: 13px;
  }

  .nav-link-icon {
    width: 18px;
    height: 18px;
    font-size: 15px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .data-table {
    font-size: 12px;
  }

  .data-table th,
  .data-table td {
    padding: 8px;
  }

  .console-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
}

.toast {
  background: white;
  border-radius: 8px;
  padding: 16px 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideInRight 0.3s ease-out;
  min-width: 300px;
  border-left: 4px solid;
}

.toast.success {
  border-left-color: var(--success-color);
}

.toast.error {
  border-left-color: var(--danger-color);
}

.toast.info {
  border-left-color: var(--primary-color);
}

.toast.warning {
  border-left-color: var(--warning-color);
}

.toast-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.toast.success .toast-icon {
  color: var(--success-color);
}

.toast.error .toast-icon {
  color: var(--danger-color);
}

.toast.info .toast-icon {
  color: var(--primary-color);
}

.toast.warning .toast-icon {
  color: var(--warning-color);
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.toast-message {
  font-size: 13px;
  color: var(--text-secondary);
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.2s;
}

.toast-close:hover {
  color: var(--text-primary);
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.fade-out {
  animation: slideOutRight 0.3s ease-out forwards;
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Pagination ellipsis */
.pagination span {
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14px;
  min-width: 32px;
  height: 40px;
  justify-content: center;
}

/* Nav link icons */
.nav-link i {
  margin-right: 6px;
  font-size: 14px;
}

/* Animación para nuevas actividades */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Pestañas Campañas WhatsApp */
.whatsapp-tab {
  padding: 10px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition:
    color 0.2s,
    border-color 0.2s;
}
.whatsapp-tab:hover {
  color: var(--text-primary);
}
.whatsapp-tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}
.whatsapp-tab i {
  margin-right: 6px;
}

/* Sub-pestañas Enviar WhatsApp (Individual / Campaña) */
.whatsapp-send-tab {
  padding: 8px 14px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition:
    color 0.2s,
    border-color 0.2s;
}
.whatsapp-send-tab:hover {
  color: var(--text-primary);
}
.whatsapp-send-tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}
.whatsapp-send-tab i {
  margin-right: 6px;
}

/* ========== RESPONSIVE 100% - Móviles y pantallas pequeñas ========== */
html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body {
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Safe area para dispositivos con notch */
@supports (padding: env(safe-area-inset-top)) {
  .main-content-header-mobile {
    padding-left: max(16px, env(safe-area-inset-left));
  }
  .main-content {
    padding-left: max(16px, env(safe-area-inset-left));
  }
}

/* ===== Breakpoint 1024px - Tablets y pequeños laptops ===== */
@media (max-width: 1024px) {
  .navbar {
    width: min(280px, 85vw);
    z-index: 1100;
  }
  .sidebar-overlay {
    z-index: 1050;
    touch-action: none;
  }
  .nav-menu {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    padding-bottom: env(safe-area-inset-bottom, 12px);
  }
  .nav-section-bottom {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}

/* ===== Breakpoint 768px - Tablets portrait / Phones landscape ===== */
@media (max-width: 768px) {
  .main-content {
    padding: 12px 10px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .page-header {
    margin-bottom: 12px;
    gap: 8px;
  }
  .page-header h1 {
    font-size: clamp(1.2rem, 4.5vw, 1.5rem);
  }
  .dashboard-header .dashboard-subtitle,
  .page-header p {
    font-size: 0.8rem;
    margin-top: 2px;
  }
  .send-container {
    padding: 16px 12px;
    margin: 0 -2px;
    border-radius: 12px;
  }
  .send-form .form-group,
  .form-group {
    margin-bottom: 14px;
  }
  .tabs {
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px;
  }
  .tab-btn {
    flex: 1 1 calc(50% - 6px);
    min-width: 120px;
    padding: 12px 16px;
    font-size: 14px;
  }
  .tab-btn i {
    font-size: 14px;
  }
  .card {
    padding: 20px 16px;
  }
  .data-table-wrapper,
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -12px;
    padding: 0 12px;
  }
  .data-table {
    min-width: 500px;
    font-size: 13px;
  }
  .data-table th,
  .data-table td {
    padding: 10px 8px;
  }
  .modal-content {
    max-width: min(100vw - 24px, 520px) !important;
    margin: 12px;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
  }
  .modal {
    padding: 12px;
    align-items: flex-start;
    padding-top: max(12px, env(safe-area-inset-top));
  }
  .dashboard-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }
  .stat-card {
    padding: 12px 10px;
  }
  .stat-card .stat-info h3 {
    font-size: 1.25rem;
  }
  .stat-card .stat-info p {
    font-size: 0.75rem;
  }
  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
  .whatsapp-tabs,
  .whatsapp-send-tabs {
    flex-wrap: wrap;
    gap: 4px;
  }
  .whatsapp-tab,
  .whatsapp-send-tab {
    padding: 10px 12px;
    font-size: 13px;
  }
  .btn {
    min-height: 44px;
    padding: 12px 20px;
  }
  .btn-sm {
    min-height: 38px;
    padding: 8px 12px;
  }
  .form-row,
  .form-row-2 {
    flex-direction: column;
  }
  .form-row .form-group,
  .form-row-2 .form-group {
    min-width: 100%;
  }
  .console-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .console-stats > div {
    padding: 12px;
    font-size: 13px;
  }
  .schedule-form-card,
  .schedule-list-section {
    padding: 14px 12px;
  }
  .schedule-section-title {
    font-size: 1rem;
    margin-bottom: 12px;
  }
  .schedule-form-block {
    margin-bottom: 16px;
  }
  .schedule-form-block .schedule-block-label {
    font-size: 12px;
    margin-bottom: 8px;
  }
  .schedule-form-actions {
    margin-top: 16px;
  }
  .schedule-list-section .schedule-section-title {
    margin-bottom: 10px;
  }
  .schedule-table-wrap {
    margin-bottom: 10px;
  }
  .whatsapp-tabs {
    margin-bottom: 16px !important;
  }
  #history-table-container {
    margin-top: 8px;
  }
  .history-actions {
    margin-top: 12px;
  }
}

/* ===== Breakpoint 640px - Phones grandes ===== */
@media (max-width: 640px) {
  .main-content {
    padding: 10px 8px;
  }
  .main-content-header-mobile {
    padding: 10px 12px;
  }
  .sidebar-toggle-mobile {
    width: 44px;
    height: 44px;
  }
  .navbar {
    width: min(260px, 90vw);
  }
  .page-header {
    flex-wrap: wrap;
    gap: 8px;
  }
  .send-container {
    padding: 12px 10px;
  }
  .send-form .form-group,
  .form-group {
    margin-bottom: 12px;
  }
  .templates-list {
    gap: 12px;
  }
  .tabs {
    flex-direction: column;
    gap: 6px;
  }
  .tab-btn {
    flex: none;
    width: 100%;
    padding: 10px 12px;
  }
  .card {
    padding: 16px 12px;
  }
  .stat-card {
    padding: 16px 14px;
  }
  .stat-icon {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }
  .modal-content {
    margin: 8px;
    max-height: calc(100vh - 16px);
  }
  .modal-header {
    flex-wrap: wrap;
    gap: 8px;
  }
  .modal-header h2,
  .modal-header h3 {
    font-size: 1.1rem;
  }
  #cancel-send-btn {
    font-size: 13px;
    padding: 10px 14px;
  }
}

/* ===== Breakpoint 480px - Phones pequeños ===== */
@media (max-width: 480px) {
  .main-content {
    padding: 8px 6px;
  }
  .page-header {
    margin-bottom: 10px;
  }
  .page-header h1 {
    font-size: 1.15rem;
  }
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .dashboard-cards {
    gap: 8px;
  }
  .stat-card {
    flex-direction: row;
    padding: 10px 10px;
  }
  .stat-card .stat-info h3 {
    font-size: 1.1rem;
  }
  .stat-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
  .send-container {
    padding: 10px 8px;
  }
  .send-form .form-group,
  .form-group {
    margin-bottom: 10px;
  }
  .tab-btn {
    padding: 12px 14px;
    font-size: 13px;
  }
  .data-table {
    min-width: 400px;
    font-size: 12px;
  }
  .data-table th,
  .data-table td {
    padding: 8px 6px;
  }
  .modal-content {
    margin: 6px;
    padding: 16px;
  }
  .modal-body {
    padding: 16px 0;
  }
  .whatsapp-tab,
  .whatsapp-send-tab {
    padding: 8px 10px;
    font-size: 12px;
  }
  .brand-title-menu {
    font-size: 13px;
  }
  .nav-link {
    padding: 12px 14px;
    min-height: 44px;
  }
  .search-clients-input-wrap {
    flex-direction: column;
  }
  .search-clients-input-wrap .search-clients-input {
    width: 100%;
  }
  .toast-message,
  .toast {
    max-width: calc(100vw - 32px);
    min-width: auto;
  }
  #toast-container {
    left: 16px;
    right: 16px;
    max-width: none;
  }
}

/* ========== Delicate Branding UI (Lemonade Style) ========== */
.branding-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 3rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  padding-bottom: 2rem;
}

.header-icon-box {
  width: 64px;
  height: 64px;
  background: #ffebf4;
  color: #ff0084;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  font-size: 1.5rem;
  box-shadow: 0 8px 16px rgba(255, 0, 132, 0.1);
}

.branding-container {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 3rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .branding-container {
    grid-template-columns: 1fr;
  }
}

.branding-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.branding-card {
  background: #fff;
  border-radius: 24px;
  padding: 2rem;
  box-shadow:
    0 2px 12px rgba(0, 0, 0, 0.03),
    0 1px 2px rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.04);
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
}

.branding-card:hover {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.05);
}

.branding-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  color: #2d2d2d;
}

.branding-card-header i {
  color: #ff0084;
  opacity: 0.8;
}

.branding-card-header h3 {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
}

.branding-color-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.color-control-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: #fdfdfd;
  border: 1px solid #f0f0f0;
  border-radius: 12px;
}

.color-control-item label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 0 !important;
}

.delicate-color-picker {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.delicate-color-picker input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  background: none;
}

.delicate-color-picker input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.delicate-color-picker input[type="color"]::-webkit-color-swatch {
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #e2e8f0;
}

.color-hex {
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 0.75rem;
  color: #94a3b8;
  text-transform: uppercase;
  min-width: 70px;
}

.btn-link {
  background: none;
  border: none;
  color: #ff0084;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
  text-decoration: underline rgba(255, 0, 132, 0.2);
}

.btn-link:hover {
  color: #d1006d;
}

.branding-save-container {
  margin-top: 1rem;
}

.btn-delicate-save {
  width: 100%;
  padding: 1.125rem !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
  background: #ff0084 !important;
  border-radius: 16px !important;
  box-shadow: 0 12px 24px rgba(255, 0, 132, 0.2) !important;
}

.btn-delicate-save:hover {
  background: #d1006d !important;
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(255, 0, 132, 0.3) !important;
}

.branding-preview-panel {
  position: sticky;
  top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.preview-header {
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.05em;
  padding-left: 0.5rem;
}

.minimal-preview-card {
  background: #fff;
  border-radius: 32px;
  overflow: hidden;
  aspect-ratio: 16/10;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
}

.preview-nav-mock {
  height: 60px;
  border-bottom: 1px solid #f8fafc;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.mock-logo {
  width: 24px;
  height: 24px;
  background: #ff0084;
  border-radius: 6px;
}

.mock-links span {
  display: inline-block;
  width: 40px;
  height: 8px;
  background: #f1f5f9;
  border-radius: 4px;
  margin-right: 0.75rem;
}

.preview-content-mock {
  padding: 2.5rem;
  flex: 1;
}

.mock-brand-name {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  color: #2d2d2d;
}

.preview-content-mock p {
  color: #64748b;
  font-size: 0.875rem;
}

.mock-stats {
  display: flex;
  gap: 1rem;
  margin: 1.5rem 0;
}

.mock-stat-card {
  flex: 1;
  height: 64px;
  background: #fdfdfd;
  border: 1px solid #f1f5f9;
  border-radius: 12px;
}

.mock-btn {
  padding: 0.75rem 1.5rem;
  background: #ff0084;
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.8125rem;
  box-shadow: 0 8px 16px rgba(255, 0, 132, 0.15);
}

.preview-note {
  font-size: 0.8125rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem;
}

.preview-note i {
  color: #ff0084;
  opacity: 0.6;
}

/* Ocultar encabezado solo en NUEVA FACTURA (para membrete físico) */
#invoices-create-page .invoice-preview-header,
#invoices-create-page .invoice-preview-legal {
  display: none !important;
}

#invoices-create-page #invoice-preview {
  padding-top: 2rem;
}
