@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --sidebar-w: 200px;
  --sidebar-w-collapsed: 64px;
  --sidebar-bg: #12243A;
  --sidebar-active: rgba(99,102,241,0.15);
  --sidebar-active-text: #818CF8;
  --sidebar-text: #8BA4BE;
  --sidebar-text-hover: #C8D8E8;
  --bg: #F2F5FA;
  --bg2: #FFFFFF;
  --bg3: #F7F9FC;
  --bg4: #EDF1F7;
  --border: #E4E9F2;
  --border2: #D0D8E8;
  --text: #1A2640;
  --text2: #5E718A;
  --text3: #94A3B8;
  --primary: #6366F1;
  --primary-dark: #4F46E5;
  --primary-hover: rgba(99,102,241,0.08);
  --accent: #25D366;
  --accent-dark: #1DAA52;
  --green: #22C55E;
  --orange: #F59E0B;
  --red: #EF4444;
  --blue: #3B82F6;
  --purple: #8B5CF6;
  --shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
  --sidebar-bg: #0A1628;
  --sidebar-active: rgba(99,102,241,0.18);
  --sidebar-active-text: #A5B4FC;
  --sidebar-text: #5A7A9A;
  --sidebar-text-hover: #A0BDD8;
  --bg: #0D1B2E;
  --bg2: #111F33;
  --bg3: #162538;
  --bg4: #1C2E42;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --text: #D8E8F8;
  --text2: #6A8AAA;
  --text3: #3D5570;
  --primary-hover: rgba(99,102,241,0.12);
  --shadow: 0 1px 4px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
}

/* Dark mode msg preview */
[data-theme="dark"] .msg-preview {
  background: #0D2818;
  color: #A7F3C5;
  border-color: rgba(37,211,102,0.15);
}
[data-theme="dark"] .msg-bubble-wrap {
  background: #0B1F12;
  border-color: rgba(34,197,94,0.1);
}
[data-theme="dark"] .sql-box { background: #070E1A; }
[data-theme="dark"] .input-readonly { background: var(--bg3); }

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; font-size: 14px; }

/* ============================
   LAYOUT
   ============================ */
.app { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: width 0.25s ease;
  overflow: hidden;
}

.topbar-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  margin-right: 8px;
}
.topbar-hamburger:hover { background: var(--bg4); color: var(--text); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 199;
  backdrop-filter: blur(2px);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 14px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  overflow: hidden;
  min-width: var(--sidebar-w);
}
.sidebar-logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--primary) 0%, #818CF8 100%);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(99,102,241,0.4);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px; color: #fff;
  flex-shrink: 0;
}
.sidebar-logo-text { overflow: hidden; white-space: nowrap; }
.sidebar-logo-name { font-size: 14px; font-weight: 800; color: #fff; line-height: 1.2; letter-spacing: -0.2px; }
.sidebar-logo-sub  { font-size: 10px; color: rgba(255,255,255,0.45); margin-top: 2px; letter-spacing: 0.3px; text-transform: uppercase; }

/* Usuario activo en sidebar */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  margin-bottom: 4px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  overflow: hidden;
}
.sidebar-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, #818CF8 100%);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name  { font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-email { font-size: 10px; color: rgba(255,255,255,0.4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Collapsed: ocultar texto usuario */
.sidebar.collapsed .sidebar-user { justify-content: center; padding: 8px 6px; }
.sidebar.collapsed .sidebar-user-info { display: none; }

/* Toggle button */
.sidebar-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 7px;
  cursor: pointer;
  color: var(--sidebar-text);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  z-index: 1;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.1); color: var(--sidebar-text-hover); }
#toggleIcon { transition: transform 0.25s ease; }

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: var(--sidebar-w);
}
.sidebar-nav button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.sidebar-nav button:hover { background: rgba(255,255,255,0.05); color: var(--sidebar-text-hover); }
.sidebar-nav button.active { background: var(--sidebar-active); color: var(--sidebar-active-text); font-weight: 600; }
.sidebar-nav button svg { flex-shrink: 0; opacity: 0.7; }
.sidebar-nav button.active svg { opacity: 1; color: var(--sidebar-active-text); }

/* Etiquetas de grupo */
.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
  padding: 12px 10px 4px;
  white-space: nowrap;
  overflow: hidden;
}

/* Tooltip when collapsed */
.sidebar.collapsed .sidebar-nav button { position: relative; }
.sidebar.collapsed .sidebar-nav button .nav-label { display: none; }
.sidebar.collapsed .nav-group-label { display: none; }

.sidebar-footer {
  padding: 10px 8px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  overflow: hidden;
  min-width: var(--sidebar-w);
}
.btn-direct-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 10px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  overflow: hidden;
}
.btn-direct-msg:hover { background: var(--accent-dark); }

.sidebar-footer-links { display: flex; flex-direction: column; gap: 2px; }
.sidebar-footer-links button {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  background: transparent;
  border: none;
  color: var(--sidebar-text);
  font-size: 12px;
  font-family: inherit;
  border-radius: 7px;
  cursor: pointer;
  width: 100%;
  white-space: nowrap;
  transition: all 0.15s;
}
.sidebar-footer-links button:hover { background: rgba(255,255,255,0.05); color: var(--sidebar-text-hover); }

.sidebar-sync {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  font-size: 11px;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
}

/* ── COLLAPSED STATE ── */
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar.collapsed .sidebar-logo { min-width: 0; justify-content: center; padding-right: 14px; }
.sidebar.collapsed .sidebar-logo-text { display: none; }
.sidebar.collapsed .sidebar-toggle { right: 50%; transform: translate(50%, -50%); }
.sidebar.collapsed #toggleIcon { transform: rotate(180deg); }
.sidebar.collapsed .sidebar-nav { min-width: 0; align-items: center; padding: 10px 6px; }
.sidebar.collapsed .sidebar-nav button { justify-content: center; padding: 10px; gap: 0; }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .sidebar-footer { min-width: 0; align-items: center; }
.sidebar.collapsed .btn-direct-msg { padding: 9px; justify-content: center; }
.sidebar.collapsed .sidebar-footer-links button { justify-content: center; padding: 8px; gap: 0; }
.sidebar.collapsed .sidebar-sync { justify-content: center; }
.sidebar.collapsed #syncLabel { display: none; }

/* APP CONTENT */
.app-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.25s ease;
}
.sidebar.collapsed ~ .app-content { margin-left: var(--sidebar-w-collapsed); }

/* TOP BAR */
.topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.topbar-date {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
}
.topbar-date svg { color: var(--text3); }

