/* ============================================================================
   CUPON LOUNGE · PORTAL DE ANUNCIANTES
   theme.css — Sistema de diseño (tokens, reset, tipografía y componentes)
   Único origen de verdad. Las hojas por página sólo componen layout.
   ========================================================================= */

/* ---------------------------------------------------------------------------
   1. TOKENS
------------------------------------------------------------------------- */
:root {
  /* Marca — turquesa */
  --brand-50:  #e7f7f9;
  --brand-100: #c3ecf0;
  --brand-200: #8fdbe3;
  --brand-300: #4ec5d2;
  --brand-400: #17b1c1;
  --brand-500: #00a7b5;
  --brand-600: #008a97;
  --brand-700: #006c77;
  --brand-800: #08525a;

  /* Marca — ciruela / morado */
  --plum-50:  #f4effa;
  --plum-100: #e6dcf3;
  --plum-200: #cbb6e4;
  --plum-300: #a883cf;
  --plum-400: #7d4fae;
  --plum-500: #5a2d82;
  --plum-600: #4a2370;
  --plum-700: #3a1b58;
  --plum-800: #2a1340;

  /* Neutros (con matiz violeta para armonizar con la marca) */
  --ink-900: #191221;
  --ink-800: #2a2136;
  --ink-700: #3f3550;
  --ink-600: #574d68;
  --ink-500: #6f6682;
  --ink-400: #948da4;
  --ink-300: #bdb7c8;
  --ink-200: #ddd8e6;
  --ink-100: #eeeaf3;
  --ink-50:  #f7f5fa;

  /* Semánticos */
  --success-50:#e8f7f1; --success-500:#0f9d6b; --success-700:#0a7350;
  --warning-50:#fdf3e3; --warning-500:#c9820c; --warning-700:#8f5c05;
  --danger-50: #fdedee; --danger-500: #d13438; --danger-600:#b02529; --danger-700:#8c1d21;
  --info-50:   #eaf2fd; --info-500:   #2563eb;

  /* Superficies */
  --canvas:        #f5f3f9;
  --canvas-veil:   #efebf6;
  --surface:       #ffffff;
  --surface-muted: var(--ink-50);
  --surface-sunken:#faf9fc;
  --line:          #e4dfec;
  --line-strong:   #d3ccdf;

  /* Texto */
  --text:        var(--ink-900);
  --text-muted:  var(--ink-500);
  --text-subtle: var(--ink-400);
  --text-invert: #ffffff;

  /* Tipografía */
  --font-sans: 'Montserrat', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --font-num: 'Montserrat', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Escala fluida (clamp: móvil → escritorio) */
  --fs-3xs: 0.6875rem;                              /* 11px  */
  --fs-2xs: 0.75rem;                                /* 12px  */
  --fs-xs:  0.8125rem;                              /* 13px  */
  --fs-sm:  0.875rem;                               /* 14px  */
  --fs-md:  0.9375rem;                              /* 15px  */
  --fs-lg:  1rem;                                   /* 16px  */
  --fs-xl:  clamp(1.0625rem, 0.99rem + 0.35vw, 1.1875rem);
  --fs-2xl: clamp(1.25rem, 1.14rem + 0.5vw, 1.5rem);
  --fs-3xl: clamp(1.5rem, 1.3rem + 0.95vw, 2rem);
  --fs-4xl: clamp(1.875rem, 1.5rem + 1.6vw, 2.75rem);

  --lh-tight: 1.15;
  --lh-snug: 1.35;
  --lh-normal: 1.55;
  --lh-relaxed: 1.7;

  --ls-tight: -0.02em;
  --ls-normal: 0;
  --ls-wide: 0.02em;
  --ls-wider: 0.06em;
  --ls-caps: 0.09em;

  /* Espaciado */
  --sp-1: 0.25rem;  --sp-2: 0.5rem;   --sp-3: 0.75rem;  --sp-4: 1rem;
  --sp-5: 1.25rem;  --sp-6: 1.5rem;   --sp-7: 2rem;     --sp-8: 2.5rem;
  --sp-9: 3rem;     --sp-10: 4rem;    --sp-11: 5rem;

  /* Contenedores */
  --container: 1200px;
  --container-wide: 1360px;
  --gutter: clamp(1rem, 0.55rem + 2.2vw, 2.5rem);

  /* Radios */
  --r-xs: 6px;  --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-xl: 28px; --r-pill: 999px;

  /* Elevación (sombras teñidas de ciruela, no negras) */
  --sh-xs: 0 1px 2px rgba(42, 19, 64, 0.06);
  --sh-sm: 0 1px 2px rgba(42, 19, 64, 0.05), 0 2px 6px rgba(42, 19, 64, 0.05);
  --sh-md: 0 2px 4px rgba(42, 19, 64, 0.05), 0 8px 20px -4px rgba(42, 19, 64, 0.10);
  --sh-lg: 0 4px 8px rgba(42, 19, 64, 0.05), 0 18px 40px -8px rgba(42, 19, 64, 0.16);
  --sh-xl: 0 8px 16px rgba(42, 19, 64, 0.06), 0 32px 64px -12px rgba(42, 19, 64, 0.24);
  --sh-focus: 0 0 0 3px var(--brand-100), 0 0 0 1px var(--brand-500);

  /* Movimiento */
  --dur-1: 120ms; --dur-2: 200ms; --dur-3: 320ms; --dur-4: 480ms;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);

  /* Capas */
  --z-nav: 100;
  --z-drawer: 200;
  --z-modal: 300;
  --z-toast: 400;
  --z-loader: 500;

  /* Alto de la barra superior (para offsets sticky) */
  --nav-h: 68px;
}

