/* ============================================================
   AURUM — STYLES v2 (CSS variables + reducción de overrides)
   ============================================================ */

/* ============================================================
   1. TOKENS SEMÁNTICOS
   ============================================================ */
:root {
  --color-brand: #f59e0b;
  --color-brand-soft: rgba(245, 158, 11, 0.15);
  --color-brand-border: rgba(245, 158, 11, 0.35);

  /* Superficies */
  --surface: #070a11;
  --surface-1: rgba(17, 24, 39, 0.75);
  --surface-2: rgba(15, 23, 42, 0.6);
  --surface-3: rgba(30, 41, 59, 0.5);
  --surface-glass: rgba(17, 24, 39, 0.7);
  --surface-glass-soft: rgba(17, 24, 39, 0.45);
  --surface-overlay: rgba(0, 0, 0, 0.8);

  /* Texto */
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* Bordes */
  --border: rgba(255, 255, 255, 0.08);
  --border-soft: rgba(148, 163, 184, 0.2);
  --border-strong: rgba(255, 255, 255, 0.12);

  /* Acentos semánticos */
  --accent-emerald: #10b981;
  --accent-cyan: #06b6d4;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-violet: #8b5cf6;
  --accent-fuchsia: #d946ef;
  --accent-teal: #14b8a6;
  --accent-slate: #64748b;

  /* Legacy compat */
  --color-dark-bg: #070a11;
  --color-text: #f1f5f9;
  --card-bg: rgba(17, 24, 39, 0.75);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-bg-soft: rgba(15, 23, 42, 0.6);
}

[data-theme="light"] {
  --surface: #e2e8f0;
  --surface-1: rgba(255, 255, 255, 0.95);
  --surface-2: rgba(248, 250, 252, 0.95);
  --surface-3: rgba(241, 245, 249, 0.95);
  --surface-glass: rgba(255, 255, 255, 0.9);
  --surface-glass-soft: rgba(255, 255, 255, 0.75);
  --surface-overlay: rgba(15, 23, 42, 0.5);

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --border: rgba(0, 0, 0, 0.08);
  --border-soft: rgba(148, 163, 184, 0.4);
  --border-strong: rgba(0, 0, 0, 0.12);

  --color-dark-bg: #e2e8f0;
  --color-text: #0f172a;
  --card-bg: rgba(255, 255, 255, 0.95);
  --card-border: rgba(0, 0, 0, 0.08);
  --card-bg-soft: #ffffff;
}

/* ============================================================
   2. RESET Y BASE
   ============================================================ */
* { touch-action: manipulation; box-sizing: border-box; }

html { 
  overflow-x: hidden; 
  background-color: var(--surface) !important;
  color-scheme: dark; /* 🔥 Fuerza la barra oscura en Android */
}

[data-theme="light"] html,
html[data-theme="light"] {
  background-color: var(--surface) !important;
  color-scheme: light; /* 🔥 Fuerza la barra clara en Android */
}

body { 
  overflow-x: clip; 
  max-width: 100vw; 
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--surface);
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
  transition: background-color 0.3s ease, color 0.3s ease;
}

[data-theme="light"] body { background-color: var(--surface); color: var(--text-primary); }
[data-theme="light"] .bg-darkbg { background-color: var(--surface) !important; }

/* ============================================================
   3. LOGO AURUM
   ============================================================ */
.logo-aurum {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 15%, #fbbf24 35%, #f59e0b 55%, #d97706 75%, #b45309 90%, #fbbf24 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  font-weight: 700;
  font-style: italic;
  letter-spacing: -0.02em;
  filter: drop-shadow(0 2px 4px rgba(251, 191, 36, 0.25));
}
.logo-aurum-lg { font-size: 2rem; line-height: 1.1; }
.logo-aurum-md { font-size: 1.6rem; line-height: 1; }
.logo-aurum-sm { font-size: 0.9rem; line-height: 1; }

/* ============================================================
   4. GLASS EFFECTS
   ============================================================ */