.btn-theme-toggle {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 7px 9px;
  cursor: pointer;
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.btn-theme-toggle:hover { background: var(--bg4); color: var(--text); }
/* En modo light: mostrar sol (para cambiar a dark). En modo dark: mostrar luna (para cambiar a light) */
[data-theme="dark"] #iconSun  { display: none; }
[data-theme="dark"] #iconMoon { display: block; }
html:not([data-theme="dark"]) #iconSun  { display: block; }
html:not([data-theme="dark"]) #iconMoon { display: none; }

/* MAIN */
.main { padding: 20px 24px; flex: 1; }

/* ============================
   CARDS
   ============================ */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.overdue-card { border-top: 3px solid var(--red); }
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title svg { color: var(--text3); }
.card-body { padding: 16px 20px; }
.card-body.p0 { padding: 0; }

/* Contenedor del calendario con scroll horizontal en mobile */
#page-mensual .card-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ============================
   STAT CARDS
   ============================ */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
}
.stat-icon.orange { background: rgba(245,158,11,0.12); color: var(--orange); }
.stat-icon.blue   { background: rgba(59,130,246,0.12); color: var(--blue); }
.stat-icon.green  { background: rgba(34,197,94,0.12);  color: var(--green); }
.stat-icon.red    { background: rgba(239,68,68,0.12);  color: var(--red); }
.stat-label { font-size: 11px; color: var(--text3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; line-height: 1; }
.stat-value.resumen-stat-multi { line-height: 1; }
.resumen-totals { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; }
.fecha-desktop { display: inline; }
.fecha-mobile  { display: none; }
.resumen-total-item { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; white-space: nowrap; }
.resumen-total-secondary { font-size: 16px; font-weight: 600; color: var(--text2); letter-spacing: -0.3px; }
.stat-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* ============================
   BADGES
   ============================ */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-green     { background: rgba(34,197,94,0.1);   color: #16A34A; border: 1px solid rgba(34,197,94,0.25); }
.badge-orange    { background: rgba(245,158,11,0.1);  color: #D97706; border: 1px solid rgba(245,158,11,0.25); }
.badge-red       { background: rgba(239,68,68,0.1);   color: #DC2626; border: 1px solid rgba(239,68,68,0.25); }
.badge-gray      { background: var(--bg3);            color: var(--text2); border: 1px solid var(--border); }
.badge-blue      { background: rgba(99,102,241,0.1);  color: var(--primary); border: 1px solid rgba(99,102,241,0.25); }
.badge-urgent    { background: rgba(239,68,68,0.08); color: #DC2626; border: 1px solid rgba(239,68,68,0.2); font-weight: 700; letter-spacing: 0.5px; }
.badge-cancelled { background: var(--bg4); color: var(--text3); border: 1px solid var(--border2); }
.badge-pending   { background: rgba(245,158,11,0.08); color: #B45309; border: 1px solid rgba(245,158,11,0.2); }

/* ============================
   BUTTONS
   ============================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-whatsapp { background: var(--accent); color: #fff; }
.btn-whatsapp:hover { background: var(--accent-dark); }
.btn-danger { background: rgba(239,68,68,0.08); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border2); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-success { background: rgba(34,197,94,0.08); color: #16A34A; border: 1px solid rgba(34,197,94,0.2); }
.btn-success:hover { background: var(--green); color: #fff; border-color: var(--green); }
/* Botones pequeños: 100px mínimo garantiza legibilidad de textos "Cobrar"/"Reenviar" */
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; min-width: 100px; white-space: nowrap; justify-content: center; }
.btn-status-paid,
.btn-status-paid-overdue { min-width: 80px; }
.btn-icon-only { padding: 5px 10px; font-size: 16px; }
.btn-icon {
  padding: 5px 7px;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 6px;
  color: var(--text3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-family: inherit;
}
.btn-icon:hover { background: var(--bg3); color: var(--text2); }

/* ============================
   TABLE
   ============================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  background: var(--bg3);
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }
tr.paid td { opacity: 0.45; }
.clientes-table tr.cancelled { background: rgba(239, 68, 68, 0.1); opacity: 0.65; }
.clientes-table tr.cancelled td { color: #EF4444; text-decoration: line-through; }

/* ============================
   FORM
   ============================ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid > .form-group { min-width: 0; width: 100%; } /* Permite que los form-groups se contraigan correctamente en grid */
/* Grids para detalles del servicio - alineados */
.form-grid-asimetrico-1 { grid-template-columns: 2fr 3fr !important; } /* Fecha (40%) | Duración (60%) */
.form-grid-asimetrico-1 .form-group { min-width: 0 !important; } /* Evitar superposición */
.form-grid-3col { grid-template-columns: 2fr 1.5fr 1.5fr !important; } /* Vence (40%) | Moneda (30%) | Monto (30%) */
.form-grid-3col .form-group { min-width: 0 !important; } /* Evitar superposición */

/* Responsive: mobile - misma estructura para alineación */
@media (max-width: 768px) {
  .form-grid-asimetrico-1 { grid-template-columns: 1fr 1.5fr !important; } /* Fecha (40%) | Duración (60%) */
  .form-grid-3col { grid-template-columns: 1fr 1fr 1fr !important; } /* 3 columnas iguales para que quepan en una fila */
}
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group:last-of-type { margin-bottom: 0; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; }
input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border2);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--bg2);
  color: var(--text);
}
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' 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 10px center;
  padding-right: 32px;
  cursor: pointer;
}
input::placeholder { color: var(--text3); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
textarea { resize: vertical; min-height: 80px; }
.input-readonly { background: var(--bg3); color: var(--accent-dark); font-weight: 600; cursor: default; }
.input-readonly:focus { border-color: var(--border2); box-shadow: none; }

.filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.filter-bar input { flex: 1; min-width: 140px; }
.filter-bar select { min-width: 120px; }

/* Etiquetas de columna: mostrar versión larga en desktop, corta en mobile */
.th-mobile { display: none; }
.th-desktop { display: inline; }

/* Clientes: buscar + estado + servicio en una sola línea en desktop */
.clientes-filter-bar { flex-wrap: wrap; gap: 8px; }
.clientes-filter-bar input         { flex: 1 1 200px; min-width: 0; }
.clientes-filter-bar #filterService { flex: 0 0 180px; min-width: 0; }
.clientes-filter-bar #filterStatus  { flex: 0 0 160px; min-width: 0; }

/* ===== PÁGINA CUENTAS ===== */
.cuenta-platform-group { border-bottom: 1px solid var(--border); }
.cuenta-platform-group:last-child { border-bottom: none; }
.cuenta-platform-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 10px;
}
.cuenta-platform-badge {
  font-size: 11px; font-weight: 700; color: #fff;
  padding: 3px 10px; border-radius: 20px;
}
.cuentas-header-actions { display: flex; gap: 8px; align-items: center; }
.cuentas-menu { position: relative; }
.cuentas-menu-dropdown {
  display: flex;
  flex-direction: row;
  gap: 4px;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  z-index: 100;
  min-width: unset;
  margin-top: 0;
  align-items: center;
}
.cuentas-menu-dropdown.visible {
  display: flex;
}
.cuentas-menu-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  background: var(--bg2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  border-radius: 6px;
}
.cuentas-menu-item:hover {
  background: var(--bg3);
}
.cuentas-menu-item:first-child {
  border-radius: 6px;
}
.cuentas-menu-item:last-child {
  border-radius: 6px;
}
/* Tabla de cuentas: proporciones consistentes */
.cuentas-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.cuentas-table th {
  padding: 8px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
/* Columnas: (1)Email(30%) (2)Perfiles(20%) (3)Próximo Pago(15%) (4)Costo(15%) (5)Acciones(20%) */
.cuentas-table th:nth-child(1) { width: 30%; } /* Email */
.cuentas-table th:nth-child(2) { width: 20%; } /* Perfiles */
.cuentas-table th:nth-child(3) { width: 15%; } /* Próximo Pago */
.cuentas-table th:nth-child(4) { width: 15%; } /* Costo */
.cuentas-table th:nth-child(5) { width: 20%; } /* Acciones */
.cuentas-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cuentas-table tbody tr:last-child td { border-bottom: none; }
.cuentas-table tr:hover td { background: rgba(0,0,0,0.015); }

@media (max-width: 600px) {
  /* Cards de resumen: 2 columnas fijas en móvil */
  #cuentasStats { grid-template-columns: 1fr 1fr !important; }

  /* Header botones: menú en mobile */
  .cuentas-header-actions {
    width: 100%;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    flex-direction: row-reverse;
  }
  .cuentas-header-actions .btn { font-size: 12px; }

  /* Menú dropdown en mobile */
  .cuentas-menu { position: relative; }
  .cuentas-menu-dropdown { display: none; }
  .cuentas-menu-dropdown.visible { display: flex; flex-direction: column; align-items: flex-start; position: absolute; top: 100%; right: 0; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-md); min-width: 160px; margin-top: 4px; }
  .cuentas-menu-dropdown.visible .cuentas-menu-item { border-radius: 0; background: transparent; padding: 10px 14px; gap: 8px; }
  .cuentas-menu-dropdown.visible .cuentas-menu-item:first-child { border-radius: 8px 8px 0 0; }
  .cuentas-menu-dropdown.visible .cuentas-menu-item:last-child { border-radius: 0 0 8px 8px; }
  #btnCuentasMenuToggle {
    padding: 8px 10px;
    font-size: 16px;
    min-width: auto;
    flex-shrink: 0;
  }
  #btnNuevaCuenta, #btnNuevaInvCuenta {
    flex: 0 1 auto;
    justify-content: center;
    padding: 8px 14px;
    white-space: nowrap;
  }
  .inv-btn-label { display: none; }
  #btnOpenImportInvModal, #btnOpenInvSortModal { padding: 8px 10px; min-width: 0; flex-shrink: 0; }

  /* Tabla → cards */
  .cuentas-table thead { display: none; }
  .cuentas-table tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin: 8px 12px;
    padding: 4px 0;
    background: var(--bg2);
  }
  .cuentas-table tbody tr:last-child { border: 1px solid var(--border); }
  .cuentas-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    min-height: 36px;
  }
  .cuentas-table td:last-child {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 10px 12px;
    white-space: normal !important;
    overflow: visible !important;
    min-height: 36px;
    border-bottom: 1px solid var(--border) !important;
  }
  .cuentas-table tbody tr:last-child td:last-child {
    border-bottom: none !important;
  }
  .cuentas-table td::before {
    content: attr(data-label);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text2);
    flex-shrink: 0;
    margin-right: 10px;
  }
}

/* Dots de perfil */
.perfil-dot {
  width: 12px; height: 12px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.perfil-dot.ocupado { background: var(--primary); }
.perfil-dot.libre   { background: var(--border2); }

/* Cards de perfil en modal */
.perfil-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.perfil-card-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}
.perfil-num {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.perfil-nombre { font-size: 13px; font-weight: 600; color: var(--text); }
.perfil-card-body { padding: 12px 14px; }

/* Buscador de cliente en perfil */
.cliente-search-wrap { display: flex; flex-direction: column; gap: 4px; }
.cliente-search-dropdown {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow-md);
  max-height: 180px; overflow-y: auto;
}
.cliente-search-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: pointer; font-size: 13px; color: var(--text);
}
.cliente-search-item:hover { background: var(--bg3); }

/* Cliente ya asignado */
.cliente-asignado-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 6px 10px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px;
}
.cliente-asignado-info { display: flex; align-items: center; gap: 8px; }