@media (max-width: 640px) { :root { --nav-h: 60px; } }

/* ---------------------------------------------------------------------------
   2. RESET MODERNO
------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

body {
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  color: var(--text);
  background-color: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img, svg, video, canvas { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; }
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }
ul[class], ol[class] { list-style: none; padding: 0; }
a { color: var(--plum-500); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }

/* Bloqueo de scroll cuando hay overlay abierto */
body.is-locked { overflow: hidden; }

/* Anillo de foco consistente en toda la app */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

::selection { background: var(--brand-100); color: var(--plum-700); }

/* Barras de scroll discretas (WebKit) */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--ink-200);
  border: 3px solid transparent;
  border-radius: var(--r-pill);
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-300); background-clip: content-box; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------------------------------------------------------------------------
   3. TIPOGRAFÍA
------------------------------------------------------------------------- */
h1, h2, h3, h4 { line-height: var(--lh-tight); letter-spacing: var(--ls-tight); font-weight: 700; color: var(--ink-900); }
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }

.eyebrow {
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--brand-600);
}

.lead { font-size: var(--fs-lg); line-height: var(--lh-relaxed); color: var(--text-muted); }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); font-size: var(--fs-sm); }

/* Sólo visible para lectores de pantalla */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Salto al contenido (accesibilidad de teclado) */
.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: var(--sp-4);
  z-index: calc(var(--z-toast) + 1);
  transform: translateY(-200%);
  background: var(--plum-600);
  color: #fff;
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--sh-lg);
  transition: transform var(--dur-2) var(--ease-out);
}
.skip-link:focus-visible { transform: translateY(0); }

/* ---------------------------------------------------------------------------
   4. LAYOUT / SHELL
------------------------------------------------------------------------- */
/* Estructura sticky-footer: el <footer> siempre al fondo aunque haya poco contenido */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.app-shell > main,
.app-shell > .app-main { flex: 1 0 auto; }

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--wide { max-width: var(--container-wide); }

.stack > * + * { margin-top: var(--sp-4); }
.stack-lg > * + * { margin-top: var(--sp-7); }

/* ---------------------------------------------------------------------------
   5. BARRA DE NAVEGACIÓN
------------------------------------------------------------------------- */
.top-nav {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-5);
  min-height: var(--nav-h);
  padding: var(--sp-3) var(--gutter);
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  transition: box-shadow var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
.top-nav.is-stuck { box-shadow: var(--sh-md); background: rgba(255, 255, 255, 0.95); }

.logo-nav { display: flex; align-items: center; flex: 0 0 auto; }
.logo-nav a { display: block; line-height: 0; border-radius: var(--r-xs); }
.nav-logo { width: 118px; height: auto; }

.menu {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  margin-left: auto;
}
.menu a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: var(--ls-wide);
  color: var(--ink-600);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
