/* ============================================================================
   TPL FOUNDATION — base unica del frontend publico
   ----------------------------------------------------------------------------
   Antes cada pagina traia su propio :root y su propia copia del header/footer:
   index.css, tpl-shell.css, global-tokens.css, tpl-design-system.css y
   proyecto.css declaraban paletas distintas (tres azules y dos naranjos), asi
   que el color de marca dependia del orden de carga de cada pagina. Este
   archivo es la unica fuente de verdad de tokens + shell + primitivas; los CSS
   de pagina se cargan despues y solo aportan su layout.

   Orden de carga esperado en cada HTML:
     1. tpl-foundation.css   (esto)
     2. css de la pagina     (index.css, parcela.css, ...)
   ============================================================================ */

/* === 1. TOKENS =========================================================== */
:root {
  color-scheme: light;

  /* --- Marca: azul --------------------------------------------------------
     Anclado en #002b54, el azul historico de TPL y el theme-color declarado
     en los <meta>. El resto de la escala se deriva del mismo tono (~208deg). */
  --tpl-navy-950: #011a34;
  --tpl-navy-900: #002b54;
  --tpl-navy-800: #003f7a;
  --tpl-navy-700: #005089;
  --tpl-navy-600: #0d6193;
  --tpl-navy-500: #2a7fb0;
  --tpl-navy-400: #5ea3cb;
  --tpl-navy-300: #97c5e0;
  --tpl-navy-200: #c6dff0;
  --tpl-navy-100: #e2eef8;
  --tpl-navy-050: #f1f7fc;

  /* --- Marca: naranjo (CTA sobre fondo claro) ------------------------------
     #a8410f / #bd5522 dan 6.1:1 y 4.7:1 con texto blanco. El par anterior
     (#db5b24 / #e57644) daba 3.8:1 y 3.0:1, bajo el minimo AA. Se conserva la
     version accesible y se elimina la otra de los archivos que aun la tenian. */
  --tpl-orange-700: #8d3409;
  --tpl-orange-600: #a8410f;
  --tpl-orange-500: #bd5522;
  --tpl-orange-100: #fbe9df;
  --tpl-orange-050: #fdf5f0;

  /* --- Marca: dorado (acento sobre fondo oscuro) --------------------------- */
  --tpl-gold-600: #b8912a;
  --tpl-gold-500: #d4af37;
  --tpl-gold-400: #f2cf4a;
  --tpl-gold-100: #fdf3d2;

  /* --- Verde de apoyo (etiquetas de naturaleza) ---------------------------- */
  --tpl-teal-700: #14595b;
  --tpl-teal-600: #1a6e70;
  --tpl-teal-500: #218e91;
  --tpl-teal-100: #e4f2f2;

  /* WhatsApp: el verde de marca (#25D366) con texto blanco da 1.98:1.
     Esta variante mas profunda mantiene la lectura de marca con 5.4:1. */
  --tpl-whatsapp: #0f7a4f;
  --tpl-whatsapp-hover: #0b6340;

  /* --- Neutros ------------------------------------------------------------- */
  --tpl-ink-900: #0f1c28;
  --tpl-ink: #14212e;
  --tpl-ink-2: #33465a;
  --tpl-ink-3: #5a6b7d;
  /* 5.0:1 sobre blanco y 4.7:1 sobre --tpl-surface-2. El tono anterior
     (#6b7c8d) se quedaba en 4.29:1, bajo el minimo AA para texto normal. */
  --tpl-muted: #5f7183;
  --tpl-line: #dfe6ee;
  --tpl-line-2: #ccd7e2;
  --tpl-surface: #ffffff;
  --tpl-surface-2: #f6f9fc;
  --tpl-surface-3: #eef3f8;
  --tpl-surface-warm: #faf7f0;

  /* --- Semanticos ---------------------------------------------------------- */
  --tpl-success: #1d7a4c;
  --tpl-success-bg: #e6f4ec;
  --tpl-warning: #96610f;
  --tpl-warning-bg: #fdf1dc;
  --tpl-danger: #a5322b;
  --tpl-danger-bg: #fbeae9;
  --tpl-info: var(--tpl-navy-800);
  --tpl-info-bg: var(--tpl-navy-100);

  /* --- Tipografia ---------------------------------------------------------- */
  --tpl-font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --tpl-font-display: 'Lora', Georgia, 'Times New Roman', serif;

  /* Escala fluida: el mismo salto se ve bien de 360px a 1440px sin media queries. */
  --tpl-text-xs: 0.75rem;
  --tpl-text-sm: 0.8125rem;
  --tpl-text-base: 0.9375rem;
  --tpl-text-md: 1rem;
  --tpl-text-lg: clamp(1.05rem, 0.98rem + 0.35vw, 1.2rem);
  --tpl-text-xl: clamp(1.25rem, 1.12rem + 0.6vw, 1.5rem);
  --tpl-text-2xl: clamp(1.5rem, 1.28rem + 1.05vw, 2.05rem);
  --tpl-text-3xl: clamp(1.9rem, 1.5rem + 1.9vw, 2.9rem);
  --tpl-text-4xl: clamp(2.35rem, 1.6rem + 3.4vw, 4.2rem);

  --tpl-leading-tight: 1.12;
  --tpl-leading-snug: 1.3;
  --tpl-leading-normal: 1.6;
  --tpl-leading-relaxed: 1.7;

  --tpl-tracking-tight: -0.03em;
  --tpl-tracking-normal: 0;
  --tpl-tracking-wide: 0.08em;
  --tpl-tracking-caps: 0.16em;

  /* --- Espaciado (base 4px) ------------------------------------------------ */
  --tpl-space-1: 4px;
  --tpl-space-2: 8px;
  --tpl-space-3: 12px;
  --tpl-space-4: 16px;
  --tpl-space-5: 20px;
  --tpl-space-6: 24px;
  --tpl-space-8: 32px;
  --tpl-space-10: 40px;
  --tpl-space-12: 48px;
  --tpl-space-16: 64px;
  --tpl-space-20: 80px;

  /* Ritmo vertical de seccion: se comprime solo en pantallas chicas. */
  --tpl-section-y: clamp(48px, 6vw, 96px);
  --tpl-gutter: clamp(16px, 4vw, 40px);
  --tpl-container: 1280px;
  --tpl-container-narrow: 780px;

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

  /* --- Sombras (tintadas con el azul de marca, no gris neutro) ------------- */
  --tpl-shadow-xs: 0 1px 2px rgba(0, 30, 60, 0.05);
  --tpl-shadow-sm: 0 1px 2px rgba(0, 30, 60, 0.04), 0 6px 16px rgba(0, 30, 60, 0.06);
  --tpl-shadow-md: 0 2px 4px rgba(0, 30, 60, 0.05), 0 14px 32px rgba(0, 30, 60, 0.09);
  --tpl-shadow-lg: 0 6px 12px rgba(0, 30, 60, 0.07), 0 28px 56px rgba(0, 30, 60, 0.13);
  --tpl-shadow-xl: 0 12px 24px rgba(0, 16, 32, 0.14), 0 40px 80px rgba(0, 16, 32, 0.24);

  /* --- Movimiento ---------------------------------------------------------- */
  --tpl-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --tpl-ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  --tpl-duration-fast: 140ms;
  --tpl-duration: 240ms;
  --tpl-duration-slow: 420ms;

  /* --- Cromo fijo ---------------------------------------------------------- */
  --tpl-header-h: 72px;
  --tpl-ribbon-h: 46px;
  --tpl-focus-ring: 0 0 0 3px rgba(0, 90, 160, 0.35);

  /* --- Capas --------------------------------------------------------------- */
  --tpl-z-header: 200;
  --tpl-z-ribbon: 150;
  --tpl-z-menu: 210;
  --tpl-z-overlay: 300;
}