/* ===== MODAL V2 (cliente) ===== */
.modal.modal-v2 { max-width: 760px; }
.modal-v2 .form-grid { grid-template-columns: 1fr 1fr; }
.modal-v2 .form-group-vence-row { grid-template-columns: 2fr 1fr 1fr; }

.mv2-section {
  padding: 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mv2-section + .mv2-section { margin-top: 6px; }
.mv2-section { padding: 10px 12px; gap: 6px; }
.mv2-section .form-grid { gap: 4px; }

.mv2-section-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text2);
}

.mv2-streaming-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
}

.mv2-add-btn {
  display: inline-flex; align-items: center; gap: 4px;
  height: 28px; padding: 0 10px;
  background: var(--primary); color: #fff;
  border: none; border-radius: 8px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s;
}
.mv2-add-btn:hover { opacity: 0.85; }

/* Fila Vence+Moneda+Monto: Vence igual a Fecha de inicio (3fr = 60% del ancho) */
.form-group-vence-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 3fr 1fr 1fr; /* Vence: 3/(3+1+1)=60%, Moneda: 20%, Monto: 20% */
  gap: 6px;
}

/* Prefix input (WhatsApp) */
.input-prefix-wrap { display: flex; width: 100%; min-width: 0; } /* 100% width para alinearse con inputs normales */
.input-prefix-editable {
  width: 52px !important; text-align: center; flex-shrink: 0;
  border-right: none !important; border-radius: 8px 0 0 8px !important;
  padding: 0 6px !important; color: var(--text2);
}
.input-with-prefix { flex: 1; min-width: 0; border-radius: 0 8px 8px 0 !important; } /* flex: 1 para ocupar espacio restante */
.input-with-prefix input { width: 100%; } /* Input ocupa 100% del contenedor flex */

/* ===== STREAMING EN MODAL CLIENTE ===== */
.streaming-section {
  margin-top: 4px;
  padding: 12px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.streaming-section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.streaming-section-title {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text2);
}
.streaming-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.streaming-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 8px 5px 6px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 20px; font-size: 12px;
}
.streaming-chip-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.streaming-chip-info { display: flex; flex-direction: column; line-height: 1.2; }
.streaming-chip-plat { font-size: 10px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: 0.3px; }
.streaming-chip-perfil { font-size: 12px; font-weight: 500; color: var(--text); }
.streaming-chip-remove {
  background: none; border: none; cursor: pointer;
  color: var(--text3); font-size: 11px; padding: 0 0 0 2px;
  line-height: 1; opacity: 0.6; transition: opacity 0.15s;
}
.streaming-chip-remove:hover { opacity: 1; color: var(--danger); }

/* ===== IMPORTAR EXCEL ===== */
.import-dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 2px dashed var(--border2); border-radius: 12px;
  padding: 32px 24px; text-align: center;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.import-dropzone:hover, .import-dropzone.drag-over {
  border-color: var(--primary); background: rgba(99,102,241,0.04);
}
.import-row-ok td { color: var(--text); }
.import-row-err td { color: var(--danger); background: rgba(239,68,68,0.04); }
.import-row-err td:first-child::before { content: '⚠ '; }

/* ===== PÁGINA USUARIOS ===== */
#page-usuarios .card-header {
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
}
#page-usuarios .card-header > div:last-child {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.usuarios-table { width: 100%; border-collapse: collapse; }
.usuarios-table th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.usuarios-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.u-col-badge { white-space: nowrap; }
.u-col-member { font-size: 12px; color: var(--text2); white-space: nowrap; }
.usuarios-table tr:last-child td { border-bottom: none; }
.usuarios-table tr:hover td { background: rgba(0,0,0,0.015); }