.menu a:hover { color: var(--plum-600); background: var(--plum-50); }
.menu a.active {
  color: var(--plum-600);
  background: var(--plum-50);
}
.menu a.active::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 18px;
  height: 3px;
  transform: translateX(-50%);
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--brand-500), var(--plum-500));
}
/* «Cerrar sesión» se separa visualmente del resto */
.menu .menu-logout {
  margin-left: var(--sp-3);
  padding-inline: var(--sp-4);
  color: var(--ink-500);
  border: 1px solid var(--line-strong);
}
.menu .menu-logout:hover { color: var(--danger-600); border-color: var(--danger-500); background: var(--danger-50); }

/* Botón hamburguesa (accesible: es un <button>) */
.hamburger {
  display: none;
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background var(--dur-2) var(--ease);
}
.hamburger:hover { background: var(--plum-50); }
.hamburger span {
  display: block;
  width: 21px;
  height: 2px;
  border-radius: var(--r-pill);
  background: var(--plum-600);
  transition: transform var(--dur-3) var(--ease-out), opacity var(--dur-1) var(--ease);
}
.hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; transform: scaleX(0.4); }
.hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Cajón lateral móvil */
.mobile-menu {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: var(--z-drawer);
  display: flex;
  flex-direction: column;
  width: min(86vw, 320px);
  padding: var(--sp-6) var(--sp-5) calc(var(--sp-6) + env(safe-area-inset-bottom));
  background: var(--surface);
  box-shadow: var(--sh-xl);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform var(--dur-3) var(--ease-out), visibility var(--dur-3);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.mobile-menu.active { transform: translateX(0); visibility: visible; }
#mobile_menu_logo { width: 120px; margin-bottom: var(--sp-7); }
.mobile-menu a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  margin-bottom: var(--sp-1);
  border-radius: var(--r-sm);
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--ink-700);
  text-decoration: none;
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.mobile-menu a:hover { background: var(--ink-50); }
.mobile-menu a.active { background: var(--plum-50); color: var(--plum-600); }
.mobile-menu .menu-logout { margin-top: auto; color: var(--danger-600); }
.mobile-menu .menu-logout:hover { background: var(--danger-50); }

/* Velo detrás del cajón */
.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-drawer) - 1);
  background: rgba(26, 18, 33, 0.45);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur-3) var(--ease), visibility var(--dur-3);
}
.drawer-scrim.active { opacity: 1; visibility: visible; }

@media (max-width: 900px) {
  .menu { display: none; }
  .hamburger { display: flex; }
}

/* ---------------------------------------------------------------------------
   6. BOTONES
------------------------------------------------------------------------- */
.btn,
.btn-access, .btn-register, .btn-add-promotion, .btn-renew, .btn-details,
.btn-delete, .btn-subscribe, .btn-teal, .btn-purple, .submit-btn {
  --btn-bg: var(--plum-600);
  --btn-fg: #fff;
  --btn-bg-hover: var(--plum-500);
  --btn-border: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: 0 var(--sp-6);
  border: 1px solid var(--btn-border);
  border-radius: var(--r-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: var(--ls-wide);
  line-height: 1;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  isolation: isolate;
  transition: background var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease),
              color var(--dur-2) var(--ease),
              box-shadow var(--dur-2) var(--ease),
              transform var(--dur-1) var(--ease);
}
.btn:hover, .btn-access:hover, .btn-register:hover, .btn-add-promotion:hover,
.btn-renew:hover, .btn-details:hover, .btn-delete:hover, .btn-subscribe:hover,
.btn-teal:hover, .btn-purple:hover, .submit-btn:hover {
  background: var(--btn-bg-hover);
  box-shadow: var(--sh-md);
}
.btn:active, .btn-access:active, .btn-register:active, .btn-add-promotion:active,
.btn-renew:active, .btn-details:active, .btn-delete:active, .btn-subscribe:active,
.btn-teal:active, .btn-purple:active, .submit-btn:active { transform: translateY(1px); box-shadow: var(--sh-xs); }

.btn:disabled, .submit-btn:disabled, button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
  transform: none;
}

