/* 
   Shoppers Express - Sistema de Diseño y estilos (Accesible v2.1)
npm run lint:css    
*/

/* 
 * 1. VARIABLES Y ESTILOS BASE
 */
:root {
  /* Paleta de Colores (Ajustada para Accesibilidad AA - Contraste 4.5:1+) */
  --color-primary: #005a9e;      /* Azul más oscuro */
  --color-secondary: #d95d2e;    /* Naranja con mejor contraste */
  --color-danger: #c52233;       /* Rojo más legible */
  --color-success-text: #166534;
  
  /* Textos */
  --color-text: #1e293b;         /* Gris casi negro (Slate-800) */
  --color-text-muted: #475569;   /* Gris medio oscuro (Slate-600) */
  
  /* Fondos */
  --color-bg-body: #f8fafc;      /* Blanco humo */
  --color-bg-card: #ffffff;
  --color-bg-footer: #0f172a;    /* Footer casi negro */
  --color-bg-admin: #334155;     /* Slate-700 */

  /* Bordes */
  --color-border: #cbd5e1;       /* Slate-300 */

  /* Geometría y Sombras */
  --border-radius: 0.375rem;
  --panel-radius: 0.5rem;
  --panel-shadow: 0 1px 2px rgba(0,0,0,0.06);

  /* Gradientes */
  --accent-grad-h: linear-gradient(90deg, var(--color-secondary) 0%, var(--color-primary) 100%);
  --accent-grad-v: linear-gradient(180deg, var(--color-secondary) 0%, var(--color-primary) 100%);

  /* Interacción */
  --focus-ring: 3px solid #66a3ff;

    /* ENLACE (Azul oscuro ) */
  --color-link: #0056b3; 
    --color-link-hover: #003d66; /* Azul oscuro */
}

/* =========================================
   DEFINICIONES DE TEMA (Oscuro / Alto Contraste / Invertido)
   ========================================= */

/* 1. Modo Oscuro */
[data-theme="dark"] {
  --color-bg-body: #0f172a;
  --color-bg-card: #1e293b;
  --color-bg-footer: #020617;
  --color-bg-admin: #0f172a;
  --color-text: #f8fafc;
  --color-text-muted: #cbd5e1;
  --color-border: #334155;
  --color-primary: #38bdf8;
  --color-danger: #f87171;
  --color-success-text: #86efac;
  --panel-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);

  /* Enlaces color celeste brillante para contrastar con fondo oscuro */
  --color-link: #60a5fa; 
    /* HOVER EN MODO OSCURO: Debe ser MÁS CLARO */
  --color-link-hover: #93c5fd; 
}

/* 2. Alto Contraste */
[data-theme="hc"] {
  --color-bg-body: #000000;
  --color-bg-card: #000000;
  --color-bg-footer: #000000;
  --color-bg-admin: #000000;
  --color-text: #ffffff;
  --color-text-muted: #ffff00;
  --color-primary: #00ffff;
  --color-secondary: #ffff00;
  --color-danger: #ff0000;
  --color-success-text: #00ff00;
  --color-border: #ffffff;
  --panel-shadow: none;

  /* Enlaces amarillos o cian para máximo contraste sobre negro */
  --color-link: #ffff00; 
    /* HOVER EN HC: blanco o cian para destacar sobre el amarillo */
  --color-link-hover: #00ffff; 
}

/* Superficies de encabezado con fondo de marca en alto contraste. */
[data-theme="hc"] :where(
  .app-shell__header,
  .inicio-hero,
  .section-header,
  .post-header,
  .prose > header.text-center
) {
  background-color: #000000 !important;
  border-bottom: 2px solid #ffffff;
}

/* 3. Inversión de Colores (Filtro CSS) */
/* Esta clase la agrega el JS al <body> */
.invert-theme {
  filter: invert(1) hue-rotate(180deg);
}

/* Evitamos que las imágenes y videos se vean como negativos de foto */
.invert-theme img,
.invert-theme video,
.invert-theme iframe,
.invert-theme .post-card__img {
  filter: invert(1) hue-rotate(180deg);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  margin: 0;
  background-color: var(--color-bg-body);
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.6;
}

main {
  padding: 1.5rem;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--color-text);
  margin-top: 0;
  margin-bottom: 1rem;
  font-weight: 700;
}

/* Evita desbordes en títulos largos */
h1, h2, h3 {
  overflow-wrap: anywhere;
}

h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

/* Enlaces Generales */
a {
    color: var(--color-link); /* Usar variable */
  text-decoration: none;
  font-weight: 500;
}

a:hover {
  text-decoration: underline;
    color: var(--color-link-hover);
}

fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

legend {
  padding: 0;
  font-weight: 600;
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

hr {
  margin: 2rem 0;
  border: 0;
  border-top: 1px solid var(--color-border);
}

/* 
 * 2. LAYOUT Y ESTRUCTURA DE PÁGINA
 */
/* --- A. Superficies de encabezado con fondo de marca --- */
:where(
  .app-shell__header,
  .inicio-hero,
  .section-header,
  .post-header,
  .prose > header.text-center
) {
  background-color: var(--color-primary);
  color: #ffffff;
  padding: 1rem 1.5rem;
  text-align: center;
}

/* El contenido conserva contraste sobre Azul de Mando. */
:where(
  .app-shell__header,
  .inicio-hero,
  .section-header,
  .post-header,
  .prose > header.text-center
) :where(a, h1, h2, h3, p, .page-intro, .intro-text) {
  color: #ffffff !important; 
  text-decoration: none;
  opacity: 1 !important;
}
:where(
  .app-shell__header,
  .inicio-hero,
  .section-header,
  .post-header,
  .prose > header.text-center
) a:hover { text-decoration: underline; }

/* --- B. Header Interno (Perfil, Dashboard, Admin) --- */
/* Este header vive dentro del contenido, sobre fondo blanco */
.page-header {
  background-color: transparent; 
  color: var(--color-text); /* Texto oscuro */
  padding: 0;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Aseguramos contraste oscuro para títulos internos */
.page-header h1,
.page-header h2,
.page-header h3 {
  color: var(--color-text) !important;
}

@media (max-width: 767px) {
  .page-header--list > :where(h1, .btn) {
    box-sizing: border-box;
    flex: 1 1 100%;
    width: 100%;
  }
}

/* --- C. Textos y Contenedores --- */
.page-intro {
  color: var(--color-text-muted); /* Gris oscuro (definido en root) */
  font-size: 1.125rem;
  margin-bottom: 1.5rem;
  width: 100%;
}

/* Superficies administrativas: una secuencia clara de contexto, datos y acción. */
.operational-flow {
  display: grid;
  gap: 1.5rem;
}

.operational-flow > * {
  min-width: 0;
  margin: 0;
}

.operational-flow > .page-intro {
  max-width: 70ch;
}

/* CRUD de administradores: recorrido contenido y continuidad entre vistas. */
.admin-account-flow {
  box-sizing: border-box;
  display: grid;
  gap: 1.5rem;
  width: 100%;
  margin-inline: auto;
}

.admin-account-flow--form {
  max-width: 48rem;
}

.admin-account-flow--detail {
  max-width: 56rem;
}

.admin-account-flow > * {
  min-width: 0;
  margin-block: 0;
}

.admin-account-flow .page-intro {
  margin: 0;
  font-size: 1rem;
}

.admin-account-header {
  align-items: flex-start;
  margin: 0;
}

.admin-account-flow__heading {
  flex: 1 1 24rem;
  min-width: 0;
}

.admin-account-flow__heading h1 {
  margin-bottom: 0.5rem;
  overflow-wrap: anywhere;
}

.admin-account-flow__summary {
  max-width: 70ch;
  margin: 0;
  color: var(--color-text-muted);
}

.admin-account-flow .alert {
  margin: 0;
}

.admin-account-flow .btn {
  box-sizing: border-box;
  min-height: 44px;
}

.admin-account-form {
  display: grid;
  gap: 1.5rem;
}

.admin-account-form > fieldset,
.admin-account-form > .form-actions {
  min-width: 0;
  margin: 0;
}

.admin-account-form > .form-actions {
  padding-top: 1.5rem;
}

.admin-account-detail {
  margin: 0;
}

.admin-account-detail > h2 {
  margin-bottom: 1rem;
}

.admin-account-detail__list {
  grid-template-columns: minmax(9rem, 11rem) minmax(0, 1fr);
}

.admin-account-detail__list dd,
.admin-account-detail__list a {
  min-width: 0;
  overflow-wrap: anywhere;
}

.admin-account-actions {
  margin: 0;
}

.admin-account-actions h2 {
  flex: 1 1 100%;
  margin: 0;
}

.admin-account-flow > .danger-zone {
  margin-top: 0;
}

@media (max-width: 599px) {
  .admin-account-header > .btn,
  .admin-account-form__actions > .btn,
  .admin-account-actions > .btn,
  .admin-account-flow .danger-zone .btn {
    width: 100%;
  }

  .admin-account-detail__list {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.25rem;
  }

  .admin-account-detail__list dt:not(:first-child) {
    margin-top: 0.75rem;
  }
}
/* --- E. Excepciones Home (Landing) --- */
#intro,
#como-empezar-titulo,
.section-header .intro-text,
.section-header p { /* <--- Recuperado */
  color: #ffffff !important;
  opacity: 1 !important;
}
/* Resto de headers de sección normales */
.section-header h2 { color: var(--color-text); }

/* =========================================
   HEADER PRINCIPAL (LOGOTIPO Y SLOGAN)
   ========================================= */

/* Contenedor Flex para alinear Logo y Slogan */
.header-brand-bar {
  display: flex;
  align-items: center;
  justify-content: center; /* En móvil centrado */
  flex-wrap: wrap;
  gap: 0.5rem;
}

@media (min-width: 768px) {
  .header-brand-bar {
    justify-content: space-between; /* Desktop: Logo izq, Slogan der */
  }
}

/* Enlace del Logo */
.brand-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  color: #ffffff !important; /* Forzamos blanco */
}

.brand-link:hover {
  text-decoration: underline;
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.15em;
  opacity: 1;
}

.brand-link:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 4px;
  border-radius: var(--border-radius);
  text-decoration: underline;
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.15em;
}

/* Texto del Logo */
.brand-text {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em; /* Un toque moderno, letras un poco más juntas */
}

/* Slogan / Tagline */
.brand-tagline {
  font-size: 0.9rem;
  font-weight: 500;
  /* Blanco con 85% de opacidad: se ve "muted" pero limpio sobre azul */
  color: rgba(255, 255, 255, 0.85); 
  display: none; /* Oculto por defecto (móvil) */
}

@media (min-width: 768px) {
  .brand-tagline {
    display: block; /* Visible en desktop */
  }
}

/* =========================================
   FOOTER (PIE DE PÁGINA)
   ========================================= */

.app-shell__footer {
  background-color: var(--color-bg-footer);
  color: #ffffff;
  padding: 3rem 0 2rem;
  font-size: 0.875rem;
  margin-top: 3rem;
  text-align: left;
}

/* El pie administrativo conserva la identidad sin repetir contenido comercial. */
.app-shell__footer--admin {
  margin-top: 2rem;
  padding: 1rem 0;
}

/* Títulos de columnas */
.footer-title {
  color: #ffffff;
  font-weight: 700;
  font-size: 1rem;
  margin: 0 0 1rem;
  display: block;
  line-height: 1.3;
}

/* Grid Layout */
.footer-grid {
  display: grid;
  gap: 2rem;
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .footer-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Enlaces Generales */
.app-shell__footer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: #ffffff !important;
  text-decoration: none;
  font-weight: 500;
}

.app-shell__footer a:hover {
  text-decoration: underline;
  opacity: 0.9;
}

.app-shell__footer a:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
  border-radius: 0.25rem;
  text-decoration: underline;
}

/* Listas */
.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-links li {
  margin-bottom: 0.5rem;
}

/* Dirección */
.footer-address {
  font-style: normal;
  line-height: 1.6;
  color: #cbd5e1;
}

.footer-address p {
  margin: 0 0 0.5rem 0;
}

.footer-address a {
  color: #cbd5e1 !important;
  font-weight: 400;
}

.footer-address a:hover {
  color: #ffffff !important;
}

/* --- ESTILOS DE PAGOS (Badge / Píldoras) --- */
.payment-icons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.badge-payment {
  /* Borde fino semitransparente */
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  color: #ffffff;
  /* Fondo muy sutil, casi transparente */
  background-color: rgba(255, 255, 255, 0.1); 
  display: inline-block;
  white-space: nowrap;
}

/* Nota pequeña debajo de pagos */
.footer-note {
  font-size: 0.75rem;
  color: #94a3b8; /* Gris azulado medio */
  margin: 0;
}

/* --- BARRA INFERIOR (Copyright + Admin) --- */
.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 1.5rem;
  text-align: center;
  color: #cbd5e1;
}

.footer-bottom p {
  margin: 0; /* Quitamos margen por defecto del párrafo */
}

/* Separador vertical (|) */
.footer-separator {
  color: #334155;
  margin: 0 0.5rem;
}

/* --- ENLACE "DISCRETO" ADMIN --- */
.app-shell__footer .admin-login-link {
       /* Es visible, pero al ser gris mate, no destaca como un botón primario. */
  color: #94a3b8 !important; 
  font-size: 0.875rem;
  text-decoration: none;
  transition: color 0.3s ease;
    margin-left: 0.5rem; /* Pequeña separación del separador vertical */
}

.app-shell__footer .admin-login-link:hover,
.app-shell__footer .admin-login-link:focus-visible {
  /* Al pasar mouse o teclado, se ilumina a blanco */
  color: #ffffff !important; 
  text-decoration: underline;
}
/* Override para Modo Oscuro/HC del link admin */
[data-theme="dark"] .admin-login-link,
[data-theme="hc"] .admin-login-link {
  color: var(--color-text-muted) !important; /* Se adapta al gris claro del tema */
}

/* Utilidad de alineación */
.text-center {
  text-align: center;
}