/* Badges de rol en tabla */
.u-role-badge { display:inline-block; font-size:11px; font-weight:600; padding:2px 8px; border-radius:20px; background:rgba(100,116,139,0.1); color:#64748B; border:1px solid rgba(100,116,139,0.2); }
.u-role-badge.admin { background:rgba(99,102,241,0.1); color:#6366F1; border-color:rgba(99,102,241,0.25); }

/* Acciones compactas */
.u-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  height: 30px;
}
.u-btn {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  height: 30px;
  min-width: 30px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1.5px solid;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 30px;
  box-sizing: border-box;
  flex-shrink: 0;
  vertical-align: middle;
}
.u-btn svg { display:block; flex-shrink:0; }
.u-btn-success { background:#fff; color:#16A34A; border-color:#86EFAC; min-width:90px; }
.u-btn-success:hover { background:#F0FDF4; }
.u-btn-danger  { background:#fff; color:#DC2626; border-color:#FCA5A5; min-width:90px; }
.u-btn-danger:hover  { background:#FEF2F2; }
.u-btn-ghost   { background:#fff; color:var(--text2); border-color:var(--border); padding:0 8px; }
.u-btn-ghost:hover   { background:var(--bg3,#F1F5F9); }
.u-role-select {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  height: 28px;
}

.sidebar-role-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(100,116,139,0.15);
  color: rgba(255,255,255,0.5);
  margin-left: 4px;
  vertical-align: middle;
}
.sidebar-role-badge.admin {
  background: rgba(99,102,241,0.3);
  color: #c7d2fe;
}

/* ===== MODAL CONFIRM (deshacer) ===== */
.confirm-modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px 22px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.confirm-modal-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  background: #FEF3C7;
  color: #D97706;
  border-radius: 50%;
  margin-bottom: 16px;
}
.confirm-modal-icon-success {
  background: rgba(34,197,94,0.12);
  color: #16A34A;
}
[data-theme="dark"] .confirm-modal-icon { background: rgba(245,158,11,0.15); color: #FBBF24; }
[data-theme="dark"] .confirm-modal-icon-success { background: rgba(34,197,94,0.16); color: #4ADE80; }
.confirm-modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.confirm-modal-desc {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.55;
  margin-bottom: 22px;
}
.confirm-modal-desc strong { color: var(--text); font-weight: 700; }
.confirm-modal-actions {
  display: flex;
  gap: 10px;
}
.confirm-btn {
  flex: 1;
  padding: 10px 0;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid;
  transition: background 0.15s, color 0.15s, border-color 0.15s, filter 0.15s;
  font-family: inherit;
}
.confirm-btn-cancel {
  background: var(--bg2);
  color: var(--text2);
  border-color: var(--border2);
}
.confirm-btn-cancel:hover { background: var(--bg3); }
.confirm-btn-danger {
  background: var(--bg2);
  color: #DC2626;
  border-color: #FCA5A5;
}
.confirm-btn-danger:hover { background: #FEF2F2; }
[data-theme="dark"] .confirm-btn-danger { color: #F87171; border-color: rgba(248,113,113,0.4); }
[data-theme="dark"] .confirm-btn-danger:hover { background: rgba(248,113,113,0.12); }
.confirm-btn-success {
  background: #16A34A;
  color: #fff;
  border-color: #16A34A;
}
.confirm-btn-success:hover { filter: brightness(1.08); }
[data-theme="dark"] .confirm-btn-success { background: #22C55E; border-color: #22C55E; }

/* ===== PAGINACIÓN ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  gap: 8px;
}
.pagination-info {
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
}
.pagination-controls {
  display: flex;
  gap: 4px;
  align-items: center;
}
.pg-dots { font-size: 13px; color: var(--text2); padding: 0 2px; line-height: 32px; }
.pg-size-btn {
  font-size: 11px;
  padding: 0 8px;
  white-space: nowrap;
}
.pg-size-dropdown {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 4px;
  min-width: 130px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pg-size-dropdown.hidden { display: none; }
.pg-size-opt {
  width: 100%;
  padding: 6px 10px;
  text-align: left;
  background: none;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.pg-size-opt:hover { background: var(--bg2); }
.pg-size-opt.active { color: var(--primary); font-weight: 600; }
.pg-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}
.pg-btn:hover:not(:disabled) { background: var(--primary-hover); }
.pg-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.pg-btn.pg-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 700;
}

@media (max-width: 768px) {
  .clientes-filter-bar input          { flex: 1 1 0; min-width: 0; }
  .clientes-filter-bar #filterStatus  { flex: 0 0 130px; font-size: 11px; }
  .clientes-filter-bar #filterService { flex: 1 1 100%; }
}

/* Resumen: Buscar arriba, selects abajo */
.resumen-filter-bar { flex-wrap: wrap; }
.resumen-filter-bar input  { flex: 1 1 100%; }
.resumen-filter-bar select { flex: 1 1 0; min-width: 0; }

/* Campos de fecha responsivos */
.date-input-wrap { display: flex; position: relative; width: 100%; }
.date-input-wrap > input { border-radius: 8px 0 0 8px; flex: 1; }
.date-picker-btn {
  padding: 0 12px;
  background: var(--accent);
  border: none;
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  color: #fff;
  display: flex; align-items: center;
  flex-shrink: 0;
}
/* Contenedor del botón calendario: position:relative para que el input[type=date]
   transparente se posicione encima y reciba el tap directo del usuario.
   En iOS Safari, el picker nativo solo se abre con un gesto directo sobre el
   input — llamarlo desde el handler de otro elemento (showPicker en un botón)
   es rechazado. */
.date-picker-btn-wrap {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-self: stretch;
}
.date-picker-btn-wrap .date-picker-btn {
  height: 100%;
  border-radius: 0 8px 8px 0;
}
.date-picker-hidden {
  position: absolute; inset: 0;
  opacity: 0;
  cursor: pointer;
  border-radius: 0;
}

.platform-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 6px; }
.platform-label-selected { color: var(--accent); font-weight: 700; margin-left: 6px; font-size: 12px; }
.plat-check { display: none; }
.plat-label {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border: 1.5px solid var(--border2); border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: 500; transition: all 0.15s; user-select: none;
  background: var(--bg2); color: var(--text2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.plat-label:hover { border-color: var(--accent); color: var(--text); background: var(--bg3); }
.plat-check:checked + .plat-label {
  border-color: var(--accent); background: rgba(37,211,102,0.07); color: var(--accent); font-weight: 600;
}
.plat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ============================
   MODAL
   ============================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,25,40,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%; max-width: 520px;
  max-height: 90vh;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal-body {
  overflow-y: auto;
  flex: 1;
}
.modal-body::-webkit-scrollbar { width: 5px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 10px; }
.modal-body::-webkit-scrollbar-thumb:hover { background: var(--text3); }
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 700; color: var(--text); }
.modal-close {
  background: var(--bg3); border: 1px solid var(--border2); color: var(--text2);
  border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 14px;
  font-family: inherit; transition: all 0.15s;
}
.modal-close:hover { background: var(--bg4); color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ============================
   IMPORT EXCEL
   ============================ */
.import-dropzone {
  border: 2px dashed var(--border2);
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg3);
  display: flex; flex-direction: column; align-items: center;
}
.import-dropzone:hover { border-color: var(--primary); background: rgba(99,102,241,0.04); }
.import-dropzone.drag-over { border-color: var(--primary); background: rgba(99,102,241,0.08); }

/* Paginación */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap;
}
.pagination-info { font-size: 12px; color: var(--text3); }
.pagination-btns { display: flex; gap: 4px; align-items: center; }
.pg-btn {
  min-width: 32px; height: 32px; padding: 0 8px;
  border: 1.5px solid var(--border2); border-radius: 7px;
  background: var(--bg2); color: var(--text2);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; display: flex; align-items: center; justify-content: center;
}
.pg-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: rgba(99,102,241,0.07); }
.pg-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pg-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.pg-ellipsis { font-size: 13px; color: var(--text3); padding: 0 4px; }

/* Resumen mensual — acciones */
.ms-actions { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }

.import-template-hint {
  margin-top: 16px;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text2);
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  line-height: 1.6;
}
.import-template-hint svg { flex-shrink: 0; }
.import-template-hint code {
  background: var(--bg4); color: var(--primary);
  padding: 1px 6px; border-radius: 4px; font-size: 11px;
  white-space: nowrap;
}
.import-template-hint .btn { margin-top: 6px; width: 100%; justify-content: center; }

.import-preview-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.import-preview-errors {
  background: rgba(239,68,68,0.06);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--red);
}
.import-row-error td { background: rgba(239,68,68,0.05); }
.import-status-ok  { color: var(--green); font-size: 14px; }
.import-status-err { color: var(--red);   font-size: 14px; }

/* ============================
   SERVICE ICON
   ============================ */
.service-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 11px; color: #fff;
  flex-shrink: 0;
}

/* ============================
   TODAY (list as table rows)
   ============================ */
.client-name-cell { font-weight: 600; font-size: 13px; color: var(--text); }
.client-sub { font-size: 11px; color: var(--text3); margin-top: 1px; }
.client-cell { display: flex; align-items: center; gap: 10px; }
.atraso-days { font-size: 12px; font-weight: 600; color: var(--red); }
.today-actions { display: flex; gap: 5px; flex-wrap: nowrap; }

/* Hoy tables — columnas alineadas entre las 3 secciones */
.hoy-table { table-layout: fixed; width: 100%; }
.col-hoy-cliente  { width: 28%; }
.col-hoy-servicio { width: 26%; }
.col-hoy-monto    { width: 12%; }
.col-hoy-extra    { width: 14%; }
.col-hoy-accion   { width: 20%; }
.hoy-table td, .hoy-table th { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hoy-table td:first-child    { white-space: normal; }
.hoy-table th:first-child, .hoy-table th:last-child { text-align: center; }

/* Clientes table */
.svc-badge { color: #fff; padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; }
/* Puntos de plataforma: alternativa compacta al badge de Servicio para mobile,
   oculta en desktop porque la columna Servicio ya muestra el nombre completo. */
.client-platforms-mobile { display: none; }
.platform-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.fidelidad-badge { font-size: 11px; font-weight: 600; color: var(--primary); background: rgba(99,102,241,0.1); border: 1px solid rgba(99,102,241,0.2); padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.fidelidad-badge.new { color: #16A34A; background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.25); }
.vence-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.vence-date { font-size: 12px; color: var(--text2); }
.vence-short { display: none; }
.monto-cell { font-weight: 700; font-size: 13px; white-space: nowrap; }
/* Row actions — desktop vs mobile */
.row-actions-wrap { position: relative; }
.row-actions-desktop { display: flex; gap: 4px; align-items: center; }
.row-actions-mobile { display: none; align-items: center; position: relative; }

.action-btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg3);
  cursor: pointer; transition: all 0.15s; color: var(--text2);
}
.action-btn:hover { border-color: var(--border2); }
.action-btn.wa  { color: #25D366; }
.action-btn.wa:hover  { background: rgba(37,211,102,0.1); border-color: #25D366; }
.action-btn.key { color: #f59e0b; }
.action-btn.key:hover { background: rgba(245,158,11,0.1); border-color: #f59e0b; }
.action-btn.edit:hover { background: rgba(99,102,241,0.1); border-color: var(--primary); color: var(--primary); }
.action-btn.del        { color: var(--red); border-color: rgba(239,68,68,0.3); }
.action-btn.del:hover  { background: rgba(239,68,68,0.1);  border-color: var(--red); }

/* Mobile menu button */
.action-btn-menu {
  display: none;
  align-items: center; justify-content: center;
  padding: 6px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg2);
  cursor: pointer; font-size: 18px; color: var(--text2); transition: background 0.15s;
  flex-shrink: 0; font-family: inherit;
}
.action-btn-menu:hover { background: var(--bg3); }

.row-actions-dropdown {
  position: fixed; z-index: 9999;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  min-width: 160px;
  display: none; flex-direction: column;
  overflow: hidden;
}
.row-actions-dropdown.open { display: flex; }
.row-action-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; font-size: 13px; color: var(--text);
  background: transparent; border: none; cursor: pointer;
  transition: background 0.15s; text-align: left; font-weight: 500;
  white-space: nowrap; width: 100%; font-family: inherit;
}
.row-action-item:hover { background: var(--bg3); }
.row-action-item:first-child { border-radius: 8px 8px 0 0; }
.row-action-item:last-child { border-radius: 0 0 8px 8px; }
.row-action-item svg { flex-shrink: 0; }
.row-action-item.row-action-delete { color: var(--red); }
.row-action-item.row-action-delete:hover { background: rgba(239,68,68,0.08); }

/* Mobile responsive */
@media (max-width: 768px) {
  .row-actions-desktop { display: none; }
  .row-actions-mobile { display: flex; }
  .action-btn-menu { display: flex; }
}

/* ============================
   CALENDAR
   ============================ */
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7,1fr);
  gap: 6px; margin-bottom: 6px;
}
.cal-weekdays div {
  text-align: center; font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--text3); padding: 6px 4px;
  border-bottom: 2px solid var(--border);
}
.month-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 6px; }

.day-cell {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 6px 6px;
  min-height: 80px;
  transition: box-shadow 0.15s, border-color 0.15s;
  cursor: default;
}
.day-cell:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(99,102,241,0.1); }

.day-cell.has-data {
  background: var(--bg3);
  border-color: rgba(99,102,241,0.25);
}
.day-cell.today-cell {
  border: 2px solid var(--primary);
  background: rgba(99,102,241,0.06);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.day-num {
  font-size: 11px; font-weight: 700; color: var(--text2);
  margin-bottom: 5px; line-height: 1;
  display: flex; align-items: center; justify-content: space-between;
}
.today-cell .day-num { color: var(--primary); }

/* Dot indicador cuando hay clientes */
.day-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--primary); flex-shrink: 0;
}

.day-item {
  font-size: 9.5px; font-weight: 600;
  border-radius: 4px; padding: 2px 5px; margin-bottom: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: block;
}
.day-item.paid-item {
  background: rgba(34,197,94,0.12); color: #16A34A;
  border-left: 3px solid #16A34A;
}
.day-item.sent-item {
  background: rgba(59,130,246,0.12); color: #2563EB;
  border-left: 3px solid #2563EB;
}
.day-item.cancelled-item {
  background: rgba(239,68,68,0.1); color: #DC2626;
  border-left: 3px solid #DC2626;
  text-decoration: line-through; opacity: 0.75;
}
.day-item.unpaid-item {
  background: rgba(245,158,11,0.12); color: #D97706;
  border-left: 3px solid #F59E0B;
}
.day-more {
  font-size: 9px; color: var(--text3); font-weight: 600;
  margin-top: 1px; text-align: right;
}

/* Leyenda del calendario */
.cal-legend {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border);
}
.cal-legend-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text2); font-weight: 500;
}
.cal-legend-dot {
  width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0;
}

/* ============================
   MESSAGE PREVIEW
   ============================ */
.msg-preview {
  background: #DCFCE7;
  border: 1px solid rgba(37,211,102,0.2);
  border-radius: 12px;
  border-top-right-radius: 2px;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.6;
  color: #1A3A2A;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-bubble-wrap { background: #F0FDF4; border: 1px solid rgba(34,197,94,0.15); padding: 14px; border-radius: 10px; }

/* ============================
   MESSAGES MODULE — TABS & EDITOR
   ============================ */
.msg-card { overflow: hidden; }

/* Tab bar */
.msg-tabs {
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
  scrollbar-width: none;
}
.msg-tabs::-webkit-scrollbar { display: none; }

.msg-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, background .15s;
  margin-bottom: -1px;
}
.msg-tab:hover { color: var(--text); background: var(--bg4); }
.msg-tab.active { color: var(--text); font-weight: 600; }
.msg-tab[data-tab="cobro"].active       { border-bottom-color: #25D366; color: #1DAA52; }
.msg-tab[data-tab="recordatorio"].active { border-bottom-color: #EF4444; color: #DC2626; }
.msg-tab[data-tab="renovacion"].active  { border-bottom-color: #3B82F6; color: #1D4ED8; }
.msg-tab[data-tab="tv"].active          { border-bottom-color: #8B5CF6; color: #6D28D9; }
[data-theme="dark"] .msg-tab[data-tab="cobro"].active       { color: #25D366; }
[data-theme="dark"] .msg-tab[data-tab="recordatorio"].active { color: #F87171; }
[data-theme="dark"] .msg-tab[data-tab="renovacion"].active  { color: #60A5FA; }
[data-theme="dark"] .msg-tab[data-tab="tv"].active          { color: #A78BFA; }

.msg-tab-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* Panels */
.msg-panel { display: none; }
.msg-panel.active { display: block; }

/* Variable chips */
.msg-vars {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-bottom: 14px;
}
.msg-vars-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .05em;
  flex-shrink: 0;
}
.var-chip {
  padding: 3px 9px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 20px;
  font-size: 11.5px;
  font-family: 'Cascadia Code', 'Consolas', monospace;
  color: var(--accent-dark);
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .1s;
  line-height: 1.4;
}
.var-chip:hover {
  background: #DCFCE7;
  border-color: #25D366;
  transform: translateY(-1px);
}
[data-theme="dark"] .var-chip:hover { background: #0D2818; border-color: #25D366; }

/* Side-by-side editor */
.msg-editor-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}
.msg-editor-left {
  display: flex;
  flex-direction: column;
}
.msg-editor-left textarea {
  width: 100%;
  box-sizing: border-box;
  resize: none;
  flex: 1;
  min-height: 160px;
}
.msg-editor-right {
  display: flex;
  flex-direction: column;
}
.msg-editor-right .msg-bubble-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.msg-editor-right .msg-preview {
  flex: 1;
}
.msg-preview-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}

/* Panel footer */
.msg-panel-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg3);
}
.msg-panel-hint {
  font-size: 11px;
  color: var(--text3);
  margin-right: auto;
}

/* Buscador de cliente (dentro del modal Probar) */
.client-search-box {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  background: var(--bg3);
  border: 1.5px solid var(--border2);
  border-radius: 8px;
  cursor: text;
  transition: border-color .15s;
}
.client-search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37,211,102,.12);
}
.client-search-box svg { color: var(--text3); flex-shrink: 0; }
.client-search-box input {
  border: none;
  background: none;
  outline: none;
  font-size: 13px;
  color: var(--text);
  width: 100%;
  min-width: 0;
}
.client-search-box input::placeholder { color: var(--text3); }

/* Lista de clientes en el modal Probar */
.test-client-list {
  margin-top: 8px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* Cliente seleccionado en el modal Probar */
.test-client-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg3);
  border: 1.5px solid var(--accent);
  border-radius: 10px;
}
.test-client-clear {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: var(--bg4);
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.test-client-clear:hover { background: var(--red); color: #fff; }
.client-search-item {
  padding: 10px 12px;
  cursor: pointer;
  transition: background .1s;
  border-bottom: 1px solid var(--border);
}
.client-search-item:last-child { border-bottom: none; }
.client-search-item:hover, .client-search-item.csi-active { background: var(--bg3); }
.csi-name { font-size: 13px; font-weight: 500; color: var(--text); }
.csi-svc  { font-size: 11px; color: var(--text3); margin-top: 1px; }
.client-search-empty { padding: 18px 12px; text-align: center; font-size: 13px; color: var(--text3); }

@media (max-width: 620px) {
  .msg-editor-layout { grid-template-columns: 1fr; }

  /* Tabs en grid 2x2: las 4 visibles sin scroll horizontal */
  .msg-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow-x: visible;
  }
  .msg-tab {
    justify-content: center;
    padding: 10px 8px;
    font-size: 12px;
    gap: 5px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
  .msg-tab:nth-child(2n) { border-right: none; }
  .msg-tab:nth-child(n+3) { border-bottom: none; }
  /* La pestaña activa conserva su indicador de color (estilo solid + 2px) */
  .msg-tab.active { border-bottom-style: solid; border-bottom-width: 2px; padding-bottom: 9px; }
}

/* ============================
   DOWNLOAD TEMPLATE BUTTON
   ============================ */
.btn-download-template {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 10px 16px; border-radius: 8px;
  background: rgba(34,197,94,0.08);
  border: 1.5px solid rgba(34,197,94,0.3);
  color: #16A34A; font-weight: 600; font-size: 13px;
  transition: background 0.15s, border-color 0.15s;
}
.btn-download-template:hover { background: rgba(34,197,94,0.15); border-color: #16A34A; }
[data-theme="dark"] .btn-download-template { color: #4ADE80; border-color: rgba(74,222,128,0.3); background: rgba(74,222,128,0.07); }
[data-theme="dark"] .btn-download-template:hover { background: rgba(74,222,128,0.14); border-color: #4ADE80; }

/* ============================
   IMPORT PROGRESS BAR
   ============================ */
.import-progress-wrap { margin-top: 14px; }
.import-progress-track {
  height: 6px; background: var(--bg3); border-radius: 999px; overflow: hidden;
}
.import-progress-fill {
  height: 100%; background: var(--primary); border-radius: 999px;
  transition: width 0.3s ease; width: 0%;
}
.import-progress-label {
  font-size: 12px; color: var(--text2); margin-top: 6px; text-align: center;
}

/* ============================
   MESSAGE PLATFORM DROPDOWN
   ============================ */
.msg-plat-dropdown-wrap { position: relative; }

.msg-plat-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 500; color: var(--text2);
}
.msg-plat-count {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff;
  border-radius: 10px; font-size: 10px; font-weight: 700;
  padding: 0 6px; min-width: 18px; height: 16px;
}

.msg-plat-dropdown {
  position: absolute; bottom: calc(100% + 8px); left: 0;
  background: var(--bg); border: 1px solid var(--border2);
  border-radius: 10px; box-shadow: 0 4px 24px rgba(0,0,0,0.13);
  padding: 8px; z-index: 200;
  display: flex; flex-direction: column; gap: 3px;
  min-width: 180px;
}
.msg-plat-empty { color: var(--text3); font-size: 11px; font-style: italic; padding: 4px 6px; }

.msg-plat-check-item {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 10px; border-radius: 7px;
  border: 1px solid transparent; font-size: 12px; font-weight: 500;
  cursor: pointer; transition: background 0.1s, border-color 0.1s, color 0.1s;
  user-select: none; color: var(--text2);
}
.msg-plat-check-item:hover { background: var(--bg3); color: var(--text); }
.msg-plat-check-item:has(input:checked) {
  background: rgba(139,92,246,0.07); color: #6D28D9;
  border-color: rgba(139,92,246,0.25);
}
[data-theme="dark"] .msg-plat-check-item:has(input:checked) { color: #A78BFA; background: rgba(139,92,246,0.12); }
.msg-plat-check-item input[type="checkbox"] {
  width: 13px; height: 13px; margin: 0; flex-shrink: 0;
  cursor: pointer; accent-color: #8B5CF6;
}
.msg-plat-check-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ============================
   CONFIG
   ============================ */
.config-section { margin-bottom: 24px; }
.config-section h3 {
  font-size: 11px; font-weight: 700; color: var(--text3);
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: 0.8px;
}
.sql-box {
  background: #0F1923; color: #7DD3FC;
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 11px; padding: 14px; border-radius: 8px;
  overflow-x: auto; white-space: pre; line-height: 1.7;
  border: 1px solid var(--border);
}
.copy-btn {
  font-size: 11px; font-family: inherit;
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text2); border-radius: 6px;
  padding: 5px 12px; cursor: pointer; margin-top: 8px;
  transition: all 0.15s; display: inline-flex; align-items: center; gap: 5px;
}
.copy-btn:hover { background: var(--bg4); color: var(--text); }

/* ============================
   QUEUE MODAL
   ============================ */
.queue-progress-wrap {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 14px;
}
.queue-progress-track {
  background: var(--border); border-radius: 20px; height: 6px; flex: 1;
}
.queue-progress-bar {
  background: var(--accent); height: 6px; border-radius: 20px; transition: width 0.3s;
}
.queue-card {
  border: 1.5px solid var(--border); border-radius: 12px;
  padding: 18px; margin-bottom: 16px;
}
.queue-card-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
}
.queue-name { font-size: 16px; font-weight: 700; }
.queue-amount { margin-left: auto; font-size: 17px; font-weight: 700; color: var(--accent); }
.queue-done { text-align: center; padding: 30px 0; }
.queue-done-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }

/* ============================
   MISC
   ============================ */
.hint-text { font-size: 12px; color: var(--text3); }
.hint-text code {
  background: var(--bg3); padding: 1px 6px; border-radius: 4px;
  font-family: monospace; font-size: 12px; color: var(--accent-dark);
}
.section-label { font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 10px; }

.empty { text-align: center; padding: 40px 20px; color: var(--text3); }
.empty p { font-size: 14px; margin-bottom: 6px; color: var(--text2); }
.empty small { font-size: 12px; }

.toast {
  position: fixed; bottom: 24px; right: 24px; left: 24px;
  max-width: 480px; margin: 0 auto;
  background: var(--text); color: #fff;
  padding: 12px 20px; border-radius: 10px;
  font-size: 13px; z-index: 9999;
  animation: slideUp 0.3s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  text-align: center;
}
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

.hidden { display: none !important; }
.page { display: none; }
.page.active { display: block; }

.sync-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text3); display: inline-block; flex-shrink: 0; }
.sync-dot.green { background: var(--green); box-shadow: 0 0 5px var(--green); }
.sync-dot.red { background: var(--red); }
.sync-dot.yellow { background: var(--orange); animation: pulse 1s infinite; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 180px; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 220px; }

  /* Evitar scroll horizontal en toda la página; solo .resumen-table-wrap scrollea internamente */
  html, body { max-width: 100vw; overflow-x: hidden; }

  /* Inputs con prefijo alineados correctamente en mobile */
  .input-prefix-wrap { width: 100% !important; }
  .input-with-prefix { flex: 1; width: auto; min-width: 0; }

  /* Sidebar: overlay desde la izquierda */
  .sidebar {
    left: calc(-1 * var(--sidebar-w));
    width: var(--sidebar-w) !important; /* no colapsar en mobile */
    box-shadow: none;
    transition: left 0.25s ease;
  }
  .sidebar.mobile-open {
    left: 0;
    box-shadow: 4px 0 24px rgba(0,0,0,0.25);
  }
  /* Nunca mostrar en collapsed en mobile */
  .sidebar.collapsed { width: var(--sidebar-w) !important; }
  .sidebar.collapsed .sidebar-logo-text,
  .sidebar.collapsed .nav-label { display: flex; }
  .sidebar.collapsed .sidebar-nav button { justify-content: flex-start; padding: 10px 16px; gap: 10px; }

  .sidebar-overlay.visible { display: block; }

  /* El contenido ocupa todo el ancho sin desbordar */
  .app-content { margin-left: 0 !important; width: 100%; max-width: 100vw; overflow-x: hidden; }

  /* Topbar */
  .topbar-hamburger { display: flex !important; }
  .topbar { padding: 10px 16px; gap: 8px; }
  .topbar-date { font-size: 12px; }
  .btn-agregar-text { display: none; }
  .btn-agregar { padding: 8px 10px; }

  /* Main content */
  .main { padding: 14px 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 22px; }
  .resumen-totals { flex-direction: column; gap: 4px; }
  .resumen-total-item { font-size: 22px; }
  .resumen-total-secondary { font-size: 14px; }

  /* Tabla Resumen responsive */
  .resumen-table { table-layout: fixed; width: 100%; font-size: 11px; border-collapse: collapse; }
  .resumen-table th, .resumen-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 7px 6px; }
  .fecha-desktop    { display: none; }
  .fecha-mobile     { display: inline; }
  .rcol-fecha       { width: 13%; }
  .rcol-cliente     { width: 22%; }
  .rcol-plat        { width: 26%; }
  .rcol-pago        { width: 18%; }
  .rcol-estado      { width: 21%; }

  /* Cards */
  .card-header { flex-wrap: wrap; gap: 8px; }
  .card-header h3 { font-size: 13px; }

  /* Filtros resumen: Buscar (fila 1), Mes+Año (fila 2), Estado (fila 3) */
  .resumen-filter-bar { gap: 6px; }
  .resumen-filter-bar #resumenMonth  { flex: 1 1 0; min-width: 0; }
  .resumen-filter-bar #resumenYear   { flex: 1 1 0; min-width: 0; }
  .resumen-filter-bar #resumenStatus { flex: 1 1 100%; min-width: 0; }

  /* Tablas: sin scroll horizontal */
  .table-wrap { overflow-x: visible; }
  /* Solo la tabla de resumen tiene scroll horizontal contenido en su wrapper */
  .resumen-table-wrap { overflow-x: auto; width: 100%; }
  table { width: 100%; font-size: 12px; table-layout: auto; }
  th, td { padding: 8px 6px; white-space: normal; word-break: break-word; }

  /* Ocultar columna Servicio */
  .col-servicio { display: none; }

  /* Tabla Hoy: redistribuir anchos sin columna Servicio (Cliente | Monto | Estado/Atraso | Acción) */
  .hoy-table { table-layout: fixed; }
  .col-hoy-cliente  { width: 33%; }
  .col-hoy-servicio { width: 0;    }   /* oculta, sin espacio */
  .col-hoy-monto    { width: 20%; white-space: nowrap; }
  .col-hoy-extra    { width: 21%; }
  .col-hoy-accion   { width: 26%; }
  .hoy-table th:last-child { text-align: center; }
  .hoy-table td:nth-child(1) { padding-left: 14px; }
  .hoy-table td:nth-child(1) .client-name-cell { white-space: normal; overflow: visible; text-overflow: clip; }
  /* Cliente | Servicio | Monto | Atraso/Estado | Acción (Hoy y Sin cobrar) */
  .hoy-table:not(#upcomingTable) th:nth-child(3) { text-align: right; padding-right: 16px; }
  .hoy-table:not(#upcomingTable) th:nth-child(4) { text-align: center; }
  .hoy-table:not(#upcomingTable) td:nth-child(3) { text-align: right; padding-right: 16px; }
  .hoy-table:not(#upcomingTable) td:nth-child(4) { text-align: center; overflow: visible; }
  /* Cliente | Servicio | Fecha Venc. | Monto | Estado (Próximos) */
  #upcomingTable th:nth-child(4) { text-align: right; padding-right: 16px; }
  #upcomingTable td:nth-child(4) { text-align: right; padding-right: 16px; }

  /* Filtros resumen mensual — buscar arriba full; servicios y estados en la misma fila */
  #searchMonthSummary { flex: 1 1 100% !important; min-width: 0 !important; max-width: none !important; width: auto !important; box-sizing: border-box; }
  #filterMonthSvc     { flex: 1 1 0 !important; min-width: 0 !important; max-width: none !important; }
  #filterMonthEstado  { flex: 1 1 0 !important; min-width: 0 !important; max-width: none !important; }

  /* Tabla Resumen Mensual responsive */
  .month-summary-table { table-layout: fixed; width: 100%; font-size: 11px; border-collapse: collapse; }
  .month-summary-table th, .month-summary-table td {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    padding: 6px 4px; text-align: center;
  }
  .month-summary-table td:nth-child(3) { text-align: left; } /* Cliente alineado izq */
  .ms-col-estado { display: none !important; }
  /* Anchos visibles: CB | Día | Cliente | Servicio | Monto | Acción */
  .month-summary-table th:nth-child(1), .month-summary-table td:nth-child(1) { width: 7%; padding: 4px 2px; }
  .month-summary-table th:nth-child(2), .month-summary-table td:nth-child(2) { width: 13%; }
  .month-summary-table th:nth-child(3), .month-summary-table td:nth-child(3) { width: 18%; }
  .month-summary-table th:nth-child(4), .month-summary-table td:nth-child(4) { width: 17%; }
  .month-summary-table th:nth-child(5), .month-summary-table td:nth-child(5) { width: 18%; }
  .month-summary-table th:last-child,   .month-summary-table td:last-child  { width: 27%; }
  /* Ocultar texto de botones de acción en móvil */
  .ms-btn-text { display: none; }
  .ms-actions { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; align-items: center; }
  .ms-btn { padding: 5px 6px !important; min-width: 0 !important; }

  /* Calendario: celdas muy compactas para entrar en pantalla mobile */
  .month-grid { gap: 2px; width: 100%; min-width: 0; }
  .day-cell { min-height: 40px; padding: 2px; border-radius: 4px; font-size: 9px; }
  .day-num { font-size: 7px; margin-bottom: 1px; font-weight: 600; }
  .day-dot { width: 2px; height: 2px; }
  .day-item { font-size: 6px; padding: 0px 2px; margin-bottom: 1px; border-left-width: 1px; line-height: 1; }
  .day-more { font-size: 6px; }
  .cal-legend { gap: 4px; margin-top: 8px; flex-wrap: wrap; }
  .cal-legend-item { font-size: 9px; }
  .cal-weekdays div { padding: 3px 2px; font-size: 9px; }

  /* Tabla Clientes responsive */
  .cl-col-svc, .cl-col-estado, .cl-col-fidelidad { display: none; }
  .client-platforms-mobile { display: flex; align-items: center; gap: 4px; margin-top: 3px; flex-wrap: wrap; }
  .th-mobile { display: inline; }
  .th-desktop { display: none; }
  .clientes-table { table-layout: fixed; width: 100%; }
  .clientes-table th, .clientes-table td {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  /* Columna Cliente: header no wrappea, celdas sí pueden */
  .clientes-table th:nth-child(1) { width: 38%; white-space: nowrap; text-align: center; }
  .clientes-table td:nth-child(1) { width: 38%; white-space: normal; }
  .client-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
  /* Vence */
  .clientes-table th:nth-child(3),
  .clientes-table td:nth-child(3) { width: 20%; font-size: 11px; }
  /* Monto */
  .clientes-table th:nth-child(4),
  .clientes-table td:nth-child(4) { width: 20%; }
  .monto-cell { font-size: 12px; }
  /* Acciones */
  .clientes-table th:last-child,
  .clientes-table td:last-child { width: 22%; text-align: center; }
  .row-actions-mobile { justify-content: center; }
  .clientes-table .action-btn { width: 22px; height: 22px; border-radius: 5px; }
  .clientes-table .row-actions { gap: 2px; }
  /* Vence: mostrar solo DD/MM en mobile */
  .vence-full { display: none; }
  .vence-short { display: inline; }

  /* Monto sin wrap */
  .col-monto-hoy { white-space: nowrap; }
  /* Acción centrada */
  .today-actions { justify-content: center; }

  /* Action buttons: solo íconos en mobile */
  .today-actions { flex-direction: row; flex-wrap: nowrap; gap: 4px; align-items: center; }
  /* Botones pequeños (32x32px) para mobile */
  .today-actions .btn-sm { padding: 6px; font-size: 14px; min-width: auto; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
  .today-actions .btn-status-paid,
  .today-actions .btn-status-paid-overdue { width: 32px; height: 32px; min-width: auto; }
  .today-actions .btn-icon { width: 28px; height: 28px; }
  .today-actions .btn-text { display: none; }

  /* Detalles del servicio: inputs responsive - mismo tamaño para "Fecha de inicio" y "Vence el" */
  .date-input-wrap { width: 100%; max-width: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-group-vence-row { grid-template-columns: 1fr; grid-column: 1 / -1; }
  .form-group-vence-row .form-group { width: 100%; margin-bottom: 10px; }

  /* Botones de acciones: tamaño reducido para mobile */
  .btn-sm { min-width: 70px; padding: 5px 8px; }
  .btn-status-paid,
  .btn-status-paid-overdue { min-width: 60px; }

  /* Ocultar texto de botones de acción, dejar solo íconos */
  .btn-wa-text, .btn-cobrar-text { display: none; }

  /* Nombre cliente más compacto */
  .client-name-cell { font-size: 12px; }
  .client-sub { font-size: 10px; }
  .service-icon { width: 28px; height: 28px; font-size: 9px; flex-shrink: 0; }

  .modal {
    border-radius: 0;
    max-height: 100dvh;
    max-width: 100%;
    width: 100%;
  }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-body { padding: 12px; }
  .modal-header { padding: 10px 12px; }
  .modal-footer { padding: 10px 12px; }

  /* Asignar cliente a un perfil de inventario: centrado en vez de bottom-sheet,
     es un modal chico (un solo input) y se ve mejor en el centro. */
  #invSlotModal { align-items: center; padding: 20px; }
  #invSlotModal .modal { border-radius: 14px; max-height: 90vh; max-width: 360px; width: calc(100% - 40px); }

  /* Formulario en modal mobile */
  .form-group { margin-bottom: 10px; gap: 3px; }
  input, select, textarea {
    padding: 8px 10px !important;
    font-size: 12px !important;
  }
  label { font-size: 10px; }

  /* Grid de formulario en mobile: 2 columnas */
  .form-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  /* Plataforma ocupa 2 columnas */
  .form-grid > .form-group.full:first-of-type {
    grid-column: 1 / -1;
  }
  /* Perfiles y Fecha de pago: lado a lado */
  .form-grid > .form-group[data-grid-field="perfiles"] { grid-column: 1; grid-row: 3; }
  .form-grid > .form-group[data-grid-field="fecha"] { grid-column: 2; grid-row: 3; }

  /* Moneda (col1) y Costo (col2): lado a lado en fila 4 */
  .form-grid > .form-group[data-grid-field="moneda"] { grid-column: 1; grid-row: 4; }
  .form-grid > .form-group[data-grid-field="costo"] { grid-column: 2; grid-row: 4; }

  /* Notas ocupa 2 columnas */
  .form-grid > .form-group.full:last-of-type {
    grid-column: 1 / -1;
  }

  /* Sections en modal mobile */
  .mv2-section { padding: 8px 10px; gap: 8px; }
  .mv2-section .form-grid { gap: 2px; }

  /* ── Header Usuarios botones ── */
  #page-usuarios .card-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  #page-usuarios .card-header > div:last-child { width: 100%; display: flex; gap: 6px; flex-wrap: wrap; }
  #page-usuarios .card-header .btn { flex: 1; justify-content: center; font-size: 12px; min-width: 0; }

  /* ── Tabla Usuarios → cards en mobile ── */
  .usuarios-table thead { display: none; }
  .usuarios-table,
  .usuarios-table tbody { display: block; width: 100%; }

  .usuarios-table tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "user    badge"
      "member  member"
      "reg     actions";
    column-gap: 12px;
    row-gap: 6px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
  }
  .usuarios-table tr:last-child { border-bottom: none; }

  .usuarios-table td {
    border: none;
    padding: 0;
    font-size: 13px;
    min-width: 0;
  }

  /* Col 1: Usuario — limitar email para que no desborde */
  .usuarios-table td:nth-child(1) {
    grid-area: user;
    min-width: 0;
  }
  .usuarios-table td:nth-child(1) > div { min-width: 0; }
  .usuarios-table td:nth-child(1) > div > div:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Col 2: Badge estado */
  .usuarios-table td:nth-child(2) {
    grid-area: badge;
    align-self: center;
    justify-self: end;
  }

  /* Col 3: Fechas membresía */
  .usuarios-table td:nth-child(3) {
    grid-area: member;
    font-size: 11px;
    color: var(--text2);
  }

  /* Col 4: Registrado */
  .usuarios-table td:nth-child(4) {
    grid-area: reg;
    font-size: 11px;
    color: var(--text2);
  }
  .usuarios-table td:nth-child(4)::before {
    content: "Registro: ";
    font-weight: 600;
  }

  /* Col 5: Acciones */
  .usuarios-table td:nth-child(5) {
    grid-area: actions;
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }
  .u-actions { flex-wrap: nowrap; gap: 6px; height: auto; }
}

@media (min-width: 481px) and (max-width: 1024px) {
  /* Tablet pequeña (481-768px) y mediana (769-1024px): mostrar mejor Monto y botones como íconos */
  .col-hoy-cliente  { width: 38%; }
  .col-hoy-monto    { width: 20%; }
  .col-hoy-extra    { width: 18%; }
  .col-hoy-accion   { width: 24%; text-align: right; }

  /* Detalles del servicio: alinear "Vence el" con "Fecha de inicio" */
  .form-group-vence-row { grid-template-columns: 2fr 1fr 1fr; }
  .date-input-wrap { width: 100%; }

  /* Botones solo íconos en tablet */
  .today-actions { gap: 6px; flex-wrap: nowrap; }
  .today-actions .btn-sm { width: 36px; height: 36px; min-width: auto; padding: 6px; display: flex; align-items: center; justify-content: center; }
  .today-actions .btn-status-paid,
  .today-actions .btn-status-paid-overdue { width: 36px; height: 36px; min-width: auto; }
  .today-actions .btn-icon { width: 36px; height: 36px; padding: 6px; display: flex; align-items: center; justify-content: center; }
  .today-actions .btn-text { display: none; }
}

/* ── MOBILE PEQUEÑO (≤600px) ── Botones en fila ajustados */
@media (max-width: 600px) {
  .u-actions {
    display: flex !important;
    flex-direction: row !important;
    gap: 6px !important;
    height: 32px !important;
    width: auto !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
  }
  .u-btn {
    height: 32px !important;
    min-width: auto !important;
    padding: 4px 8px !important;
    font-size: 12px !important;
    line-height: 1.4 !important;
    white-space: nowrap !important;
    border-radius: 6px !important;
  }
  .u-btn-success {
    flex: 0 1 auto !important;
    min-width: auto !important;
    font-size: 12px !important;
    padding: 6px 12px !important;
  }
  .u-btn-ghost {
    flex: 0 0 auto !important;
    width: 32px !important;
    height: 32px !important;
    padding: 4px !important;
    font-size: 14px !important;
  }
}

/* Desktop: mostrar menú expandido */
@media (min-width: 601px) {
  #btnCuentasMenuToggle {
    display: none;
  }
  .cuentas-menu-dropdown {
    display: flex !important;
  }
}

/* Estilos para botones de sort modal */
/* Nota: En touch, :hover se activa al presionar. :active proporciona feedback visual. */
.sort-btn-up:hover,
.sort-btn-down:hover {
  background: var(--accent-dark) !important;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3) !important;
  transform: translateY(-2px);
}

.sort-btn-up:active,
.sort-btn-down:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(37, 211, 102, 0.2) !important;
}

/* ============================
   INVENTARIO
   ============================ */
.inv-platform-filter { display: flex; align-items: center; }
.inv-plat-select { width: auto; max-width: 200px; font-weight: 600; }
.inv-plat-select:hover, .inv-plat-select:focus { border-color: var(--primary); }
.inv-search-wrap {
  position: relative; flex: 1; min-width: 160px; max-width: 280px;
}
.inv-search-wrap input { width: 100%; box-sizing: border-box; }
.inv-search-dropdown {
  position: fixed; z-index: 1100;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18); max-height: 240px; overflow-y: auto;
}
.inv-search-dropdown.hidden { display: none; }
.inv-search-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; cursor: pointer; transition: background 0.1s;
}
.inv-search-item:hover, .inv-search-item.active { background: var(--bg2); }
.inv-search-item:not(:last-child) { border-bottom: 1px solid var(--border); }
.inv-search-item-name { font-size: 13px; font-weight: 600; color: var(--text); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inv-search-item-platform {
  font-size: 11px; font-weight: 600; padding: 2px 7px;
  border-radius: 20px; border: 1.5px solid; flex-shrink: 0;
}
.inv-search-empty { padding: 12px; font-size: 13px; color: var(--text2); text-align: center; }

.inv-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 24px; }

.inv-platform-group { display: flex; flex-direction: column; gap: 12px; }
.inv-platform-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: var(--text); padding-top: 8px;
}
.inv-platform-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.inv-platform-link { text-decoration: none; transition: opacity 0.15s; }
.inv-platform-link:hover { text-decoration: underline; opacity: 0.85; }
.inv-cost-badge {
  font-size: 11px; font-weight: 600; color: #b45309;
  background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.25);
  padding: 1px 7px; border-radius: 20px; white-space: nowrap;
}