/* --- Alias heredados -------------------------------------------------------
   index.css, tpl-shell.css, parcela.css, cotizador.css y el CRM siguen usando
   estos nombres. Apuntarlos aqui evita reescribir miles de declaraciones y, a
   la vez, deja una sola paleta efectiva en todo el sitio. */
:root {
  --blue: var(--tpl-navy-900);
  --blue-2: var(--tpl-navy-800);
  --blue-3: var(--tpl-navy-700);
  --orange: var(--tpl-orange-600);
  --orange-2: var(--tpl-orange-500);
  --gold: var(--tpl-gold-500);
  --gold-light: var(--tpl-gold-400);
  --ink: var(--tpl-ink);
  --muted: var(--tpl-muted);
  --line: var(--tpl-line);
  --soft: var(--tpl-surface-2);
  --white: var(--tpl-surface);
  --glass: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.5);
  --shadow-soft: var(--tpl-shadow-md);
  --shadow-hover: var(--tpl-shadow-lg);
  --transition: all var(--tpl-duration) var(--tpl-ease-out);
  --radius-sm: var(--tpl-radius-xs);
  --radius-md: var(--tpl-radius-sm);
  --radius-lg: var(--tpl-radius-md);
  --radius-xl: var(--tpl-radius-lg);
  --header-h: var(--tpl-header-h);
  --commune-h: var(--tpl-ribbon-h);
  --font-sans: var(--tpl-font-sans);
  --font-serif: var(--tpl-font-display);
  --font-family: var(--tpl-font-sans);
}

