/* Victoria 365 - Opticas Victoria Lens
   Rosa por defecto: extraido del logo real de la optica (promosdelbanco.com
   Optica-Lens.png), RGB(219,29,123) = #DB1D7B. */
:root {
  --primary-top: #DB1D7B;
  --primary-bottom: #8E1257;
  --primary: #DB1D7B;
  --primary-dark: #8E1257;
  --primary-light: #FDE3F1;
  --pill-bg: #FBD0E8;
  --bg: #F6F6F8;
  --card: #FFFFFF;
  --text: #29242A;
  --muted: #767180;
  --border: #ECE7EC;
  --success-bg: #E6F9EA;
  --success-text: #147D29;
  --warning-bg: #FFF4E5;
  --warning-text: #B45309;
  --info-bg: #E7F1FC;
  --info-text: #1971C2;
  --pagos-card-bg: #FAE9F1;
  --shadow: 0 2px 10px rgba(142, 18, 87, 0.08);
  --radius: 12px;
}

/* Temas seleccionables (icono junto a la campanita). El default "rosa" ya
   esta en :root arriba (color real del logo); los demas pisan solo los
   colores de marca. "bordo" es el tema original, ahora una alternativa mas. */
html[data-theme="bordo"] {
  --primary-top: #B0014C; --primary-bottom: #6C0135; --primary: #A6134B;
  --primary-dark: #7A0D38; --primary-light: #FFE7F5; --pill-bg: #FFD5F1;
  --shadow: 0 2px 10px rgba(108, 1, 53, 0.06);
}
html[data-theme="azul"] {
  --primary-top: #1565C0; --primary-bottom: #0D3B75; --primary: #1565C0;
  --primary-dark: #0D3B75; --primary-light: #E3F0FC; --pill-bg: #CFE4FB;
  --shadow: 0 2px 10px rgba(13, 59, 117, 0.08);
}
html[data-theme="verde"] {
  --primary-top: #1E8E5C; --primary-bottom: #0B5C36; --primary: #1E8E5C;
  --primary-dark: #0B5C36; --primary-light: #E1F7EC; --pill-bg: #C8F0DC;
  --shadow: 0 2px 10px rgba(11, 92, 54, 0.08);
}
html[data-theme="violeta"] {
  --primary-top: #7B1FA2; --primary-bottom: #4A0072; --primary: #7B1FA2;
  --primary-dark: #4A0072; --primary-light: #F3E5FA; --pill-bg: #E6C6F5;
  --shadow: 0 2px 10px rgba(74, 0, 114, 0.08);
}
html[data-theme="grafito"] {
  --primary-top: #37474F; --primary-bottom: #1C262B; --primary: #455A64;
  --primary-dark: #1C262B; --primary-light: #ECEFF1; --pill-bg: #CFD8DC;
  --shadow: 0 2px 10px rgba(28, 38, 43, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; }
img { max-width: 100%; }

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

/* ===================== Banner de "Entrar como" (impersonación) ===================== */
.impersonando-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 44px;
  background: #B45309;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 0 20px;
  font-size: 12.5px;
  z-index: 500;
}
.impersonando-banner-btn {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 1.5px solid rgba(255,255,255,.5);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.impersonando-banner-btn:hover { background: rgba(255,255,255,.28); }
body.impersonando .app-shell { padding-top: 44px; }
body.impersonando .sidebar { top: 44px; height: calc(100vh - 44px); }

.sidebar {
  width: 250px;
  flex: 0 0 250px;
  background: linear-gradient(180deg, var(--primary-top) 0%, var(--primary-bottom) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 18px;
}
.sidebar-logo .logo-mark {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--primary);
  flex-shrink: 0;
}
.sidebar-logo .logo-text { line-height: 1.15; }
.sidebar-logo .logo-text small { display: block; font-size: 10px; letter-spacing: .12em; opacity: .85; }
.sidebar-logo .logo-text strong { font-size: 17px; font-style: italic; }

.sidebar-badge {
  text-align: center;
  font-size: 11px;
  letter-spacing: .15em;
  font-weight: 700;
  padding: 8px 0 18px;
  border-bottom: 1px solid rgba(255,255,255,.18);
  margin-bottom: 10px;
}

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: .92;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.12); }
.sidebar-nav a.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
  opacity: 1;
}
.sidebar-nav .icon { width: 18px; text-align: center; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 24px;
  padding: 16px 32px;
  flex-wrap: wrap;
  background: linear-gradient(90deg, var(--primary-top) 0%, var(--primary-bottom) 100%);
}
.topbar .notif-bell,
.topbar .hamburger-btn { color: #fff; }
.topbar .notif-bell .badge-count { border: 2px solid var(--primary-top); }
.topbar .user-chip .name { color: #fff; }
.topbar .user-chip .sub { color: rgba(255, 255, 255, .75); }
.topbar .user-chip:hover { background: rgba(255, 255, 255, .16); }
.hamburger-btn {
  display: none;
  background: none; border: none; cursor: pointer;
  font-size: 22px; margin-right: auto;
}
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40;
}
.sidebar-backdrop.open { display: block; }
.topbar-right { display: flex; align-items: center; gap: 18px; }

.notif-bell {
  position: relative; font-size: 20px; color: var(--text);
  background: none; border: none; cursor: pointer; padding: 0;
}
.notif-bell .badge-count {
  position: absolute; top: -6px; right: -8px;
  background: var(--primary); color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 50%; width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
}

.tema-switcher { position: relative; }
.tema-menu {
  display: none; position: absolute; top: 32px; right: 0; z-index: 20;
  background: #fff; border-radius: 10px; box-shadow: 0 8px 20px rgba(0,0,0,.2);
  padding: 8px; width: 160px; flex-direction: column; gap: 2px;
}
.tema-menu.open { display: flex; }
.tema-opcion {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 7px;
  border: none; background: none; cursor: pointer; font-size: 12.5px; color: var(--text); text-align: left;
}
.tema-opcion:hover { background: var(--bg); }
.tema-opcion.activo { background: var(--primary-light); font-weight: 700; }
.tema-swatch { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 1px var(--border); }
.tema-swatch-rosa { background: linear-gradient(135deg, #DB1D7B, #8E1257); }
.tema-swatch-bordo { background: linear-gradient(135deg, #B0014C, #6C0135); }
.tema-swatch-azul { background: linear-gradient(135deg, #1565C0, #0D3B75); }
.tema-swatch-verde { background: linear-gradient(135deg, #1E8E5C, #0B5C36); }
.tema-swatch-violeta { background: linear-gradient(135deg, #7B1FA2, #4A0072); }
.tema-swatch-grafito { background: linear-gradient(135deg, #37474F, #1C262B); }

.toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 999;
  display: flex; flex-direction: column; gap: 10px; max-width: 300px;
}
.toast-notif {
  background: #fff; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.22);
  padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
  border-left: 4px solid var(--primary);
  animation: toast-entrar .25s ease-out;
}
.toast-notif.salir { animation: toast-salir .5s ease-in forwards; }
.toast-icon {
  width: 26px; height: 26px; border-radius: 50%; background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0;
}
.toast-body { font-size: 12px; line-height: 1.4; color: var(--text); }
.toast-body strong { display: block; font-size: 12.5px; margin-bottom: 2px; }
@keyframes toast-entrar { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toast-salir { to { transform: translateX(40px); opacity: 0; } }

.user-chip {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 4px 10px 4px 4px; border-radius: 30px; transition: background .15s ease;
  border: none; background: none; font-family: inherit; text-align: left;
}
.user-chip:hover { background: var(--primary-light); }
.user-chip .avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary-top), var(--primary-bottom));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; color: #fff; overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
}
.avatar-img { width: 100%; height: 100%; object-fit: cover; }
.user-chip .name { font-weight: 600; font-size: 13.5px; color: var(--text); }
.user-chip .sub { font-size: 11.5px; color: var(--muted); }

.user-menu {
  display: none; position: absolute; top: 54px; right: 0; z-index: 20;
  background: #fff; border-radius: 10px; box-shadow: 0 8px 20px rgba(0,0,0,.2);
  padding: 8px; width: 230px; flex-direction: column; gap: 2px;
}
.user-menu.open { display: flex; }
.user-menu-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 7px;
  border: none; background: none; cursor: pointer; font-size: 12.5px; font-family: inherit;
  color: var(--text); text-align: left; text-decoration: none; width: 100%;
}
.user-menu-item:hover { background: var(--bg); }
.user-menu-item-danger { color: #B4232C; font-weight: 700; }
.user-menu-item-danger:hover { background: #FDEAEA; }

.sidebar-logo-img { max-height: 88px; max-width: 210px; width: auto; height: auto; display: block; margin: 0 auto; }

/* ===================== Recortador de logo (Configuración > Diseño) ===================== */
.logo-cropper-frame {
  width: 420px; max-width: 100%; height: 176px;
  background: linear-gradient(180deg, var(--primary-top) 0%, var(--primary-bottom) 100%);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  cursor: grab;
  touch-action: none;
}
.logo-cropper-frame.dragging { cursor: grabbing; }
.logo-cropper-frame canvas { display: block; width: 100%; height: 100%; }
.logo-cropper-controls { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.logo-cropper-controls label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.logo-cropper-controls input[type="range"] { width: 160px; }
.logo-cropper-real-preview {
  width: 210px; height: 88px;
  background: linear-gradient(180deg, var(--primary-top) 0%, var(--primary-bottom) 100%);
  border-radius: 10px;
  overflow: hidden;
}
.logo-cropper-real-preview canvas { display: block; width: 100%; height: 100%; }

.content { padding: 10px 32px 40px; flex: 1; }

.footer-note {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .06em;
  padding: 18px;
  text-transform: uppercase;
}

/* ===================== Search box ===================== */
.search-box {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #fff;
  border-radius: var(--radius);
  padding: 8px 10px;
  box-shadow: var(--shadow);
  max-width: 620px;
  margin: 14px 0 22px;
}
.search-box select, .search-box input[type=text], .search-box input[type=search] {
  border: none; outline: none; font-size: 14px; background: transparent; padding: 8px;
}
.search-box select { border-right: 1px solid var(--border); border-radius: 0; }
.search-box input { flex: 1; }

.search-autocomplete-wrap { position: relative; max-width: 620px; margin-bottom: 8px; }
.search-autocomplete-wrap .search-box { margin: 14px 0 0; max-width: 100%; }

/* Buscador destacado (Afiliados, Recetas, Cobranzas) -- los mas usados del
   sitio, se les da un marco degradado + tipografia mas grande para que
   sobresalgan del resto. */
.search-box-frame {
  padding: 5px;
  margin: 14px 0 22px;
  background: linear-gradient(90deg, var(--primary-top) 0%, var(--primary-bottom) 100%);
  border-radius: 16px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, .18);
}
.search-box-frame .search-box {
  margin: 0;
  max-width: 100%;
  padding: 6px 8px;
  box-shadow: none;
}
.search-box-frame .search-box input[type=text] { font-size: 15px; padding: 12px 10px; }
.search-box-frame .search-box button.btn-primary { padding: 12px 26px; font-size: 14px; }

/* Variante para un input suelto (sin el combo select+input+boton de .search-box),
   ej: el campo "Buscar afiliado" dentro del formulario de filtros de Cobranzas. */
.search-box-frame > input[type=text] {
  display: block; width: 100%; font-family: inherit; color: var(--text);
  border: none; outline: none; border-radius: 11px;
  background: #fff; font-size: 15px; padding: 12px 14px;
}

.autocomplete-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff; border-radius: var(--radius); box-shadow: 0 8px 24px rgba(108,1,53,.15);
  border: 1px solid var(--border); overflow: hidden; z-index: 20;
  max-height: 320px; overflow-y: auto;
}
.autocomplete-item {
  display: block; padding: 10px 16px; border-bottom: 1px solid var(--border);
  transition: background .1s ease;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--primary-light); }
.autocomplete-item strong { display: block; font-size: 13px; color: var(--text); }
.autocomplete-item span { font-size: 11.5px; color: var(--muted); }
.autocomplete-empty { padding: 14px 16px; font-size: 12.5px; color: var(--muted); text-align: center; }

/* ===================== Buttons ===================== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: none; border-radius: 9px; padding: 10px 18px;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--primary); padding: 6px 10px; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
.btn-success { background: var(--success-text); color: #fff; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ===================== Cards / grid ===================== */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
/* Recuadro mas marcado para separar cada plan (Plan 1 / Plan 2 / Plan 3) entre si. */
.plan-card, .card-boxed { border: 2px solid var(--pill-bg); }
.card-title {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--primary);
  text-transform: uppercase;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Titulos de seccion con fondo oscuro + redondeado, para delimitar bloques
   dentro de una pagina (Cobranzas, Beneficios, Ordenes/Entregas). */
.card-title.card-title-dark {
  color: #FFFFFF;
  background: var(--primary-dark);
  padding: 10px 16px;
  border-radius: 10px;
  gap: 10px;
}
.card-title.card-title-dark .text-muted { color: rgba(255, 255, 255, .75); }
.card-title.card-title-dark label { color: rgba(255, 255, 255, .85); }

/* ===================== Badges / pills ===================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700; padding: 4px 10px;
  border-radius: 20px; white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-info { background: var(--info-bg); color: var(--info-text); }
.badge-neutral { background: #EFEDF0; color: var(--muted); }
.badge-error { background: #FDEAEA; color: #B4232C; }

.pill {
  background: var(--pill-bg); color: var(--primary);
  font-weight: 800; font-size: 13px;
  padding: 6px 16px; border-radius: 8px; display: inline-block;
}

/* ===================== Perfil de afiliado ===================== */
.profile-header {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: 20px;
  align-items: stretch;
  margin-bottom: 20px;
}
.profile-header > .card { display: flex; flex-direction: column; }
.profile-box-perfil-body { display: flex; flex-direction: row; gap: 20px; align-items: flex-start; }
@media (max-width: 1200px) {
  .profile-header { grid-template-columns: 1fr; }
}
.profile-avatar-wrap { position: relative; width: 180px; }
.profile-avatar {
  width: 180px; height: 180px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.profile-avatar-img { object-fit: cover; border: 4px solid #fff; box-shadow: var(--shadow); }
.profile-avatar-default {
  background: linear-gradient(135deg, var(--primary-top), var(--primary-bottom));
  color: #fff; font-size: 54px; font-weight: 800; letter-spacing: .02em;
}
.avatar-edit-btn {
  position: absolute; bottom: 4px; right: 4px;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; cursor: pointer; border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.avatar-edit-btn:hover { background: var(--primary-dark); }
.profile-name { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.profile-meta { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }
.profile-detail-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 6px; color: #4a444d; }
.profile-detail-row .icon { color: var(--primary); width: 16px; }

.info-list .info-item { display: flex; align-items: flex-start; gap: 8px; font-size: 12.8px; margin-bottom: 10px; color: #4a444d; }
.info-list .info-item .icon { color: var(--primary); margin-top: 1px; }
.info-list .info-item strong { display: block; font-weight: 600; color: var(--text); }

.info-list-divided .info-item { padding-bottom: 12px; border-bottom: 2px solid var(--pill-bg); }
.info-list-divided .info-item:last-child { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }

.plan-highlight {
  margin-top: 6px;
  padding: 18px 16px;
  border-radius: 14px;
  text-align: center;
  background: linear-gradient(160deg, var(--pill-bg) 0%, #ffffff 130%);
  border: 1px solid var(--pill-bg);
}
.plan-highlight .pill { margin-bottom: 10px; }
.plan-highlight-nombre { font-size: 21px; font-weight: 800; color: var(--primary-dark); line-height: 1.25; }

.pagos-card {
  background: var(--pagos-card-bg);
  border-radius: var(--radius);
  padding: 18px;
}
.pagos-card .estado-title { color: var(--primary); font-weight: 700; font-size: 12px; text-transform: uppercase; margin-bottom: 8px; }
.pagos-card .estado-value { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; color: var(--success-text); margin-bottom: 12px; }
.pagos-card .estado-row { font-size: 12.5px; margin-bottom: 4px; color: #4a444d; }
.pagos-card .estado-row strong { display: block; color: var(--text); }

/* ===================== Listas de beneficios ===================== */
.benefit-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.benefit-row:last-of-type { border-bottom: none; }
.benefit-icon {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0;
}
.benefit-info { flex: 1; min-width: 0; }
.benefit-info strong { display: block; font-size: 13px; }
.benefit-info span { font-size: 11.5px; color: var(--muted); }
.benefit-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }

/* Timeline (historial de beneficios) */
.timeline { position: relative; padding-left: 6px; }
.timeline-item { display: flex; gap: 12px; padding-bottom: 18px; position: relative; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-check {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--success-bg); color: var(--success-text);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 13px;
}
.timeline-body strong { display: block; font-size: 13px; }
.timeline-body span { display: block; font-size: 11.5px; color: var(--muted); }

/* Notas internas de un afiliado */
.notas-lista { display: flex; flex-direction: column; gap: 12px; max-height: 340px; overflow-y: auto; }
.nota-item { padding: 10px 14px; border-radius: 8px; }
.nota-texto { font-size: 12.8px; white-space: pre-wrap; }
.nota-meta { font-size: 11px; margin-top: 6px; }

.nota-item:nth-child(odd) { background: #1B3358; }
.nota-item:nth-child(odd) .nota-texto { color: #FFFFFF; }
.nota-item:nth-child(odd) .nota-meta { color: rgba(255, 255, 255, .72); }

.nota-item:nth-child(even) { background: #F5921E; }
.nota-item:nth-child(even) .nota-texto { color: #2B1B00; }
.nota-item:nth-child(even) .nota-meta { color: rgba(43, 27, 0, .68); }

/* ===================== Tablas ===================== */
table.table { width: 100%; border-collapse: collapse; font-size: 12.8px; }
table.table th {
  text-align: left; color: var(--muted); font-weight: 600;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em;
  padding: 8px 6px; border-bottom: 1px solid var(--border);
}
table.table td { padding: 10px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.table tr:last-child td { border-bottom: none; }

/* ===================== Familiares ===================== */
.family-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.family-row:last-of-type { border-bottom: none; }
.family-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.family-info { flex: 1; min-width: 0; }
.family-info strong { display: block; font-size: 13px; }
.family-info span { font-size: 11.5px; color: var(--muted); }

/* ===================== Árbol de grupo familiar (modal) ===================== */
.family-tree { padding: 6px 4px 2px; overflow-x: auto; }
.family-tree-node { display: inline-flex; flex-direction: column; align-items: center; gap: 5px; position: relative; cursor: default; }
.family-tree-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; border: 2px solid #fff; box-shadow: var(--shadow);
}
.family-tree-titular { display: flex; margin: 0 auto 0; width: fit-content; }
.family-tree-titular .family-tree-avatar { width: 54px; height: 54px; font-size: 17px; background: var(--primary-dark); color: #fff; }
.family-tree-name { font-size: 11.5px; font-weight: 700; color: var(--text); max-width: 92px; text-align: center; line-height: 1.25; }
.family-tree-tooltip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px);
  background: var(--primary-dark); color: #fff; font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: 6px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 5;
}
.family-tree-tooltip::after {
  content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--primary-dark);
}
.family-tree-node:hover .family-tree-tooltip { opacity: 1; transform: translateX(-50%) translateY(0); }
.family-tree-trunk { width: 2px; height: 22px; background: var(--pill-bg); margin: 0 auto; }
.family-tree-children { display: flex; justify-content: center; gap: 26px; flex-wrap: wrap; width: fit-content; margin: 0 auto; padding-top: 22px; }
.family-tree-children.has-multi { border-top: 2px solid var(--pill-bg); }
.family-tree-branch { position: relative; }
.family-tree-branch::before {
  content: ''; position: absolute; top: -22px; left: 50%; width: 2px; height: 22px;
  background: var(--pill-bg); transform: translateX(-1px);
}

/* ===================== Chips de bucket (Cobranzas: 1/2/3+ cuotas) ===================== */
.cuotas-bucket-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.cuotas-bucket-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 10px; border: 1.5px solid var(--pill-bg);
  background: #fff; color: var(--text); font-size: 12.5px; font-weight: 700;
  text-decoration: none;
}
.cuotas-bucket-chip:hover { border-color: var(--primary); }
.cuotas-bucket-chip .cuotas-bucket-count {
  background: var(--pill-bg); color: var(--primary); border-radius: 20px;
  padding: 2px 9px; font-size: 12px; font-weight: 800;
}
.cuotas-bucket-chip.active { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.cuotas-bucket-chip.active .cuotas-bucket-count { background: rgba(255,255,255,.25); color: #fff; }
.cuotas-bucket-chip-morosos { border-color: #F3B9B9; }
.cuotas-bucket-chip-morosos .cuotas-bucket-count { background: #FDEAEA; color: #B4232C; }
.cuotas-bucket-chip-morosos.active { background: #B4232C; border-color: #B4232C; }

/* ===================== Forms ===================== */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 7px; color: #4a444d; }
.form-group .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

.form-control {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 13.5px; background: #FBFAFB; font-family: inherit; color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.form-control::placeholder { color: #B8B2BC; }
.form-control:hover { border-color: #DDBBCB; }
.form-control:focus {
  outline: none; border-color: var(--primary); background: #fff;
  box-shadow: 0 0 0 4px var(--primary-light);
}
.form-control.is-invalid { border-color: #d64545; background: #FFF7F7; }
.field-error { color: #d64545; font-size: 11.5px; margin-top: 4px; font-weight: 600; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }

/* Campos grandes (ej: formulario de recetas) para que sea comodo tocar/hacer
   click sin errores, sobre todo los steppers +/- de los campos numericos. */
.form-grande .form-group label { font-size: 14px; }
.form-grande .form-control { padding: 14px 16px; font-size: 17px; border-radius: 12px; }
.form-grande textarea.form-control { font-size: 15px; }

.stepper { display: flex; align-items: stretch; gap: 8px; }
.stepper-input {
  flex: 1; min-width: 0; text-align: center; font-weight: 800;
  -moz-appearance: textfield;
}
.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-btn {
  flex-shrink: 0; width: 52px; border: 1.5px solid var(--border); border-radius: 12px;
  background: var(--bg); color: var(--primary); font-size: 26px; font-weight: 800;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  line-height: 1; padding: 0; transition: background .15s ease, border-color .15s ease;
}
.stepper-btn:hover { background: var(--primary-light); border-color: var(--primary); }
.stepper-btn:active { background: var(--primary); color: #fff; }

/* Sectores con color de fondo en el formulario de recetas, para que se note
   a simple vista que son bloques de datos distintos a completar. */
.receta-seccion { border-radius: 14px; padding: 16px 18px 4px; margin-bottom: 18px; }
.receta-seccion-title { font-weight: 800; font-size: 13.5px; margin-bottom: 8px; }
.receta-seccion .form-control { background: #fff; }
.receta-od { background: var(--primary-light); }
.receta-od .receta-seccion-title { color: var(--primary-dark); }
.receta-oi { background: var(--info-bg); }
.receta-oi .receta-seccion-title { color: var(--info-text); }
.receta-dp { background: var(--warning-bg); }
.receta-dp .receta-seccion-title { color: var(--warning-text); }
.required-mark { color: var(--primary); }

textarea.form-control { resize: vertical; min-height: 70px; }

/* Select con flecha propia, mismo lenguaje visual que los inputs */
select.form-control {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23A6134B'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.19l3.71-3.96a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
  padding-right: 38px; cursor: pointer;
}
select.form-control:disabled { cursor: not-allowed; opacity: .7; }

/* Checkboxes y radios con el color de marca */
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--primary);
  width: 17px; height: 17px; cursor: pointer; vertical-align: middle;
}
label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) {
  cursor: pointer;
}
.form-group label:has(input[type="checkbox"]) {
  display: flex; align-items: center; gap: 8px; font-weight: 600;
  background: var(--primary-light); border-radius: 9px; padding: 10px 12px;
  border: 1.5px solid transparent; transition: border-color .15s ease;
}
.form-group label:has(input[type="checkbox"]):hover { border-color: var(--pill-bg); }

.alert { padding: 12px 16px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; }
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-error { background: #FDEAEA; color: #B4232C; }
.alert-info { background: var(--info-bg); color: var(--info-text); }
.alert-blink { animation: alert-blink-kf 1s infinite; }
@keyframes alert-blink-kf {
  0%, 100% { background: #FDEAEA; }
  50% { background: #F7B7B7; }
}

/* ===================== Wizard (Nueva Afiliacion) ===================== */
.wizard-steps { display: flex; gap: 8px; margin-bottom: 24px; }
.wizard-step {
  display: block; flex: 1; text-align: center; padding: 10px; border-radius: 8px;
  background: #EFEDF0; color: var(--muted); font-size: 12px; font-weight: 700;
  text-decoration: none; transition: opacity .15s ease;
}
.wizard-step.active { background: var(--primary); color: #fff; }
.wizard-step.done { background: var(--success-bg); color: var(--success-text); }
a.wizard-step.done { cursor: pointer; }
a.wizard-step.done:hover { opacity: .75; }
.wizard-card { max-width: 640px; margin: 0 auto; }

.upload-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 30px 20px; text-align: center; color: var(--muted); cursor: pointer;
  background: var(--bg); transition: border-color .15s ease, background .15s ease, color .15s ease;
  width: 100%;
}
.upload-box:hover, .upload-box:active { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }
.upload-box .upload-icon {
  width: 54px; height: 54px; border-radius: 50%; background: #fff; color: var(--primary);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 12px;
  font-size: 24px; box-shadow: var(--shadow);
}
.upload-box .upload-text { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.upload-box .hint { margin-top: 4px; }
.upload-box-sm { padding: 18px 16px; }
.upload-box .upload-icon-sm { width: 42px; height: 42px; font-size: 19px; margin-bottom: 8px; }

.upload-result {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--success-text); border-radius: var(--radius);
  padding: 10px 14px; background: var(--success-bg);
}
.upload-result img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex-shrink: 0; border: 2px solid #fff; box-shadow: var(--shadow); }
.upload-result-info { flex: 1; font-size: 12.5px; color: var(--success-text); font-weight: 700; }
.upload-result-change {
  font-size: 11.5px; color: var(--muted); cursor: pointer; text-decoration: underline;
  background: none; border: none; padding: 0; flex-shrink: 0;
}
.upload-result-change:hover { color: var(--primary); }

.upload-preview { max-width: 100%; max-height: 340px; border-radius: 10px; margin-top: 12px; }

.direccion-sugerencias {
  display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0,0,0,.15); max-height: 240px; overflow-y: auto; margin-top: 2px;
}
.sugerencia-item {
  padding: 10px 12px; font-size: 12.5px; cursor: pointer; border-bottom: 1px solid var(--border);
  line-height: 1.35;
}
.sugerencia-item:last-child { border-bottom: none; }
.sugerencia-item:hover { background: var(--primary-light); color: var(--primary-dark); }

.plan-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 20px; }
.plan-pick-card {
  border: 2px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer;
}
.plan-pick-card.selected { border-color: var(--primary); background: var(--primary-light); }
.plan-pick-card h4 { color: var(--primary); font-size: 13px; margin-bottom: 4px; }
.plan-pick-card .price { font-weight: 700; font-size: 16px; margin: 6px 0; }
.plan-pick-card .price small { font-size: 11px; color: var(--muted); font-weight: 400; }

.qr-box { text-align: center; padding: 20px; }
.qr-box img { width: 220px; height: 220px; border: 1px solid var(--border); border-radius: 10px; }

/* ===================== Login ===================== */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--primary-top), var(--primary-bottom));
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 380px;
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.login-card .logo-mark { width: 56px; height: 56px; border-radius: 14px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 800; margin: 0 auto 14px; font-size: 22px; }
.login-card h1 { text-align: center; font-size: 18px; margin-bottom: 4px; }
.login-card p.subtitle { text-align: center; color: var(--muted); font-size: 12.5px; margin-bottom: 24px; }

/* ===================== Error pages ===================== */
.error-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.error-box { text-align: center; }
.error-box h1 { font-size: 64px; color: var(--primary); }

/* ===================== Stat tiles / dashboard Inicio ===================== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }

.stat-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-tile .stat-label { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.stat-tile .stat-value { font-size: 30px; font-weight: 700; font-variant-numeric: proportional-nums; color: var(--text); line-height: 1.1; }
.stat-tile .stat-delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; margin-top: 8px; }
.stat-tile .stat-delta.up { color: var(--success-text); }
.stat-tile .stat-delta.down { color: #B4232C; }
.stat-tile .stat-delta.flat { color: var(--muted); }

.stat-tile.tile-warning { border-color: #F3D2B0; background: var(--warning-bg); }
.stat-tile.tile-warning .stat-label { color: var(--warning-text); }
.stat-tile.tile-warning .stat-value { color: var(--warning-text); }

.stat-tile.tile-danger { border-color: #F5C2C2; background: #FDEAEA; }
.stat-tile.tile-danger .stat-label { color: #B4232C; }
.stat-tile.tile-danger .stat-value { color: #B4232C; }

.stat-tile.tile-success { border-color: #B7E8C4; background: var(--success-bg); }
.stat-tile.tile-success .stat-label { color: var(--success-text); }
.stat-tile.tile-success .stat-value { color: var(--success-text); }

.stat-tile.tile-info { border-color: #BFDCF5; background: var(--info-bg); }
.stat-tile.tile-info .stat-label { color: var(--info-text); }
.stat-tile.tile-info .stat-value { color: var(--info-text); }

.stat-tile.tile-primary { border-color: var(--pill-bg); background: var(--primary-light); }
.stat-tile.tile-primary .stat-label { color: var(--primary-dark); }
.stat-tile.tile-primary .stat-value { color: var(--primary); }

.stat-tile.tile-gold { border-color: #F5DFA0; background: #FEF6E0; }
.stat-tile.tile-gold .stat-label { color: #96700E; }
.stat-tile.tile-gold .stat-value { color: #96700E; }

.stat-tile.tile-link { cursor: pointer; text-decoration: none; display: block; transition: transform .1s ease, box-shadow .15s ease; }
.stat-tile.tile-link:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(108,1,53,.12); }

/* Hero money tile ("comisión ganada") */
.money-tile {
  border-radius: var(--radius);
  padding: 28px;
  background: linear-gradient(135deg, var(--primary-top), var(--primary-bottom));
  color: #fff;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.money-tile .money-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; flex-shrink: 0;
}
.money-tile .money-body { flex: 1; min-width: 200px; }
.money-tile .money-label { font-size: 12.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; opacity: .85; margin-bottom: 6px; }
.money-tile .money-value { font-size: 40px; font-weight: 800; font-variant-numeric: proportional-nums; line-height: 1.05; }
.money-tile .money-sub { font-size: 12.5px; opacity: .9; margin-top: 8px; }
.money-tile .money-badge { background: rgba(255,255,255,.2); border-radius: 20px; padding: 4px 12px; font-size: 12px; font-weight: 700; display: inline-block; margin-top: 10px; }

/* Fila compacta de tiles de dinero (ej: ganado hoy/semana/mes) */
.money-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .money-row { grid-template-columns: 1fr; } }
.money-tile-compact {
  border-radius: var(--radius);
  padding: 18px 20px;
  background: linear-gradient(135deg, var(--primary-top), var(--primary-bottom));
  color: #fff;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
}
.money-tile-compact .money-icon {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.money-tile-compact .money-label { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; opacity: .85; margin-bottom: 4px; }
.money-tile-compact .money-value { font-size: 24px; font-weight: 800; font-variant-numeric: proportional-nums; line-height: 1.1; }

/* Segmented control (filtro de periodo) */
.segmented { display: inline-flex; background: #EFEDF0; border-radius: 9px; padding: 3px; gap: 2px; }
.segmented a {
  padding: 7px 14px; border-radius: 7px; font-size: 12.5px; font-weight: 600;
  color: var(--muted); text-decoration: none;
}
.segmented a.active { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* ===================== Utilidades ===================== */
.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.link-more { font-size: 12.5px; font-weight: 600; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.page-header h1 { font-size: 20px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }

/* ===================== Modal de confirmacion ===================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(41,36,42,.55);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 20px;
}
.modal-box {
  background: #fff; border-radius: var(--radius); padding: 26px;
  max-width: 460px; width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.modal-box-img { max-width: 700px; }

.resumen-receta-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.resumen-receta-row:last-child { border-bottom: none; }
.resumen-receta-row span { color: var(--muted); font-weight: 600; }
.resumen-receta-row strong { color: var(--text); font-weight: 800; text-align: right; }
.resumen-receta-section { border-radius: 10px; padding: 10px 14px; margin: 10px 0; }
.resumen-receta-section .resumen-receta-row { border-bottom-color: rgba(0,0,0,.1); }
.resumen-receta-section-title { font-weight: 800; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.resumen-od { background: var(--info-bg); }
.resumen-od .resumen-receta-section-title { color: var(--info-text); }
.resumen-oi { background: var(--warning-bg); }
.resumen-oi .resumen-receta-section-title { color: var(--warning-text); }

/* Aviso bien notorio cuando se va a usar una receta de mas de 30 dias para
   una entrega: la graduacion pudo haber cambiado desde entonces. */
.alerta-receta-vieja {
  background: #D93A46; color: #fff; font-weight: 700; font-size: 13px; line-height: 1.4;
  border-radius: 10px; padding: 12px 14px; margin-top: 10px;
  animation: alerta-titilar 1.1s ease-in-out infinite;
}
@keyframes alerta-titilar {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}

/* ===================== Mensajes configurables: mockup de WhatsApp ===================== */
.whatsapp-mensajes-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }

.whatsapp-mock {
  border-radius: 14px; overflow: hidden; box-shadow: 0 4px 16px rgba(0,0,0,.12);
  border: 1px solid var(--border);
}
.whatsapp-mock-header {
  background: #075E54; color: #fff; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
}
.whatsapp-mock-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: #FFD5F1; color: #A6134B;
  display: flex; align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0;
}
.whatsapp-mock-header-info { line-height: 1.25; }
.whatsapp-mock-header-info strong { display: block; font-size: 13.5px; }
.whatsapp-mock-header-info span { font-size: 11px; opacity: .8; }

.whatsapp-mock-chat {
  background-color: #E5DDD5;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(0,0,0,.035) 0, transparent 40%),
    radial-gradient(circle at 85% 60%, rgba(0,0,0,.035) 0, transparent 40%),
    radial-gradient(circle at 40% 85%, rgba(0,0,0,.035) 0, transparent 40%);
  padding: 18px 14px; min-height: 130px; display: flex; align-items: flex-start;
}
.whatsapp-bubble-wrap { margin-left: auto; max-width: 88%; }
.whatsapp-bubble {
  display: block; width: 100%; resize: vertical;
  background: #DCF8C6; color: #111b21; border: none;
  border-radius: 10px 10px 2px 10px; padding: 9px 11px; font-size: 13.5px; line-height: 1.4;
  font-family: inherit; box-shadow: 0 1px 1px rgba(0,0,0,.1);
}
.whatsapp-bubble:focus { outline: 2px solid #075E54; outline-offset: 1px; }
.whatsapp-bubble-meta {
  text-align: right; font-size: 10.5px; color: #667781; margin-top: 3px; padding-right: 4px;
}
.whatsapp-check { color: #53BDEB; font-weight: 700; }

@media (max-width: 700px) { .whatsapp-mensajes-grid { grid-template-columns: 1fr; } }

/* ===================== Catálogo de diagnósticos: chips con onda ===================== */
.diagnostico-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.diagnostico-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px 16px; border-radius: 999px; font-size: 13px; font-weight: 700;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.diagnostico-chip-remove {
  width: 22px; height: 22px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.6); color: inherit; font-weight: 800; font-size: 13px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; padding: 0;
  transition: background .15s ease;
}
.diagnostico-chip-remove:hover { background: rgba(255,255,255,.95); }

.diagnostico-chip-0 { background: var(--pill-bg); color: var(--primary-dark); }
.diagnostico-chip-1 { background: var(--info-bg); color: var(--info-text); }
.diagnostico-chip-2 { background: var(--success-bg); color: var(--success-text); }
.diagnostico-chip-3 { background: var(--warning-bg); color: var(--warning-text); }
.diagnostico-chip-4 { background: #EAE1FF; color: #5B3FBF; }
.diagnostico-chip-5 { background: #FFE1DC; color: #C23B2E; }

.diagnostico-add-form {
  display: flex; max-width: 420px; border: 1.5px solid var(--border); border-radius: 999px;
  overflow: hidden; background: #FBFAFB; transition: border-color .15s ease;
}
.diagnostico-add-form:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); }
.diagnostico-add-form input {
  border: none; background: transparent; flex: 1; padding: 12px 18px; font-size: 13.5px; font-family: inherit;
}
.diagnostico-add-form input:focus { outline: none; }
.diagnostico-add-form button {
  border: none; background: var(--primary); color: #fff; padding: 0 22px; font-weight: 800;
  font-size: 19px; cursor: pointer; transition: background .15s ease;
}
.diagnostico-add-form button:hover { background: var(--primary-dark); }

/* ===================== Reportes: tags de accesos rapidos (elegante, monocromo) ===================== */
.tag-bubbles { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; padding: 4px 2px 8px; }
.tag-bubble {
  display: inline-flex; align-items: center; text-decoration: none;
  white-space: nowrap; border-radius: 999px; padding: 6px 16px;
  animation: tag-bubble-entrada .4s ease-out backwards;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, color .16s ease;
  cursor: pointer;
}
.tag-bubble:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(142,18,87,.22);
}
@keyframes tag-bubble-entrada {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
/* Mismo tamaño para todas las burbujas; el color distingue la categoria
   (barrio vs diagnostico), no el peso -- comparar cantidades de cosas muy
   distintas por tamaño no es representativo. */
.tag-bubble-barrio { background: var(--primary-light); color: var(--primary-dark); font-weight: 700; }
.tag-bubble-barrio:hover { background: linear-gradient(135deg, var(--primary-top), var(--primary-bottom)); color: #fff; }
.tag-bubble-diagnostico { background: #E7F1FC; color: #1971C2; font-weight: 700; }
.tag-bubble-diagnostico:hover { background: linear-gradient(135deg, #2E86D8, #124D80); color: #fff; }

/* ===================== Librería de íconos (Configuración > Cards) ===================== */
.libreria-iconos-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px;
  max-height: 340px; overflow-y: auto; padding-right: 4px;
}
.libreria-icono-item {
  border: 1.5px solid var(--border); border-radius: 10px; background: #fff; cursor: pointer;
  padding: 8px; display: flex; align-items: center; justify-content: center;
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.libreria-icono-item:hover { border-color: var(--primary); background: var(--primary-light); transform: scale(1.08); }
.libreria-icono-item img { width: 32px; height: 32px; }
.modal-box h3 { font-size: 16px; margin-bottom: 12px; }
.modal-message-preview {
  background: var(--bg); border-radius: 10px; padding: 14px;
  font-size: 12.5px; color: #4a444d; white-space: pre-wrap; margin-bottom: 14px;
  border-left: 3px solid var(--primary); max-height: 160px; overflow-y: auto;
}
.modal-recipient-count {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
  background: var(--primary-light); border-radius: 10px; padding: 12px 14px;
}
.modal-recipient-count .num { font-size: 22px; font-weight: 800; color: var(--primary); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.modal-step-danger { background: #FFF4E5; border-left: 3px solid var(--warning-text); border-radius: 8px; padding: 10px 12px; font-size: 12px; color: var(--warning-text); margin-bottom: 14px; }

/* ===================== Barras horizontales (Reportes) ===================== */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-chart-row { display: grid; grid-template-columns: 160px 1fr 44px; align-items: center; gap: 10px; }
.bar-chart-label { font-size: 12px; color: var(--text); font-weight: 600; white-space: normal; line-height: 1.25; word-break: break-word; }
.bar-chart-track { background: var(--bg); border-radius: 5px; height: 10px; overflow: hidden; }
.bar-chart-fill { height: 100%; border-radius: 5px; background: var(--primary); min-width: 3px; }
.bar-chart-value { font-size: 12px; font-weight: 700; color: var(--text); text-align: right; font-variant-numeric: proportional-nums; }
.bar-chart-fill.fill-success { background: var(--success-text); }
.bar-chart-fill.fill-warning { background: var(--warning-text); }
.bar-chart-fill.fill-danger { background: #B4232C; }

/* ===================== Separador de secciones (Reportes) ===================== */
.section-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 28px 0 16px;
}
.section-divider:first-child { margin-top: 0; }
.section-divider .label {
  font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: #fff; white-space: nowrap;
  background: var(--primary-dark); padding: 7px 16px; border-radius: 20px;
}
.section-divider .line { flex: 1; height: 1px; background: var(--border); }

/* ===================== Dashboard cards: color + drag&drop ===================== */
.dash-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.dash-card {
  position: relative; border-radius: 12px; padding: 14px 16px;
  cursor: grab; user-select: none; transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
  border: 1px solid transparent;
}
.dash-card:active { cursor: grabbing; }
.dash-card.dragging { opacity: .4; }
.dash-card.drag-over { outline: 2px dashed var(--primary); outline-offset: 2px; }
.dash-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.dash-card:hover .dash-card-tools { opacity: 1; }

.dash-card-tools {
  position: absolute; top: 8px; right: 8px; display: flex; gap: 4px;
  opacity: 0; transition: opacity .12s ease;
}
.dash-card-tools button {
  width: 22px; height: 22px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.55); font-size: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.dash-card-tools button:hover { background: rgba(255,255,255,.9); }

.dash-card-icon {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center;
  font-size: 15px; margin-bottom: 8px;
}
.dash-card-label { font-size: 11.5px; font-weight: 700; margin-bottom: 6px; padding-right: 32px; line-height: 1.3; opacity: .92; }
.dash-card-value { font-size: 26px; font-weight: 800; font-variant-numeric: proportional-nums; line-height: 1; }
.dash-card-sub { font-size: 10.5px; margin-top: 6px; font-weight: 600; opacity: .85; }
.dash-card-link { text-decoration: none; display: block; }

.dash-card.card-lista { grid-column: span 2; min-width: 260px; }
.dash-card-list-body { margin-top: 4px; }
.dash-card-list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 5px 0; font-size: 12px; border-bottom: 1px solid rgba(255,255,255,.15);
}
.dash-card-list-row:last-child { border-bottom: none; }
.dash-card-list-row .rank { width: 16px; flex-shrink: 0; text-align: center; font-size: 11px; }
.dash-card-list-row .nombre { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.dash-card-list-row .cant { flex-shrink: 0; font-weight: 800; font-size: 11.5px; background: rgba(255,255,255,.2); padding: 1px 7px; border-radius: 10px; }

/* Top vendedores: sin color de fondo, tarjeta blanca como estaba antes.
   Selector con dos clases (.dash-card.dash-card-lista-plano) a proposito:
   necesita mas especificidad que ".dash-card { color:#fff }" (mas abajo en
   este archivo), sino el texto queda blanco sobre fondo blanco. */
.dash-card.dash-card-lista-plano {
  background: var(--card); color: var(--text); border: 1px solid var(--border); cursor: grab;
}
.dash-card.dash-card-lista-plano .dash-card-label { color: var(--text); opacity: 1; }
.dash-card.dash-card-lista-plano .dash-card-list-row { border-bottom: 1px solid var(--border); }
.dash-card.dash-card-lista-plano .dash-card-list-row .cant { background: var(--bg); color: var(--text); }
.dash-card.dash-card-lista-plano .dash-card-icon { background: var(--primary-light); }

/* Paleta de fondos elegibles (6) - solidos/oscuros, como las cards de "Ganado" */
.dash-card { color: #fff; }
.dash-card-primary { background: linear-gradient(135deg, var(--primary-top), var(--primary-bottom)); }
.dash-card-success { background: linear-gradient(135deg, #1E9636, #0E5C1E); }
.dash-card-info { background: linear-gradient(135deg, #2E86D8, #124D80); }
.dash-card-warning { background: linear-gradient(135deg, #E8912B, #96570A); }
.dash-card-danger { background: linear-gradient(135deg, #D93A46, #7A1218); }
.dash-card-gold { background: linear-gradient(135deg, #D4A72C, #8A6A0E); }

/* Paleta de color de letra elegible (independiente del fondo) */
.dash-text-blanco { color: #fff; }
.dash-text-oscuro { color: #221F29; }
.dash-text-primary { color: #FFD5F1; }
.dash-text-success { color: #C8F5D3; }
.dash-text-info { color: #CFE8FB; }
.dash-text-warning { color: #FFE3C2; }
.dash-text-danger { color: #FFD0D3; }
.dash-text-gold { color: #FFF0C2; }

.color-picker-popover {
  position: absolute; top: 34px; right: 8px; background: #fff; border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0,0,0,.25); padding: 10px; display: none; flex-direction: column; gap: 8px; z-index: 15;
  width: 168px; cursor: default;
}
.color-picker-popover.open { display: flex; }
.color-picker-popover .picker-row-label { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.color-picker-popover .picker-row { display: flex; flex-wrap: wrap; gap: 6px; }
.color-dot {
  width: 20px; height: 20px; border-radius: 50%; cursor: pointer; border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--border); flex-shrink: 0;
}
.color-dot:hover { box-shadow: 0 0 0 2px var(--primary); }
.color-dot.dot-primary { background: linear-gradient(135deg, var(--primary-top), var(--primary-bottom)); }
.color-dot.dot-success { background: linear-gradient(135deg, #1E9636, #0E5C1E); }
.color-dot.dot-info { background: linear-gradient(135deg, #2E86D8, #124D80); }
.color-dot.dot-warning { background: linear-gradient(135deg, #E8912B, #96570A); }
.color-dot.dot-danger { background: linear-gradient(135deg, #D93A46, #7A1218); }
.color-dot.dot-gold { background: linear-gradient(135deg, #D4A72C, #8A6A0E); }
.color-dot.dot-text-blanco { background: #fff; }
.color-dot.dot-text-oscuro { background: #221F29; }
.color-dot.dot-text-primary { background: #FFD5F1; }
.color-dot.dot-text-success { background: #C8F5D3; }
.color-dot.dot-text-info { background: #CFE8FB; }
.color-dot.dot-text-warning { background: #FFE3C2; }
.color-dot.dot-text-danger { background: #FFD0D3; }
.color-dot.dot-text-gold { background: #FFF0C2; }

/* ===================== Responsive / mobile ===================== */
@media (max-width: 900px) {
  .hamburger-btn { display: block; }

  .sidebar {
    position: fixed; top: 0; bottom: 0; left: -280px; z-index: 50;
    width: 260px; flex: 0 0 260px; transition: left .2s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.25);
  }
  .sidebar.open { left: 0; }

  .app-shell { display: block; }
  .main { min-width: 0; }

  .content { padding: 10px 14px 40px; }
  .topbar { padding: 14px 14px 8px; }

  .card { padding: 14px; }
  .page-header { flex-wrap: wrap; gap: 10px; }
  .page-header h1 { font-size: 18px; }

  /* tablas anchas: que scrolleen adentro de su card en vez de desbordar la pantalla */
  .card:has(> table.table),
  .card:has(> div > table.table) { overflow-x: auto; }

  .wizard-card { max-width: 100%; }
  .wizard-steps { gap: 4px; }
  .wizard-step { font-size: 10px; padding: 8px 4px; }

  .dash-grid { grid-template-columns: 1fr 1fr; }
  .dash-card.card-lista { grid-column: span 2; }

  .money-row { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-card.card-lista { grid-column: span 1; }
  .stat-grid { grid-template-columns: 1fr; }
  .wizard-step { font-size: 9px; }
  .login-card { padding: 26px 20px; }

  .profile-avatar-wrap, .profile-avatar { width: 120px; height: 120px; }
  .profile-avatar-default { font-size: 36px; }
}

/* Reportes: selector de "General" + reportes personalizados */
.reporte-selector-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.reporte-tab {
  padding: 7px 14px;
  border-radius: 20px;
  background: #fff;
  border: 1px solid #e3e1e6;
  color: var(--text-muted, #767180);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.reporte-tab.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}
.reporte-tab-eliminar {
  background: none;
  border: none;
  color: inherit;
  opacity: .55;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  line-height: 1;
}
.reporte-tab-eliminar:hover { opacity: 1; }
.reporte-selector-bar .btn-outline { border-radius: 20px; }

.reporte-secciones-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
}
.reporte-seccion-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid #e3e1e6;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
}
.reporte-seccion-check:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* Exportar a PDF: solo se ve el contenido del reporte, sin chrome de la app */
@media print {
  .sidebar, .topbar, .footer-note, .sidebar-backdrop, .no-print { display: none !important; }
  .app-layout, .content { margin: 0 !important; padding: 0 !important; width: 100% !important; }
  body { background: #fff !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; page-break-inside: avoid; }
  .section-divider { break-after: avoid; }
}

/* Pills de PLAN con color propio para identificar rapido cada plan */
.pill-plan-0 { background: #FFE3C2; color: #9A5200; }
.pill-plan-1 { background: #CDEEFB; color: #0B6FA4; }
.pill-plan-2 { background: #E3D4C4; color: #6B4226; }
.pill-plan-3 { background: #DCE8FF; color: #2F4FA8; }
.pill-plan-4 { background: #E3D9FB; color: #6431A8; }
.pill-plan-5 { background: #D9F2E3; color: #1F7A4D; }

/* Selects chicos e inline (ej: "Mostrar" en Beneficios, "Ordenar por" en
   Afiliados) que necesitan su propio padding-right para no tapar la flecha
   con el texto de la ultima opcion. */
select.form-control.select-compacto {
  width: auto; padding: 4px 30px 4px 8px; font-size: 12.5px;
  background-position: right 8px center; background-size: 13px;
}

/* ===================== Configuración: tabs ===================== */
.config-tabs {
  display: flex; gap: 4px; border-bottom: 2px solid var(--border);
  margin-bottom: 22px; flex-wrap: wrap; overflow-x: auto;
}
.config-tab-btn {
  background: none; border: none; padding: 12px 18px; font-size: 14px; font-weight: 700;
  color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent;
  margin-bottom: -2px; white-space: nowrap; transition: color .15s ease, border-color .15s ease;
  font-family: inherit;
}
.config-tab-btn:hover { color: var(--text); }
.config-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.config-subtabs {
  display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap;
}
.config-subtab-btn {
  background: #fff; border: 1.5px solid var(--border); border-radius: 20px;
  padding: 7px 16px; font-size: 12.5px; font-weight: 700; color: var(--muted); cursor: pointer;
  font-family: inherit; transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.config-subtab-btn:hover { border-color: var(--primary); }
.config-subtab-btn.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); }

.manuales-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px;
}
.manual-card {
  border: 1px solid var(--border); border-radius: 12px; padding: 20px 18px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.manual-card-icono { font-size: 30px; margin-bottom: 4px; }
.manual-card-label { font-weight: 800; font-size: 14.5px; }
.manual-card-desc { color: var(--muted); font-size: 12px; margin-bottom: 10px; line-height: 1.4; }
.manual-card-fecha { color: var(--muted); font-size: 11px; margin-bottom: 10px; }