.inv-cuentas-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px;
}

/* Skeleton loading: siluetas animadas mientras carga la data real, en vez de
   un simple texto "Cargando..." (Inventario, Cuentas, Usuarios). */
@keyframes skel-shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.skel {
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg4) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
  border-radius: 6px;
}
.skel-circle { border-radius: 50%; flex-shrink: 0; }
.skel-card {
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg2);
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.skel-card-header { display: flex; align-items: center; gap: 10px; }

.inv-cuenta-card {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg2); overflow: hidden;
}
.inv-cuenta-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; gap: 8px; border-bottom: 1px solid var(--border);
}
.inv-cuenta-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.inv-cuenta-email {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.inv-cuenta-meta { font-size: 11px; color: var(--text2); display: flex; gap: 8px; flex-wrap: wrap; }
.inv-cuenta-actions { display: flex; gap: 4px; flex-shrink: 0; }
.inv-renewal-slot {
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.inv-renewal-slot:hover { background: var(--bg3); }
.inv-renewal-slot.active { background: var(--bg3); border-color: var(--primary); }

.inv-pw-row {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text2); margin: 1px 0;
}
.inv-pw-value { font-family: monospace; letter-spacing: 1px; min-width: 70px; }
.inv-pw-btn {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border: none; border-radius: 4px;
  background: transparent; color: var(--text3); cursor: pointer;
  transition: background 0.15s, color 0.15s; flex-shrink: 0;
}
.inv-pw-btn:hover { background: var(--bg3); color: var(--text); }

.inv-slots-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px; padding: 12px 14px;
}
.inv-slot {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px; border-radius: 7px; border: 1.5px dashed var(--border2);
  cursor: pointer; transition: all 0.15s; min-height: 36px;
  font-size: 12px; color: var(--text2);
}
.inv-slot:hover { border-color: var(--primary); color: var(--primary); background: rgba(99,102,241,0.05); }
.inv-slot.occupied {
  border-style: solid; border-color: var(--border);
  background: var(--bg); color: var(--text); font-weight: 500;
}
.inv-slot.occupied:hover { border-color: var(--primary); background: rgba(99,102,241,0.05); }
.inv-slot-num {
  font-size: 10px; font-weight: 700; color: var(--text3);
  background: var(--bg3); border-radius: 4px; padding: 1px 5px; flex-shrink: 0;
}
.inv-slot-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.inv-slots-bar {
  font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 10px;
}
.inv-slots-bar.full  { background: rgba(239,68,68,0.1);  color: var(--red); }
.inv-slots-bar.avail { background: rgba(34,197,94,0.1);  color: #16A34A; }

@media (max-width: 600px) {
  .inv-cuentas-grid { grid-template-columns: 1fr; }
  .inv-slots-grid   { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}

/* ============================
   SPLASH SCREEN
   ============================ */
#splash {
  position: fixed; inset: 0; z-index: 10000;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 24px;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}
#splash.splash-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.splash-logo {
  width: 64px; height: 64px; border-radius: 18px;
  background: rgba(99,102,241,0.15);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 1px rgba(99,102,241,0.25);
}
.splash-logo img { width: 36px; height: 36px; }
.splash-title {
  font-size: 18px; font-weight: 700; color: #C8D8E8; letter-spacing: -0.3px;
}
.splash-dots {
  display: flex; gap: 8px; align-items: center;
}
.splash-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(99,102,241,0.5);
  animation: splash-bounce 1.2s ease-in-out infinite;
}
.splash-dots span:nth-child(2) { animation-delay: 0.15s; }
.splash-dots span:nth-child(3) { animation-delay: 0.30s; }
@keyframes splash-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40%            { transform: scale(1);   opacity: 1; background: #818CF8; }
}