/* === 2. RESET + BASE ===================================================== */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  /* El header pegajoso tapaba el destino de cada ancla (#buscador, #resultados). */
  scroll-padding-top: calc(var(--tpl-header-h) + var(--tpl-ribbon-h) + 12px);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--tpl-font-sans);
  font-size: var(--tpl-text-md);
  line-height: var(--tpl-leading-normal);
  color: var(--tpl-ink);
  background: var(--tpl-surface-2);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body, button, input, select, textarea { font-family: var(--tpl-font-sans); }

img, svg, video, canvas, iframe { display: block; max-width: 100%; }
img, video { height: auto; }

button, select { font: inherit; cursor: pointer; }
a { color: inherit; }
p { margin: 0; }
ol, ul { list-style: none; margin: 0; padding: 0; }

::selection { background: rgba(212, 175, 55, 0.4); color: var(--tpl-ink-900); }

/* Barras de scroll discretas donde el navegador lo permite. */
* { scrollbar-width: thin; scrollbar-color: var(--tpl-line-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--tpl-line-2); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--tpl-navy-300); background-clip: content-box; }

/* === 3. TIPOGRAFIA ======================================================= */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--tpl-font-display);
  font-weight: 600;
  /* Sobre fondo claro el titulo va en azul de marca; sobre fondo oscuro ese
     azul es ilegible, asi que los bloques oscuros redefinen el token en vez de
     repetir `color:#fff` en cada h1/h2 suelto. */
  color: var(--tpl-heading-color, var(--tpl-navy-900));
  letter-spacing: var(--tpl-tracking-tight);
  line-height: var(--tpl-leading-tight);
  text-wrap: balance;
}
h1 { font-size: var(--tpl-text-4xl); }
h2 { font-size: var(--tpl-text-3xl); }
h3 { font-size: var(--tpl-text-xl); line-height: var(--tpl-leading-snug); }
h4 { font-size: var(--tpl-text-lg); line-height: var(--tpl-leading-snug); }

/* Superficies oscuras: gancho generico para paginas y componentes. */
.tpl-on-dark,
.section-dark,
[data-surface="dark"],
.tpl-footer { --tpl-heading-color: #fff; }

/* Los parrafos largos se leen mejor con medida controlada. */
p { text-wrap: pretty; }

small { font-size: var(--tpl-text-sm); }
strong, b { font-weight: 700; }

.tpl-eyebrow,
.tpl-section-eyebrow,
.context-label,
.tpl-campo-story__eyebrow {
  display: inline-block;
  font-family: var(--tpl-font-sans);
  font-size: var(--tpl-text-xs);
  font-weight: 800;
  letter-spacing: var(--tpl-tracking-caps);
  text-transform: uppercase;
  color: var(--tpl-navy-700);
}

.tpl-lead {
  font-size: var(--tpl-text-lg);
  line-height: var(--tpl-leading-relaxed);
  color: var(--tpl-ink-3);
}

/* === 4. LAYOUT =========================================================== */
.tpl-container,
.container, .shell, .page-shell, .content-shell {
  width: min(var(--tpl-container), 100% - (var(--tpl-gutter) * 2));
  margin-inline: auto;
}
.tpl-container--narrow { width: min(var(--tpl-container-narrow), 100% - (var(--tpl-gutter) * 2)); }
.tpl-section { padding-block: var(--tpl-section-y); }

/* === 5. SALTO AL CONTENIDO =============================================== */
.tpl-skip-link {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: calc(var(--tpl-z-overlay) + 10);
  padding: 12px 20px;
  border-radius: var(--tpl-radius-xs);
  background: var(--tpl-navy-900);
  color: #fff;
  font-size: var(--tpl-text-base);
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--tpl-shadow-lg);
  transform: translateY(-160%);
  transition: transform var(--tpl-duration) var(--tpl-ease);
}
.tpl-skip-link:focus-visible { transform: translateY(0); }