/* Variantes */
.btn--primary, .btn-access, .btn-details, .btn-purple, .submit-btn {
  --btn-bg: var(--plum-600); --btn-bg-hover: var(--plum-500);
}
.btn--brand, .btn-register, .btn-add-promotion, .btn-renew, .btn-subscribe, .btn-teal {
  --btn-bg: var(--brand-500); --btn-bg-hover: var(--brand-600);
}
.btn--ghost {
  --btn-bg: transparent; --btn-fg: var(--ink-700);
  --btn-bg-hover: var(--ink-50); --btn-border: var(--line-strong);
}
.btn--ghost:hover { color: var(--plum-600); border-color: var(--plum-200); }
.btn--soft {
  --btn-bg: var(--plum-50); --btn-fg: var(--plum-600);
  --btn-bg-hover: var(--plum-100); --btn-border: transparent;
}
.btn--danger, .btn-delete {
  --btn-bg: transparent; --btn-fg: var(--danger-600);
  --btn-bg-hover: var(--danger-50); --btn-border: rgba(209, 52, 56, 0.35);
}
.btn--danger:hover, .btn-delete:hover { border-color: var(--danger-500); }
.btn--danger-solid {
  --btn-bg: var(--danger-500); --btn-fg: #fff;
  --btn-bg-hover: var(--danger-600); --btn-border: transparent;
}

/* Tamaños */
.btn--sm { min-height: 36px; padding-inline: var(--sp-4); font-size: var(--fs-xs); }
.btn--lg { min-height: 52px; padding-inline: var(--sp-8); font-size: var(--fs-lg); }
.btn--block { width: 100%; }
.btn--icon { padding: 0; width: 44px; min-height: 44px; }

/* Estado de carga: el texto se oculta y aparece un spinner centrado */
.btn.loading, .submit-btn.loading, .btn-access.loading, .btn-subscribe.loading,
.btn-teal.loading, .action-btn.loading, .loading[class*="btn"] {
  color: transparent !important;
  pointer-events: none;
  cursor: progress;
}
.btn.loading::after, .submit-btn.loading::after, .btn-access.loading::after,
.btn-subscribe.loading::after, .btn-teal.loading::after, .action-btn.loading::after,
.loading[class*="btn"]::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px; height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: cl-spin 0.7s linear infinite;
}
.btn--ghost.loading::after, .btn--danger.loading::after, .btn-delete.loading::after {
  border-color: rgba(90, 45, 130, 0.25);
  border-top-color: var(--plum-500);
}

@keyframes cl-spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------------------
   7. FORMULARIOS
------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.field > label,
.form-group > label,
.field-label {
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--ink-600);
}
.field-hint, .image-hint {
  font-size: var(--fs-2xs);
  line-height: var(--lh-snug);
  color: var(--text-subtle);
}
.field-error {
  display: none;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-2xs);
  font-weight: 600;
  color: var(--danger-600);
}
.field.has-error .field-error { display: flex; }

/* Controles */
input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="url"], input[type="number"], input[type="date"], input[type="search"],
select, textarea {
  width: 100%;
  min-height: 46px;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-md);
  line-height: 1.4;
  transition: border-color var(--dur-2) var(--ease),
              box-shadow var(--dur-2) var(--ease),
              background var(--dur-2) var(--ease);
  appearance: none;
  -webkit-appearance: none;
}
textarea { min-height: 120px; padding-block: var(--sp-3); resize: vertical; line-height: var(--lh-normal); }

input::placeholder, textarea::placeholder { color: var(--ink-400); }

input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) {
  border-color: var(--ink-300);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: var(--sh-focus);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-muted);
  color: var(--text-subtle);
  border-color: var(--line);
  cursor: not-allowed;
}
input[type="date"] { min-height: 46px; }
input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.55; }
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }

/* Estado inválido — sólo tras interacción, nunca al cargar la página */
.field.has-error input, .field.has-error select, .field.has-error textarea,
input.is-invalid, select.is-invalid, textarea.is-invalid {
  border-color: var(--danger-500);
  box-shadow: 0 0 0 3px var(--danger-50);
}

/* Flecha personalizada del <select> */
select:not([multiple]) {
  padding-right: var(--sp-9);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236f6682' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-4) center;
  cursor: pointer;
}
select[multiple] { padding: var(--sp-2); min-height: 46px; }