/* ============================
   TUTORIAL
   ============================ */
#tutorial {
  position: fixed; inset: 0; z-index: 10001;
  background: rgba(0,0,0,0.82);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
#tutorial.tutorial-hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.tutorial-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 24px 22px;
  width: 100%; max-width: 340px;
  display: flex; flex-direction: column; gap: 14px;
  position: relative;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  animation: tutIn 0.28s cubic-bezier(.22,.68,0,1.2);
}
@keyframes tutIn {
  from { transform: scale(0.92) translateY(12px); opacity: 0; }
  to   { transform: scale(1)    translateY(0);     opacity: 1; }
}

.tutorial-skip {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none;
  color: var(--text3); font-size: 12px; cursor: pointer;
  padding: 4px 8px; border-radius: 6px; transition: all 0.15s;
}
.tutorial-skip:hover { color: var(--text2); background: var(--bg4); }

.tutorial-icon {
  width: 50px; height: 50px; border-radius: 14px;
  background: rgba(99,102,241,0.1);
  border: 1px solid rgba(99,102,241,0.2);
  display: flex; align-items: center; justify-content: center;
  color: #818CF8; flex-shrink: 0;
}

.tutorial-badge {
  font-size: 11px; font-weight: 600;
  color: var(--primary); text-transform: uppercase; letter-spacing: 0.6px;
}

.tutorial-title {
  font-size: 17px; font-weight: 700; color: var(--text); line-height: 1.3;
  margin-top: -4px;
}

.tutorial-desc {
  font-size: 13px; color: var(--text2); line-height: 1.65;
}

.tutorial-dots {
  display: flex; gap: 5px; align-items: center; margin-top: 2px;
}
.tutorial-dot {
  height: 5px; border-radius: 3px;
  background: var(--border2); transition: all 0.25s ease;
  width: 5px;
}
.tutorial-dot.active { width: 18px; background: var(--primary); }

.tutorial-actions {
  display: flex; gap: 8px; margin-top: 4px;
}
.tutorial-btn-prev {
  flex: 1; padding: 10px 12px;
  background: var(--bg4); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text2);
  font-size: 13px; font-weight: 500; cursor: pointer; transition: background 0.15s;
}
.tutorial-btn-prev:hover { background: var(--bg3); }
.tutorial-btn-next {
  flex: 2; padding: 10px 12px;
  background: var(--primary); border: none;
  border-radius: 10px; color: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.15s;
}
.tutorial-btn-next:hover { background: var(--primary-dark); }