/* === 6. FOCO ============================================================= */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--tpl-navy-700);
  outline-offset: 2px;
  border-radius: var(--tpl-radius-xs);
}
/* Sobre superficies oscuras el anillo azul desaparece: se usa el dorado. */
:where(.tpl-search-widget, .tpl-footer, .tpl-campo-story, .section-dark)
  :where(a, button, input, select, textarea):focus-visible {
  outline-color: var(--tpl-gold-400);
}

/* === 7. HEADER =========================================================== */
.tpl-header {
  position: sticky;
  top: 0;
  z-index: var(--tpl-z-header);
  display: flex;
  align-items: center;
  gap: var(--tpl-space-6);
  height: var(--tpl-header-h);
  padding-inline: var(--tpl-gutter);
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid rgba(0, 43, 84, 0.08);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  font-family: var(--tpl-font-sans);
}
/* Sin soporte de backdrop-filter el header translucido se ve sucio. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .tpl-header { background: #fff; }
}

.tpl-brand {
  display: inline-flex;
  align-items: center;
  margin-right: auto;
  text-decoration: none;
  border-radius: var(--tpl-radius-sm);
}
.tpl-brand img {
  height: 46px;
  width: auto;
  transition: transform var(--tpl-duration) var(--tpl-ease);
}
.tpl-brand:hover img { transform: scale(1.04); }

.tpl-nav {
  display: flex;
  align-items: center;
  gap: var(--tpl-space-1);
}
.tpl-nav a {
  position: relative;
  padding: 9px 12px;
  border-radius: var(--tpl-radius-xs);
  color: var(--tpl-ink-2);
  font-size: var(--tpl-text-base);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--tpl-duration-fast) ease, background-color var(--tpl-duration-fast) ease;
}
.tpl-nav a:hover { color: var(--tpl-navy-900); background: var(--tpl-navy-050); }

/* Subrayado de la pagina actual: lo marca js/tpl-shell.js con aria-current. */
.tpl-nav a[aria-current="page"] { color: var(--tpl-navy-900); }
.tpl-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: var(--tpl-gold-500);
}

/* CTA "Publicar": es la unica accion primaria del header. */
.tpl-nav .tpl-publish,
a.tpl-publish {
  margin-left: var(--tpl-space-2);
  padding: 10px 20px;
  border-radius: var(--tpl-radius-pill);
  background: var(--tpl-navy-800);
  color: #fff !important;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(0, 63, 122, 0.24);
  transition: background-color var(--tpl-duration) var(--tpl-ease-out),
              box-shadow var(--tpl-duration) var(--tpl-ease-out),
              transform var(--tpl-duration) var(--tpl-ease-out);
}
.tpl-nav .tpl-publish:hover,
a.tpl-publish:hover {
  background: var(--tpl-navy-900);
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(0, 43, 84, 0.3);
}
.tpl-nav .tpl-publish::after { content: none; }