/* Grupo con prefijo/sufijo (p. ej. moneda o botón «ver contraseña») */
.input-affix { position: relative; display: flex; align-items: center; }
.input-affix input { padding-right: 46px; }
.input-affix__btn {
  position: absolute;
  right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--r-xs);
  color: var(--ink-400);
  cursor: pointer;
  transition: color var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
.input-affix__btn:hover { color: var(--plum-500); background: var(--ink-50); }

/* Casillas y radios con aspecto de marca */
input[type="checkbox"], input[type="radio"] {
  width: 20px; height: 20px;
  min-height: 0;
  padding: 0;
  flex: 0 0 auto;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-xs);
  background: var(--surface);
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:checked, input[type="radio"]:checked {
  background: var(--brand-500);
  border-color: var(--brand-500);
}
input[type="checkbox"]:checked::after {
  content: '';
  width: 10px; height: 6px;
  border: 2px solid #fff;
  border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px);
}
input[type="radio"]:checked::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #fff; }

/* Selector de archivo → zona de arrastre */
input[type="file"] { display: block; width: 100%; font-size: var(--fs-sm); color: var(--text-muted); border: 0; padding: 0; min-height: 0; background: none; }
input[type="file"]::file-selector-button {
  margin-right: var(--sp-4);
  padding: var(--sp-2) var(--sp-5);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--plum-600);
  font-size: var(--fs-sm);
  font-weight: 700;
  cursor: pointer;
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
input[type="file"]::file-selector-button:hover { background: var(--plum-50); border-color: var(--plum-200); }

.dropzone {
  display: grid;
  gap: var(--sp-4);
  padding: var(--sp-6);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  text-align: center;
  transition: border-color var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
.dropzone.is-dragover { border-color: var(--brand-500); background: var(--brand-50); }

/* Cuadrícula de formulario — sustituye a los antiguos .form-row flex */
.form-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--sp-5);
}
.col-3  { grid-column: span 3; }
.col-4  { grid-column: span 4; }
.col-5  { grid-column: span 5; }
.col-6  { grid-column: span 6; }
.col-7  { grid-column: span 7; }
.col-8  { grid-column: span 8; }
.col-9  { grid-column: span 9; }
.col-12 { grid-column: span 12; }

@media (max-width: 860px) {
  .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9 { grid-column: span 6; }
}
@media (max-width: 600px) {
  .form-grid { gap: var(--sp-4); }
  .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9 { grid-column: span 12; }
}

/* Compatibilidad con el marcado heredado (.form-row / .half-col / …) */
.form-row { display: flex; flex-wrap: wrap; gap: var(--sp-5); }
.form-group { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; flex: 1 1 220px; }
.small-col { flex: 1 1 200px; }
.large-col { flex: 3 1 320px; }
.half-col  { flex: 1 1 260px; }
.full-col  { flex: 1 1 100%; }
@media (max-width: 600px) { .form-row { gap: var(--sp-4); } .form-group { flex: 1 1 100%; } }

/* Bloque de campos agrupados (fieldset con estilo) */
.form-section {
  display: grid;
  gap: var(--sp-5);
  padding: var(--sp-6);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.form-section__head { display: grid; gap: var(--sp-1); }
.form-section__title {
  display: flex; align-items: center; gap: var(--sp-3);
  font-size: var(--fs-lg); font-weight: 700; color: var(--plum-600);
}
.form-section__step {
  display: grid; place-content: center;
  width: 26px; height: 26px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--plum-50);
  color: var(--plum-600);
  font-size: var(--fs-2xs);
  font-weight: 800;
}
.form-section__desc { font-size: var(--fs-sm); color: var(--text-muted); }

/* ---------------------------------------------------------------------------
   8. TARJETAS Y SUPERFICIES
------------------------------------------------------------------------- */
.card, .surface {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
.card--interactive { transition: box-shadow var(--dur-3) var(--ease), transform var(--dur-3) var(--ease), border-color var(--dur-3) var(--ease); }
.card--interactive:hover { box-shadow: var(--sh-lg); transform: translateY(-2px); border-color: var(--plum-100); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-md);
  overflow: hidden;
}
.panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-6) var(--sp-7);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--surface-sunken));
}
.panel__body { padding: var(--sp-7); }
@media (max-width: 640px) {
  .panel { border-radius: var(--r-md); }
  .panel__head { padding: var(--sp-5); }
  .panel__body { padding: var(--sp-5); }
}