.glass {
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
}
[data-theme="light"] .glass {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.glass-card {
  background: linear-gradient(135deg, var(--surface-3) 0%, var(--surface-1) 100%);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
}
[data-theme="light"] .glass-card {
  background: var(--surface-2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.glass-input {
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  transition: all 0.2s ease;
}
[data-theme="light"] .glass-input {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #0f172a;
}
.glass-input::placeholder { color: var(--text-dim); }
.glass-input:focus {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
  outline: none;
}

.glass-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: var(--surface-1);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23fbbf24' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px 16px;
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  transition: all 0.2s ease;
  padding-right: 42px !important;
  cursor: pointer;
}
[data-theme="light"] .glass-select {
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23f59e0b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
.glass-select option { background-color: #0f172a; color: #f1f5f9; padding: 10px; }
[data-theme="light"] .glass-select option { background-color: #ffffff; color: #0f172a; }

/* ============================================================
   5. INPUT DATE
   ============================================================ */
input[type="date"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-color: var(--surface-1);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23fbbf24' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  background-size: 18px 18px !important;
  padding-right: 42px !important;
  color-scheme: dark;
  position: relative;
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  transition: all 0.2s ease;
}
input[type="date"]:focus {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
  outline: none;
}
input[type="date"]::-webkit-calendar-picker-indicator {
  position: absolute !important; right: 0 !important; top: 0 !important;
  width: 100% !important; height: 100% !important;
  opacity: 0 !important; cursor: pointer !important;
  background: transparent !important; color: transparent !important;
}
input[type="date"]::-webkit-inner-spin-button,
input[type="date"]::-webkit-clear-button,
input[type="date"]::-webkit-outer-spin-button { -webkit-appearance: none; display: none; margin: 0; }
input[type="date"]::-webkit-datetime-edit { color: #fff; padding: 0; }
input[type="date"]::-webkit-datetime-edit-fields-wrapper { color: #fff; }
input[type="date"]::-webkit-datetime-edit-text { color: var(--text-muted); padding: 0 2px; }
input[type="date"]::-webkit-datetime-edit-day-field,
input[type="date"]::-webkit-datetime-edit-month-field,
input[type="date"]::-webkit-datetime-edit-year-field { color: #fff; background: transparent; border-radius: 4px; padding: 2px 4px; }
input[type="date"]::-webkit-datetime-edit-day-field:focus,
input[type="date"]::-webkit-datetime-edit-month-field:focus,
input[type="date"]::-webkit-datetime-edit-year-field:focus { background: rgba(245, 158, 11, 0.3); color: #fff; outline: none; }
input[type="date"]::-moz-focus-inner { border: 0; }

[data-theme="light"] input[type="date"] {
  background-color: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
  color-scheme: light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23f59e0b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E") !important;
}
[data-theme="light"] input[type="date"]::-webkit-datetime-edit,
[data-theme="light"] input[type="date"]::-webkit-datetime-edit-fields-wrapper,
[data-theme="light"] input[type="date"]::-webkit-datetime-edit-day-field,
[data-theme="light"] input[type="date"]::-webkit-datetime-edit-month-field,
[data-theme="light"] input[type="date"]::-webkit-datetime-edit-year-field { color: #0f172a; }
[data-theme="light"] input[type="date"]::-webkit-datetime-edit-text { color: #64748b; }
[data-theme="light"] input[type="date"]::-webkit-datetime-edit-day-field:focus,
[data-theme="light"] input[type="date"]::-webkit-datetime-edit-month-field:focus,
[data-theme="light"] input[type="date"]::-webkit-datetime-edit-year-field:focus { background: rgba(245, 158, 11, 0.25); color: #92400e; }

/* ============================================================
   6. ANIMACIONES
   ============================================================ */
.animate-fadeIn { animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.animate-slideUp { animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.animate-expand { animation: expand 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes expand { from { opacity: 0; max-height: 0; } to { opacity: 1; max-height: 3000px; } }
@keyframes bounce-notif { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.15); } }
.animate-bounce-notif { animation: bounce-notif 0.6s ease-in-out infinite; }

/* ============================================================
   7. SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #334155; }
[data-theme="light"] ::-webkit-scrollbar-track { background: var(--surface); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #94a3b8; }

/* ============================================================
   8. ENTITY CARDS
   ============================================================ */
.entity-card { transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.entity-card:hover { border-color: rgba(245, 158, 11, 0.4); }
.entity-card.expanded { border-color: rgba(245, 158, 11, 0.5); box-shadow: 0 10px 40px -10px rgba(245, 158, 11, 0.25); }
.chevron { transition: transform 0.3s ease; }
.expanded .chevron { transform: rotate(180deg); }
.avatar-circle { background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%); }

/* ============================================================
   9. CARDS COMPRAS / VENTAS
   ============================================================ */
.compra-card, .venta-card { position: relative; }
.compra-card::before, .venta-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 3px 0 0 3px;
}
.compra-card::before { background: linear-gradient(180deg, #fbbf24, #d97706); }
.venta-card::before { background: linear-gradient(180deg, #10b981, #0d9488); }

/* ============================================================
   10. CONNECTION
   ============================================================ */
.conn-dot { width: 8px; height: 8px; border-radius: 9999px; }
.conn-online { background: #10b981; box-shadow: 0 0 8px rgba(16,185,129,0.8); }
.conn-offline { background: #f43f5e; box-shadow: 0 0 8px rgba(244,63,94,0.8); }
.conn-syncing { background: #f59e0b; box-shadow: 0 0 8px rgba(245,158,11,0.8); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

#offlineBanner { position: fixed; top: 0; left: 0; right: 0; z-index: 60; transform: translateY(-100%); transition: transform 0.3s ease; }
#offlineBanner.show { transform: translateY(0); }

/* ============================================================
   11. CUOTAS
   ============================================================ */
.cuota-checkbox { transition: all 0.2s ease; cursor: pointer; }
.cuota-checkbox:hover { border-color: rgba(245, 158, 11, 0.6); background: rgba(245, 158, 11, 0.05); }
.cuota-checkbox.selected { border-color: #f59e0b; background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(217, 119, 6, 0.1)); box-shadow: 0 4px 15px -5px rgba(245, 158, 11, 0.4); }
.cuota-checkbox.selected .cuota-check-icon { background: #f59e0b; border-color: #f59e0b; color: #0f172a; }
.cuota-checkbox.locked { cursor: not-allowed; }
.cuota-vencida { border-color: rgba(244, 63, 94, 0.5) !important; background: linear-gradient(135deg, rgba(244, 63, 94, 0.12), rgba(190, 24, 93, 0.08)) !important; }
.cuota-por-vencer { border-color: rgba(245, 158, 11, 0.5) !important; background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(217, 119, 6, 0.08)) !important; }
.cuota-pagada { border-color: rgba(16, 185, 129, 0.4) !important; background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(13, 148, 136, 0.06)) !important; opacity: 0.7; }

/* ============================================================
   12. NOTIFICACIONES
   ============================================================ */
.notif-card { position: relative; transition: all 0.2s ease; border: 2px solid transparent; }
.notif-card:hover { transform: translateX(2px); }
.notif-card.notif-urgente { border-color: #f43f5e !important; }
.notif-card.notif-hoy { border-color: #10b981 !important; }
.notif-card.notif-proximo { border-color: #f59e0b !important; }
.notif-card.notif-semana { border-color: #64748b !important; }

.notif-section-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 10px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.notif-header-urgente { background: rgba(244, 63, 94, 0.15); color: #fb7185; border: 1px solid rgba(244, 63, 94, 0.25); }
.notif-header-hoy { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.25); }
.notif-header-proximo { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.25); }
.notif-header-semana { background: rgba(100, 116, 139, 0.15); color: #94a3b8; border: 1px solid rgba(100, 116, 139, 0.25); }

/* ============================================================
   13. KPI CARDS
   ============================================================ */
.kpi-card { position: relative; overflow: hidden; border-radius: 1rem; padding: 1.25rem; transition: transform 0.25s ease, box-shadow 0.25s ease; }
.kpi-card:hover { transform: translateY(-3px); }
.kpi-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; border-radius: 1rem 1rem 0 0; }
.kpi-emerald { background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(13, 148, 136, 0.05)); border: 1px solid rgba(16, 185, 129, 0.25); }
.kpi-emerald::before { background: linear-gradient(90deg, #10b981, #0d9488); }
.kpi-cyan { background: linear-gradient(135deg, rgba(6, 182, 212, 0.12), rgba(8, 145, 178, 0.05)); border: 1px solid rgba(6, 182, 212, 0.25); }
.kpi-cyan::before { background: linear-gradient(90deg, #06b6d4, #0891b2); }
.kpi-rose { background: linear-gradient(135deg, rgba(244, 63, 94, 0.12), rgba(190, 24, 93, 0.05)); border: 1px solid rgba(244, 63, 94, 0.25); }
.kpi-rose::before { background: linear-gradient(90deg, #f43f5e, #be185d); }
.kpi-amber { background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(217, 119, 6, 0.05)); border: 1px solid rgba(245, 158, 11, 0.25); }
.kpi-amber::before { background: linear-gradient(90deg, #f59e0b, #d97706); }
.kpi-violet { background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(109, 40, 217, 0.05)); border: 1px solid rgba(139, 92, 246, 0.25); }
.kpi-violet::before { background: linear-gradient(90deg, #8b5cf6, #6d28d9); }
.kpi-slate { background: linear-gradient(135deg, rgba(100, 116, 139, 0.12), rgba(51, 65, 85, 0.05)); border: 1px solid rgba(100, 116, 139, 0.25); }
.kpi-slate::before { background: linear-gradient(90deg, #64748b, #334155); }

/* ============================================================
   14. CHARTS
   ============================================================ */
.chart-container { position: relative; height: 240px; width: 100%; }
@media (min-width: 768px) { .chart-container { height: 280px; } }

/* ============================================================
   15. SCORE BADGES
   ============================================================ */
.score-badge { display: inline-flex; align-items: center; justify-content: center; padding: 2px 8px; border-radius: 9999px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; }
.score-excelente { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.score-bueno { background: rgba(6, 182, 212, 0.15); color: #22d3ee; border: 1px solid rgba(6, 182, 212, 0.3); }
.score-regular { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.score-riesgoso { background: rgba(249, 115, 22, 0.15); color: #fb923c; border: 1px solid rgba(249, 115, 22, 0.3); }
.score-malo { background: rgba(244, 63, 94, 0.15); color: #fb7185; border: 1px solid rgba(244, 63, 94, 0.3); }
.score-sin-datos { background: rgba(100, 116, 139, 0.15); color: #94a3b8; border: 1px solid rgba(100, 116, 139, 0.3); }

[data-theme="light"] .score-excelente { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
[data-theme="light"] .score-bueno { background: #cffafe; color: #155e75; border-color: #67e8f9; }
[data-theme="light"] .score-regular { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
[data-theme="light"] .score-riesgoso { background: #ffedd5; color: #9a3412; border-color: #fdba74; }
[data-theme="light"] .score-malo { background: #ffe4e6; color: #9f1239; border-color: #fda4af; }
[data-theme="light"] .score-sin-datos { background: #e2e8f0; color: #475569; border-color: #cbd5e1; }

/* ============================================================
   16. HISTORIAL
   ============================================================ */
.historial-item { background: var(--surface-2); border: 1px solid rgba(100, 116, 139, 0.2); border-radius: 12px; padding: 10px 12px; transition: all 0.2s ease; }
.historial-item:hover { border-color: rgba(100, 116, 139, 0.4); background: var(--surface-1); }
[data-theme="light"] .historial-item { background: #f8fafc; border-color: #e2e8f0; }

/* ============================================================
   17. LOGIN / APP VISIBILITY
   ============================================================ */
#loginSection, #appSection { visibility: hidden; }
body.app-ready #loginSection, body.app-ready #appSection { visibility: visible; }

/* ============================================================
   18. RECIBO
   ============================================================ */
#reciboModal .recibo-scroll-area {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-top: 4rem;
  padding-bottom: 6rem;
}
#reciboContenido { width: 100%; max-width: 420px; margin: 0 auto; }

/* ============================================================
   19. MENÚS CONTEXTUALES
   ============================================================ */
@keyframes menuIn { from { opacity: 0; transform: scale(0.95) translateY(-4px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.menu-3puntos, .header-menu, .filtro-dropdown { position: fixed; z-index: 100; animation: menuIn 0.15s ease-out; }
.menu-3puntos { min-width: 230px; }
.header-menu { min-width: 0; width: min(360px, calc(100vw - 16px)); max-height: calc(100vh - 16px); overflow-y: auto; }
.filtro-dropdown { min-width: 260px; max-height: 70vh; overflow-y: auto; }

.menu-3puntos button { width: 100%; text-align: left; padding: 10px 12px; display: flex; align-items: center; gap: 8px; font-size: 12px; color: #e2e8f0; transition: all 0.15s ease; border-radius: 8px; cursor: pointer; }
.menu-3puntos button:hover { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }

.header-menu button { width: 100%; text-align: left; padding: 11px 13px; display: flex; align-items: center; gap: 10px; font-size: 13px; color: #e2e8f0; transition: all 0.15s ease; border-radius: 8px; cursor: pointer; font-weight: 500; }
.header-menu button:hover { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }
.header-menu button.danger:hover { background: rgba(244, 63, 94, 0.12); color: #fb7185; }
.header-menu .menu-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 4px 0; }

/* Tarjeta de plan dentro del menú de 3 puntos */
.header-menu .menu-plan-card {
  padding: 10px;
  margin-bottom: 6px;
  border: 1px solid rgba(245, 158, 11, 0.24);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(245,158,11,.10), rgba(15,23,42,.55));
}
.header-menu .menu-plan-label {
  font-size: 8px;
  line-height: 1;
  letter-spacing: .09em;
  text-transform: uppercase;
  font-weight: 800;
  color: #94a3b8;
}
.header-menu .menu-plan-main {
  margin-top: 5px;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 7px;
}
.header-menu .menu-plan-title {
  margin: 0;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 900;
  color: #fff;
  text-transform: uppercase;
}
.header-menu .menu-plan-detail {
  margin: 0;
  font-size: 11px;
  line-height: 1.3;
  font-weight: 600;
  color: #cbd5e1;
}
.header-menu .menu-plan-btn {
  width: 100%;
  margin-top: 9px;
  min-height: 46px;
  padding: 13px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  text-align: center;
  border-radius: 11px;
  background: linear-gradient(90deg, #fbbf24, #d97706);
  color: #020617;
  font-size: 12px;
  line-height: 1.1;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.header-menu .menu-plan-btn:hover {
  background: linear-gradient(90deg, #fcd34d, #f59e0b);
  color: #020617;
}

.filtro-dropdown button { width: 100%; text-align: left; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: #e2e8f0; transition: all 0.15s ease; border-radius: 8px; cursor: pointer; font-weight: 500; }
.filtro-dropdown button:hover { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }
.filtro-dropdown button.active { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.filtro-dropdown .filtro-dropdown-count { background: rgba(255,255,255,0.08); color: inherit; padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 800; min-width: 22px; text-align: center; }
.filtro-dropdown button.active .filtro-dropdown-count { background: rgba(245, 158, 11, 0.3); color: #fbbf24; }

/* ============================================================
   20. BOTONES
   ============================================================ */
.btn-filtrar { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 12px; font-size: 13px; font-weight: 700; background: var(--surface-1); border: 1px solid rgba(245, 158, 11, 0.4); color: #fbbf24; transition: all 0.2s ease; cursor: pointer; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.btn-filtrar:hover { background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.6); }
.btn-filtrar:active { transform: scale(0.98); }
.btn-filtrar .hamburguesa { display: flex; flex-direction: column; gap: 3px; flex-shrink: 0; }
.btn-filtrar .hamburguesa span { display: block; width: 14px; height: 2px; background: currentColor; border-radius: 2px; }
.btn-filtrar .filtro-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-filtrar .filtro-badge { background: rgba(245, 158, 11, 0.25); padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 800; flex-shrink: 0; }
[data-theme="light"] .btn-filtrar { background: #ffffff; }

.btn-menu-cuota { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 6px; color: #94a3b8; transition: all 0.15s ease; flex-shrink: 0; cursor: pointer; }
.btn-menu-cuota:hover { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

.contact-btn {
  flex: 1 1 0; min-width: 0; padding: 10px 4px; border-radius: 12px;
  font-size: 10px; font-weight: 700; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
  transition: all 0.15s ease; cursor: pointer; border: 1px solid;
  text-align: center; min-height: 64px; line-height: 1.15; overflow: hidden;
}
.contact-btn:active { transform: scale(0.97); }
.contact-btn svg { width: 18px; height: 18px; flex-shrink: 0; display: block; }
.contact-btn span { display: block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; line-height: 1.15; }

.action-bar { display: flex; align-items: stretch; gap: 8px; width: 100%; }
.action-btn-square {
  display: flex; flex-direction: row; align-items: center; justify-content: center;
  gap: 6px; padding: 10px 10px; border-radius: 12px; font-size: 11px; font-weight: 700;
  transition: all 0.15s ease; cursor: pointer; border: 1px solid; line-height: 1.1;
  text-align: center; min-height: 42px; white-space: nowrap; overflow: hidden;
}
.action-btn-square:active { transform: scale(0.97); }
.action-btn-square svg { width: 14px; height: 14px; flex-shrink: 0; display: block; }
.action-btn-square span { display: block; line-height: 1.1; white-space: nowrap; }
.action-btn-square.has-text { flex: 1 1 0; min-width: 0; }
.action-btn-square.icon-only { flex: 0 0 auto; width: 42px; min-width: 42px; padding: 10px; gap: 0; }
.action-btn-square.icon-only svg { width: 18px; height: 18px; }

@media (max-width: 360px) {
  .contact-btn { font-size: 9px; padding: 8px 3px; gap: 5px; min-height: 58px; }
  .contact-btn svg { width: 16px; height: 16px; }
  .action-bar { gap: 6px; }
  .action-btn-square { font-size: 10px; padding: 9px 8px; min-height: 40px; gap: 5px; }
  .action-btn-square svg { width: 13px; height: 13px; }
  .action-btn-square.icon-only { width: 40px; min-width: 40px; padding: 9px; }
  .action-btn-square.icon-only svg { width: 16px; height: 16px; }
}

/* ============================================================
   21. MODALES
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: var(--surface-overlay);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  z-index: 50; display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.hidden { display: none; }
#paywallOverlay { z-index: 90; }
#pagoPremiumModal { z-index: 96; }
.modal-content {
  background: var(--surface-1);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 1.5rem; padding: 1.5rem 2rem;
  max-height: 90vh; overflow-y: auto; width: 100%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
[data-theme="light"] .modal-content { background: #ffffff; border: 1px solid #e2e8f0; }

.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  padding-bottom: 0.75rem; margin-bottom: 1.25rem;
}
.modal-close { color: #94a3b8; transition: color 0.15s ease; }
.modal-close:hover { color: #fff; }
[data-theme="light"] .modal-close:hover { color: #0f172a; }

/* Datos de pago Premium */
.pago-ayuda {
  padding: 10px; border: 1px dashed rgba(148, 163, 184, 0.28);
  border-radius: 10px; color: #94a3b8; font-size: 11px; text-align: center;
}
.pago-datos-card {
  border: 1px solid rgba(245, 158, 11, 0.28);
  background: rgba(245, 158, 11, 0.06);
  border-radius: 12px; padding: 12px;
}
.pago-datos-usdt {
  border-color: rgba(16, 185, 129, 0.28);
  background: rgba(16, 185, 129, 0.06);
}
.pago-datos-titulo {
  font-size: 13px; font-weight: 900; color: #fbbf24;
  letter-spacing: .06em; text-transform: uppercase; margin-bottom: 8px;
}
.pago-datos-usdt .pago-datos-titulo { color: #34d399; }
.pago-linea {
  display: flex; align-items: center; flex-wrap: wrap; gap: 7px;
  font-size: 13px; line-height: 1.5; color: #cbd5e1; margin-top: 5px;
}
.pago-label { color: #94a3b8; font-size: 12px; }
.pago-valor { color: #fff; font-weight: 700; font-size: 14px; word-break: break-word; }
.pago-vacio { color: #64748b; font-style: italic; }
.pago-monto .pago-valor { color: #fbbf24; font-weight: 900; font-size: 15px; }
.pago-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 4px; padding: 6px 0;
  border-top: 1px solid rgba(148, 163, 184, 0.10);
}
.pago-row-text {
  min-width: 0; display: flex; align-items: baseline; flex-wrap: wrap; gap: 7px;
}
.pago-campo { margin-top: 10px; }
.pago-campo-fila {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 4px;
}
.pago-nota { margin-top: 8px; font-size: 10px; line-height: 1.4; color: #64748b; }
.empresa-menu {
  position: absolute; right: 4px; top: 38px; z-index: 60; width: 176px;
}
.empresa-codigo {
  user-select: all;
  -webkit-user-select: all;
  cursor: pointer;
}
.pago-vigencia {
  padding: 8px 10px; border-radius: 9px; text-align: center;
  font-size: 11px; font-weight: 800; color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.28);
  background: rgba(245, 158, 11, 0.07);
}
.pago-vigencia-vencida {
  color: #fb7185; border-color: rgba(244, 63, 94, 0.35);
  background: rgba(244, 63, 94, 0.08);
}
#pagoVerificandoOverlay { z-index: 97; }
#confettiCanvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none;
}
.pago-spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(245, 158, 11, 0.2);
  border-top-color: #fbbf24;
  animation: pagoSpin .8s linear infinite;
}
@keyframes pagoSpin { to { transform: rotate(360deg); } }
.pago-check {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(16, 185, 129, 0.15); color: #34d399;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 900;
}
.pago-check-error {
  background: rgba(244, 63, 94, 0.15) !important;
  color: #fb7185 !important;
}
.pago-copy {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.55); color: #cbd5e1;
  transition: all .15s ease; cursor: pointer;
}
.pago-copy:hover { color: #fbbf24; border-color: rgba(245, 158, 11, 0.55); }
.pago-copy svg { width: 17px; height: 17px; display: block; }

.backup-btn {
  width: 100%; padding: 0.875rem; background: var(--surface-1);
  border: 1px solid rgba(100, 116, 139, 0.4); border-radius: 1rem;
  display: flex; align-items: center; gap: 0.75rem; transition: all 0.2s ease;
  text-align: left; cursor: pointer;
}
.backup-btn:hover { background: var(--surface-2); border-color: rgba(245, 158, 11, 0.5); }
[data-theme="light"] .backup-btn { background: #f8fafc; border-color: #e2e8f0; }
[data-theme="light"] .backup-btn:hover { background: #f1f5f9; }
.backup-btn-icon {
  width: 2.5rem; height: 2.5rem; border-radius: 0.75rem; border: 1px solid;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.theme-btn {
  padding: 0.75rem; background: var(--surface-1);
  border: 1px solid rgba(100, 116, 139, 0.4); border-radius: 0.75rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  font-size: 0.75rem; font-weight: 600; color: #94a3b8;
  transition: all 0.2s ease; cursor: pointer;
}
.theme-btn:hover { border-color: rgba(245, 158, 11, 0.5); color: #fbbf24; }
.theme-btn.active { background: rgba(245, 158, 11, 0.15); border-color: #f59e0b; color: #fbbf24; }
[data-theme="light"] .theme-btn { background: #f8fafc; border-color: #e2e8f0; color: #64748b; }
[data-theme="light"] .theme-btn:hover { border-color: #f59e0b; color: #d97706; }
[data-theme="light"] .theme-btn.active { background: #fffbeb; border-color: #f59e0b; color: #b45309; }

/* ============================================================
   22. TOASTS
   ============================================================ */
#toastContainer {
  z-index: 9999;
  bottom: calc(84px + env(safe-area-inset-bottom));
  max-width: calc(100vw - 24px);
}
.toast {
  padding: 0.75rem 1.25rem; border-radius: 0.75rem;
  background: var(--surface-1); border: 1px solid;
  font-size: 0.8125rem; font-weight: 600;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.6);
  animation: slideUp 0.3s ease-out; pointer-events: auto;
  backdrop-filter: blur(12px);
}
.toast-success { border-color: rgba(16, 185, 129, 0.4); color: #34d399; }
.toast-error { border-color: rgba(244, 63, 94, 0.4); color: #fb7185; }
.toast-info { border-color: rgba(245, 158, 11, 0.4); color: #fbbf24; }
.toast-warning { border-color: rgba(245, 158, 11, 0.4); color: #fbbf24; }
[data-theme="light"] .toast { background: #ffffff; }
[data-theme="light"] .toast-success { color: #047857; border-color: #10b981; }
[data-theme="light"] .toast-error { color: #be123c; border-color: #f43f5e; }
[data-theme="light"] .toast-info { color: #b45309; border-color: #f59e0b; }
[data-theme="light"] .toast-warning { color: #b45309; border-color: #f59e0b; }

/* ============================================================
   23. CALENDARIO
   ============================================================ */
#calendarioCuotas { width: 100%; overflow: hidden; }
.calendario-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; width: 100%; table-layout: fixed; }
.calendario-header-cell { text-align: center; font-size: 10px; font-weight: 700; color: var(--text-dim); padding: 6px 0; line-height: 1; }
.calendario-dia { border-radius: 6px; background: var(--surface-2); border: 1px solid rgba(100, 116, 139, 0.15); cursor: pointer; transition: all 0.15s ease; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 42px; padding: 3px 1px; overflow: hidden; width: 100%; box-sizing: border-box; }
.calendario-dia.vacio { background: transparent; border-color: transparent; cursor: default; pointer-events: none; }
.calendario-dia.hoy { border-color: #f59e0b; background: rgba(245, 158, 11, 0.15); }
.calendario-dia.con-cuotas { border-color: rgba(6, 182, 212, 0.5); background: rgba(6, 182, 212, 0.08); }
.calendario-dia.con-vencidas { border-color: rgba(244, 63, 94, 0.6); background: rgba(244, 63, 94, 0.1); }
.calendario-dia-num { font-size: 11px; font-weight: 700; color: var(--text-secondary); line-height: 1.1; }
.calendario-dia.vacio .calendario-dia-num { color: transparent; }
.calendario-dia-monto { font-size: 8px; font-weight: 800; color: #fbbf24; line-height: 1.1; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.calendario-dia-count { font-size: 7px; color: var(--text-muted); line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

[data-theme="light"] .calendario-header-cell { color: #475569; }
[data-theme="light"] .calendario-dia { background: #f8fafc; border-color: #e2e8f0; }
[data-theme="light"] .calendario-dia.hoy { background: #fffbeb; border-color: #f59e0b; }
[data-theme="light"] .calendario-dia-num { color: #334155; }
[data-theme="light"] .calendario-dia-monto { color: #b45309; }
[data-theme="light"] .calendario-dia-count { color: #64748b; }

@media (max-width: 400px) {
  .calendario-dia { min-height: 38px; padding: 2px 1px; border-radius: 5px; }
  .calendario-dia-num { font-size: 10px; }
  .calendario-dia-monto { font-size: 7px; }
  .calendario-dia-count { display: none; }
  .calendario-header-cell { font-size: 9px; padding: 4px 0; }
}
@media (max-width: 340px) {
  .calendario-grid { gap: 1px; }
  .calendario-dia { min-height: 34px; border-radius: 4px; }
  .calendario-dia-num { font-size: 9px; }
  .calendario-dia-monto { font-size: 6px; }
}

/* ============================================================
   24. HEATMAP
   ============================================================ */
.heatmap-grid { display: grid; grid-template-columns: 36px repeat(7, 1fr); gap: 2px; width: 100%; }
.heatmap-label { font-size: 9px; color: var(--text-dim); display: flex; align-items: center; justify-content: center; font-weight: 600; min-width: 0; }
.heatmap-cell { aspect-ratio: 1; border-radius: 3px; background: var(--surface-2); transition: transform 0.15s ease; cursor: pointer; min-width: 0; }
.heatmap-cell:hover { transform: scale(1.15); z-index: 10; }
[data-theme="light"] .heatmap-label { color: #475569; }
[data-theme="light"] .heatmap-cell { background: #f1f5f9; }
@media (max-width: 400px) {
  .heatmap-grid { grid-template-columns: 30px repeat(7, 1fr); gap: 1px; }
  .heatmap-label { font-size: 8px; }
}

/* ============================================================
   25. BÚSQUEDA GLOBAL
   ============================================================ */
.search-result-item { padding: 0.75rem; border-radius: 0.75rem; cursor: pointer; transition: all 0.15s ease; border: 1px solid transparent; display: flex; align-items: center; gap: 0.75rem; }
.search-result-item:hover { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.3); }
.search-result-cat { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 6px; border-radius: 4px; }
[data-theme="light"] .search-result-item:hover { background: #fffbeb; }

/* ============================================================
   26. PAGINACIÓN
   ============================================================ */
.page-btn { min-width: 36px; height: 36px; padding: 0 10px; border-radius: 8px; background: var(--surface-1); border: 1px solid rgba(100, 116, 139, 0.3); color: #94a3b8; font-size: 12px; font-weight: 700; transition: all 0.15s ease; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.page-btn:hover:not(:disabled) { border-color: rgba(245, 158, 11, 0.5); color: #fbbf24; }
.page-btn.active { background: rgba(245, 158, 11, 0.15); border-color: #f59e0b; color: #fbbf24; }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }
[data-theme="light"] .page-btn { background: #ffffff; border-color: #cbd5e1; color: #64748b; }
[data-theme="light"] .page-btn.active { background: #fffbeb; border-color: #f59e0b; color: #b45309; }

/* ============================================================
   27. SCROLL INFINITO + SKELETON + PULL-TO-REFRESH
   ============================================================ */
.infinite-scroll-sentinel { height: 1px; width: 100%; pointer-events: none; }
.infinite-scroll-loading,
.infinite-scroll-end { width: 100%; animation: fadeIn 0.3s ease-out; }

.spinner { width: 24px; height: 24px; border: 3px solid rgba(245, 158, 11, 0.15); border-top-color: #f59e0b; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton-card { position: relative; overflow: hidden; }
.skeleton-avatar { width: 48px; height: 48px; border-radius: 9999px; background: linear-gradient(90deg, rgba(30, 41, 59, 0.6) 0%, rgba(51, 65, 85, 0.8) 50%, rgba(30, 41, 59, 0.6) 100%); background-size: 200% 100%; animation: skeletonShimmer 1.4s ease-in-out infinite; flex-shrink: 0; }
.skeleton-line { height: 12px; border-radius: 6px; background: linear-gradient(90deg, rgba(30, 41, 59, 0.6) 0%, rgba(51, 65, 85, 0.8) 50%, rgba(30, 41, 59, 0.6) 100%); background-size: 200% 100%; animation: skeletonShimmer 1.4s ease-in-out infinite; }
.skeleton-line.h-3 { height: 10px; }
.skeleton-badge { width: 60px; height: 22px; border-radius: 9999px; background: linear-gradient(90deg, rgba(30, 41, 59, 0.6) 0%, rgba(51, 65, 85, 0.8) 50%, rgba(30, 41, 59, 0.6) 100%); background-size: 200% 100%; animation: skeletonShimmer 1.4s ease-in-out infinite; flex-shrink: 0; }
@keyframes skeletonShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
[data-theme="light"] .skeleton-avatar,
[data-theme="light"] .skeleton-line,
[data-theme="light"] .skeleton-badge { background: linear-gradient(90deg, #e2e8f0 0%, #cbd5e1 50%, #e2e8f0 100%); background-size: 200% 100%; }

.infinite-scroll-load-more { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px; margin: 8px 0; background: var(--surface-2); border: 1px solid rgba(245, 158, 11, 0.3); border-radius: 12px; color: #fbbf24; font-size: 13px; font-weight: 700; cursor: pointer; transition: all 0.2s ease; }
.infinite-scroll-load-more:hover { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.5); }
.infinite-scroll-load-more:active { transform: scale(0.98); }
[data-theme="light"] .infinite-scroll-load-more { background: #f8fafc; color: #b45309; }

#clientesList > .entity-card,
#prestamosList > .entity-card,
#comprasList > .entity-card,
#ventasList > .entity-card { animation: cardFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) backwards; }
@keyframes cardFadeIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

.ptr-indicator { position: fixed; top: 0; left: 50%; transform: translate(-50%, -60px); opacity: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 20px; background: var(--surface-1); border: 1px solid rgba(245, 158, 11, 0.4); border-radius: 16px; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5); pointer-events: none; will-change: transform, opacity; }
.ptr-spinner { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; color: #fbbf24; transition: transform 0.2s ease; }
.ptr-spinner svg { width: 22px; height: 22px; }
.ptr-text { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.ptr-indicator.ptr-ready .ptr-text { color: #fbbf24; }
.ptr-indicator.ptr-ready .ptr-spinner { color: #fbbf24; }
.ptr-indicator.ptr-loading .ptr-spinner { animation: spin 0.8s linear infinite; }
.ptr-indicator.ptr-loading .ptr-text { color: #fbbf24; }
[data-theme="light"] .ptr-indicator { background: rgba(255, 255, 255, 0.98); border-color: #f59e0b; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.15); }
[data-theme="light"] .ptr-text { color: #64748b; }
[data-theme="light"] .ptr-indicator.ptr-ready .ptr-text { color: #b45309; }

/* ============================================================
   28. PURO / MARKET / BUSCADOR CLIENTE
   ============================================================ */
#compraClienteSearchWrap { position: relative; }

#compraClienteDropdown {
  background: var(--surface-1);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.6);
}
[data-theme="light"] #compraClienteDropdown {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.15);
}

#btnAddClienteFromCompra { box-shadow: 0 4px 15px -4px rgba(16, 185, 129, 0.5); }
#btnAddClienteFromCompra:active { transform: scale(0.94); }

.puro-card { position: relative; }
.puro-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 3px 0 0 3px;
  background: linear-gradient(180deg, #fbbf24, #d97706, #b45309);
}

.market-card { transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease; }
.market-card:hover { transform: translateY(-3px); box-shadow: 0 15px 35px -10px rgba(217, 70, 239, 0.25); border-color: rgba(217, 70, 239, 0.4); }
.market-card img { background: var(--surface-2); }

@media (max-width: 360px) {
  nav.tab-btn-mob span,
  .tab-btn-mob span { font-size: 11px; }
  .tab-btn-mob svg { width: 18px; height: 18px; }
}

[data-theme="light"] .market-card { background: #ffffff; border-color: #e2e8f0; }
[data-theme="light"] .market-card:hover { border-color: #d946ef; box-shadow: 0 15px 35px -10px rgba(217, 70, 239, 0.15); }
[data-theme="light"] .puro-card::before { background: linear-gradient(180deg, #f59e0b, #b45309); }

/* ============================================================
   29. MODALES APILADOS
   ============================================================ */
#clienteModal[data-stack-over="compraModal"] {
  background: rgba(0, 0, 0, 0.65);
}

/* ============================================================
   30. ANTI-FLASH
   ============================================================ */
body:not(.app-ready) #loginSection,
body:not(.app-ready) #appSection { visibility: hidden; }
body.app-ready #loginSection.hidden,
body.app-ready #appSection.hidden { display: none !important; }
#loginForm input { transition: none !important; }

/* ============================================================
   31. VISUALIZADOR DE PRECIOS
   ============================================================ */
#preciosForm input[type="number"] { font-weight: 600; text-align: center; }
#preciosForm .grid-cols-2 > div:first-child input { border-color: rgba(244, 63, 94, 0.25); }
#preciosForm .grid-cols-2 > div:first-child input:focus { border-color: #f43f5e; box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.15); }
#preciosForm .grid-cols-2 > div:last-child input { border-color: rgba(16, 185, 129, 0.25); }
#preciosForm .grid-cols-2 > div:last-child input:focus { border-color: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15); }
[data-theme="light"] #preciosForm .grid-cols-2 > div:first-child input { border-color: #fda4af; }
[data-theme="light"] #preciosForm .grid-cols-2 > div:last-child input { border-color: #6ee7b7; }

/* ============================================================
   32. MODAL CONTENT RESPONSIVE
   ============================================================ */
.modal-content { padding: 1.25rem 1rem !important; }
@media (min-width: 640px) { .modal-content { padding: 1.5rem 2rem !important; } }

#whatsappForm input { min-width: 0 !important; }
#whatsappForm button { white-space: nowrap; }

/* ============================================================
   33. STICKY DATE SEPARATOR (compras / puro / market)
   ============================================================ */
.sticky-date-separator {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
  margin: 4px 0;
  pointer-events: none;
}
.sticky-date-separator span {
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 12px;
  border-radius: 9999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: auto;
}
[data-theme="light"] .sticky-date-separator span {
  background: #ffffff;
  border-color: #e2e8f0;
  color: #64748b;
}

/* ============================================================
   34. LIGHT THEME — OVERRIDES MÍNIMOS PARA TAILWIND
   ============================================================
   En vez de reescribir cada clase Tailwind una por una,
   ahora solo se ajustan las más comunes. El resto se apoya
   en las CSS variables definidas arriba.
   ============================================================ */

[data-theme="light"] body,
[data-theme="light"] .bg-darkbg { background-color: var(--surface) !important; color: var(--text-primary) !important; }

[data-theme="light"] .text-white { color: var(--text-primary) !important; }
[data-theme="light"] h1.text-white,
[data-theme="light"] h2.text-white,
[data-theme="light"] h3.text-white,
[data-theme="light"] h4.text-white { color: var(--text-primary) !important; }
[data-theme="light"] .text-slate-100 { color: var(--text-primary) !important; }
[data-theme="light"] .text-slate-200 { color: var(--text-secondary) !important; }
[data-theme="light"] .text-slate-300 { color: #475569 !important; }
[data-theme="light"] .text-slate-400 { color: var(--text-muted) !important; }
[data-theme="light"] .text-slate-500 { color: var(--text-muted) !important; }

[data-theme="light"] .text-emerald-400 { color: #047857 !important; }
[data-theme="light"] .text-emerald-300 { color: #059669 !important; }
[data-theme="light"] .text-cyan-400 { color: #0e7490 !important; }
[data-theme="light"] .text-cyan-300 { color: #0891b2 !important; }
[data-theme="light"] .text-violet-400 { color: #6d28d9 !important; }
[data-theme="light"] .text-violet-300 { color: #7c3aed !important; }
[data-theme="light"] .text-rose-400 { color: #be123c !important; }
[data-theme="light"] .text-rose-300 { color: #e11d48 !important; }
[data-theme="light"] .text-amber-400 { color: #b45309 !important; }
[data-theme="light"] .text-amber-300 { color: #d97706 !important; }
[data-theme="light"] .text-teal-400 { color: #0f766e !important; }
[data-theme="light"] .text-blue-400 { color: #1d4ed8 !important; }
[data-theme="light"] .text-indigo-400 { color: #4338ca !important; }
[data-theme="light"] .text-fuchsia-400 { color: #a21caf !important; }

[data-theme="light"] .bg-slate-900,
[data-theme="light"] [class*="bg-slate-900/"] { background-color: rgba(248, 250, 252, 0.9) !important; }
[data-theme="light"] .bg-slate-800,
[data-theme="light"] [class*="bg-slate-800/"] { background-color: rgba(241, 245, 249, 0.9) !important; }
[data-theme="light"] .bg-slate-700 { background-color: #e2e8f0 !important; }
[data-theme="light"] .bg-slate-950 { background-color: #f8fafc !important; }

[data-theme="light"] .border-slate-800,
[data-theme="light"] [class*="border-slate-800/"] { border-color: #e2e8f0 !important; }
[data-theme="light"] .border-slate-700 { border-color: #cbd5e1 !important; }
[data-theme="light"] .border-slate-600 { border-color: #cbd5e1 !important; }

[data-theme="light"] .kpi-card h3 { color: var(--text-primary) !important; }
[data-theme="light"] .kpi-card p { color: var(--text-muted) !important; }
[data-theme="light"] .kpi-card { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }

[data-theme="light"] .kpi-emerald { background: linear-gradient(135deg, #ecfdf5, #d1fae5) !important; border-color: #6ee7b7 !important; }
[data-theme="light"] .kpi-emerald p:first-child { color: #047857 !important; }
[data-theme="light"] .kpi-cyan { background: linear-gradient(135deg, #ecfeff, #cffafe) !important; border-color: #67e8f9 !important; }
[data-theme="light"] .kpi-cyan p:first-child { color: #0e7490 !important; }
[data-theme="light"] .kpi-rose { background: linear-gradient(135deg, #fff1f2, #ffe4e6) !important; border-color: #fda4af !important; }
[data-theme="light"] .kpi-rose p:first-child { color: #be123c !important; }
[data-theme="light"] .kpi-violet { background: linear-gradient(135deg, #f5f3ff, #ede9fe) !important; border-color: #c4b5fd !important; }
[data-theme="light"] .kpi-violet p:first-child { color: #6d28d9 !important; }
[data-theme="light"] .kpi-amber { background: linear-gradient(135deg, #fffbeb, #fef3c7) !important; border-color: #fcd34d !important; }
[data-theme="light"] .kpi-amber p:first-child { color: #b45309 !important; }
[data-theme="light"] .kpi-slate { background: linear-gradient(135deg, #f8fafc, #f1f5f9) !important; border-color: #cbd5e1 !important; }
[data-theme="light"] .kpi-slate p:first-child { color: #475569 !important; }

[data-theme="light"] .glass-card h1,
[data-theme="light"] .glass-card h2,
[data-theme="light"] .glass-card h3,
[data-theme="light"] .glass-card h4 { color: var(--text-primary) !important; }

[data-theme="light"] .entity-card h3 { color: var(--text-primary) !important; }
[data-theme="light"] .entity-card .text-white { color: var(--text-primary) !important; }
[data-theme="light"] .entity-card p { color: var(--text-secondary); }
[data-theme="light"] .entity-card .text-slate-400 { color: var(--text-muted) !important; }

[data-theme="light"] label.text-slate-400 { color: var(--text-secondary) !important; }

[data-theme="light"] .modal-content { background: #ffffff !important; color: var(--text-primary) !important; }
[data-theme="light"] .modal-content h3 { color: var(--text-primary) !important; }
[data-theme="light"] .modal-content label { color: var(--text-secondary) !important; }
[data-theme="light"] .modal-content .text-white { color: var(--text-primary) !important; }
[data-theme="light"] .modal-content .text-slate-400,
[data-theme="light"] .modal-content .text-slate-500 { color: var(--text-muted) !important; }
[data-theme="light"] .modal-content .bg-slate-900\/80,
[data-theme="light"] .modal-content .bg-slate-900\/90 { background: #f8fafc !important; }
[data-theme="light"] .modal-header { border-bottom-color: #e2e8f0 !important; }
[data-theme="light"] .modal-close { color: #64748b; }
[data-theme="light"] .modal-close:hover { color: var(--text-primary); }

[data-theme="light"] .header-menu,
[data-theme="light"] .menu-3puntos,
[data-theme="light"] .filtro-dropdown {
  background: #ffffff !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.15);
}
[data-theme="light"] .header-menu button,
[data-theme="light"] .menu-3puntos button,
[data-theme="light"] .filtro-dropdown button { color: var(--text-secondary) !important; }
[data-theme="light"] .header-menu button:hover,
[data-theme="light"] .menu-3puntos button:hover,
[data-theme="light"] .filtro-dropdown button:hover { background: #fffbeb !important; color: #b45309 !important; }
[data-theme="light"] .header-menu .menu-divider { background: #e2e8f0; }

[data-theme="light"] .btn-filtrar { background: #ffffff !important; border-color: #f59e0b !important; color: #b45309 !important; }
[data-theme="light"] .btn-filtrar:hover { background: #fffbeb !important; }

[data-theme="light"] .glass-card input { color: var(--text-primary) !important; }
[data-theme="light"] .glass-card input::placeholder { color: var(--text-dim); }

[data-theme="light"] [class*="bg-slate-900"] .text-white,
[data-theme="light"] [class*="bg-slate-900"] h3,
[data-theme="light"] [class*="bg-slate-900"] h4 { color: var(--text-primary) !important; }

[data-theme="light"] .historial-item { background: #f8fafc; border-color: #e2e8f0; }
[data-theme="light"] .historial-item .text-white { color: var(--text-primary) !important; }
[data-theme="light"] .historial-item p { color: var(--text-secondary); }

[data-theme="light"] nav.glass { background: rgba(255, 255, 255, 0.95); border-top-color: #e2e8f0; }
[data-theme="light"] .tab-btn-mob.text-slate-400 { color: #64748b; }
[data-theme="light"] header.glass { background: rgba(255, 255, 255, 0.95); }

[data-theme="light"] .glass.hover\:bg-slate-800\/60 { background: #f1f5f9; border-color: #e2e8f0; color: #475569; }
[data-theme="light"] .glass.hover\:bg-slate-800\/60:hover { background: #e2e8f0; }

[data-theme="light"] .bg-emerald-500\/10 { background: #d1fae5 !important; }
[data-theme="light"] .bg-cyan-500\/10 { background: #cffafe !important; }
[data-theme="light"] .bg-violet-500\/10 { background: #ede9fe !important; }
[data-theme="light"] .bg-rose-500\/10 { background: #ffe4e6 !important; }
[data-theme="light"] .bg-amber-500\/10 { background: #fef3c7 !important; }
[data-theme="light"] .bg-teal-500\/10 { background: #ccfbf1 !important; }
[data-theme="light"] .bg-blue-500\/10 { background: #dbeafe !important; }
[data-theme="light"] .bg-indigo-500\/10 { background: #e0e7ff !important; }

[data-theme="light"] .border-emerald-500\/20,
[data-theme="light"] .border-emerald-500\/30 { border-color: #6ee7b7 !important; }
[data-theme="light"] .border-cyan-500\/20,
[data-theme="light"] .border-cyan-500\/30 { border-color: #67e8f9 !important; }
[data-theme="light"] .border-violet-500\/20,
[data-theme="light"] .border-violet-500\/30 { border-color: #c4b5fd !important; }
[data-theme="light"] .border-rose-500\/20,
[data-theme="light"] .border-rose-500\/30 { border-color: #fda4af !important; }
[data-theme="light"] .border-amber-500\/20,
[data-theme="light"] .border-amber-500\/30 { border-color: #fcd34d !important; }

[data-theme="light"] .notif-card { background: #f8fafc !important; }
[data-theme="light"] .notif-card .text-white { color: var(--text-primary) !important; }

[data-theme="light"] .cuota-checkbox { background: #f8fafc; border-color: #e2e8f0; }
[data-theme="light"] .cuota-checkbox.selected { background: #fef3c7; border-color: #f59e0b; }
[data-theme="light"] .cuota-vencida { background: #ffe4e6 !important; }
[data-theme="light"] .cuota-por-vencer { background: #fef3c7 !important; }
[data-theme="light"] .cuota-pagada { background: #d1fae5 !important; }

[data-theme="light"] .modal-overlay { background: rgba(15, 23, 42, 0.5); }
[data-theme="light"] kbd { background: #f1f5f9; border-color: #cbd5e1; color: #64748b; }

/* ============================================================
   35. TAMAÑO DEL LOGO AURUM EN MÓVIL
   ============================================================ */
@media (max-width: 768px) {
  /* Forzamos el tamaño del texto en móviles */
  .logo-aurum-md {
    font-size: 1.70rem !important; 
    line-height: 1.1 !important;
  }
  
  /* Hacemos el logo un poco más grande para que haga juego */
  header .w-9.h-9 {
    width: 2.5rem !important;
    height: 2.5rem !important;
  }
}

/* ============================================================
   36. RENDIMIENTO EN MÓVIL: sin desenfoques de fondo pesados
   ============================================================
   Apilar backdrop-filter en overlay + contenido (y repintar gráficas al
   mismo tiempo) bloqueaba el hilo de composición en equipos Android
   modestos: la app quedaba "congelada" con un modal abierto. En pantallas
   pequeñas se usa un fondo semitransparente sólido en su lugar. */
@media (max-width: 820px) {
  .modal-overlay,
  .modal-content,
  #reciboModal,
  .header-menu,
  .menu-3puntos,
  .filtro-dropdown,
  .fundicion-toolbar {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
  .modal-overlay {
    background: rgba(2, 6, 23, 0.9);
  }
  [data-theme="light"] .modal-overlay {
    background: rgba(15, 23, 42, 0.55);
  }
  .modal-content {
    background: var(--surface-1);
  }
}

/* ============================================================
   37. FUNDICIÓN — selección, IDs y trazabilidad
   ============================================================ */
/* Botones de la cabecera de Compras (Seleccionar / Comprar) */
.compras-actions { display: flex; align-items: center; gap: 8px; width: 100%; }
.compras-actions > button { flex: 1 1 0; min-width: 0; }
.compras-actions > #btnModoFundicion.active {
  background: rgba(217, 70, 239, 0.18);
  border-color: rgba(217, 70, 239, 0.7);
  color: #f0abfc;
}
@media (min-width: 640px) {
  .compras-actions { width: auto; }
  .compras-actions > button { flex: 0 0 auto; }
}

.fundicion-firmante {
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analitica-prov-name {
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Identificador opaco: monoespaciado y cifras tabulares para que un
   cambio de dígito salte a la vista al comparar códigos. */
.fundicion-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  word-break: break-all;
}

.fundicion-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.4;
  border: 1px solid rgba(217, 70, 239, 0.35);
  background: rgba(217, 70, 239, 0.12);
  color: #f0abfc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fundicion-chip.muted {
  border-color: rgba(148, 163, 184, 0.3);
  background: rgba(148, 163, 184, 0.1);
  color: #94a3b8;
  font-family: inherit;
}

/* Barra de selección (aparece al marcar compras) */
.fundicion-toolbar {
  position: sticky;
  top: 8px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(217, 70, 239, 0.18), rgba(245, 158, 11, 0.12));
  border: 1px solid rgba(217, 70, 239, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  animation: menuIn 0.2s ease-out;
}
/* La utilidad .hidden debe ganar sobre el display:flex de la barra. */
.fundicion-toolbar.hidden { display: none; }
.fundicion-toolbar-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fundicion-toolbar-count { font-size: 13px; font-weight: 800; color: #f0abfc; }
.fundicion-toolbar-meta {
  font-size: 10px;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.fundicion-toolbar-sep { opacity: 0.5; }
.fundicion-toolbar-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.fundicion-btn-enviar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #d946ef, #a21caf);
  border: 1px solid rgba(240, 171, 252, 0.4);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.fundicion-btn-enviar:hover:not(:disabled) { filter: brightness(1.1); }
.fundicion-btn-enviar:disabled { opacity: 0.45; cursor: not-allowed; }
.fundicion-btn-enviar svg { width: 14px; height: 14px; flex-shrink: 0; }

.fundicion-btn-cancelar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  flex-shrink: 0;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.fundicion-btn-cancelar:hover { color: #fff; background: rgba(15, 23, 42, 0.9); }
.fundicion-btn-cancelar svg { width: 14px; height: 14px; }

@media (max-width: 420px) {
  .fundicion-toolbar { flex-direction: column; align-items: stretch; }
  .fundicion-toolbar-actions { justify-content: flex-end; }
  .fundicion-btn-enviar { flex: 1; justify-content: center; }
}

/* Tarjetas en modo selección */
#comprasList.fundicion-modo .entity-card { cursor: default; }
.entity-card.fundicion-selected {
  border-color: rgba(217, 70, 239, 0.65) !important;
  box-shadow: 0 0 0 1px rgba(217, 70, 239, 0.35), 0 10px 30px -12px rgba(217, 70, 239, 0.35);
  background: rgba(217, 70, 239, 0.06);
}

.fundicion-check {
  width: 22px;
  height: 22px;
  border-radius: 9999px;
  flex-shrink: 0;
  border: 2px solid rgba(148, 163, 184, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: all 0.15s ease;
}
.fundicion-check svg { width: 12px; height: 12px; }
.fundicion-check.on {
  background: #d946ef;
  border-color: #e879f9;
  color: #fff;
}
.fundicion-check.disabled { opacity: 0.3; }

/* Historial */
.fundicion-hist-card { border: 1px solid var(--border-soft); }
.fundicion-hist-card.expanded {
  border-color: rgba(217, 70, 239, 0.5);
  box-shadow: 0 10px 40px -14px rgba(217, 70, 239, 0.3);
}
.fundicion-hist-card .chevron { transition: transform 0.2s ease; }
.fundicion-hist-card.expanded .chevron { transform: rotate(180deg); }

.fundicion-estado {
  font-size: 9px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 9999px;
  border: 1px solid;
  white-space: nowrap;
  flex-shrink: 0;
}
.estado-fundida { color: #fbbf24; background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.35); }
.estado-puro { color: #22d3ee; background: rgba(6, 182, 212, 0.12); border-color: rgba(6, 182, 212, 0.35); }
.estado-market { color: #e879f9; background: rgba(217, 70, 239, 0.12); border-color: rgba(217, 70, 239, 0.35); }
.estado-vendida { color: #34d399; background: rgba(16, 185, 129, 0.12); border-color: rgba(16, 185, 129, 0.35); }

.fundicion-market-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 8px;
  font-weight: 700;
  color: #f0abfc;
  letter-spacing: 0.01em;
}

[data-theme="light"] .fundicion-toolbar {
  background: #ffffff;
  border-color: #e9d5ff;
}
[data-theme="light"] .fundicion-toolbar-count { color: #a21caf; }
[data-theme="light"] .fundicion-toolbar-meta { color: #475569; }
[data-theme="light"] .fundicion-btn-cancelar { background: #f8fafc; color: #475569; }
[data-theme="light"] .fundicion-chip { color: #a21caf; background: #fdf4ff; border-color: #f0abfc; }
[data-theme="light"] .fundicion-id { color: inherit; }
/* ================================================================
   CHAT - AURUM
   ================================================================ */
.chat-shell {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 190px);
  min-height: 520px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.92), rgba(2, 6, 23, 0.96));
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 1.25rem;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  background: radial-gradient(circle at top left, rgba(245, 158, 11, 0.10), transparent 55%);
}

.chat-tab {
  padding: 0.4rem 0.7rem;
  border-radius: 0.65rem;
  font-size: 0.65rem;
  font-weight: 800;
  color: #94a3b8;
  border: 1px solid transparent;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.chat-tab:hover { color: #fff; }
.chat-tab.active {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.10);
  border-color: rgba(245, 158, 11, 0.25);
}
.chat-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  margin-left: 3px;
  border-radius: 999px;
  background: #f43f5e;
  color: #fff;
  font-size: 8px;
  font-weight: 900;
}

.chat-grid {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

.chat-list-pane {
  min-height: 0;
  overflow-y: auto;
  border-right: 1px solid rgba(148, 163, 184, 0.10);
  background: rgba(2, 6, 23, 0.35);
}

.chat-conv {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.75rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.07);
  transition: background 0.16s ease;
}
.chat-conv:hover { background: rgba(245, 158, 11, 0.05); }
.chat-conv.active { background: rgba(245, 158, 11, 0.09); }

.chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fbbf24, #b45309);
  color: #0f172a;
  font-size: 0.65rem;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-unread {
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #f43f5e;
  color: #fff;
  font-size: 8px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-context-chip {
  display: inline-block;
  max-width: 100%;
  margin-top: 0.3rem;
  padding: 0.15rem 0.45rem;
  border-radius: 0.4rem;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.18);
  color: #fcd34d;
  font-size: 0.55rem;
  font-weight: 700;
}

.chat-thread-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background:
    radial-gradient(circle at 85% 10%, rgba(217, 70, 239, 0.07), transparent 45%),
    radial-gradient(circle at 15% 90%, rgba(245, 158, 11, 0.06), transparent 50%);
}

.chat-thread-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.10);
  background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(12px);
}

.chat-back {
  display: none;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 0.55rem;
  color: #cbd5e1;
  background: rgba(30, 41, 59, 0.8);
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-bubble {
  max-width: 78%;
  padding: 0.55rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.78rem;
  line-height: 1.45;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.chat-bubble.mine {
  align-self: flex-end;
  background: linear-gradient(135deg, #fbbf24, #d97706);
  color: #0f172a;
  border-bottom-right-radius: 0.25rem;
}
.chat-bubble.theirs {
  align-self: flex-start;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.12);
  color: #e2e8f0;
  border-bottom-left-radius: 0.25rem;
}
.chat-time {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.55rem;
  opacity: 0.65;
  text-align: right;
}

.chat-system {
  align-self: center;
  max-width: 85%;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.10);
  color: #94a3b8;
  font-size: 0.6rem;
  text-align: center;
}

.chat-card {
  align-self: flex-start;
  max-width: 85%;
  padding: 0.8rem;
  border-radius: 1rem;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(245, 158, 11, 0.25);
}
.chat-card.mine {
  align-self: flex-end;
  border-color: rgba(16, 185, 129, 0.30);
}

.chat-composer {
  padding: 0.7rem;
  border-top: 1px solid rgba(148, 163, 184, 0.10);
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(12px);
}

.chat-quick {
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.20);
  color: #fcd34d;
  font-size: 0.6rem;
  font-weight: 800;
  white-space: nowrap;
}

.chat-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.chat-input {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 0.85rem;
  border-radius: 0.85rem;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.16);
  color: #fff;
  font-size: 0.8rem;
  outline: none;
}
.chat-input:focus { border-color: rgba(245, 158, 11, 0.45); }
.chat-send {
  width: 40px;
  height: 40px;
  border-radius: 0.85rem;
  background: linear-gradient(135deg, #fbbf24, #d97706);
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.25);
}

.chat-empty {
  margin: auto;
  padding: 2rem 1rem;
  text-align: center;
}

.chat-aviso {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem;
  border-radius: 0.9rem;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.10);
  text-align: left;
}
.chat-aviso.unread {
  background: rgba(245, 158, 11, 0.07);
  border-color: rgba(245, 158, 11, 0.25);
}
.chat-aviso-icon {
  width: 30px;
  height: 30px;
  border-radius: 0.6rem;
  background: rgba(245, 158, 11, 0.10);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

@media (max-width: 767px) {
  .chat-shell {
    height: calc(100dvh - 172px);
    min-height: 480px;
    border-radius: 1rem;
  }
  .chat-head {
    padding: 0.75rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
  }
  .chat-head > div:last-child {
    justify-content: flex-end;
  }
  .chat-grid { grid-template-columns: 1fr; }
  .chat-thread-pane { display: none; }
  .chat-shell.chat-abierto .chat-list-pane { display: none; }
  .chat-shell.chat-abierto .chat-thread-pane { display: flex; }
  .chat-back { display: inline-flex; }
  .chat-context-chip { max-width: 40%; }
}

.chat-bubble p { white-space: pre-wrap; }
#chatBadgeDesk, #chatBadgeMob { min-width: 16px; }

.chat-context-chip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#marketFiltrosCount { min-width: 16px; }

[data-theme="light"] .chat-shell { background: #ffffff; border-color: #e2e8f0; box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08); }
[data-theme="light"] .chat-head { background: radial-gradient(circle at top left, rgba(245, 158, 11, 0.10), transparent 55%); border-color: #e2e8f0; }
[data-theme="light"] .chat-list-pane { background: #f8fafc; border-color: #e2e8f0; }
[data-theme="light"] .chat-conv { border-color: #e2e8f0; }
[data-theme="light"] .chat-conv:hover { background: #fffbeb; }
[data-theme="light"] .chat-conv.active { background: #fef3c7; }
[data-theme="light"] .chat-thread-pane { background: #f8fafc; }
[data-theme="light"] .chat-thread-head { background: rgba(255,255,255,0.85); border-color: #e2e8f0; }
[data-theme="light"] .chat-bubble.theirs { background: #ffffff; border-color: #e2e8f0; color: #0f172a; }
[data-theme="light"] .chat-system { background: #f1f5f9; border-color: #e2e8f0; color: #64748b; }
[data-theme="light"] .chat-composer { background: rgba(255,255,255,0.9); border-color: #e2e8f0; }
[data-theme="light"] .chat-input { background: #ffffff; border-color: #e2e8f0; color: #0f172a; }
[data-theme="light"] .chat-card { background: #ffffff; border-color: #fcd34d; }
[data-theme="light"] .chat-aviso { background: #ffffff; border-color: #e2e8f0; }
[data-theme="light"] .chat-aviso.unread { background: #fffbeb; border-color: #fcd34d; }

[data-theme="light"] .chat-head h2,
[data-theme="light"] .chat-thread-head .text-white,
[data-theme="light"] .chat-conv .text-white,
[data-theme="light"] .chat-card .text-white { color: #0f172a !important; }
[data-theme="light"] .chat-head p,
[data-theme="light"] .chat-thread-head p { color: #64748b; }

.break-all { word-break: break-all; }
.whitespace-pre-line { white-space: pre-line; }

.chat-avisos-scroll { flex: 1; min-height: 0; overflow-y: auto; }

.chat-day {
  align-self: center;
  margin: 0.35rem 0;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.08);
  color: #94a3b8;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.chat-conv, .chat-tab, .chat-quick, .chat-send, .chat-back, .chat-aviso { cursor: pointer; }

.chat-trace {
  padding: 0.4rem 0.9rem;
  background: rgba(217, 70, 239, 0.06);
  border-bottom: 1px solid rgba(217, 70, 239, 0.16);
  color: #f0abfc;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ================================================================
   CHAT FULL-BLEED - ocupa header ? nav, sin tarjeta ni doble scroll
   ================================================================ */
#appSection.chat-mode {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  padding-bottom: 5rem; /* deja libre la barra inferior movil */
}
#appSection.chat-mode main {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#appSection.chat-mode main > * + * { margin-top: 0; }
#appSection.chat-mode .desktop-tabs {
  flex-shrink: 0;
  padding: 0.75rem 2rem 0.75rem;
  margin: 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.10);
}
#appSection.chat-mode #chatTab:not(.hidden) {
  flex: 1;
  min-height: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
#appSection.chat-mode #chatApp {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#appSection.chat-mode .chat-shell {
  flex: 1;
  height: auto;
  min-height: 0;
  max-height: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}
#appSection.chat-mode .chat-head { flex-shrink: 0; }
#appSection.chat-mode .chat-grid { flex: 1; min-height: 0; }
#appSection.chat-mode .chat-list-pane,
#appSection.chat-mode .chat-thread-pane { min-height: 0; }

@media (min-width: 768px) {
  #appSection.chat-mode { padding-bottom: 0; }
}

@media (max-width: 767px) {
  #appSection.chat-mode .chat-head {
    flex-direction: row;
    align-items: center;
    padding: 0.55rem 0.75rem;
    gap: 0.5rem;
  }
  #appSection.chat-mode .chat-head > div:first-child p { display: none; }
  #appSection.chat-mode .chat-head h2 { font-size: 1rem; }
  #appSection.chat-mode .chat-head > div:last-child { margin-left: auto; }
  #appSection.chat-mode .chat-shell { min-height: 0; }
}

/* ================================================================
   MARKET - selector Oro / Divisas (tarjetas, no pills)
   ================================================================ */
.market-hub-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
}
.market-hub-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.8rem;
  border-radius: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(15, 23, 42, 0.62);
  text-align: left;
  overflow: hidden;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.market-hub-card:hover { transform: translateY(-1px); }
.market-hub-card .market-hub-icon {
  width: 34px;
  height: 34px;
  border-radius: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.market-hub-card.oro .market-hub-icon {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.22);
  color: #fbbf24;
}
.market-hub-card.divisas .market-hub-icon {
  background: rgba(34, 211, 238, 0.10);
  border: 1px solid rgba(34, 211, 238, 0.20);
  color: #22d3ee;
}
.market-hub-copy { min-width: 0; display: flex; flex-direction: column; }
.market-hub-copy strong {
  color: #e2e8f0;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.15;
}
.market-hub-copy small {
  color: #64748b;
  font-size: 0.55rem;
  font-weight: 600;
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.market-hub-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  margin-left: auto;
  background: transparent;
  flex-shrink: 0;
}
.market-hub-card.oro.active {
  border-color: rgba(245, 158, 11, 0.45);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.14), rgba(15, 23, 42, 0.72));
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.08);
}
.market-hub-card.oro.active .market-hub-copy strong { color: #fcd34d; }
.market-hub-card.oro.active .market-hub-dot { background: #fbbf24; box-shadow: 0 0 10px rgba(251, 191, 36, 0.6); }
.market-hub-card.divisas.active {
  border-color: rgba(34, 211, 238, 0.45);
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.12), rgba(15, 23, 42, 0.72));
  box-shadow: 0 8px 24px rgba(34, 211, 238, 0.07);
}
.market-hub-card.divisas.active .market-hub-copy strong { color: #67e8f9; }
.market-hub-card.divisas.active .market-hub-dot { background: #22d3ee; box-shadow: 0 0 10px rgba(34, 211, 238, 0.6); }

[data-theme="light"] .market-hub-card { background: #ffffff; border-color: #e2e8f0; }
[data-theme="light"] .market-hub-copy strong { color: #0f172a; }
[data-theme="light"] .market-hub-copy small { color: #64748b; }

.chat-composer, .chat-thread-head { flex-shrink: 0; }

.chat-head { flex-shrink: 0; }

.market-hub-card { cursor: pointer; }
[data-theme="light"] .market-hub-card.oro.active { background: linear-gradient(135deg, #fffbeb, #fff7ed); }
[data-theme="light"] .market-hub-card.divisas.active { background: linear-gradient(135deg, #ecfeff, #f0fdfa); }

@media (max-width: 767px) {
  #appSection.chat-mode { padding-bottom: calc(5rem + env(safe-area-inset-bottom)); }
}

/* Evita el scroll de pagina mientras se usa el Chat y quita la linea del borde */
html.chat-lock,
body.chat-lock {
  overflow: hidden !important;
  height: 100dvh;
}

.chat-messages,
.chat-list-pane,
.chat-avisos-scroll {
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.22) transparent;
}
.chat-messages::-webkit-scrollbar,
.chat-list-pane::-webkit-scrollbar,
.chat-avisos-scroll::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.chat-messages::-webkit-scrollbar-track,
.chat-list-pane::-webkit-scrollbar-track,
.chat-avisos-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb,
.chat-list-pane::-webkit-scrollbar-thumb,
.chat-avisos-scroll::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.18);
  border-radius: 999px;
}

@media (max-width: 767px) {
  .chat-list-pane { border-right: 0; }
}

@media (max-width: 767px) {
  .chat-messages,
  .chat-list-pane,
  .chat-avisos-scroll { scrollbar-width: none; }
  .chat-messages::-webkit-scrollbar,
  .chat-list-pane::-webkit-scrollbar,
  .chat-avisos-scroll::-webkit-scrollbar { width: 0; height: 0; display: none; }
}

.chat-messages,
.chat-list-pane,
.chat-avisos-scroll { scrollbar-width: none; }
.chat-messages::-webkit-scrollbar,
.chat-list-pane::-webkit-scrollbar,
.chat-avisos-scroll::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* MARKET SEARCH TOGGLE */
.market-search-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: #94a3b8;
  border-radius: 0.7rem;
  transition: color 0.18s ease, background 0.18s ease;
}
.market-search-btn:hover,
.market-search-btn.active { color: #fbbf24; background: transparent; }
.market-search-wrap {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.15rem 0.15rem 0.65rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}
.market-search-wrap.hidden { display: none; }
.market-search-input {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #fff;
  font-size: 0.82rem;
}
.market-search-input::placeholder { color: #64748b; }
.market-search-clear {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: #64748b;
}

/* CHAT SEARCH TOGGLE */
.chat-icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: #94a3b8;
  border-radius: 0.55rem;
}
.chat-icon-btn.active { color: #fbbf24; }
.chat-search-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.1rem 0.9rem 0.55rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.10);
  flex-shrink: 0;
}
.chat-search-wrap.hidden { display: none; }
.chat-search-input {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #fff;
  font-size: 0.8rem;
}
.chat-search-input::placeholder { color: #64748b; }
.chat-search-clear {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: #64748b;
}

/* CHAT FLAT / NO PANEL BOXES */
#appSection.chat-mode .chat-head,
#appSection.chat-mode .chat-thread-head,
#appSection.chat-mode .chat-composer {
  background: transparent;
  border: 0;
  box-shadow: none;
}
#appSection.chat-mode .chat-head { border-bottom: 0; padding-top: 0.45rem; }
#appSection.chat-mode .chat-thread-head { border-bottom: 0; padding-top: 0.35rem; }
#appSection.chat-mode .chat-list-pane { background: transparent; border-right: 0; }
#appSection.chat-mode .chat-conv {
  border-bottom: 0;
  background: transparent;
  border-radius: 0.75rem;
}
#appSection.chat-mode .chat-conv:hover { background: rgba(148, 163, 184, 0.06); }
#appSection.chat-mode .chat-conv.active {
  background: transparent;
  box-shadow: inset 2px 0 0 #fbbf24;
  border-radius: 0;
}
#appSection.chat-mode .chat-tab {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
#appSection.chat-mode .chat-tab.active {
  background: transparent;
  border-color: transparent;
  color: #fbbf24;
  box-shadow: inset 0 -2px 0 #fbbf24;
}
#appSection.chat-mode .chat-quick {
  background: transparent;
  border: 0;
  padding-left: 0;
  padding-right: 0;
}
#appSection.chat-mode .chat-context-chip {
  background: transparent;
  border: 0;
  padding: 0;
}
#appSection.chat-mode .chat-trace {
  background: transparent;
  border: 0;
}
#appSection.chat-mode .chat-aviso {
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  border-radius: 0;
}
#appSection.chat-mode .chat-composer { padding-top: 0.35rem; }
#appSection.chat-mode .chat-input {
  background: rgba(15, 23, 42, 0.42);
  border-color: rgba(148, 163, 184, 0.12);
}

@media (max-width: 767px) {
  #appSection.chat-mode { padding-bottom: calc(6.25rem + env(safe-area-inset-bottom)); }
  #appSection.chat-mode .chat-composer { padding-bottom: 0.85rem; }
}

[data-theme="light"] .market-search-wrap,
[data-theme="light"] .chat-search-wrap { border-color: #e2e8f0; }
[data-theme="light"] .market-search-input,
[data-theme="light"] .chat-search-input { color: #0f172a; }
[data-theme="light"] #appSection.chat-mode .chat-head,
[data-theme="light"] #appSection.chat-mode .chat-thread-head,
[data-theme="light"] #appSection.chat-mode .chat-composer,
[data-theme="light"] #appSection.chat-mode .chat-list-pane,
[data-theme="light"] #appSection.chat-mode .chat-conv { background: transparent; }

#appSection.chat-mode .chat-thread-pane,
#appSection.chat-mode .chat-grid { background: transparent; }

#appSection.chat-mode { box-sizing: border-box; max-height: 100dvh; }

#appSection.chat-mode .chat-thread-head,
#appSection.chat-mode .chat-composer {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

[data-theme="light"] .chat-aviso .text-white { color: #0f172a !important; }

.market-search-wrap,
.chat-search-wrap { animation: searchDrop 0.18s ease; }
@keyframes searchDrop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 767px) {
  #appSection.chat-mode {
    padding-bottom: calc(var(--chat-nav-space, 4.25rem) + env(safe-area-inset-bottom));
  }
  #appSection.chat-mode .chat-composer { padding-bottom: 0.35rem; }
}

@media (min-width: 640px) {
  #marketSort { max-width: 18rem; margin-left: auto; }
}

@media (max-width: 767px) {
  #appSection.chat-mode { padding-bottom: 0; }
  #appSection.chat-mode .chat-composer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--chat-nav-space, 4.25rem) + env(safe-area-inset-bottom));
    z-index: 35;
    padding: 0.45rem 0.9rem 0.35rem;
    background: linear-gradient(180deg, rgba(2, 6, 23, 0) 0%, rgba(2, 6, 23, 0.88) 38%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
  #appSection.chat-mode .chat-messages {
    padding-bottom: calc(var(--chat-nav-space, 4.25rem) + 100px);
  }
  [data-theme="light"] #appSection.chat-mode .chat-composer {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.92) 38%);
  }
}

@media (max-width: 767px) {
  #appSection.chat-mode .chat-list-pane,
  #appSection.chat-mode .chat-avisos-scroll {
    padding-bottom: calc(var(--chat-nav-space, 4.25rem) + 12px);
  }
}

@media (max-width: 767px) {
  #appSection.chat-mode .chat-composer {
    bottom: var(--chat-nav-space, 4.25rem);
    padding-bottom: 0.5rem;
    background: linear-gradient(180deg, rgba(2, 6, 23, 0) 0%, rgba(2, 6, 23, 0.97) 22%, #020617 100%);
  }
  [data-theme="light"] #appSection.chat-mode .chat-composer {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.97) 22%, #ffffff 100%);
  }
}

#appSection.chat-mode .chat-input { background: rgba(15, 23, 42, 0.9); }

[data-theme="light"] #appSection.chat-mode .chat-input { background: #ffffff; }

@media (max-width: 767px) {
  #appSection.chat-mode .chat-composer {
    bottom: calc(var(--chat-nav-space, 4.25rem) - 4px);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  #appSection.chat-mode .chat-composer::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 28px;
    background: #020617;
    pointer-events: none;
  }
  [data-theme="light"] #appSection.chat-mode .chat-composer::after {
    background: #ffffff;
  }
}

/* Tarjeta de referidos con borde luminoso */
.referidos-card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: 1.6rem;
  background: #0b0f16;
  border: 1px solid rgba(245, 158, 11, 0.28);
}
.referidos-card::before {
  content: "";
  position: absolute;
  inset: -65%;
  z-index: -2;
  background: conic-gradient(from 0deg, transparent 0deg, #fbbf24 70deg, transparent 140deg, #f59e0b 220deg, transparent 300deg);
  animation: referidosGlow 5.5s linear infinite;
}
.referidos-card::after {
  content: "";
  position: absolute;
  inset: 2px;
  z-index: -1;
  border-radius: 1.45rem;
  background: #0b0f16;
}
@keyframes referidosGlow {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .referidos-card::before { animation: none; background: #f59e0b; opacity: .45; }
}

.referidos-card {
  background: #07090d;
  border: 1.5px solid #b8860b;
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.08), 0 22px 60px rgba(0, 0, 0, 0.65);
}
.referidos-titulo {
  background: linear-gradient(180deg, #ffe066 0%, #f5c400 55%, #d99a00 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.referidos-btn {
  background: linear-gradient(180deg, #f7dd4a 0%, #e8c400 100%);
  color: #0b0f16;
  box-shadow: 0 4px 14px rgba(232, 196, 0, 0.22);
}
.referidos-btn:active { transform: scale(0.985); }

#referidosModal { z-index: 98; }
.referidos-card { width: 100%; }
.referidos-titulo {
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: -0.02em;
}
@media (max-width: 380px) {
  .referidos-titulo { font-size: 27px; }
}

#referidosModal {
  height: 100dvh;
  overscroll-behavior: none;
}

.referidos-back {
  top: max(0px, calc(env(safe-area-inset-top, 0px) - 2px));
}

.referidos-stack { gap: 45px; }

.referidos-target {
  width: 160px;
  height: 160px;
  color: #f3d38a;
}
@media (max-height: 740px) {
  .referidos-target { width: 120px; height: 120px; }
}

.market-location-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(245, 158, 11, 0.28);
  background: rgba(245, 158, 11, 0.08);
  color: #fcd34d;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  transition: background .18s, border-color .18s, transform .18s;
}
.market-location-pill:hover { background: rgba(245, 158, 11, 0.14); border-color: rgba(245, 158, 11, 0.5); }
.market-location-pill:active { transform: scale(.97); }

/* Reportes de errores */
.reporte-card {
  background: #0b0f16;
  border: 1.5px solid rgba(245, 158, 11, 0.42);
  border-radius: 1.4rem;
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.05), 0 22px 60px rgba(0, 0, 0, 0.6);
}
.reporte-tipo {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.6);
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  transition: border-color .18s, background .18s, transform .18s;
}
.reporte-tipo:hover { border-color: rgba(245, 158, 11, 0.35); background: rgba(30, 41, 59, 0.7); }
.reporte-tipo:active { transform: scale(.99); }
.reporte-tipo.activo {
  border-color: rgba(245, 158, 11, 0.7);
  background: rgba(245, 158, 11, 0.1);
  color: #fde68a;
}

#reportesErrorModal { z-index: 98; height: 100dvh; }

#verificacionConfettiCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#verificacionEsperaModal { z-index: 99; }

#verificacionEsperaModal {
  z-index: 99;
  overflow: hidden;
  background: rgba(3, 5, 9, 0.72);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
#verificacionEsperaModal::before {
  content: "";
  position: absolute;
  inset: -35%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 30% 30%, rgba(245, 158, 11, 0.22), transparent 45%),
    radial-gradient(circle at 70% 68%, rgba(217, 119, 6, 0.18), transparent 42%);
  filter: blur(70px);
  animation: verificacionGlowMove 12s ease-in-out infinite alternate;
}
@keyframes verificacionGlowMove {
  0% { transform: translate3d(-3%, -2%, 0) scale(1); }
  50% { transform: translate3d(3%, 2%, 0) scale(1.08); }
  100% { transform: translate3d(-2%, 3%, 0) scale(1.03); }
}
.verificacion-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}
@media (prefers-reduced-motion: reduce) {
  #verificacionEsperaModal::before { animation: none; }
}

.verificacion-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.verificacion-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

#premiumGateModal {
  background: rgba(3, 5, 9, 0.84);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.premium-gate-card {
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.96), rgba(8, 13, 25, 0.98));
  border: 1.5px solid rgba(245, 158, 11, 0.5);
  border-radius: 1.6rem;
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.06), 0 24px 70px rgba(0, 0, 0, 0.65);
}

#premiumGateModal {
  z-index: 120 !important;
  position: fixed !important;
}