/* --- Acciones moviles ---------------------------------------------------- */
.tpl-mobile-actions {
  display: none;
  align-items: center;
  gap: var(--tpl-space-2);
  margin-left: auto;
}
.tpl-mobile-actions .tpl-publish { padding: 9px 16px; font-size: var(--tpl-text-sm); }
.tpl-mobile-parcelas {
  padding: 9px 10px;
  color: var(--tpl-navy-900);
  font-size: var(--tpl-text-sm);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.tpl-menu-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--tpl-line);
  border-radius: var(--tpl-radius-xs);
  background: #fff;
  color: var(--tpl-navy-900);
  font-size: 1.2rem;
  line-height: 1;
  transition: background-color var(--tpl-duration-fast) ease, border-color var(--tpl-duration-fast) ease;
}
.tpl-menu-button:hover { background: var(--tpl-navy-050); border-color: var(--tpl-navy-200); }
.tpl-menu-button[aria-expanded="true"] { background: var(--tpl-navy-900); border-color: var(--tpl-navy-900); color: #fff; }

/* --- Menu movil ---------------------------------------------------------- */
.tpl-mobile-menu {
  position: absolute;
  top: var(--tpl-header-h);
  left: 0;
  right: 0;
  z-index: var(--tpl-z-menu);
  display: flex;
  flex-direction: column;
  padding: var(--tpl-space-2) 0 var(--tpl-space-3);
  background: #fff;
  border-bottom: 1px solid var(--tpl-line);
  box-shadow: var(--tpl-shadow-lg);
}
.tpl-mobile-menu[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .tpl-mobile-menu { animation: tpl-menu-in var(--tpl-duration) var(--tpl-ease) both; }
}
@keyframes tpl-menu-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}
.tpl-mobile-menu a {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 0 var(--tpl-gutter);
  color: var(--tpl-ink);
  font-size: var(--tpl-text-md);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--tpl-surface-2);
  transition: background-color var(--tpl-duration-fast) ease, color var(--tpl-duration-fast) ease;
}
.tpl-mobile-menu a:last-child { border-bottom: none; }
.tpl-mobile-menu a:hover,
.tpl-mobile-menu a:focus-visible { background: var(--tpl-navy-050); color: var(--tpl-navy-900); }
.tpl-mobile-menu a[aria-current="page"] {
  color: var(--tpl-navy-900);
  box-shadow: inset 3px 0 0 var(--tpl-gold-500);
}

/* === 8. FOOTER =========================================================== */
.tpl-footer {
  display: grid;
  place-items: center;
  gap: var(--tpl-space-4);
  padding: var(--tpl-space-16) var(--tpl-gutter) var(--tpl-space-10);
  background: var(--tpl-navy-950);
  color: rgba(255, 255, 255, 0.72);
  text-align: center;
  font-family: var(--tpl-font-sans);
}
.tpl-footer img { height: 52px; width: auto; }
.tpl-footer p {
  max-width: 46ch;
  color: rgba(255, 255, 255, 0.72);
  font-size: var(--tpl-text-base);
}
.tpl-footer h2, .tpl-footer h3, .tpl-footer strong { color: #fff; }
.tpl-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--tpl-space-1) var(--tpl-space-2);
  padding-top: var(--tpl-space-2);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  width: min(900px, 100%);
  margin-top: var(--tpl-space-2);
}
.tpl-footer nav a {
  padding: 8px 12px;
  border-radius: var(--tpl-radius-xs);
  color: rgba(255, 255, 255, 0.8);
  font-size: var(--tpl-text-base);
  font-weight: 600;
  text-decoration: none;
  transition: color var(--tpl-duration-fast) ease, background-color var(--tpl-duration-fast) ease;
}
.tpl-footer nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