/* ---------------------------------------------------------------------------
   9. DISTINTIVOS Y ETIQUETAS
------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 3px var(--sp-3);
  border-radius: var(--r-pill);
  font-size: var(--fs-3xs);
  font-weight: 800;
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--ink-100);
  color: var(--ink-600);
}
.badge--brand   { background: var(--brand-50);   color: var(--brand-700); }
.badge--plum    { background: var(--plum-50);    color: var(--plum-600); }
.badge--success { background: var(--success-50); color: var(--success-700); }
.badge--warning { background: var(--warning-50); color: var(--warning-700); }
.badge--danger  { background: var(--danger-50);  color: var(--danger-700); }
.badge--vip {
  background: linear-gradient(135deg, var(--plum-500), var(--brand-500));
  color: #fff;
}
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------------------------------------------------------------------------
   10. MODALES
   El JS heredado asigna style.display = 'flex' | 'block'; ambos funcionan.
------------------------------------------------------------------------- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  padding: clamp(0.75rem, 3vh, 3rem) var(--sp-4);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(26, 18, 33, 0.55);
  -webkit-backdrop-filter: blur(6px) saturate(140%);
  backdrop-filter: blur(6px) saturate(140%);
  animation: cl-fade var(--dur-2) var(--ease) both;
}
@keyframes cl-fade { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
  width: 100%;
  max-width: 980px;
  margin-inline: auto;
  align-self: flex-start;   /* evita el estirado vertical cuando display:flex */
  position: relative;
  padding: 0;
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  overflow: hidden;
  animation: cl-modal-in var(--dur-4) var(--ease-out) both;
}
@keyframes cl-modal-in {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}
@media (max-width: 640px) {
  .modal { padding: 0; }
  .modal-content { max-width: none; min-height: 100dvh; border-radius: 0; }
}

/* Cabecera del modal — pegajosa para no perder el contexto al desplazarse */
.modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-7);
  padding-right: calc(var(--sp-7) + 44px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.modal-logo { width: 44px; height: auto; flex: 0 0 auto; }
.modal-title {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: var(--ls-tight);
  color: var(--plum-600);
}
.modal-subtitle { font-size: var(--fs-sm); color: var(--text-muted); }
.modal-body { padding: var(--sp-7); display: grid; gap: var(--sp-6); }

/* Barra de acciones pegada al fondo del modal */
.modal-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-7);
  padding-bottom: calc(var(--sp-5) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.modal-footer .btn--ghost { margin-right: auto; }
@media (max-width: 640px) {
  .modal-header, .modal-body, .modal-footer { padding-inline: var(--sp-5); }
  .modal-footer > * { flex: 1 1 100%; }
  .modal-footer .btn--ghost { margin-right: 0; order: 2; }
}

/* Botón de cierre */
.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  display: grid;
  place-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-500);
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  transition: color var(--dur-2) var(--ease), background var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.close-button:hover {
  color: var(--danger-600);
  background: var(--danger-50);
  border-color: rgba(209, 52, 56, 0.3);
  transform: rotate(90deg);
}

/* Modal compacto (confirmaciones) */
.modal-content--sm { max-width: 480px; }
.modal-content--md { max-width: 680px; }
@media (max-width: 640px) {
  .modal-content--sm, .modal-content--md {
    min-height: 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    margin-top: auto;
    align-self: flex-end;
  }
  .modal:has(.modal-content--sm), .modal:has(.modal-content--md) {
    padding-top: 20vh;
    align-items: flex-end;
  }
}

/* Ilustración de advertencia dentro de un diálogo destructivo */
.dialog-icon {
  display: grid;
  place-content: center;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--danger-50);
  color: var(--danger-500);
  margin-bottom: var(--sp-4);
}
.dialog-icon--brand { background: var(--brand-50); color: var(--brand-600); }