/* Estilos para el logo y branding (CSP Fix) */
.brand-logo {
  font-size: 1.5rem;
  text-decoration: none;  
}

.nav__brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffffff !important;
  text-decoration: none;
}

/* --- Layouts de Grid --- */
.form-layout-grid,
.profile-layout-grid,
.details-layout-grid,
.grid-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

.form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

@media (min-width: 768px) {
  .grid-container.cols-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-container.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .form-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .grid-container.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .form-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
  
  .form-layout-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .form-main-column { grid-column: span 2 / span 2; }
  .form-sidebar-column { grid-column: span 1 / span 1; }

  .profile-layout-grid,
  .details-layout-grid {
    grid-template-columns: 2fr 1fr;
  }
}

.form-sidebar-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

.profile-main-column, .profile-sidebar-column,
.details-main-column, .details-sidebar-column {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

@media (max-width: 1023px) { 
  .form-layout-grid { grid-template-columns: 1fr; }
  .form-main-column, .form-sidebar-column { grid-column: auto; }
}


/* 
 * 3. COMPONENTES
 */

/* --- Navegación --- */
.responsive-nav {
  position: relative;
  width: 100%;
  background-color: var(--color-bg-card);
  border-bottom: 1px solid var(--color-border);
}

.admin-nav {
  background-color: var(--color-bg-admin);
}
.admin-nav a { 
  color: #f8fafc; /* Blanco humo */
  font-weight: 500;
}
.admin-nav a:hover { 
  color: #ffffff; 
  text-decoration: underline; 
}

.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  margin: 0.5rem 0 0.5rem auto;
  padding: 0.5rem 0.75rem;
  color: var(--color-text);
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  cursor: pointer;
  font: inherit;
}

.admin-nav .hamburger-btn {
  color: #f8fafc;
  background-color: transparent;
  border-color: #f8fafc;
}

.menu-links {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0.25rem;
}

.responsive-nav.is-enhanced .hamburger-btn {
  display: inline-flex;
}

.responsive-nav.is-enhanced .menu-links {
  display: none;
}

.responsive-nav.is-enhanced.open .menu-links {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
  padding: 0.5rem 1rem 1rem;
  background: var(--color-bg-card);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}
.admin-nav.is-enhanced.open .menu-links { background-color: var(--color-bg-admin); }

.responsive-nav :where(.nav-link, .btn-secondary-sm, .accesible-partials summary),
.responsive-nav .btn {
  min-height: 44px;
}

.responsive-nav .nav-link,
.responsive-nav .btn-secondary-sm {
  display: flex;
  align-items: center;
  box-sizing: border-box;
}

.responsive-nav .btn-secondary-sm {
  justify-content: center;
  padding: 0.5rem 0.75rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  font: inherit;
}

.responsive-nav .nav-link[aria-current="page"] {
  color: #ffffff;
  background-color: var(--color-primary);
  box-shadow: inset 0 -3px 0 #ffffff;
  font-weight: 700;
}

.admin-nav .nav-link[aria-current="page"] {
  color: #1e293b;
  background-color: #ffffff;
  box-shadow: inset 0 -3px 0 var(--color-secondary);
}

[data-theme="dark"] .responsive-nav .nav-link[aria-current="page"] {
  color: #0f172a;
}

[data-theme="hc"] .responsive-nav .nav-link[aria-current="page"] {
  color: #000000;
  background-color: #00ffff;
  box-shadow: inset 0 -4px 0 #ffff00;
}

@media (min-width: 768px) {
  .responsive-nav.is-enhanced .hamburger-btn { display: none; }
  .menu-links { display: flex; flex-flow: row wrap; align-items: center; position: static; width: auto; padding: 0; border: none; background: none !important; }
  .nav-container .menu-links { flex: 1; }
  .responsive-nav.is-enhanced .menu-links,
  .responsive-nav.is-enhanced.open .menu-links { display: flex; position: static; padding: 0; }
  .menu-links .logout-item { margin-left: auto; }
}

.opcion__menu { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.25rem; }
.nav-link { display: block; padding: 0.5rem 0.75rem; border-radius: var(--border-radius); text-decoration: none; }
.nav-link:hover { background-color: var(--color-bg-body); text-decoration: none; }

/* --- Resumen de Pago --- */
.payment-summary {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.payment-total, .payment-balance {
  display: flex;
  justify-content: space-between;
  font-size: 1.125rem;
  color: var(--color-text);
}

.payment-balance {
  font-weight: 700; /* Destaca el saldo final */
}

.payment-breakdown {
  text-align: right;
  /* Usar la variable ajustada para asegurar contraste AA */
  color: var(--color-text-muted); 
}

/* --- Botones --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  border: 1px solid transparent;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  line-height: 1.2;
  min-height: 44px; /* A11y */
}

.btn:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-sm {
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
  min-height: 36px;
}

/* Variantes de Color Accesibles */
.btn-primary { 
  background-color: var(--color-primary); 
  color: #ffffff; 
}
.btn-primary:hover { 
  background-color: #004d80; 
  color: #ffffff;
}

.btn-secondary { 
  background-color: #ffffff; 
  color: var(--color-text); 
  border-color: var(--color-border); 
}
.btn-secondary:hover { 
  background-color: #f1f5f9; 
}

/* --- Confirmación de cotización: secuencia operativa y revisión final --- */
.confirmation-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
  width: 100%;
  max-width: 1100px;
  margin-inline: auto;
  align-items: start;
}

.confirmation-workspace__main,
.confirmation-workspace__review {
  min-width: 0;
}

.confirmation-step__heading {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.confirmation-workspace__main > .confirmation-step__heading:not(:first-child) {
  margin-top: 2rem;
}

.confirmation-workspace__review .form-actions {
  margin-top: 1.5rem;
  padding-top: 1rem;
}

.confirmation-workspace__review .form-actions .btn {
  width: 100%;
  min-height: 44px;
}

.confirmation-step .confirmation-benefit-option {
  display: grid;
  grid-template-columns: 1.25rem minmax(0, 1fr);
  gap: 0.25rem 0.75rem;
  align-items: start;
  min-height: 44px;
}

.confirmation-step .confirmation-benefit-option input[type="checkbox"] {
  grid-column: 1;
  grid-row: 1;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.75rem;
}

.confirmation-step .confirmation-benefit-option label {
  display: flex;
  grid-column: 2;
  grid-row: 1;
  align-items: center;
  min-width: 0;
  min-height: 44px;
  cursor: pointer;
}

.confirmation-step .confirmation-benefit-option input:disabled + label {
  cursor: not-allowed;
}

.confirmation-step .confirmation-benefit-option .form-hint {
  grid-column: 2;
  margin: 0;
}

.confirmation-back-link {
  width: 100%;
  max-width: 1100px;
  margin: 1.5rem auto 0;
}

.confirmation-back-link a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.confirmation-step {
  min-width: 0;
  padding-top: 0.25rem;
}

.confirmation-step__intro {
  max-width: 70ch;
  margin: -0.5rem 0 1.5rem;
  color: var(--color-text-muted);
}

.confirmation-review {
  min-width: 0;
  margin-top: 0;
}

.confirmation-review > legend {
  padding-right: 0.5rem;
  color: var(--color-text);
}

.confirmation-review__list {
  display: grid;
  grid-template-columns: minmax(9rem, auto) minmax(0, 1fr);
  gap: 0.625rem 1rem;
  margin: 0;
}

.confirmation-review__list dt {
  color: var(--color-text-muted);
  font-weight: 600;
}

.confirmation-review__list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.confirmation-review__total {
  color: var(--color-primary);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
}

.confirmation-review__balance {
  font-weight: 700;
}

@media (max-width: 480px) {
  .confirmation-review {
    padding: 1rem;
  }

  .confirmation-review__list {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.125rem;
  }

  .confirmation-review__list dd + dt {
    margin-top: 0.75rem;
  }
}

@media (min-width: 1024px) {
  .confirmation-workspace {
    grid-template-columns: minmax(0, 2fr) minmax(18rem, 1fr);
  }
}

@media (forced-colors: active) {
  .confirmation-review {
    border: 1px solid CanvasText;
    box-shadow: none;
  }

  .confirmation-review__total {
    color: LinkText;
  }
}

[data-theme="dark"] .btn-secondary,
[data-theme="hc"] .btn-secondary {
  background-color: var(--color-bg-card);
  color: var(--color-text);
  border-color: var(--color-border);
}

[data-theme="dark"] .btn-secondary:hover,
[data-theme="hc"] .btn-secondary:hover {
  background-color: var(--color-bg-body);
  color: var(--color-link-hover);
}

[data-theme="hc"] .btn-primary,
[data-theme="hc"] .btn-danger {
  background-color: #000000;
  border-width: 2px;
}

[data-theme="hc"] .btn-primary {
  color: #00ffff;
  border-color: #00ffff;
}

[data-theme="hc"] .btn-danger {
  color: #ff4d4d;
  border-color: #ff4d4d;
}

[data-theme="hc"] .btn-primary:hover {
  background-color: #00ffff;
  color: #000000;
}

[data-theme="hc"] .btn-danger:hover {
  background-color: #ff4d4d;
  color: #000000;
}

.btn-danger { 
  background-color: var(--color-danger); 
  color: #ffffff; 
}
.btn-danger:hover { 
  background-color: #a51d2b; 
}

.btn-accent { 
  background-color: var(--color-secondary); 
  color: #ffffff; 
}
.btn-accent:hover { 
  background-color: #c24e25; 
}

.admin-nav .btn-secondary-sm { background: #fff; color: #111827; border: 1px solid #e5e7eb; }
.admin-nav .btn-secondary-sm:hover { background: #f3f4f6; }

.btn-full-width { display: block; width: 100%; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; }
.btn-icon svg { width: 1.1em; height: 1.1em; margin-right: .5rem; flex-shrink: 0; }

.card .btn {
  margin-top: 1rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}

.admin-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0 0;
  padding: 0;
}

.admin-card-actions li {
  display: flex;
}

.admin-card-actions .btn {
  margin-top: 0;
}

.btn[disabled],
.btn.is-disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.72;
  box-shadow: none;
}

/* --- Editor Markdown (Pestañas) --- */
/* Corrección de accesibilidad para área táctil mínima */
#tab-write, 
#tab-preview {
  display: inline-block;
  min-height: 44px; /* Cumple estándar WCAG AA (Target Size) */
  padding: 0.5rem 1rem;
  font-weight: 500;
  cursor: pointer;
  background-color: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  color: var(--color-text-muted);
}

#tab-write.active, 
#tab-preview.active {
  background-color: var(--color-bg-body);
  border-color: var(--color-border);
  color: var(--color-primary);
  font-weight: 600;
}

/* --- Tarjetas y Paneles --- */
.card { 
  background-color: var(--color-bg-card); 
  padding: 1.5rem; 
  border-radius: 0.5rem; 
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1); 
  border: 1px solid var(--color-border);
}
.card--highlight { border: 1px solid var(--color-border); }
.card--muted { background-color: var(--color-bg-body); }
.card-status { margin: 1rem 0 0; }

.summary-box { background-color: var(--color-bg-body); padding: 1rem; border-radius: var(--border-radius); margin-bottom: 1.5rem; }
.cobro-cliente-grid { margin-bottom: 1.5rem; align-items: start; }
.cobro-cliente-preview { margin-top: 1.5rem; }
.cobro-cliente-preview h3 { font-size: 1.125rem; margin: 0; }
.cobro-cliente-preview .definition-list { margin-top: 0; }
.cobro-cliente-preview-list { margin: 1rem 0 0; padding-left: 1.25rem; }
.cobro-cliente-preview-list li + li { margin-top: 0.5rem; }

.login-panel { 
  background-color: var(--color-bg-card); 
  box-sizing: border-box;
  padding: clamp(1.25rem, 6vw, 2.5rem);
  border-radius: var(--border-radius); 
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  max-width: 400px;
  width: 100%;           /* Asegura que en móviles use el ancho disponible */
  margin: 1rem auto;
  border-top: 5px solid var(--color-primary);
}

.login-panel .input-field { box-sizing: border-box; }
.login-panel .form-group-checkbox { min-height: 2.75rem; }
.login-panel .form-group-checkbox label {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
}

.empty-state-panel { text-align: center; padding: 2rem; border: 1px dashed var(--color-border); border-radius: var(--border-radius); background-color: var(--color-bg-body); }
.empty-state-panel p { margin-bottom: 1rem; }

.client-account-actions,
.client-form-context,
.client-form { max-width: 72ch; }
.client-form-context { margin-bottom: 1.5rem; padding: 1rem; border: 1px solid var(--color-border); border-radius: var(--border-radius); background-color: var(--color-bg-card); }
.client-form-context p { margin: 0; }
.client-form-context p + p { margin-top: 0.5rem; }
.client-account-actions { margin-top: 2rem; }
.client-account-actions__item { margin-top: 1rem; }
.client-account-actions__item h3 { font-size: 1.125rem; margin-bottom: 0.5rem; }
.danger-zone { margin-top: 2rem; }
.danger-zone__title { font-size: 1.125rem; font-weight: 500; color: var(--color-danger); }
.danger-zone__content { margin-top: 0.5rem; padding: 1rem; border: 1px solid var(--color-danger); border-radius: var(--border-radius); background-color: var(--color-bg-card); }
.danger-zone__content p { font-size: 0.875rem; margin-bottom: 1rem; }
.completion-notice { text-align: center; font-weight: 500; padding: 0.75rem 1.25rem;   margin-top: 1rem; background-color: var(--color-bg-body); border: 1px solid var(--color-border); border-radius: var(--border-radius); }