.tpl-footer-contact {
  color: rgba(255, 255, 255, 0.8);
  font-size: var(--tpl-text-base);
  font-weight: 600;
  text-decoration: none;
}
.tpl-footer-contact:hover { color: #fff; }

/* Puerta de entrada al CRM. Antes era un texto al 55% de opacidad que los
   asesores no encontraban: ahora es un boton legible, tambien en movil. */
.tpl-internal-access {
  display: inline-flex;
  align-items: center;
  gap: var(--tpl-space-2);
  margin-top: var(--tpl-space-5);
  padding: 12px 24px;
  border: 1px solid rgba(242, 207, 74, 0.45);
  border-radius: var(--tpl-radius-pill);
  background: rgba(242, 207, 74, 0.1);
  color: var(--tpl-gold-400);
  font-size: var(--tpl-text-base);
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: color var(--tpl-duration-fast) ease,
              border-color var(--tpl-duration-fast) ease,
              background-color var(--tpl-duration-fast) ease,
              transform var(--tpl-duration-fast) ease;
}
.tpl-internal-access svg { width: 17px; height: 17px; flex: none; }
.tpl-internal-access:hover {
  border-color: var(--tpl-gold-400);
  background: var(--tpl-gold-400);
  color: var(--tpl-navy-950);
  transform: translateY(-1px);
}

/* === 9. BOTONES ========================================================== */
.tpl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--tpl-space-2);
  min-height: 46px;
  padding: 12px 22px;
  border: 1px solid transparent;
  border-radius: var(--tpl-radius-xs);
  font-size: var(--tpl-text-base);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--tpl-duration) var(--tpl-ease-out),
              border-color var(--tpl-duration) var(--tpl-ease-out),
              color var(--tpl-duration) var(--tpl-ease-out),
              box-shadow var(--tpl-duration) var(--tpl-ease-out),
              transform var(--tpl-duration) var(--tpl-ease-out);
}
.tpl-btn:hover { transform: translateY(-1px); }
.tpl-btn:active { transform: translateY(0); }
.tpl-btn[disabled], .tpl-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.tpl-btn--primary { background: var(--tpl-orange-600); color: #fff; box-shadow: 0 4px 14px rgba(168, 65, 15, 0.24); }
.tpl-btn--primary:hover { background: var(--tpl-orange-700); box-shadow: 0 8px 22px rgba(168, 65, 15, 0.3); }

.tpl-btn--navy { background: var(--tpl-navy-800); color: #fff; box-shadow: 0 4px 14px rgba(0, 63, 122, 0.22); }
.tpl-btn--navy:hover { background: var(--tpl-navy-900); box-shadow: 0 8px 22px rgba(0, 43, 84, 0.28); }

.tpl-btn--secondary { background: #fff; border-color: var(--tpl-line-2); color: var(--tpl-navy-900); box-shadow: var(--tpl-shadow-xs); }
.tpl-btn--secondary:hover { border-color: var(--tpl-navy-700); background: var(--tpl-navy-050); }

.tpl-btn--ghost { background: transparent; color: var(--tpl-navy-800); }
.tpl-btn--ghost:hover { background: var(--tpl-navy-050); }

.tpl-btn--gold { background: var(--tpl-gold-400); color: var(--tpl-navy-900); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18); }
.tpl-btn--gold:hover { background: #fff; }

.tpl-btn--whatsapp { background: var(--tpl-whatsapp); color: #fff; box-shadow: 0 4px 14px rgba(15, 122, 79, 0.26); }
.tpl-btn--whatsapp:hover { background: var(--tpl-whatsapp-hover); box-shadow: 0 8px 22px rgba(15, 122, 79, 0.32); }

.tpl-btn--pill { border-radius: var(--tpl-radius-pill); }
.tpl-btn--block { width: 100%; }
.tpl-btn--sm { min-height: 38px; padding: 8px 16px; font-size: var(--tpl-text-sm); }
.tpl-btn--lg { min-height: 54px; padding: 15px 30px; font-size: var(--tpl-text-md); }

/* Compatibilidad con las clases que ya usaban las paginas internas. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--tpl-space-2); min-height: 46px; border: 1px solid transparent; border-radius: var(--tpl-radius-sm); font-weight: 700; text-decoration: none; cursor: pointer; transition: var(--transition); }
.btn-primary { background: var(--tpl-navy-800); color: #fff; }
.btn-primary:hover { background: var(--tpl-navy-900); }
.btn-secondary { background: #fff; border-color: var(--tpl-line-2); color: var(--tpl-navy-900); }
.btn-secondary:hover { border-color: var(--tpl-navy-700); }

/* === 10. FORMULARIOS ===================================================== */
label { display: block; color: var(--tpl-ink-2); font-size: var(--tpl-text-base); font-weight: 600; }

input, select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid var(--tpl-line-2);
  border-radius: var(--tpl-radius-xs);
  background: #fff;
  color: var(--tpl-ink);
  font-size: var(--tpl-text-md);
  transition: border-color var(--tpl-duration-fast) ease, box-shadow var(--tpl-duration-fast) ease;
}
input[type="checkbox"], input[type="radio"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  accent-color: var(--tpl-navy-800);
}
textarea { min-height: 120px; resize: vertical; }

input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: var(--tpl-navy-300); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--tpl-navy-700);
  box-shadow: var(--tpl-focus-ring);
}
input::placeholder, textarea::placeholder { color: #93a4b4; }
input:disabled, select:disabled, textarea:disabled { background: var(--tpl-surface-2); color: var(--tpl-muted); cursor: not-allowed; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--tpl-danger);
  box-shadow: 0 0 0 3px rgba(165, 50, 43, 0.18);
}

/* La flecha nativa del select no se puede pintar; se reemplaza por una propia. */
select:not([multiple]):not([size]) {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%235a6b7d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 8 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
}

fieldset { margin: 0; padding: var(--tpl-space-5); border: 1px solid var(--tpl-line); border-radius: var(--tpl-radius-sm); }
legend { padding-inline: var(--tpl-space-2); font-weight: 700; color: var(--tpl-navy-900); }

.tpl-field { display: grid; gap: var(--tpl-space-2); }
.tpl-help { color: var(--tpl-muted); font-size: var(--tpl-text-sm); }
.tpl-error { color: var(--tpl-danger); font-size: var(--tpl-text-sm); font-weight: 600; }

/* === 11. TARJETAS Y DISTINTIVOS ========================================== */
.tpl-card {
  background: var(--tpl-surface);
  border: 1px solid var(--tpl-line);
  border-radius: var(--tpl-radius-md);
  box-shadow: var(--tpl-shadow-sm);
}

.tpl-badge, .badge, .pill, .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--tpl-radius-pill);
  font-size: var(--tpl-text-xs);
  font-weight: 700;
  line-height: 1.4;
}
.tpl-badge--success, .status-success, [data-status="success"] { background: var(--tpl-success-bg); color: var(--tpl-success); }
.tpl-badge--warning, .status-warning, [data-status="warning"] { background: var(--tpl-warning-bg); color: var(--tpl-warning); }
.tpl-badge--danger, .status-danger, [data-status="danger"] { background: var(--tpl-danger-bg); color: var(--tpl-danger); }
.tpl-badge--info, .status-info, [data-status="info"] { background: var(--tpl-info-bg); color: var(--tpl-info); }