/* ---------------------------------------------------------------------------
   11. NOTIFICACIONES (sustituyen a window.alert)
------------------------------------------------------------------------- */
.toast-region {
  position: fixed;
  top: calc(var(--nav-h) + var(--sp-3));
  right: var(--sp-5);
  left: auto;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  width: min(400px, calc(100vw - var(--sp-8)));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--line);
  border-left: 4px solid var(--ink-300);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--sh-lg);
  pointer-events: auto;
  animation: cl-toast-in var(--dur-3) var(--ease-spring) both;
}
.toast.is-leaving { animation: cl-toast-out var(--dur-2) var(--ease) forwards; }
@keyframes cl-toast-in  { from { opacity: 0; transform: translateX(24px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes cl-toast-out { to { opacity: 0; transform: translateX(24px); } }

.toast__icon { flex: 0 0 auto; margin-top: 1px; }
.toast__body { flex: 1; min-width: 0; }
.toast__title { font-size: var(--fs-sm); font-weight: 700; color: var(--ink-900); }
.toast__msg { font-size: var(--fs-sm); line-height: var(--lh-snug); color: var(--text-muted); overflow-wrap: anywhere; }
.toast__close {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  display: grid; place-content: center;
  border-radius: var(--r-xs);
  color: var(--ink-400);
  cursor: pointer;
  font-size: 18px; line-height: 1;
}
.toast__close:hover { color: var(--ink-700); background: var(--ink-50); }

.toast--success { border-left-color: var(--success-500); } .toast--success .toast__icon { color: var(--success-500); }
.toast--error   { border-left-color: var(--danger-500); }  .toast--error   .toast__icon { color: var(--danger-500); }
.toast--warning { border-left-color: var(--warning-500); } .toast--warning .toast__icon { color: var(--warning-500); }
.toast--info    { border-left-color: var(--brand-500); }   .toast--info    .toast__icon { color: var(--brand-500); }

@media (max-width: 640px) {
  .toast-region {
    top: auto;
    bottom: calc(var(--sp-4) + env(safe-area-inset-bottom));
    left: var(--sp-4); right: var(--sp-4);
    width: auto;
  }
  @keyframes cl-toast-in  { from { opacity: 0; transform: translateY(24px) scale(0.96); } to { opacity: 1; transform: none; } }
  @keyframes cl-toast-out { to { opacity: 0; transform: translateY(24px); } }
}

/* ---------------------------------------------------------------------------
   12. CARGA: OVERLAY, SPINNER Y ESQUELETOS
------------------------------------------------------------------------- */
#page-loader, #loadingOverlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-loader);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 243, 249, 0.72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: cl-fade var(--dur-2) var(--ease) both;
}

.loader-spinner, .loadingIcon {
  width: 46px;
  height: 46px;
  border: 3px solid var(--plum-100);
  border-top-color: var(--plum-500);
  border-radius: 50%;
  animation: cl-spin 0.75s linear infinite;
}

/* Esqueletos de carga: evitan el «salto» de contenido */
.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-sm);
  background: var(--ink-100);
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.75), transparent);
  animation: cl-shimmer 1.4s infinite;
}
@keyframes cl-shimmer { to { transform: translateX(100%); } }
.skeleton--text { height: 12px; border-radius: var(--r-pill); }
.skeleton--title { height: 20px; width: 45%; border-radius: var(--r-pill); }
.skeleton--thumb { aspect-ratio: 1; width: 100%; border-radius: var(--r-md); }

/* ---------------------------------------------------------------------------
   13. ESTADOS VACÍOS
------------------------------------------------------------------------- */
.empty-state {
  display: grid;
  justify-items: center;
  gap: var(--sp-4);
  padding: var(--sp-10) var(--sp-6);
  text-align: center;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background:
    radial-gradient(120% 90% at 50% 0%, var(--brand-50) 0%, transparent 60%),
    var(--surface-sunken);
}
.empty-state__icon {
  display: grid; place-content: center;
  width: 64px; height: 64px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--sh-sm);
  color: var(--plum-400);
}
.empty-state__title { font-size: var(--fs-xl); color: var(--ink-900); }
.empty-state__text { max-width: 46ch; font-size: var(--fs-sm); color: var(--text-muted); line-height: var(--lh-relaxed); }
.empty-state img { max-width: 200px; margin-inline: auto; }