/* --- Post Cards --- */
.post-card__media { overflow: hidden; background: #f1f5f9; }
.post-card__img { display: block; width: 100%; height: 12rem; object-fit: cover; transition: transform 0.3s ease; }
.post-card__placeholder { width: 100%; height: 12rem; display: grid; place-items: center; background: #e5e7eb; color: #6b7280; font-size: .9rem; }
.blog-post-card:hover  .post-card__img { transform: scale(1.05); }

/* --- KPI Widgets (Soporte Universal div/p y dl/dt/dd) --- */
.kpi-grid { 
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); 
  gap: 1rem; 
}

.metricas-areas { min-width: 0; }
.metricas-areas .metricas-area-nav ul {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.4rem;
  padding: 0;
  margin: 1rem 0;
  list-style: none;
}
.metricas-areas .metricas-area-link {
  display: flex;
  align-items: center;
  min-height: 3.25rem;
  padding: 0.65rem;
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 0.25rem;
  color: inherit;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.metricas-areas .metricas-area-link:hover { text-decoration: underline; }
.metricas-areas .metricas-area-link.is-active { background: #005a9e; color: #fff; border-color: #005a9e; }
.metricas-areas a:focus-visible,
.metricas-areas .metricas-tabla:focus-visible { outline: 3px solid var(--color-text); outline-offset: 3px; }
.metricas-areas .metricas-export-link { text-align: right; }
.metricas-areas .metricas-filtros { padding: 1rem; border: 1px solid var(--color-border); border-radius: 0.5rem; }
.metricas-areas .metricas-presets { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; padding: 0; list-style: none; }
.metricas-areas .metricas-presets a { display: inline-block; padding: 0.4rem 0; }
.metricas-areas .metricas-presets [aria-current] { font-weight: 700; text-decoration-thickness: 0.15em; }
.metricas-areas .metricas-filter-form { display: flex; align-items: end; flex-wrap: wrap; gap: 1rem; }
.metricas-areas .metricas-filter-form .form-group { flex: 1 1 10rem; min-width: 0; margin: 0; }
.metricas-areas .metricas-filter-form .form-actions { flex-wrap: wrap; }
.metricas-areas .metricas-alcance { font-weight: 600; margin-top: 1rem; }
.metricas-areas section { margin: 2rem 0; padding-top: 1rem; border-top: 1px solid var(--border, #cbd5e1); }
.metricas-areas h3 { margin: 0 0 0.6rem; }
.metricas-areas .metricas-valores { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: 1rem 1.5rem; }
.metricas-areas .metricas-dato { margin: 0.75rem 0; min-width: 0; }
.metricas-areas .metricas-dato dt { font-weight: 600; }
.metricas-areas .metricas-dato dd { margin: 0.35rem 0 0; font-size: 1.4rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metricas-areas .metricas-dato small { display: block; margin-top: 0.35rem; font-size: 0.9rem; font-weight: 400; }
.metricas-areas .metricas-tabla { overflow-x: auto; margin: 1rem 0; }
.metricas-areas .data-table { width: 100%; min-width: 36rem; }
.metricas-areas .metricas-compras-tabla { min-width: 56rem; }
.metricas-areas caption { text-align: left; font-weight: 600; padding-bottom: 0.5rem; }
.metricas-areas td,
.metricas-areas th { vertical-align: top; overflow-wrap: anywhere; }
.metricas-areas details { margin: 1rem 0; }
.metricas-areas summary { cursor: pointer; padding: 0.5rem 0; }
.metricas-areas .metricas-no-disponible { padding: 1rem; border: 1px solid currentcolor; }
@media (max-width: 1050px) {
  .metricas-areas .metricas-area-nav ul { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .metricas-areas .metricas-area-nav ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metricas-detalle-compras .metricas-filter-form .form-group { flex-basis: 100%; }
}
@media (forced-colors: active) {
  .metricas-areas .metricas-area-link.is-active { background: Highlight; color: HighlightText; border-color: Highlight; }
}
.metricas-kpi-section + .metricas-kpi-section {
  margin-top: 1.5rem;
}

.metricas-kpi-section h3 {
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.kpi-widget { 
  background-color: var(--color-bg-card); 
  padding: 1rem; 
  border: 1px solid var(--color-border); 
  
  /* Flexbox para alineación vertical */
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 6rem; 
  
  /* Reset de margen por si es un <dl> */
  margin: 0;
}

/* Título: Acepta primer párrafo (<p>) O término de definición (<dt>) */
.kpi-widget p:first-child,
.kpi-widget dt { 
  font-size: 0.875rem; 
  color: var(--color-text-muted); 
  margin: 0 0 0.25rem 0; 
  font-weight: 500;
  line-height: 1.4;
}

/* Valor: Acepta segundo párrafo (<p>) O descripción (<dd>) */
.kpi-widget p:nth-child(2),
.kpi-widget dd { 
  font-size: 1.5rem; 
  font-weight: 600; 
  margin: 0; /* CRUCIAL: Quita la sangría por defecto del dd */
  color: var(--color-text);
  line-height: 1.2;
}

.kpi-widget__value-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
}

.kpi-widget__value-link {
  color: inherit;
  font-size: inherit;
}

.kpi-widget__value-meta {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.kpi-widget__condition {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin: 0.25rem 0 0 0;
}

/* Utilidad para texto pequeño (funciona en ambos) */
.kpi-widget .counter-text {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75em;
  color: var(--color-text-muted);
  font-weight: 400;
  white-space: normal;
}

.kpi-widget dd.counter-text {
  font-size: 0.875rem;
  line-height: 1.4;
}

/* Variantes de Color (Soporta p y dd) */
.kpi-widget.is-due p:nth-child(2),
.kpi-widget.is-due dd { color: var(--color-danger); } /* Ojo: en JS aplicas la clase al dd, mira abajo */

/* Corrección específica para tu JS actual: 
   En panelAdmin.js aplicas la clase 'is-due' DIRECTAMENTE al elemento <dd>, 
   no al contenedor .kpi-widget. Necesitamos esta regla extra: */
.kpi-widget dd.is-due { color: var(--color-danger); }

.kpi-widget.is-positive p:nth-child(2),
.kpi-widget.is-positive dd { color: #064e3b; }

.kpi-widget.is-warning p:nth-child(2),
.kpi-widget.is-warning dd { color: #853f09; }

/* Grid Responsive */
.kpi-grid--3-cols { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
@media (min-width: 768px) { .kpi-grid--3-cols { grid-template-columns: repeat(3, 1fr); } }

/* --- Result Box --- */
.result-box { display: flex; flex-direction: column; background-color: #eff6ff; padding: 1.5rem; border-radius: var(--border-radius); box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05); }
.result-box > h3 { order: 1; }
.result-box > .result-box__output { order: 2; }
.result-box > .result-box__status-message { order: 3; }
.result-box > .form-actions { order: 4; }
.result-box > .floating-message { order: 5; }

.result-box h3 { font-size: 1.25rem; font-weight: 500; }
.result-box__output { background-color: var(--color-bg-card); padding: 1rem; border-radius: var(--border-radius); min-height: 6rem; font-size: 1.125rem; color: var(--color-text); }
.result-box__status-message { margin-top: 0.75rem; text-align: center; font-weight: 500; color: var(--color-primary); font-size: 0.875rem; min-height: 1.25em; }
.result-box .form-actions { border-top: none; padding-top: 0; margin-top: 1rem; }
.floating-message { padding: 0.75rem 1.25rem; border-radius: var(--border-radius); font-weight: 500; text-align: center; }
.floating-message.is-success { background-color: var(--color-primary); color: white; }
.floating-message.is-error { background-color: var(--color-danger); color: white; }
.result-box .floating-message { margin-top: 1rem; font-size: 0.75rem; padding: 0.25rem 0.5rem; }

/* --- Formularios --- */
form > fieldset + fieldset { margin-top: 2rem; }
.form-group { margin-bottom: 1.5rem; }
.form-group:last-child { margin-bottom: 0; }
.form-group > label, .form-group > legend { display: block; font-weight: 500; margin-bottom: 0.5rem; }

/* Asegura que el formulario se comporte como un bloque en línea para no romper el menú */
.form-inline {
  display: inline-block;
  margin: 0;
}

.input-field { 
  box-sizing: border-box; width: 100%; max-width: 100%; padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border); border-radius: var(--border-radius); 
  background-color: var(--color-bg-card); font-size: 1rem; line-height: 1.5; color: var(--color-text);
}
.input-field-sm { font-size: 0.875rem; padding: 0.25rem 0.5rem; }
.input-field:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(0, 90, 158, 0.2); }
[data-theme="hc"] .input-field:focus { outline: 3px solid #00ffff; outline-offset: 2px; box-shadow: none; }
@media (forced-colors: active) {
  .input-field:focus {
    outline: 3px solid Highlight;
    outline-offset: 2px;
    border-color: Highlight;
    box-shadow: none;
  }
}
.input-field.is-invalid { border-color: var(--color-danger); box-shadow: 0 0 0 3px rgba(197, 34, 51, 0.2); }

.input-xl { font-size: 1.5rem; padding: 0.75rem 1rem; font-weight: 500; }
textarea.input-field { height: 6rem; resize: vertical; }
.form-group-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
}

.form-group-checkbox :is(input[type="checkbox"], input[type="radio"]) {
  flex: 0 0 1.25rem;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
}

.form-group-checkbox label {
  display: block;
  min-height: 2.75rem;
}
.checkbox-group { display: flex; align-items: flex-start; gap: 0.75rem; }
.checkbox-group input[type="checkbox"] { width: 1em; height: 1em; margin-top: 0.2rem; }
.checkbox-group label { font-weight: 600; line-height: 1.4; }

.form-hint { font-size: 0.875rem; color: var(--color-text-muted); margin-top: 0.5rem; }
.form-error { margin-top: 0.5rem; color: var(--color-danger); font-size: 0.875rem; font-weight: 600; }
.division-cr-feedback { margin-bottom: 1.5rem; }
.division-cr-feedback :where(.form-hint, .form-error) { margin: 0; }
.division-cr-feedback .btn { margin-top: 0.75rem; }
#division-cr-retry[hidden] { display: none; }
.form-actions { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--color-border); display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.form-actions > p { flex-grow: 1; margin: 0; }
.search-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.search-form :where(.input-field, .btn) {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
}

.search-form__field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.search-form__label {
  font-weight: 600;
}

@media (min-width: 768px) {
  .search-form {
    flex-flow: row wrap;
    align-items: stretch;
  }

  .search-form__field {
    flex: 1 1 12rem;
    width: auto;
  }

  .search-form__field--search {
    flex-grow: 2;
  }

  .search-form__field .input-field {
    flex: 0 1 auto;
    width: 100%;
  }

  .search-form .btn {
    flex: 0 0 auto;
    width: auto;
  }
}
.lista-errores { list-style: disc; padding-left: 1.5rem; margin-top: 0.5rem; }
.main-form { display: flex; flex-direction: column; gap: 2rem; }
.form-grid .full-width { grid-column: 1 / -1; }
.form-group--nested { padding-left: 2rem; max-width: 20rem; }
.form-actions-group { display: flex; align-items: flex-end; gap: 0.5rem; }
.form-actions-group > * { flex-grow: 1; }
@media (min-width: 1024px) { .form-grid.cols-5 .form-actions-group { grid-column: span 2 / span 2; } }
@media (min-width: 768px) and (max-width: 1023px) { .form-grid.cols-5 .form-actions-group { grid-column: span 2 / span 2; } }

.password-rules { list-style: none; padding-left: 0; margin: 0.75rem 0 0; font-size: 0.875rem; }
.password-rules li { margin-bottom: 0.25rem; color: var(--color-text-muted); transition: color 0.2s ease; }
.password-rules li.text-green-600 { color: var(--color-success-text); }
#password-match-msg.text-green-600 { color: var(--color-success-text); }
#password-match-msg.text-red-600 { color: var(--color-danger); }
#password-match-msg { font-size: 0.875rem; margin-top: 0.25rem; }

/* --- Autocompletado --- */
.autocomplete-container { position: relative; }
.cobro-cliente-busqueda-form [hidden] { display: none; }
.autocomplete-suggestions { position: absolute; top: 100%; left: 0; right: 0; z-index: 20; max-height: 10rem; overflow-y: auto; background-color: var(--color-bg-card); border: 1px solid var(--color-border); border-top: none; border-radius: 0 0 var(--border-radius) var(--border-radius); list-style: none; padding: 0; margin: 0; }
.autocomplete-suggestions li { padding: 0.5rem 0.75rem; cursor: pointer; }
.autocomplete-suggestions li:hover, .autocomplete-suggestions li.is-active { background-color: var(--color-primary); color: white; }
.autocomplete-suggestions li:not(:last-child) { border-bottom: 1px solid var(--color-border); }
.autocomplete-suggestions__option { outline: none; }
.autocomplete-suggestions__option strong { display: block; }
.autocomplete-suggestions__option .suggestion-meta { font-size: 0.875rem; }
.autocomplete-suggestions__empty { cursor: default; color: var(--color-text-muted); }

/* Opción activa del combobox: forzamos visibilidad en todos los modos */
.autocomplete-suggestions li.is-active,
.autocomplete-suggestions li[aria-selected="true"] {
  background-color: var(--color-primary);
  color: white;
  outline: 2px solid transparent;
}

@media (forced-colors: active) {
  .autocomplete-suggestions li.is-active,
  .autocomplete-suggestions li[aria-selected="true"] {
    outline: 2px solid ButtonText;
    outline-offset: -2px;
  }
}

/* Bloque de error del buscador */
.search-error {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--border-radius);
  background-color: var(--color-bg-body);
  border: 1px solid var(--color-danger);
  color: var(--color-danger);
}

.search-error__retry {
  margin-left: 0.25rem;
  padding: 0;
  color: inherit;
  text-decoration: underline;
  background: transparent;
  border: none;
  cursor: pointer;
}

.search-error__retry:hover,
.search-error__retry:focus-visible {
  text-decoration: none;
}

/* Confirmación visible de cliente seleccionado en el formulario de asignación */
.selection-confirm {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-primary);
}

/* Divulgación nativa para cliente no registrado */
.form-details {
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
}

.form-details summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--color-primary);
}

.form-details[open] summary {
  margin-bottom: 0.75rem;
}

.form-details > label {
  display: block;
  margin-bottom: 0.25rem;
}

/* Resumen unificado de cliente seleccionado */
.cliente-resumen {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius);
  background-color: var(--color-bg-body);
  border: 1px solid var(--color-border);
}

.cliente-resumen__texto {
  margin: 0;
}

.assign-form-container { margin-top: 0.75rem; padding: 0.75rem; border: 1px solid var(--color-border); background-color: var(--color-bg-body); border-radius: var(--border-radius); }
.assign-form-container form { display: flex; flex-direction: column; gap: 0.5rem; }

/* --- Alertas --- */
.alert { padding: 0.75rem 1rem; margin-bottom: 1rem; border-radius: var(--border-radius); border: 1px solid transparent; }
.alert strong { font-weight: 600; }
.alert-success { background-color: #d1fae5; border-color: #a7f3d0; color: #064e3b; }
.alert-danger { background-color: #fee2e2; border-color: #fca5a5; color: #7f1d1d; }
.alert-warning { background-color: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info { background-color: #f0f9ff; border-color: #e0f2fe; color: #075985; }

.access-message {
  max-width: 70ch;
  overflow-wrap: anywhere;
}

#flash-messages:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 3px;
}

.access-message__title:focus {
  outline: 3px solid var(--color-primary);
  outline-offset: 3px;
}

.access-message__title,
.access-message__instruction,
.access-message__copy {
  margin: 0;
}

.access-message__instruction {
  margin-top: 0.5rem;
}

.access-message__content {
  min-width: 0;
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  background-color: var(--color-bg-card);
}

.access-message__copy {
  max-width: 100%;
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.access-message__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.access-message__actions .btn {
  min-height: 2.75rem;
  white-space: normal;
}

.mensaje-solicitud { background-color: rgba(0,0,0,0.05); border-left: 4px solid var(--color-border); padding: 0.5rem 1rem; margin-top: 0.75rem; font-style: italic; }
[data-theme="dark"] .mensaje-solicitud { background-color: rgba(255,255,255,0.08); border-color: var(--color-border); }

/* --- Tablas --- */
.table-container { overflow-x: auto; padding: 0; border: 1px solid var(--color-border); border-radius: var(--border-radius); }
.operational-table-container { position: relative; }
.solicitudes-table th, .solicitudes-table td { vertical-align: top; overflow-wrap: anywhere; }
.solicitudes-table th[scope="row"] { min-width: 8rem; }
.solicitudes-table td:nth-child(2) { min-width: 11rem; }
.solicitudes-table td:nth-child(3) { min-width: 10rem; }
.solicitudes-table td:last-child { min-width: 9rem; }
.solicitudes-table-container .btn { box-sizing: border-box; min-height: 44px; margin-top: 0; }
.solicitudes-table-container .row-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.5rem; }
.solicitudes-mensaje { margin-top: 0.5rem; font-weight: 400; }
.solicitudes-mensaje summary { cursor: pointer; min-height: 44px; display: list-item; }
.solicitudes-antiguedad { margin-top: 0.5rem; }
.solicitudes-table-container .actions-panel { position: static; min-width: 0; width: 100%; box-sizing: border-box; margin-top: 0.25rem; box-shadow: none; }
.solicitudes-table-container .actions-panel__list button { white-space: normal; }
.solicitudes-filtros { display: grid; grid-template-columns: minmax(0, 1fr); align-items: end; gap: 1rem; }
.solicitudes-filtros .form-group { min-width: 0; margin-bottom: 0; }
.solicitudes-filtros .input-field, .solicitudes-filtros .btn { box-sizing: border-box; min-height: 44px; }
.solicitudes-filtros .form-actions-group { align-items: center; }
@media (min-width: 768px) {
  .solicitudes-filtros { grid-template-columns: minmax(8rem, 1fr) minmax(12rem, 2fr) 6rem; }
  .solicitudes-filtros:has(#aging) { grid-template-columns: minmax(8rem, 1fr) minmax(12rem, 2fr) minmax(8rem, 1fr) 6rem; }
  .solicitudes-filtros .form-actions-group { grid-column: 1 / -1; justify-content: flex-end; }
  .solicitudes-filtros .form-actions-group > * { flex-grow: 0; }
}
@media (min-width: 1200px) {
  .solicitudes-table td:last-child { width: 17rem; }
  .solicitudes-filtros { grid-template-columns: minmax(8rem, 1fr) minmax(12rem, 2fr) 6rem auto; }
  .solicitudes-filtros:has(#aging) { grid-template-columns: minmax(8rem, 1fr) minmax(12rem, 2fr) minmax(8rem, 1fr) 6rem auto; }
  .solicitudes-filtros .form-actions-group { grid-column: auto; }
}
.table-scroll-hint { margin: 0; padding: 0.5rem 1rem; color: var(--color-text-muted); font-size: 0.875rem; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; text-align: left; }
.data-table thead { background-color: var(--color-bg-body); text-transform: uppercase; font-size: 0.75rem; color: #0f172a; font-weight: 700; }
.data-table th, .data-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--color-border); }
.data-table tbody tr:hover { background-color: var(--color-bg-body); }
.data-table th[scope="row"] { font-weight: 600; color: var(--color-text); }
.empty-cell { padding: 1.5rem; text-align: center; color: var(--color-text); opacity: 0.7; }

.key-value-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.key-value-table th, .key-value-table td { padding: 0.5rem 0; border-bottom: 1px solid var(--color-border); }
.key-value-table th { text-align: left; font-weight: 600; padding-right: 1rem; color: #0f172a; }
.key-value-table tr:last-child th, .key-value-table tr:last-child td { border-bottom: none; }
.key-value-table .is-total { font-size: 1rem; }
.data-table--fixed { table-layout: fixed; }

/* --- Píldoras de Estado (Badges) Accesibles --- */
.status-pill { display: inline-flex; align-items: center; border-radius: 9999px; padding: 0.125rem 0.75rem; font-size: 0.75rem; font-weight: 700; border: 1px solid transparent; }

/* Texto oscuro sobre fondo claro pastel */
.status-pill--encargado { background: #dbeafe !important; color: #1e3a8a !important; }
.status-pill--comprado  { background: #ede9fe !important; color: #1e1b4b !important; }
.status-pill--envio     { background: #ffedd5 !important; color: #431407 !important; }
.status-pill--entregado { background: #dcfce7 !important; color: #022c22 !important; }
.status-pill--cancelado, 
.status-pill--rechazada { background: #fee2e2 !important; color: #450a0a !important; }
.status-pill--programado, 
.status-pill--warning   { background: #fff7ed !important; color: #431407 !important; }
.status-pill--tránsito  { background: #ecfeff !important; color: #083344 !important; }
.status-pill--borrador, 
.status-pill--default,
.status-pill--pendiente { background: #f1f5f9 !important; color: #0f172a !important; }
.status-pill--publicado, .status-pill--aprobada { background-color: #ecfdf5; color: #065f46; } /* Verde suave */
.status-pill--tag { background-color: #f3f4f6; color: #374151; font-weight: 600; }

/* Utilidades para Alertas en Dashboard */
.alertas-title {
  font-weight: 600; /* Seminegrita, destaca sobre el texto normal */
}
/* Utilidad para contadores en paneles claros */
.counter-text {
  font-size: 0.875rem; 
  color: var(--color-text-muted);
    margin-left: 0.5rem;            /* Separación del título */
  font-weight: 400;  
  white-space: nowrap;            /* evita cortes feos */
}

/* ============================================= */
/* Estilos para el componente actionsDisclosure  */
/* ============================================= */   
.actions-disclosure {
  position: relative;
  display: inline-block;
}

.actions-disclosure summary {
  list-style: none;
  min-height: 44px;
}

.actions-disclosure summary::-webkit-details-marker {
  display: none;
}

.actions-panel {
  position: absolute;
  z-index: 20;
  right: 0;
  top: calc(100% + 4px);
  min-width: 180px;
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

.actions-panel__list {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
}

.actions-panel__list li {
  margin: 0;
  padding: 0;
}

.actions-panel__list a,
.actions-panel__list button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: var(--color-text);
  text-decoration: none;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}

.actions-panel__list a:hover,
.actions-panel__list button:hover,
.actions-panel__list a:focus-visible,
.actions-panel__list button:focus-visible {
  background-color: #f3f4f6;
  color: var(--color-primary);
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

/* Las acciones operativas conservan un objetivo táctil de 44 px aun con .btn-sm. */
.operational-table-container .row-actions > .btn,
.operational-table-container .row-actions > .inline-form .btn {
  min-height: 44px;
}

/* El panel de la última fila queda dentro del desplazamiento vertical de la tabla. */
.publications-table-container .row-actions > .btn,
.publications-table-container .row-actions > .inline-form .btn {
  min-height: 44px;
}

.publications-table-container .actions-panel {
  position: static;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  margin-top: 0.25rem;
  box-shadow: none;
}

.publications-table-container .actions-panel__list a,
.publications-table-container .actions-panel__list button {
  white-space: normal;
}

@media (max-width: 767px) {
  /* El panel entra al flujo para no quedar recortado por el scroll de la tabla. */
  .operational-table-container .actions-panel {
    position: static;
    margin-top: 0.25rem;
    box-shadow: none;
  }

  .operational-table-container .actions-panel__list a,
  .operational-table-container .actions-panel__list button {
    white-space: normal;
  }
}

@media (forced-colors: active) {
  .actions-panel__list a:focus-visible,
  .actions-panel__list button:focus-visible {
    outline-color: Highlight;
  }
}

.actions-panel__list .item--danger { color: var(--color-danger); }
.actions-panel__list .item--danger:hover { background-color: #fef2f2; color: #991b1b; }

.actions-panel__list .item--warning { color: #d97706; }
.actions-panel__list .item--warning:hover { background-color: #fffbeb; color: #92400e; }

.actions-panel__list .item--disabled { color: #9ca3af; pointer-events: none; }
.actions-panel__list .item--disabled:hover { background-color: transparent; }

.actions-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10;
  background: transparent;
  display: none;
}

details[open] > .actions-overlay {
  display: block;
}

/* ============================================= */
/* Estilos para el componente de pestañas (Tabs) */
/* ============================================= */
.tab-nav {
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--color-border);
}

.tab-nav ul {
  display: flex;
  margin: 0;
  padding: 0;
  gap: 1.5rem;
}

.tab-nav__link {
  display: block;
  padding: 0.75rem 0;
       color: #0f172a !important; /* Color base (inactivo): Gris muy oscuro (Slate-900, para contraste) */
  text-decoration: none;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px; /* Para superponer al borde del contenedor */
  transition: all 0.2s ease;
}

.tab-nav__link:hover {
  color: #004d80 !important; /* Azul oscuro al pasar mouse */
    background-color: #f1f5f9; /* Fondo suave al hover */
}

.tab-nav__link.is-active {
    color: #004d80 !important;   /* Color activo: Azul oscuro seguro */
    border-bottom-color: #004d80 !important;
  font-weight: 600;
}

.tab-panel.hidden {
  display: none;
}

/* ============================================= */
/* Estilos para Acordeones (Details/Summary)     */
/* ============================================= */
.accordion {
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
  overflow: hidden;
}

.accordion__summary {
  padding: 0.75rem 1rem;
  background-color: var(--color-bg-body);
  font-weight: 500;
  cursor: pointer;
  list-style: none; /* Oculta flecha por defecto */
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.accordion__summary::-webkit-details-marker { display: none; }

.accordion__summary::after {
  content: '+';
  font-size: 1.25rem;
  line-height: 1;
}

details[open] .accordion__summary::after {
  content: '-';
}

.accordion__content {
  padding: 1rem;
  border-top: 1px solid var(--color-border);
  background-color: #fff;
}

.inline-details__content {
  padding: 0.5rem 0;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* Detalles de dirección en tablas */
.address-details { color: var(--color-text-muted); font-size: 0.875rem; font-style: italic; }
.address-details dt { float: left; clear: left; width: 5rem; font-weight: 500; }
.address-details dd { margin-left: 5.5rem; margin-bottom: 0.25rem; }

/* Contact Footer Title */
.contact-footer__title { font-size: 1.25rem; margin-bottom: 1rem; color: #ffffff; }

/* Utilidades */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.hidden { display: none; }

/* ==========================================================================
   CORRECCIONES FINALES DE CONTEXTO (OVERRIDES)
   Estas reglas fuerzan el texto a BLANCO solo cuando está sobre fondos OSCUROS
   ========================================================================== */

/* El footer global mantiene texto blanco sobre su superficie oscura. */
.app-shell__footer h1,
.app-shell__footer h2,
.app-shell__footer h3 {
  color: #ffffff !important;
}

    /* Utilidad para remover estilos de lista */
    .list-unstyled {
      list-style: none;
      padding-left: 0;
        margin: 0;
    }

/* 3. Artículos del Blog (Placeholders) */
/* Oscurecemos el gris del placeholder para que pase el ratio 4.5:1 */
.post-card__placeholder {
  color: #4b5563 !important; /* Gris más oscuro */
  background-color: #f3f4f6 !important; /* Fondo ligeramente más claro */
}

/* 4. Corrección de Tamaño Táctil (Admin Tabs) */
.tab-nav__link {
  display: inline-block; /* Asegura que tome el padding */
  padding: 0.75rem 1rem !important; /* Aumentamos área lateral */
  min-height: 44px; /* Altura mínima estándar móvil */
  box-sizing: border-box;
}

/* El encabezado interno conserva su superficie neutra. */
.page-header {
  background-color: var(--color-bg-body) !important;
}

.page-header .page-intro,
.page-header .text-muted {
  color: var(--color-text-muted) !important;
  opacity: 1 !important;
}

/* =========================================
   ESTILOS DE ACCESIBILIDAD Y BARRA DE HERRAMIENTAS
   ========================================= */

/* 1. Skip Link (Enlace de salto)
   Se oculta visualmente pero aparece al recibir foco (Tab) */
.skip-link {
  position: absolute;
  top: -9999px;
  left: 0;
  background-color: var(--color-primary); /* Fondo azul */
  color: white !important;
  padding: 1rem;
  z-index: 9999;
  text-decoration: none;
  font-weight: bold;
  border-radius: 0 0 var(--border-radius) 0;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid var(--color-secondary);
}

/* =========================================
   WIDGET DE ACCESIBILIDAD (Integrado en Nav)
   ========================================= */

/* El contenedor principal (<details>) */
.accesible-partials {
  position: relative;
  display: inline-block;
  height: auto;
  margin: 0;
  padding: 0;
}

/* El botón disparador (<summary>) */
.accesible-partials summary {
  list-style: none;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  color: var(--color-text-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: var(--border-radius);
  transition: all 0.2s ease;
  user-select: none;
}

/* Ocultar triángulo en Webkit */
.accesible-partials summary::-webkit-details-marker {
  display: none;
}

/* Estado Hover/Focus */
.accesible-partials summary:hover,
.accesible-partials summary:focus-visible {
  background-color: #f1f5f9;
  color: var(--color-primary);
}

.accesible-partials summary:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

/* Clase para el Icono (Reemplaza style inline) */
.a11y-icon {
  font-size: 1.2rem;
  line-height: 1;
}

/* El Panel Desplegable */
.accesible-partials__panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 200px;
  
  /* Posicionamiento Flotante */
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 50;
  
  /* Estética */
  background-color: var(--color-bg-card);
  padding: 1rem;
  border: 1px solid var(--color-border);
    border-top: 3px solid var(--color-primary); 
  border-radius: var(--border-radius);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Título interno del menú (Reemplaza style inline) */
.a11y-menu-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin: 0 0 0.5rem 0;
  display: block;
}

/* Ajuste Mobile */
@media (max-width: 767px) {
  .accesible-partials {
    width: 100%;
    margin-top: 0.5rem;
    border-top: 1px solid var(--color-border);
    padding-top: 0.5rem;
  }
  
  .accesible-partials summary {
    justify-content: flex-start;
    width: 100%;
  }

  .accesible-partials__panel {
    position: static;
    box-shadow: none;
    border: none;
        border-top: none; /* En móvil quitamos el borde superior flotante */
    padding-left: 0;
    padding-right: 0;
    width: 100%;
  }
}

.theme-options {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.theme-current {
  margin: 0 0 0.75rem;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--border-radius);
  color: var(--color-text);
  cursor: pointer;
}

.theme-option:hover {
  background-color: #f0f9ff;
  color: var(--color-primary);
}

.theme-option:has(input:checked) {
  background-color: #e0f2fe;
  color: var(--color-primary);
  font-weight: 700;
}

.theme-option:has(input:focus-visible) {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

.theme-option input {
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  accent-color: var(--color-primary);
  flex: 0 0 auto;
}

/* =========================================================
   MODO OSCURO
   ========================================================= */

[data-theme="dark"] .accesible-partials__panel {
  background-color: #1e293b; /* Color fondo oscuro sólido (Slate-800) */
  border-color: #334155;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5); /* Sombra más fuerte en dark */
    border-top-color: var(--color-primary); 
}

[data-theme="dark"] .theme-option:hover,
[data-theme="dark"] .theme-option:has(input:checked) {
  background-color: #334155;
  color: #ffffff;
}

/* =========================================
   ESTILOS ESPECÍFICOS DE LA PÁGINA DE INICIO
   ========================================= */

/* 1. Ajustes del Hero Header */
.inicio-hero {
  /* Conserva la superficie de marca y ajusta la composición del hero. */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.inicio-hero .logo {
  max-width: 150px; /* Ajusta según el tamaño real de tu logo */
  height: auto;
  border-radius: 50%; /* Opcional: si el logo es redondo o cuadrado */
  margin-bottom: 0.5rem;
  background-color: white; /* Por si es un JPG con fondo blanco */
  padding: 0.5rem; /* Marco blanco alrededor */
}

/* 2. Contenedor Genérico (Alias de admin-container) */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* 3. Ajustes de Tarjetas de Blog (Internos) */
.card-content {
  padding: 1rem; /* Espacio interno para que el texto no toque el borde */
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.post-meta {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.post-title {
  font-size: 1.25rem;
  margin: 0;
  line-height: 1.4;
}

.post-title a {
  color: var(--color-text);
  text-decoration: none;
}

.post-title a:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

/* Utilidad Stretched Link 
   Hace que toda la tarjeta sea cliqueable sin anidar todo en un <a> */
.blog-post-card {
  position: relative; /* Necesario para el stretched-link */
  display: flex;
  flex-direction: column;
  height: 100%; /* Para que todas las cards tengan misma altura en grid */
}

.stretched-link::after {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  content: "";
}

/* 4. Footer de Sección (Botones al final) */
.section-footer {
  margin-top: 2rem;
  text-align: center;
}

/* 5. Formulario de Pre-registro */
.registration-form-container {
  margin-top: 2rem;
  padding: 1.5rem;
  background-color: #f8fafc; /* Fondo suave diferente a la tarjeta */
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  
  /* Animación simple al aparecer */
  animation: fade-in 0.3s ease-in-out;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Ajuste para listas dentro de navegación que no sean menú principal */
nav[aria-label="Inicio de sesión"] ul {
  padding: 0;
  margin: 0;
}

/* =========================================
   ESTILOS PÁGINA DE ERROR
   ========================================= */

.error-page-container {
  max-width: 600px;
  margin: 4rem auto;
  text-align: center;
  padding: 0 1rem;
}

.error-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
  color: var(--color-danger); /* Usa tu variable roja para el ícono de alerta */
}

.error-icon svg {
  width: 5rem;  /* Tamaño grande para el ícono */
  height: 5rem;
}

/* Caja de depuración (Solo visible en desarrollo) */
.debug-box {
  margin-top: 2rem;
  text-align: left; /* El código se lee mejor alineado a la izquierda */
  background-color: var(--color-bg-card);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 1rem;
  overflow-x: auto; /* Scroll si el stack trace es muy ancho */
}

.debug-box pre {
  margin: 1rem 0 0;
  font-family: monospace;
  font-size: 0.875rem;
  white-space: pre-wrap; /* Ajuste de línea para evitar scroll horizontal excesivo */
  overflow-wrap: anywhere;
}

.debug-box > summary {
  min-height: 44px;
  box-sizing: border-box;
  padding: 0.5rem 0.25rem;
  cursor: pointer;
  font-weight: 600;
}

.debug-box > summary:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 3px;
}

@media (forced-colors: active) {
  .debug-box {
    background-color: Canvas;
    color: CanvasText;
    border-color: CanvasText;
  }

  .debug-box > summary:focus-visible {
    outline-color: Highlight;
  }
}

/* Ajuste específico: Centrar el botón de volver dentro del contenedor de error */
.error-page-container .form-actions {
  justify-content: center;
}

/* =========================================
   ESTILOS PARA EL BLOG Y PUBLICACIONES
   ========================================= */

/* 1. Contenedores de Página (Nuevos) */
.page-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Variación estrecha para lectura cómoda (Single Post) */
.page-container--narrow {
  max-width: 800px; 
}

/* La prosa legal conserva palabras y enlaces completos al ampliar el texto. */
.legal-page .prose {
  overflow-wrap: anywhere;
}

.legal-page .summary-box .list-unstyled {
  padding-left: 0;
}

.legal-page .legal-index {
  margin: 1.5rem 0 2rem;
}

.legal-page .legal-index p {
  margin-bottom: 0.5rem;
  font-size: 1rem;
  font-weight: 700;
}

.legal-page .legal-index ol {
  display: grid;
  gap: 0.25rem 2rem;
  margin: 0;
}

.legal-page .legal-index li {
  margin: 0;
}

.legal-page .prose a {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.legal-page .legal-index a {
  display: inline-block;
  box-sizing: border-box;
  min-height: 2.75rem;
  padding: 0.25rem 0;
}

.legal-page .prose h2[id] {
  scroll-margin-top: 1rem;
}

.legal-page .prose h2[id]:focus,
.legal-page .prose a:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 0.125rem;
}

@media (min-width: 768px) {
  .legal-page .legal-index ol {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  .legal-page {
    padding: 0;
  }

  .legal-page > .card {
    padding: 1rem;
  }

  .legal-page .prose > header {
    padding: 0.75rem 1rem;
  }

  .legal-page .prose > header h1 {
    font-size: 1.5rem;
    line-height: 1.3;
    margin-bottom: 0;
  }

  .legal-page .summary-box {
    padding: 0.75rem;
  }
}

/* 2. Ajuste de imagen en el listado del Blog */
.card-image-container {
  overflow: hidden;
  background-color: #f1f5f9;
  border-bottom: 1px solid var(--color-border);
}

.card-image-container img {
  display: block;
  width: 100%;
  height: 12rem; /* Altura fija uniforme */
  object-fit: cover;
  transition: transform 0.3s ease;
}

.blog-post-card:hover .card-image-container img {
  transform: scale(1.05);
}

/* 3. Paginación */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.pagination-status {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

@media (max-width: 479px) {
  .pagination--list {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .pagination--list .pagination-status {
    flex: 1 1 100%;
    order: -1;
    text-align: center;
  }

  .pagination--list .pagination-item:not(.pagination-status) {
    display: flex;
    flex: 1 1 calc(50% - 0.375rem);
  }

  .pagination--list .pagination-item:last-child {
    justify-content: flex-end;
  }

  .pagination--list .btn {
    box-sizing: border-box;
    width: 100%;
  }
}

/* 4. Estilos de Artículo Individual (Single Post) */

.post-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.post-header h1 {
  font-size: 2.25rem; /* Título grande */
  margin-bottom: 0.75rem;
  color: var(--color-text);
}

.post-header .post-meta {
  display: flex;
  gap: 1.5rem;
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

.post-figure {
  margin: 0 0 2rem 0;
  overflow: hidden;
  border-radius: var(--border-radius);
}

.post-figure img {
  width: 100%;
  height: auto;
  display: block;
}

/* 5. Clase .prose (Tipografía Rica)
   Crucial: Da estilo al HTML generado por el Markdown (h2, p, listas, etc.)
   que no tienen clases propias. */
.prose {
  color: var(--color-text);
  line-height: 1.75;
}

.prose h2, 
.prose h3 {
  color: var(--color-primary);
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.prose .manual-rule-heading {
  color: var(--color-primary);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

/* El manual conserva un recorrido completo y acceso directo por tarea. */
.manual-page .prose p,
.manual-page .manual-index {
  overflow-wrap: anywhere;
}

.manual-page .prose a {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.manual-page .manual-index > ol {
  display: grid;
  gap: 1rem 2rem;
}

.manual-page .manual-index li {
  margin-bottom: 0;
}

.manual-page .manual-index ul {
  margin-bottom: 0;
}

.manual-page .manual-index a {
  display: inline-block;
  box-sizing: border-box;
  min-height: 2.75rem;
  padding: 0.25rem 0;
}

.manual-page .prose :is(h2, h3, h4)[id] {
  scroll-margin-top: 1rem;
}

.manual-page .prose :is(h2, h3, h4)[tabindex="-1"]:focus,
.manual-page .prose a:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 0.125rem;
}

@media (min-width: 768px) {
  .manual-page .manual-index > ol {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.prose p {
  margin-bottom: 1.25rem;
  font-size: 1.125rem; /* Un poco más grande para facilitar lectura */
}

.prose ul, 
.prose ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.prose li {
  margin-bottom: 0.5rem;
}

.prose blockquote {
  border-left: 4px solid var(--color-secondary);  
  margin: 1.5rem 0;
  font-style: italic;
  color: var(--color-text-muted);
  background-color: var(--color-bg-body);
  padding: 1rem;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--border-radius);
  margin: 1.5rem 0;
}

/* Utilidad para texto introductorio destacado */
.prose .lead {
  font-size: 1.25rem;
  color: var(--color-text-muted);
  margin-bottom: 2rem;
  font-weight: 300;
}

/* 6. Footer del Post y Etiquetas */
.post-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.tags-title {
  font-size: 1rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

@media (max-width: 599px) {
  .post-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
  }

  .post-header h1 {
    font-size: clamp(1.5rem, 6vw, 1.875rem);
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  .post-header .post-meta {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.5rem;
    letter-spacing: normal;
    overflow-wrap: anywhere;
  }
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.post-navigation {
  margin-top: 2rem;
  text-align: center;
}

/* =========================================
   ESTILOS PARA MÉTRICAS Y REPORTES
   ========================================= */

/* 1. Contenedor de Pestañas (Tab Content Panel)
   Asegura que el contenido debajo de las pestañas tenga el espacio correcto */
.tab-content-panel {
  margin-top: 1.5rem;
}

/* 2. Alineación y Formato en Tablas */
/* Alinear números a la derecha (Estándar financiero) */
.text-right {
  text-align: right;
}

/* Usar fuente monoespaciada o tabular para que los números se alineen verticalmente */
.tabular-nums {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* Evitar que textos cortos (fechas, estados) se rompan en nueva línea */
.whitespace-nowrap {
  white-space: nowrap;
}

/* 3. Utilidad para Flexbox (usada en form-actions) */
.justify-end {
  justify-content: flex-end;
}

/* 4. Cajas de Exportación (Tab Exportar) */
/* Espaciado para que no se vean pegados los botones en el grid */
.export-box {
  display: flex;
  flex-direction: column;
  height: 100%; /* Para que todos los botones tengan la misma altura si están en grid */
}

/* AJUSTE OPCIONAL PARA TABLAS EN MÓVIL
   Si tienes muchas columnas, esto asegura que el scroll sea evidente */
.table-container[tabindex="0"]:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

@media (forced-colors: active) {
  .operational-table-container:focus {
    outline-color: Highlight;
  }
}

/* =========================================
   ESTILOS DE LOGIN Y PERFIL DE CLIENTE
   ========================================= */

/* --- Login --- */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  padding: 1rem;
  background-color: var(--color-bg-body);
}

.login-container h1 {
  margin-bottom: 0.75rem;
  color: var(--color-primary);
}

.login-intro {
  margin: 0 0 0.5rem;
  color: var(--color-text-muted);
}

@media (max-width: 479px) {
  .login-container {
    justify-content: flex-start;
    min-height: auto;
    padding: 0.75rem;
  }

  .login-container h1 { font-size: 1.5rem; }
}

/* --- Perfil: Header Específico --- */
.page-header--profile {
  background-color: transparent !important; /* Sobrescribe posibles fondos heredados */
  flex-direction: column;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.page-header--profile > div,
.page-header--profile .tab-nav {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.page-header--profile .tab-nav {
  overflow-x: auto;
}

@media (min-width: 768px) {
  .page-header--profile {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .page-header--profile > div {
    flex: 1 1 24rem;
    width: auto;
  }
  
  /* En desktop, las pestañas se alinean a la derecha o al final */
  .page-header--profile .tab-nav {
    margin-bottom: 0;
    width: auto;
  }
}

/* --- Perfil: Resumen operativo --- */
.profile-summary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .profile-summary-grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    align-items: start;
  }

  .profile-summary-grid__personal {
    grid-column: 1 / -1;
  }
}

/* --- Perfil: Listas de Definición (<dl>) --- */
.definition-list {
  display: grid;
  grid-template-columns: auto 1fr; /* Etiqueta | Valor */
  gap: 0.5rem 1rem;
  font-size: 0.95rem;
}

.definition-list dt {
  font-weight: 600;
  color: var(--color-text-muted);
}

.definition-list dd {
  margin: 0;
  color: var(--color-text);
}

/* Variación para instrucciones de pago (más separación) */
.definition-list--payment {
  margin-top: 0.5rem;
  padding: 1rem;
  background-color: var(--color-bg-body);
  border-radius: var(--border-radius);
  border: 1px dashed var(--color-border);
}

/* Utilidad para elementos que deben ocupar toda la fila en el grid dl */
.definition-list .full-width {
  grid-column: 1 / -1;
}
.definition-list dt.full-width {
  margin-top: 0.5rem;
  color: var(--color-primary);
}

/* --- M4: compras y cobros administrativos --- */
.registrar-abono-compra form {
  max-width: 48rem;
}

.abono-compra-saldo {
  margin-top: 0;
  padding: 0.875rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  background-color: var(--color-bg-body);
}

.abono-compra-proyeccion {
  margin-top: 1rem;
}

.abono-compra-saldo span:last-child,
.abono-compra-proyeccion span:last-child {
  font-variant-numeric: tabular-nums;
}

.abono-compra-saldo .payment-total > span:first-child {
  white-space: nowrap;
}

.cobro-cliente-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.cobro-cliente-grid > section {
  min-width: 0;
  margin-bottom: 0;
}

.cobro-cliente-resumen .definition-list dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

.cobro-cliente-formulario .payment-summary {
  margin-top: 1.25rem;
}

@media (max-width: 599px) {
  .actualizar-compra-contexto .definition-list,
  .cobro-cliente-resumen .definition-list {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.25rem;
  }

  .actualizar-compra-contexto .definition-list dt:not(:first-child),
  .cobro-cliente-resumen .definition-list dt:not(:first-child) {
    margin-top: 0.75rem;
  }
}

@media (min-width: 600px) {
  .abono-compra-proyeccion {
    flex-direction: row;
    justify-content: space-between;
    gap: 1.5rem;
  }

  .abono-compra-proyeccion > div {
    flex: 1 1 0;
  }
}

@media (min-width: 768px) {
  .cobro-cliente-grid {
    grid-template-columns: minmax(16rem, 0.8fr) minmax(0, 1.2fr);
    align-items: start;
  }

  .cobro-cliente-resumen .definition-list {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.25rem;
  }

  .cobro-cliente-resumen .definition-list dt:not(:first-child) {
    margin-top: 0.75rem;
  }
}

@media (min-width: 1024px) {
  .cobro-cliente-resumen .definition-list {
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 0.5rem 1rem;
  }

  .cobro-cliente-resumen .definition-list dt:not(:first-child) {
    margin-top: 0;
  }
}

/* --- M5: alternativas servidas por el backend --- */
.cobro-cliente-resultados-servidor,
.cobro-cliente-sin-js,
.actualizar-compra-sin-js {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  background-color: var(--color-bg-body);
}

.cobro-cliente-resultados-servidor h3,
.cobro-cliente-sin-js h3,
.actualizar-compra-sin-js h3 {
  margin-top: 0;
  font-size: 1.125rem;
}

.cobro-cliente-resultados-servidor li + li {
  margin-top: 0.75rem;
}

.cobro-cliente-resultados-servidor .form-hint {
  display: block;
}

/* --- Perfil: Textos y Utilidades de Balance --- */
.highlight-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

.highlight-text.capitalize {
  text-transform: capitalize;
}

/* Estado de deuda (Rojo) */
.is-due {
  color: var(--color-danger) !important;
}

/* Estado pagado (Verde oscuro) */
.is-paid {
  color: #064e3b !important;
}

.balance-explanation {
  font-size: 0.875rem;
  margin-top: -0.25rem;
  margin-bottom: 1rem;
}

.payment-instructions {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.payment-instructions h3,
.account-credit h3 {
  font-size: 1.125rem;
}

.account-credit {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.payment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.payment-actions .btn {
  margin-top: 0;
}

/* Contador pequeño en Headers de Sección */
.header-count {
  font-size: 0.6em; /* Relativo al tamaño del H2 */
  color: var(--color-text-muted);
  vertical-align: middle;
  margin-left: 0.5rem;
  font-weight: 400;
}

/* --- Footer de Contacto (Interno del perfil) --- */
.contact-footer {
  margin-top: 4rem;
  padding: 2rem;
  background-color: var(--color-bg-admin); /* Fondo oscuro para destacar */
  border-radius: var(--border-radius);
  text-align: center;
  color: white;
}

.contact-footer__title {
  color: white !important; /* Forzar blanco sobre fondo oscuro */
  margin-bottom: 1.5rem;
  font-size: 1.25rem;
}

.contact-footer p,
.contact-footer .text-muted {
  color: #ffffff !important;
}

/* Ajuste del botón secundario dentro del footer oscuro para que contraste */
.contact-footer .btn-secondary {
  background-color: white;
  color: var(--color-text);
  border: none;
}

.contact-footer .btn-secondary:hover {
  background-color: #f1f5f9;
}

/* =========================================
   ESTILOS EDITOR DE PUBLICACIONES (ADMIN)
   ========================================= */

/* 1. Contenedor de Pestañas del Editor */
.tab-container {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  overflow: hidden;
  background-color: var(--color-bg-card);
  color: var(--color-text);
}

.tab-list {
  display: flex;
  background-color: var(--color-bg-body);
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}

.tab-button {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  background-color: var(--color-bg-body);
  cursor: pointer;
  font-weight: 500;
  color: var(--color-text-muted);
  border-right: 1px solid var(--color-border); /* Separador */
  transition: background-color 0.2s, color 0.2s;
}

.tab-button:last-child {
  border-right: none;
}

.tab-list .tab-button:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: -3px;
}

[data-theme="hc"] .tab-list .tab-button.active:focus-visible {
  outline-color: var(--color-bg-body);
}

.tab-button:hover {
  background-color: var(--color-bg-card);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.tab-button.active {
  background-color: var(--color-bg-card);
  color: var(--color-primary);
  font-weight: 600;
  border-bottom: 2px solid transparent; /* Truco visual */
  margin-bottom: -1px; /* Tapa el borde inferior */
}

/* 2. Barra de Herramientas Markdown */
.md-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.5rem;
  background-color: var(--color-bg-body);
  border-bottom: 1px solid var(--color-border);
}

.md-toolbar__group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  min-width: 0;
}

.md-toolbar__group:not(:last-child) {
  padding-inline-end: 0.5rem;
  border-inline-end: 1px solid var(--color-border);
}

/* Ajuste específico para botones del toolbar (más compactos) */
.md-toolbar .btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  min-height: 44px;
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.md-toolbar .btn:hover {
  background-color: var(--color-bg-body);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

/* 3. Área de Texto del Editor */
#contenido {
  border: none; /* Quitamos borde porque ya lo tiene el contenedor */
  border-radius: 0;
  padding: 1rem;
  font-family: monospace; /* Fuente monoespaciada para editar código */
  line-height: 1.6;
  resize: vertical;
  min-height: 400px;
}

#contenido:focus {
  outline: 3px solid var(--color-primary);
  outline-offset: -3px;
  background-color: var(--color-bg-card);
  color: var(--color-text);
  box-shadow: none;
}

@media (forced-colors: active) {
  #contenido:focus {
    outline: 3px solid Highlight;
    outline-offset: -3px;
  }

  .tab-list .tab-button:focus-visible,
  #preview-panel:focus-visible {
    outline: 3px solid Highlight !important;
    outline-offset: -3px;
  }
}

/* 4. Panel de Vista Previa */
#preview-panel {
  padding: 2rem;
  min-height: 400px;
  background-color: var(--color-bg-card);
  color: var(--color-text);
  overflow-y: auto;
}

#preview-panel:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: -3px;
}

/* 5. Grupos de Radio Buttons (Estado) */
.radio-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
}

.radio-group input[type="radio"] {
  width: 1.1em;
  height: 1.1em;
  accent-color: var(--color-primary); /* Color nativo del navegador */
}

.radio-group label {
  font-weight: normal; /* Quita la negrita por defecto de labels */
  cursor: pointer;
  margin-bottom: 0; /* Override del estilo global */
}

/* 6. Link Discreto (Botón "Volver") */
.link-discreto {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  text-decoration: none;
  display: inline-block;
}

.link-discreto:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.mb-4 {
  margin-bottom: 1rem;
}

/* 7. Resumen de Programación (Feedback visual) */
.programacion-resumen {
  margin-top: 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  font-style: italic;
  text-align: center;
  width: 100%;
}

/* =========================================
   ESTILOS DE FORMULARIOS ADMINISTRATIVOS
   ========================================= */

/* 1. Monto Adeudado (Actualizar Compra) */
.monto-adeudado {
  font-size: 1.125rem;
  font-weight: 700;
  display: inline-block;
  /* El color lo manejan las clases .is-due / .is-paid */
}

/* 2. Utilidades de Fuente y Display (Usadas en Labels de Dirección) */
/* Reemplazo para clases tipo Tailwind que aparecieron en el HTML */

/* .block ya es el comportamiento por defecto de labels en .form-group, 
   pero lo definimos por si se usa fuera */
.block {
  display: block;
}

.font-medium {
  font-weight: 500;
}

/* 3. Ajuste de Alertas con Mensajes de Solicitud */
.mensaje-solicitud {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background-color: rgba(255,255,255, 0.5); /* Fondo semitransparente para destacar dentro de la alerta */
  border-left: 3px solid rgba(0,0,0, 0.1);
  border-radius: var(--border-radius);
  font-style: italic;
}

/* 4. Ajuste para Listas de Definición en Formularios */
/* Asegura que en el admin se vean bien alineadas si el espacio es reducido */
@media (min-width: 600px) {
  .summary-box .definition-list {
    grid-template-columns: 150px 1fr; /* Etiqueta fija, valor flexible */
  }
}

/* =========================================
   ESTILOS PARA HERRAMIENTAS Y CALCULADORAS
   ========================================= */

/* 1. Contenedor de Herramientas (Descuentos) */
.tool-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* 2. Ajustes internos de la Caja de Resultados (Descuentos) */
.result-box__content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background-color: white; /* Fondo blanco interno */
  padding: 1rem;
  border-radius: var(--border-radius);
  border: 1px solid var(--color-border);
}

.result-box__main-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary);
  margin: 0;
}

.result-box__sub-text {
  font-size: 0.9rem;
  color: #16a34a; /* Verde éxito para el ahorro */
  margin-top: 0.25rem;
}

/* 3. Estilos para Inputs Deshabilitados / Solo lectura */
.input-field:disabled,
.input-field[readonly] {
  background-color: #f1f5f9;
  color: var(--color-text-muted);
  cursor: not-allowed;
  border-color: #e2e8f0;
}

[data-theme="dark"] .input-field:disabled,
[data-theme="dark"] .input-field[readonly] {
  background-color: #334155;
  color: #cbd5e1;
  border-color: #64748b;
}

[data-theme="hc"] .input-field:disabled,
[data-theme="hc"] .input-field[readonly] {
  background-color: #000000;
  color: #ffff00;
  border-color: #ffffff;
}

/* 4. Sugerencias de Autocompletado (Asegurar visibilidad) */
.autocomplete-suggestions li {
  /* Asegurar que el texto sea legible sobre el fondo blanco */
  color: var(--color-text);
}

.autocomplete-suggestions li.is-active,
.autocomplete-suggestions li:hover {
  /* Asegurar contraste en hover */
  background-color: var(--color-primary);
  color: white;
}

/* =========================================
   ESTILOS DE DETALLES (CLIENTE / COMPRA)
   ========================================= */

/* 1. Listas de Información (Perfil Admin/Cliente) */
.info-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.info-list li {
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  border-bottom: 1px solid #f1f5f9; /* Línea sutil separadora */
  padding-bottom: 0.5rem;
}

.info-list li:last-child {
  border-bottom: none;
}

/* 2. Lista de Acciones (Sidebar) */
.actions-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* 3. Utilidades de Montos y Títulos */
.monto-positivo {
  font-weight: 700;
  color: var(--color-text); /* O puedes usar verde: #059669 */
}

.subsection-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid #f1f5f9;
  padding-bottom: 0.25rem;
}

/* 4. Lista Ordenada con Estilo (Lógica de Cálculo) */
.ordered-list {
  padding-left: 1.5rem;
  margin: 0;
}

.ordered-list li {
  margin-bottom: 0.5rem;
  color: var(--color-text);
  line-height: 1.5;
}

/* 5. Ajuste de Tablas Key-Value (Desglose de Precio) */
/* Asegura alineación correcta de montos a la derecha */
.key-value-table td {
  text-align: right; 
  font-variant-numeric: tabular-nums;
}
.key-value-table th {
  text-align: left;
}
/* =========================================
   ESTILOS DE LISTADOS Y RESULTADOS
   ========================================= */

/* Resumen de resultados de búsqueda (Lista Clientes) */
.results-summary {
  margin-bottom: 1.5rem;
  color: var(--color-text-muted);
  font-size: 1rem;
}

/* Ajuste opcional para celdas de acciones complejas (Dropdowns) */
.actions-cell {
  white-space: nowrap; /* Evita que el botón se rompa */
  width: 1%; /* Truco para que la columna ocupe el mínimo espacio necesario */
}

/* =========================================
   ESTILOS FINALES Y AJUSTES DE TABLAS
   ========================================= */

/* 1. Acordeón Compacto (para uso dentro de celdas de tabla) */
/* Sobrescribimos los estilos base de .accordion si está dentro de un td */
td .accordion {
  border: none;
  margin: 0;
  box-shadow: none;
  background: transparent;
}

td .accordion__summary {
  padding: 0.25rem 0;
  background: transparent;
  font-size: 0.875rem;
  color: var(--color-primary);
  justify-content: flex-start; /* Alinea a la izq */
  gap: 0.5rem;
}

/* Ajuste del icono +/- para que no sea gigante */
td .accordion__summary::after {
  font-size: 1rem;
}

td .accordion__content {
  padding: 0.5rem;
  background-color: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: var(--color-text);
  white-space: normal; /* Asegura que el texto largo del mensaje haga salto de línea */
  min-width: 200px; /* Ancho mínimo para leer cómodamente */
}

/* 2. Ajuste de ancho para columnas de mensaje */
/* Evita que la columna de mensaje se haga muy estrecha */
td:has(.accordion) {
  min-width: 150px;
}

/* 3. Status Pill para antigüedad (Solicitudes) */
/* Definimos los colores específicos si no existen */
.status-pill--warning {
  background-color: #fffbeb;
  color: #92400e;
  border-color: #fcd34d;
}

.status-pill--danger {
  background-color: #fef2f2;
  color: #991b1b;
  border-color: #fca5a5;
}

.status-pill--default {
  background-color: #f3f4f6;
  color: #374151;
  border-color: #e5e7eb;
}

/* =========================================
   ESTILOS DEL DASHBOARD (PANEL ADMIN)
   ========================================= */

/* 1. Panel de Estado (CMC) */
.admin-dashboard {
  min-width: 0;
}

.admin-dashboard .counter-text {
  margin-left: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.admin-dashboard__header {
  margin-bottom: 1.5rem;
}

.admin-dashboard__header > .page-intro {
  margin-block: 0;
}

.panel-with-gradient-top {
  background: linear-gradient(to bottom, #f8fafc, #ffffff);
  border: 1px solid var(--color-border);
  border-radius: var(--panel-radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--panel-shadow);
}

.operation-today {
  min-width: 0;
}

.operation-today__heading {
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

#cmc-titulo {
  margin: 0 0 0.25rem;
  color: var(--color-text);
  font-size: 1.5rem;
}

.operation-today__heading .counter-text {
  margin: 0;
}

.operation-today__section-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: var(--color-text);
}

/* 2. KPIs y Skeleton Loading */
#cmc-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: 1rem;
  min-width: 0;
  margin-bottom: 2rem;
}

.cmc-kpis-state {
  grid-column: 1 / -1;
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  background-color: var(--color-bg-card);
  color: var(--color-text-muted);
}

/* Animación de pulso para carga */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

.skeleton-kpi {
  min-width: 0;
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
  padding: 1rem;
  border-radius: var(--border-radius);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.skeleton-line {
  height: 1rem;
  background-color: #e2e8f0;
  border-radius: 4px;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.skeleton-title {
  height: 1.5rem;
  background-color: #cbd5e1;
  border-radius: 4px;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Utilidades de ancho para skeleton */
.w-75 { width: 75%; }
.w-50 { width: 50%; }
.w-full { width: 100%; }

/* 3. Alertas en el Dashboard */
.alertas-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  min-height: 44px;
  cursor: pointer;
  padding: 0.75rem 1rem;
  background-color: #f1f5f9;
  border-radius: var(--border-radius);
  color: var(--color-text);
  font-weight: 500;
  list-style: none; /* Ocultar flecha nativa si se desea personalizar */
}

.alertas-header__count {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
}

.alertas-lista {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.alertas-card-compact {
  padding: 0.75rem 1rem;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.alertas-card-compact__context,
.alertas-card-compact__cta {
  margin: 0;
}

.alertas-card-compact__title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
}

.alertas-card-compact__link {
  white-space: normal;
  font-size: 0.9rem;
  font-weight: 500;
}

.skeleton-alert {
  padding: 0.75rem;
  background-color: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
}

.cmc-state--error {
  color: var(--color-danger);
  border-color: var(--color-danger);
}

/* 4. Módulos operativos agrupados por responsabilidad */
.admin-modules {
  min-width: 0;
}

.admin-modules__heading {
  margin-bottom: 1.5rem;
}

.admin-modules__heading h2,
.admin-module-group > h3,
.admin-module > h4 {
  margin-top: 0;
}

.admin-modules__heading h2 {
  margin-bottom: 0.25rem;
}

.admin-modules__heading .page-intro,
.admin-module-group > .counter-text,
.admin-module > .counter-text {
  margin-top: 0;
}

.admin-module-groups {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  min-width: 0;
}

.admin-module-group {
  min-width: 0;
  padding: 1.25rem;
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--panel-radius);
}

.admin-module-group > h3 {
  margin-bottom: 0.25rem;
  font-size: 1.25rem;
}

.admin-module-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  min-width: 0;
  margin-top: 1rem;
}

.admin-module {
  min-width: 0;
  padding: 1rem 0;
  border-top: 1px solid var(--color-border);
}

.admin-module > h4 {
  margin-bottom: 0.25rem;
  font-size: 1rem;
}

.admin-module-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-width: 0;
  margin: 0.75rem 0 0;
  padding: 0;
}

.admin-module-actions li {
  display: flex;
  min-width: 0;
  max-width: 100%;
}

.admin-module-actions .btn {
  max-width: 100%;
  min-height: 44px;
  margin-top: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.admin-module details.opcion {
  margin-top: 1rem;
  border: 0;
  border-top: 1px solid var(--color-border);
  border-radius: 0;
}

.admin-module details.opcion:hover {
  box-shadow: none;
}

.admin-module details.opcion summary {
  min-height: 44px;
  padding: 0.75rem 0;
  font-size: 1rem;
}

.admin-module details.opcion .counter-text,
.admin-module details.opcion .opcion__menu {
  margin-right: 0;
  margin-left: 0;
}

.admin-module .nav-link {
  overflow-wrap: anywhere;
}

@media (min-width: 768px) {
  .admin-module-group--primary .admin-module-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .admin-module-groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-module-group--primary {
    grid-column: 1 / -1;
  }
}

[data-theme="dark"] .panel-with-gradient-top {
  background: linear-gradient(to bottom, #1e293b, #0f172a);
}

[data-theme="dark"] .kpi-widget.is-positive dd {
  color: #86efac;
}

[data-theme="dark"] .kpi-widget.is-warning dd {
  color: #fcd34d;
}

[data-theme="dark"] .alertas-header__count {
  color: #cbd5e1;
}

[data-theme="hc"] .panel-with-gradient-top {
  background: #000000;
  box-shadow: none;
}

[data-theme="hc"] .kpi-widget.is-positive dd {
  color: #00ff00;
}

[data-theme="hc"] .kpi-widget.is-warning dd {
  color: #ffff00;
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-line,
  .skeleton-title {
    animation: none;
  }

  details.opcion {
    transition: none;
  }
}

/* 5. Estilos para los Módulos de Menú (.opcion) */
/* Hacemos que parezcan tarjetas cliqueables */
details.opcion {
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--panel-radius);
  transition: box-shadow 0.2s ease;
}

details.opcion:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

details.opcion summary {
  padding: 1rem;
  font-weight: 600;
  font-size: 1.125rem;
  cursor: pointer;
  list-style: none; /* Ocultar flecha por defecto */
  color: var(--color-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Flecha personalizada */
details.opcion summary::after {
  content: '+';
  font-size: 1.5rem;
  line-height: 1;
  color: var(--color-text-muted);
}

details.opcion[open] summary::after {
  content: '-';
}

details.opcion .opcion__menu {
  padding: 0 1rem 1rem 1rem;
  border-top: 1px solid #f1f5f9;
  margin-top: 0;
  padding-top: 0.5rem;
}

/* =========================================
   CORRECCIONES FINALES DE CONTRASTE (A11Y)
   Solución: Texto Blanco sobre Fondos Azules
   ========================================= */


/* 1. Meta-datos del Blog */
/* El encabezado del post es una superficie de marca explícita. */
.post-header .post-meta,
.post-header .post-meta div,
.post-header .post-meta time,
.post-header .post-meta span {
  color: #ffffff !important;
  opacity: 1 !important;
  font-weight: 500; /* Un poco de peso para que el blanco resalte bien */
}

/* 2. Contador en Perfil de Cliente */
/* Los headers de sección también son azules.
   Hacemos el contador blanco para que coincida con el título */
.header-count {
  color: #ffffff !important;
  opacity: 1 !important;
  font-weight: 700;
}

/* --- Subnavegación (Filtros rápidos de fecha) --- */
.subnav { 
  margin-bottom: 1.5rem; 
}

.subnav__list { 
  list-style: none; 
  padding: 0; 
  margin: 0; 
  display: flex; 
  gap: 0.5rem; 
  flex-wrap: wrap; 
}

.subnav__link {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--color-border);
  background-color: var(--color-bg-card);
  color: var(--color-text);
  text-decoration: none;
  border-radius: var(--border-radius);
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

/* Estado Hover (Mouse) */
.subnav__link:hover {
  background-color: var(--color-bg-body);
  border-color: var(--color-primary);
  color: var(--color-primary);
  text-decoration: none;
}

/* Estado Foco Accesible (Teclado) */
.subnav__link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  /* Opcional: cambiar el borde también para mayor contraste */
  border-color: var(--color-primary); 
}

/* Estado Activo (Seleccionado) */
.subnav__link[aria-current="page"] {
  background-color: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
  font-weight: 600;
}

/* --- Utilidades para Nav Público --- */

/* Contenedor flexible para el contenido del nav */
.nav-container {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* Reglas de escritorio (min-width: 768px) */
@media (min-width: 768px) {
  /* Empujar los botones de acción (Login/Registro) hacia la derecha */
  .menu-links .push-right {
    margin-left: auto;
  }
}

/* --- Utilidades para la Home (Inicio) --- */

/* Contenedor para botones en el Hero */
.hero-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.inicio-hero .btn-accent {
  background-color: #b94720;
}

.inicio-hero .btn-accent:hover {
  background-color: #963716;
  text-decoration: none;
}

.btn-hero-secondary {
  background-color: transparent;
  color: #ffffff;
  border-color: #ffffff;
}

.btn-hero-secondary:hover {
  background-color: #ffffff;
  color: #1e293b !important;
  text-decoration: none;
}

/* Iconos grandes (Emojis) */
.feature-icon {
  font-size: 2.5rem;
  line-height: 1;
  margin-bottom: 1rem;
  display: block;
}

/* ==========================================================================
   CORRECCIONES ALTO CONTRASTE (A11Y HC FIXES) - V6 (NUCLEAR & ESPECÍFICA)
   Selectores reforzados para romper cualquier especificidad previa.
   ========================================================================== */

/* 1. TEXTOS Y TÍTULOS GLOBALES */
[data-theme="hc"] h1, [data-theme="hc"] h2, [data-theme="hc"] h3, 
[data-theme="hc"] h4, [data-theme="hc"] h5, [data-theme="hc"] h6,
[data-theme="hc"] p, [data-theme="hc"] strong, [data-theme="hc"] span,
[data-theme="hc"] .page-header h1, 
[data-theme="hc"] .alertas-title, 
[data-theme="hc"] .counter-text,
[data-theme="hc"] .form-hint,
[data-theme="hc"] legend,
[data-theme="hc"] label {
  color: #ffffff !important;
}

/* 2. TABLAS (Solución para .key-value-table y .data-table) */
/* Agregamos las clases específicas que causaban conflicto */
[data-theme="hc"] table,
[data-theme="hc"] .data-table,
[data-theme="hc"] .key-value-table, /* <--- CRUCIAL: Faltaba esta */
[data-theme="hc"] .table-container {
  background-color: #000000 !important;
  color: #ffffff !important;
  border-color: #ffffff !important;
}

/* Celdas y Cabeceras (Forzado masivo) */
[data-theme="hc"] th, 
[data-theme="hc"] td, 
[data-theme="hc"] tr, 
[data-theme="hc"] thead, 
[data-theme="hc"] tbody,
[data-theme="hc"] .data-table th, 
[data-theme="hc"] .data-table td,
[data-theme="hc"] .key-value-table th, /* <--- CRUCIAL */
[data-theme="hc"] .key-value-table td, /* <--- CRUCIAL */
[data-theme="hc"] .data-table th[scope="row"],
[data-theme="hc"] .key-value-table th[scope="row"] {
  background-color: #000000 !important;
  color: #ffffff !important;
  border-color: #ffffff !important;
}

/* 3. BOTÓN DE PELIGRO (Especificidad aumentada) */
/* Atacamos con etiqueta+clase para asegurar victoria sobre el estilo base */
[data-theme="hc"] button.btn-danger,
[data-theme="hc"] a.btn-danger,
[data-theme="hc"] .btn-danger {
  background-color: #ff0000 !important;
  color: #000000 !important; /* Texto Negro = Contraste 5.2:1 */
  border: 2px solid #ffffff !important;
  font-weight: 700 !important;
}

/* 4. OTROS BOTONES (Primario, Accent, Secundario) */
[data-theme="hc"] .btn-primary, 
[data-theme="hc"] .btn-accent {
  background-color: #00ffff !important;
  color: #000000 !important;
  border: 2px solid #ffffff !important;
  font-weight: 700 !important;
}

[data-theme="hc"] .btn-secondary,
[data-theme="hc"] .tab-button, 
[data-theme="hc"] .tab-nav__link {
  background-color: #000000 !important;
  color: #ffffff !important;
  border: 2px solid #ffffff !important;
}

/* 5. CONTENEDORES Y PANELES (Fondo Negro) */
[data-theme="hc"] .card, 
[data-theme="hc"] .alert, 
[data-theme="hc"] .alertas-header, 
[data-theme="hc"] .summary-box, 
[data-theme="hc"] .result-box, 
[data-theme="hc"] .result-box__content,
[data-theme="hc"] .definition-list--payment,
[data-theme="hc"] .contact-box, 
[data-theme="hc"] .danger-zone__content,
[data-theme="hc"] .md-toolbar,
[data-theme="hc"] .tab-container,
[data-theme="hc"] .login-panel,
[data-theme="hc"] .empty-state-panel {
  background-color: #000000 !important;
  color: #ffffff !important;
  border: 1px solid #ffffff !important;
  box-shadow: none !important;
}

/* 6. TEXTOS DENTRO DE PANELES */
[data-theme="hc"] .alert p,
[data-theme="hc"] .danger-zone__content p,
[data-theme="hc"] .result-box p,
[data-theme="hc"] .definition-list dt, 
[data-theme="hc"] .definition-list dd,
[data-theme="hc"] .info-list li,
[data-theme="hc"] .ordered-list li {
  color: #ffffff !important;
}

/* 7. PESTAÑAS ACTIVAS (IDs y Clases) */
[data-theme="hc"] .tab-button.active,
[data-theme="hc"] .tab-nav__link.is-active,
[data-theme="hc"] #tab-write.active, 
[data-theme="hc"] #tab-escribir.active,
[data-theme="hc"] #tab-preview.active {
  background-color: #ffff00 !important;
  color: #000000 !important;
  border-color: #ffffff !important;
}

/* 8. PESTAÑAS INACTIVAS (IDs) */
[data-theme="hc"] #tab-write, 
[data-theme="hc"] #tab-escribir, 
[data-theme="hc"] #tab-preview {
  background-color: #000000 !important;
  color: #ffffff !important;
  border-color: #ffffff !important;
}

/* 9. ESTADOS Y MONTOS */
[data-theme="hc"] .monto-adeudado { color: #ffffff !important; }
[data-theme="hc"] .is-paid { color: #00ff00 !important; } /* Verde Neón */
[data-theme="hc"] .is-due { color: #ff0000 !important; }  /* Rojo Puro */

/* 10. BORDES DE ALERTAS */
[data-theme="hc"] .alert-danger, [data-theme="hc"] .danger-zone__content { border-color: #ff0000 !important; border-width: 2px !important; }
[data-theme="hc"] .alert-warning { border-color: #ffff00 !important; border-width: 2px !important; }
[data-theme="hc"] .alert-success { border-color: #00ff00 !important; border-width: 2px !important; }
[data-theme="hc"] .alert-info { border-color: #00ffff !important; border-width: 2px !important; }

/* 11. PÍLDORAS DE ESTADO (TAGS Y STATUS) */
/* Soluciona el error de texto blanco sobre fondo gris en tags del blog */
[data-theme="hc"] .status-pill {
  background-color: #000000 !important;
  color: #ffffff !important;
  border: 1px solid #ffffff !important;
}

/* =========================================
   CORRECCIONES MODO OSCURO (CONTRASTE)
   Soluciona errores de texto blanco sobre fondo celeste (#38bdf8)
   ========================================= */

/* 1. Botones Primarios en Dark Mode: Texto oscuro para fondo claro */
[data-theme="dark"] .btn-primary,
[data-theme="dark"] .floating-message.is-success {
  color: #0f172a !important; /* Azul muy oscuro (casi negro) */
  font-weight: 700;
}

/* 2. Header Principal en Dark Mode:
   Mantenemos el texto blanco, pero oscurecemos el fondo 
   (Usamos el azul corporativo original #005a9e en lugar del celeste del tema) */
[data-theme="dark"] :where(
  .app-shell__header,
  .inicio-hero,
  .section-header,
  .post-header,
  .prose > header.text-center
) {
  background-color: #005a9e !important;
}

/* 3. Corrección extra para enlaces dentro del Header en Dark Mode
   Asegura que sigan siendo blancos sobre el fondo azul oscuro forzado */
[data-theme="dark"] :where(
  .app-shell__header,
  .inicio-hero,
  .section-header,
  .post-header,
  .prose > header.text-center
) :where(a, .brand-text) {
  color: #ffffff !important;
}

/* =========================================
   CORRECCIONES CRÍTICAS MODO OSCURO (V2)
   Soluciona: Inputs, H1, Botones Secundarios y Estados
   ========================================= */

/* 1. Títulos de Página: Forzar blanco para sobrescribir el !important base */
[data-theme="dark"] .page-header h1,
[data-theme="dark"] .page-header h2, 
[data-theme="dark"] .page-header h3 {
  color: #ffffff !important;
}

/* 2. Inputs y Selects: Fondo oscuro para que el texto blanco se lea */
[data-theme="dark"] .input-field,
[data-theme="dark"] input.input-field,
[data-theme="dark"] select.input-field,
[data-theme="dark"] textarea.input-field {
  background-color: #1e293b !important; /* Fondo gris azulado oscuro */
  border-color: #475569 !important;      /* Borde gris medio */
  color: #ffffff !important;             /* Texto blanco */
}

/* 3. Botones Secundarios: Texto negro sobre el fondo blanco del botón */
[data-theme="dark"] .btn-secondary,
[data-theme="dark"] a.btn-secondary,
[data-theme="dark"] button.btn-secondary {
  background-color: #ffffff !important;
  color: #0f172a !important; /* Texto casi negro para máximo contraste */
  border-color: #cbd5e1 !important;
}

/* 4. Estado "Pagado": Verde claro neón en lugar de verde bosque */
[data-theme="dark"] .is-paid,
[data-theme="dark"] .monto-positivo {
  color: #4ade80 !important; 
}

/* 5. Pestañas Activas: Celeste brillante en lugar de azul oscuro */
[data-theme="dark"] .tab-nav__link.is-active,
[data-theme="dark"] .tab-button.active {
  color: #38bdf8 !important;
  border-bottom-color: #38bdf8 !important;
}

/* =========================================
   CORRECCIONES FINALES (V3) - MODO OSCURO
   Objetivo: Eliminar las 51 violaciones restantes.
   ========================================= */

/* 1. Botones Primarios y Danger en Dark Mode */
/* Forzamos texto BLANCO sobre el fondo rojo/azul, asegurando que el fondo sea suficientemente oscuro */
[data-theme="dark"] .btn-primary,
[data-theme="dark"] .btn-danger {
  color: #ffffff !important; /* Texto blanco */
}

/* Ajuste de fondo para asegurar contraste con texto blanco */
[data-theme="dark"] .btn-primary {
  background-color: #0056b3 !important; /* Azul más oscuro (Ratio 6:1 con blanco) */
  border-color: #004494 !important;
}
[data-theme="dark"] .btn-danger {
  background-color: #b91c1c !important; /* Rojo oscuro (Ratio 5.8:1 con blanco) */
  border-color: #991b1b !important;
}

/* 2. Lista de Pagos (Perfil Cliente) */
/* El fondo era blanco fijo, lo cambiamos a oscuro */
[data-theme="dark"] .definition-list--payment {
  background-color: #1e293b !important; /* Slate-800 */
  border-color: #334155 !important;
}
[data-theme="dark"] .definition-list--payment dt {
  color: #94a3b8 !important; /* Slate-400 (visible sobre oscuro) */
}

/* 3. Contadores y Alertas (Dashboard Admin) */
/* Quitamos el fondo claro heredado */
[data-theme="dark"] .alertas-header {
  background-color: #1e293b !important;
  border: 1px solid #334155 !important;
}
[data-theme="dark"] .alertas-title,
[data-theme="dark"] .counter-text {
  color: #ffffff !important;
}

/* 4. Botones Editor Markdown */
/* Botones inactivos y herramientas */
[data-theme="dark"] .md-toolbar .btn,
[data-theme="dark"] .tab-button:not(.active) {
  background-color: #1e293b !important;
  color: #cbd5e1 !important;
  border-color: #475569 !important;
}

/* 5. Corrección específica para Textos de Peligro (Danger Zone) */
/* El texto dentro de las cajas rojas de alerta */
[data-theme="dark"] .alert-danger, 
[data-theme="dark"] .danger-zone__content {
  background-color: #450a0a !important; /* Rojo muy oscuro (fondo) */
  border-color: #7f1d1d !important;
  color: #fecaca !important; /* Texto rojo muy claro */
}
[data-theme="dark"] .alert-danger strong,
[data-theme="dark"] .danger-zone__content strong {
  color: #ffffff !important;
}

[data-theme="dark"] .access-message {
  background-color: #052e16;
  border-color: #166534;
  color: #d1fae5;
}

[data-theme="dark"] .access-message__content {
  background-color: var(--color-bg-card);
  border-color: var(--color-border);
}

/* =========================================
   CORRECCIONES FINALES (V4) - ELIMINACIÓN DE 18 ERRORES
   ========================================= */

/* 1. Corrección Tablas de Detalle (Compras) */
/* Fuerza texto blanco en encabezados y celdas de tablas clave-valor */
[data-theme="dark"] .key-value-table th,
[data-theme="dark"] .key-value-table td,
[data-theme="dark"] .data-table th,
[data-theme="dark"] .data-table td {
  color: #ffffff !important;
  border-color: #334155 !important;
}

/* 2. Corrección Editor de Publicaciones (Fondo Blanco Persistente) */
/* Oscurecemos todo el contenedor del editor */
[data-theme="dark"] .tab-container,
[data-theme="dark"] .tab-list {
  background-color: #1e293b !important; /* Fondo oscuro */
  border-color: #475569 !important;
}

/* Pestaña Activa: Fondo intermedio para diferenciar */
[data-theme="dark"] .tab-button.active {
  background-color: #334155 !important;
  color: #38bdf8 !important;
}

/* Texto de ayuda pequeño debajo de los inputs */
[data-theme="dark"] small, 
[data-theme="dark"] [id="ayudaContenido"] {
  color: #cbd5e1 !important; /* Gris claro visible sobre oscuro */
}

/* 3. Corrección Calculadora (Result Box) */
/* El fondo era azul pálido (#eff6ff), lo pasamos a oscuro */
[data-theme="dark"] .result-box,
[data-theme="dark"] .result-box__content, 
[data-theme="dark"] .result-box__output {
  background-color: #1e293b !important;
  border-color: #334155 !important;
}

/* Textos dentro de la calculadora */
[data-theme="dark"] .result-box h2,
[data-theme="dark"] .result-box h3,
[data-theme="dark"] .result-box__main-text,
[data-theme="dark"] .result-box__status-message {
  color: #ffffff !important;
}

[data-theme="hc"] .theme-option:hover,
[data-theme="hc"] .theme-option:has(input:checked) {
  background-color: #ffff00;
  color: #000000 !important;
}

/* El texto de estas opciones conserva el contraste frente al span global de HC. */
[data-theme="hc"] .theme-option:hover > span,
[data-theme="hc"] .theme-option:has(input:checked) > span {
  color: inherit !important;
}

@media (forced-colors: active) {
  .theme-option:has(input:checked) {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
}
/* Panel compuesto: cinco lecturas, sin tarjetas de relleno. */
#cmc-kpis.business-kpis {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

.business-kpi { min-width: 0; justify-content: flex-start; gap: 0.65rem; }
.business-kpi h3 { margin: 0; font-size: 1.1rem; line-height: 1.4; }
.business-kpi > p.business-kpi__value { margin: 0; font-size: 2rem; line-height: 1.2; font-weight: 700; }
.business-kpi .business-kpi__complemento p { margin: 0; font-size: 1rem; font-weight: 400; line-height: 1.5; color: var(--color-text); }
.business-kpi .business-kpi__complemento [data-field="comparacion"] { margin-top: 0.25rem; font-size: 0.9rem; color: var(--color-text-muted); }
.business-kpi [data-field="aviso"] { margin: 0; font-weight: 600; }
.business-kpi > a { align-self: flex-start; margin-top: auto; padding-block: 0.25rem; min-height: 24px; }
#cmc-panel > section + section { margin-top: 2.5rem; }
#cmc-panel #cmc-actualizar { margin-block: 1rem; }
.cmc-pendientes { padding-left: 1.25rem; }
.cmc-pendientes li { margin-bottom: 1rem; }
.cmc-pendientes p { margin-block: 0.25rem; }
.cmc-referencia { border-top: 1px solid var(--color-border); padding-top: 1.5rem; }
#cmc-alertas-lista .alertas-card-compact > h3,
#cmc-editorial-lista .alertas-card-compact > h3 { margin: 0; font-size: 1.1rem; line-height: 1.4; }
#cmc-alertas-lista .alertas-card-compact > p,
#cmc-editorial-lista .alertas-card-compact > p { margin: 0; }
#cmc-alertas-lista .alertas-card-compact > a,
#cmc-editorial-lista .alertas-card-compact > a { align-self: flex-start; padding-block: 0.25rem; min-height: 24px; }

@media (min-width: 640px) {
  #cmc-kpis.business-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1100px) {
  #cmc-kpis.business-kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .business-kpi { grid-column: span 2; }
  .business-kpi:nth-child(n+4) { grid-column: span 3; }
}