/* === 12. TABLAS ========================================================== */
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th {
  background: var(--tpl-surface-2);
  color: var(--tpl-ink-3);
  font-size: var(--tpl-text-xs);
  font-weight: 800;
  letter-spacing: var(--tpl-tracking-wide);
  text-transform: uppercase;
}
th, td { padding: 13px 14px; border-bottom: 1px solid var(--tpl-line); text-align: left; }
tbody tr:hover { background: var(--tpl-surface-2); }

/* === 13. ESTADOS ========================================================= */
.tpl-state {
  display: grid;
  gap: var(--tpl-space-2);
  place-items: center;
  padding: var(--tpl-space-12) var(--tpl-space-6);
  border: 1px dashed var(--tpl-line-2);
  border-radius: var(--tpl-radius-md);
  background: linear-gradient(180deg, #fff, var(--tpl-surface-2));
  color: var(--tpl-ink-3);
  text-align: center;
}

@keyframes tpl-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes tpl-fade-up { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }

/* === 14. RESPONSIVE DEL SHELL ============================================ */
@media (max-width: 900px) {
  .tpl-nav a { padding: 9px 9px; font-size: var(--tpl-text-sm); }
}

@media (max-width: 820px) {
  :root { --tpl-header-h: 64px; }
  .tpl-nav { display: none; }
  .tpl-mobile-actions { display: flex; }
  .tpl-brand img { height: 40px; }
  .tpl-footer { padding-top: var(--tpl-space-12); }
}

@media (max-width: 480px) {
  .tpl-mobile-parcelas { display: none; }
  .tpl-footer nav a { padding: 8px 10px; font-size: var(--tpl-text-sm); }
}

/* === 15. ACCESIBILIDAD DE MOVIMIENTO ===================================== */
@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;
    scroll-behavior: auto !important;
  }
}

/* === 16. IMPRESION ======================================================= */
@media print {
  .tpl-header, .tpl-mobile-menu, .commune-ribbon, .priority-bar, .tpl-skip-link { display: none !important; }
  body { background: #fff; }
  .tpl-footer { background: #fff; color: #000; }
}