/* ---------------------------------------------------------------------------
   14. PIE DE PÁGINA
------------------------------------------------------------------------- */
footer, .site-footer {
  flex: 0 0 auto;
  margin-top: var(--sp-9);
  padding: var(--sp-7) var(--gutter) calc(var(--sp-7) + env(safe-area-inset-bottom));
  background: linear-gradient(135deg, var(--plum-700), var(--plum-600) 55%, var(--brand-800));
  color: rgba(255, 255, 255, 0.82);
  font-size: var(--fs-sm);
  text-align: center;
}
.footer-inner {
  max-width: var(--container);
  margin-inline: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  text-align: left;
}
.footer-brand { display: flex; align-items: center; gap: var(--sp-3); font-weight: 600; color: #fff; }
.footer-links { display: flex; flex-wrap: wrap; gap: var(--sp-5); }
footer a, #link_footer {
  color: #fff;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.28);
  padding-bottom: 1px;
  transition: border-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
footer a:hover, #link_footer:hover { border-color: #fff; color: var(--brand-200); }
@media (max-width: 640px) { .footer-inner { justify-content: center; text-align: center; } }

/* ---------------------------------------------------------------------------
   15. CHOICES.JS — ajuste al sistema de diseño
------------------------------------------------------------------------- */
.choices { margin-bottom: 0 !important; }
.choices__inner {
  min-height: 46px !important;
  padding: 5px 6px !important;
  border: 1px solid var(--line-strong) !important;
  border-radius: var(--r-sm) !important;
  background: var(--surface) !important;
  font-size: var(--fs-sm) !important;
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.choices:hover .choices__inner { border-color: var(--ink-300) !important; }
.choices.is-focused .choices__inner,
.choices.is-open .choices__inner {
  border-color: var(--brand-500) !important;
  box-shadow: var(--sh-focus);
}
.choices[data-type*="select-multiple"] .choices__button { border-left-color: rgba(255,255,255,0.4) !important; }
.choices__list--multiple .choices__item {
  padding: 4px 10px !important;
  border: 0 !important;
  border-radius: var(--r-pill) !important;
  background: var(--plum-500) !important;
  font-size: var(--fs-2xs) !important;
  font-weight: 700 !important;
  letter-spacing: var(--ls-wide);
}
.choices__list--multiple .choices__item.is-highlighted { background: var(--plum-600) !important; }
.choices__list--dropdown {
  border: 1px solid var(--line) !important;
  border-radius: var(--r-sm) !important;
  box-shadow: var(--sh-lg) !important;
  overflow: hidden;
}
.choices__list--dropdown .choices__item--selectable.is-highlighted { background: var(--plum-50) !important; }
.choices__placeholder { color: var(--ink-400) !important; opacity: 1 !important; }

/* ---------------------------------------------------------------------------
   16. UTILIDADES
------------------------------------------------------------------------- */
.flow > * + * { margin-top: var(--sp-4); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row--wrap { flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.grow { flex: 1; }
.hide { display: none !important; }
@media (max-width: 640px) { .hide-sm { display: none !important; } }
@media (min-width: 641px) { .hide-lg { display: none !important; } }
.text-center { text-align: center; }
.divider { height: 1px; background: var(--line); border: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Disparador y nombre de archivo dentro de la zona de arrastre */
.dropzone__trigger {
  justify-self: center;
  min-width: 180px;
  cursor: pointer;
}
.dropzone__file {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-700);
  overflow-wrap: anywhere;
}
.dropzone__file:not([data-selected]) { color: var(--text-subtle); font-weight: 400; }
/* La zona completa reacciona al foco del teclado sobre el input oculto */
.dropzone:has(input:focus-visible) { border-color: var(--brand-500); box-shadow: var(--sh-focus); }

/* Pantallas muy estrechas (≤ 400 px): ningún botón ni bloque debe forzar
   scroll horizontal. El texto largo se reparte en dos líneas. */
.btn, .btn-access, .btn-register, .btn-add-promotion, .btn-renew, .btn-details,
.btn-delete, .btn-subscribe, .btn-teal, .btn-purple, .submit-btn { max-width: 100%; }

@media (max-width: 400px) {
  .empty-state { padding: var(--sp-8) var(--sp-4); }
  .empty-state .btn { width: 100%; white-space: normal; line-height: 1.3; padding-inline: var(--sp-4); }
  .btn, .btn-access, .btn-register, .btn-add-promotion, .btn-renew, .btn-details,
  .btn-delete, .btn-subscribe, .btn-teal, .btn-purple, .submit-btn {
    white-space: normal;
    line-height: 1.25;
    padding-inline: var(--sp-4);
  }
}
