/* ==========================================================================
   OrozcoyCo CC - Estilos Principales
   Sistema de Gestion Contable
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Temas y Variables (Lila | Azul | Oscuro)
   -------------------------------------------------------------------------- */
:root,
[data-color="blue"] {
  /* Claro por defecto; el bloque oscuro lo pisa a `dark`. Fija el render de los
     controles nativos (select, checkbox, scrollbar) al tema de la app. */
  color-scheme: light;

  --primary:        #2563eb;
  --primary-light:  #3b82f6;
  --primary-dark:   #1d4ed8;
  --primary-bg:     #eff6ff;
  --primary-muted:  rgba(37, 99, 235, 0.12);
  /* Color de texto sobre fondo --primary. Default blanco para que botones
     primary tengan contraste WCAG-AA. Override en temas claros (mono light
     usa #fff porque primary es negro, mono dark usa #000 porque primary
     es blanco). Pensado para reemplazar `color:white` hardcoded en botones. */
  --on-primary:     #ffffff;

  --bg:             #ffffff;
  --surface:        #ffffff;
  --surface-2:      #f8fafc;
  --border:         #e2e8f0;
  --border-2:       #cbd5e1;

  --text:           #0f172a;
  --text-2:         #475569;
  --text-muted:     #5d6b80;   /* 5.41:1 sobre blanco y 4.97 sobre --primary-bg,
                                  que es donde cae en las cards: el #64748b daba 4.37 ahi */

  --sidebar-bg:     #ffffff;
  --sidebar-text:   #475569;
  --sidebar-active: var(--primary);
  --sidebar-hover:  rgba(0,0,0,0.05);
  --sidebar-border: var(--border);

  --success:        #047857;   /* 5.49:1 sobre blanco y 5.21 sobre --success-bg;
                                  el #059669 daba 3.77 / 3.58 y fallaba AA */
  --success-bg:     #ecfdf5;
  --warning:        #a84c08;   /* 5.67:1 sobre blanco, 5.47 sobre --warning-bg y
                                  4.97 sobre el --primary-bg de marca, que es el
                                  tinte mas claro donde cae. El #d97706 daba 3.07. */
  --warning-bg:     #fffbeb;
  --danger:         #b91c1c;   /* 6.47:1 sobre blanco y 5.89 sobre --danger-bg;
                                  el #dc2626 pasaba sobre blanco (4.83) pero daba
                                  4.40 sobre su propio -bg */
  --danger-bg:      #fef2f2;
  /* Texto sobre un fondo semantico SOLIDO. Blanco en claro; en oscuro los
     semanticos se aclaran y esto pasa a negro. Mismo patron que --on-primary. */
  --on-success:     #ffffff;
  --on-warning:     #ffffff;
  --on-danger:      #ffffff;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg:  0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-full: 9999px;

  --sidebar-width: 240px;
  --header-height: 60px;
  --transition: 200ms ease;

  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;

  /* Aliases de tokens que varias paginas usaban SIN que existieran, del estilo
     `var(--bg-surface, #fff)`. Al no estar definidos el fallback claro ganaba
     SIEMPRE, tambien en oscuro: modales blancos, bordes claros, texto gris.
     Definirlos aca los engancha al tema en los 5 temas de una sola vez.
     (2026-08-26: 91 usos de 29 tokens fantasma; se enganchan los neutros, los
     semanticos como --bg-warning/--ok se dejan sin definir a proposito.) */
  --bg-surface:            var(--surface);
  --bg-muted:              var(--surface-2);
  --bg-soft:               var(--surface-2);
  --bg-input:              var(--surface);
  --surface-alt:           var(--surface-2);
  --border-color:          var(--border);
  --text-1:                var(--text);
  --text-primary:          var(--text);
  --text-secondary:        var(--text-2);
  --text-soft:             var(--text-muted);

  /* Aliases --color-* para componentes legacy (components.css, responsive.css).
     Mapean al sistema sin prefijo. Mantener hasta migrar el CSS completo. */
  --color-primary:         var(--primary);
  --color-primary-bg:      var(--primary-bg);
  --color-primary-dark:    var(--primary-dark);
  --color-secondary:       var(--primary-light);
  --color-secondary-bg:    var(--primary-bg);
  --color-secondary-dark:  var(--primary-dark);
  --color-accent:          var(--primary);
  --color-accent-bg:       var(--primary-bg);
  --color-accent-dark:     var(--primary-dark);
  --color-bg:              var(--bg);
  --color-bg-alt:          var(--surface-2);
  --color-surface:         var(--surface);
  --color-border:          var(--border);
  --color-border-dark:     var(--border-2);
  --color-text:            var(--text);
  --color-text-secondary:  var(--text-2);
  --color-text-muted:      var(--text-muted);
  --color-danger:          var(--danger);
  --color-danger-bg:       var(--danger-bg);
  --color-danger-dark:     var(--danger);

  /* ══════════════════════════════════════════════════════════════════════
     PALETA DE DATOS (2026-09-24) — mapas de calor, chips de estado, gráficos
     ──────────────────────────────────────────────────────────────────────
     Luz: «pásame una paleta de colores que para todos estos gráficos y demás
     y mapas de calor se puedan utilizar… no pienses el tema que se está
     usando, si es azul, morado, rosado, claro u oscuro».

     UNA sola paleta para los cuatro temas de marca. Lo único que cambia es
     claro/oscuro. A propósito: el rojo de «vencido» significa vencido — si en
     el tema cute fuera rosa y en marca morado, dejaría de significar algo. El
     tema pinta el CROMO de la app; el DATO se pinta con esto.

     🍷 POR QUÉ NO SE USA --danger-bg PARA LOS CHIPS EN OSCURO
     `--danger-bg` vale rgba(220,38,38,.15): un rojo OSCURO al 15% sobre un
     fondo casi negro se compone en #301620 — borgoña. Cualquier rojo con
     transparencia sobre fondo oscuro termina ahí; no es cuestión de elegir
     otro rojo. Por eso en oscuro el relleno es NEUTRO (la superficie elevada)
     y el color lo llevan la tinta y el borde.

     Las 12 combinaciones pasan AA; la peor es 5,9:1.
     ══════════════════════════════════════════════════════════════════════ */
  --e-critico-bg:  #fdeaea;  --e-critico-ink:  #9b1c1c;   /* vencido        7,04:1 */
  --e-grave-bg:    #fdeee4;  --e-grave-ink:    #9a3412;   /* ≤ 7 días       6,45:1 */
  --e-atencion-bg: #fdf3dd;  --e-atencion-ink: #854d0e;   /* ≤ 15 días      6,21:1 */
  --e-aviso-bg:    #fefbe8;  --e-aviso-ink:    #713f12;   /* ≤ 30 días      8,33:1 */
  --e-bien-bg:     #e9f7ef;  --e-bien-ink:     #0b6b46;   /* > 30 días      5,93:1 */
  --e-info-bg:     #e6f4ff;  --e-info-ink:     #1e4b8f;   /* presentada     7,63:1 */
  --e-neutro-bg:   #f1f5f9;  --e-neutro-ink:   #334155;   /* sin datos      9,45:1 */

  /* Series de gráficos: ORDEN FIJO. La serie 1 toma siempre --viz-1. Nunca se
     recicla ni se reordena — si una serie sale del filtro, las demás NO cambian
     de color. Más de 8 series no se resuelve con colores nuevos: se agrupa en
     «Otros». En dispersión o mapas usar SÓLO las 3 primeras (con más, dos dejan
     de distinguirse). Validado contra #ffffff: banda de luminosidad, piso de
     saturación, daltonismo ΔE 9,1 y visión normal ΔE 19,6. */
  --viz-1: #2a78d6;  --viz-2: #eb6834;  --viz-3: #1baf7a;  --viz-4: #eda100;
  --viz-5: #e87ba4;  --viz-6: #008300;  --viz-7: #4a3aa7;  --viz-8: #e34948;

}

[data-color="lila"] {
  --primary:        #7c3aed;
  --primary-light:  #8b5cf6;
  --primary-dark:   #6d28d9;
  --primary-bg:     #f5f3ff;
  --primary-muted:  rgba(124, 58, 237, 0.12);
  --sidebar-active: var(--primary);
}

/* Tema CUTE: pasteles amarillo + rosa + lila (inspirado en MODELO FINANZAS) */
[data-color="cute"] {
  --primary:        #c2255c;            /* rosa raspberry vibrante (2026-09-08): reemplaza
                                          el #a34d75 (mauve apagado que se veía VINOTINTO,
                                          pedido usuaria). 5.28:1 sobre blanco (AA) y blanco
                                          encima 5.28 — sigue apto para botones con texto blanco. */
  --primary-light:  #ffafcc;
  --primary-dark:   #99184a;            /* hover más profundo, mismo tono limpio (7.0:1 sobre blanco) */
  --primary-bg:     #fff5f8;            /* fondo rosa muy suave */
  --primary-muted:  rgba(212, 143, 184, 0.15);
  --sidebar-active: var(--primary);

  --bg:             #fff8ec;            /* fondo amarillo muy suave */
  --surface:        #ffffff;
  --surface-2:      #fff3e4;
  --border:         #ffe4ea;            /* rosa pastel */
  --border-2:       #fff3b0;            /* amarillo claro */

  --text:           #584a68;            /* lavanda oscuro; 4.72:1 sobre --danger-bg
                                          (el #5d4e6d daba 4.41) */
  --text-2:         #7d5f8c;
  --text-muted:     #7d5f8c;   /* 5.53:1 sobre blanco, 5.02 sobre --surface-2 y
                                  5.24 sobre --bg. El #8a6b9e daba 4.49/4.10/4.25:
                                  fallaba por poco en TODAS las superficies cute,
                                  que es de donde salian ~2000 de sus hallazgos. */

  --sidebar-bg:     linear-gradient(180deg, #cdb4db 0%, #ffafcc 100%);
  --sidebar-text:   #4d3f5c;   /* el blanco sobre el degrade pastel del sidebar daba
                                  1.71-1.88:1. El probe no mide gradientes, asi que
                                  esto no salia en ningun numero. */
  --sidebar-hover:  rgba(255, 255, 255, 0.2);
  --sidebar-border: rgba(255, 255, 255, 0.15);

  /* Semanticos de cute: sus -bg son pasteles saturados, mucho mas claros que
     los neutros de :root, asi que la tinta tiene que bajar mas. */
  --success:        #1a6b39;   /* 5.38:1 sobre --success-bg (era 3.35) */
  --success-bg:     #dcf7e5;   /* el #c5f4d4 era un pastel saturado: dejaba
                                  --text-muted en 4.44 */
  --warning:        #92400e;   /* 6.26:1 sobre --warning-bg (era 2.81) */
  --warning-bg:     #fff3b0;
  --danger:         #8c1d3a;
  --danger-bg:      #ffe4ec;   /* el #ffafcc es el rosa de acento, demasiado
                                  saturado para llevar texto: --text-muted
                                  quedaba en 3.15 */
}

/* Cute + oscuro: mantener pasteles pero sobre fondo noche */
[data-theme="dark"][data-color="cute"] {
  --bg:             #2a1e3d;
  --surface:        #3d2f50;
  --surface-2:      #2f2344;
  --border:         #5d4e6d;
  --text:           #ffc8dd;
  --text-2:         #e8d7f5;
  --primary-bg:     rgba(255, 175, 204, 0.15);
  /* Cute primary es rosa #d48fb8 — texto blanco encima da contraste 2.5 (FAIL WCAG).
     Override texto a lavanda muy oscuro (igual al --bg) que contrasta 5+ con el rosa. */
  --on-primary:     #2a1e3d;
}

[data-theme="dark"] {
  --bg:            #0f172a;
  --surface:       #1e293b;
  --surface-2:     #162032;
  --border:        #334155;
  --border-2:      #475569;

  --text:          #f1f5f9;
  --text-2:        #94a3b8;
  --text-muted:    #64748b;

  --sidebar-bg:     #0f172a;
  --sidebar-text:   #94a3b8;
  --sidebar-hover:  rgba(255,255,255,0.06);
  --sidebar-border: rgba(255,255,255,0.08);

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 6px -1px rgba(0,0,0,0.3);
  --shadow-lg:  0 10px 15px -3px rgba(0,0,0,0.3);

  /* 2026-09-25 — Luz, trabajando en OSCURO + MORADO: «sigo viendo todos esos
     vinotintos». El 2026-09-24 se migraron los chips del tablero SIMPLE a la
     paleta de datos y se dijo que el borgoña estaba resuelto: era FALSO. Esos
     tres tokens siguen siendo el fondo de 262 avisos en nomina, maximo,
     informes-dian, cuentas-cobrar, recaudo, asesoria y control-horas.
     MEDIDO, no supuesto: rgba(220,38,38,.15) sobre --surface-2 (#162032)
     compone en #342130 = hue 311 → ciruela/borgoña; sobre --bg (#0f172a) da
     #2e1929 = hue 313. Y NO se arregla bajando la opacidad: se probaron 15
     mezclas (rojo #dc2626, #f87171 y #ff0000 al 10/14/18/22/28 %) y TODAS
     caen entre hue 274 y 348. El fondo de la app es navy, así que cualquier
     rojo translúcido se va a magenta — la opacidad no es la variable.
     Lo que sí funciona es fijar el hex OPACO quitando el azul, y así el hue
     queda donde corresponde: rojo 5, ámbar 35, verde 152. Contraste del texto
     (--text #f1f5f9) 12,0 a 13,4:1; de la tinta semántica aclarada
     (--danger #f87171 / --warning #fbbf24 / --success #34d399) 5,3 a 7,9:1,
     sobre el 4,5:1 de AA.
     Se tocan los TOKENS y no los 262 llamadores a propósito: 112 de ellos sólo
     ponen `background` sin borde ni tinta, así que dejar el relleno NEUTRO
     (como en los chips) les quitaría el aviso entero — cambiaría el borgoña por
     «ningún color». Acá el relleno sigue avisando.
     --primary-bg se deja translúcido: el azul/morado sobre navy no produce el
     defecto, y [data-theme="dark"][data-color="lila"] lo redefine. */
  --success-bg:  #1d352a;
  --warning-bg:  #3a2e1d;
  --danger-bg:   #3a2220;
  --primary-bg:  rgba(37, 99, 235, 0.15);

  /* Semanticos ACLARADOS para oscuro (2026-08-26). Los valores de tema claro
     estan pensados para leerse sobre blanco; sobre el carbon el rojo daba
     3.59:1 — bajo AA. Se usan como TEXTO en ~194 lugares y como fondo solido
     en solo 4, asi que conviene optimizarlos para texto y cubrir esos 4 con
     --on-*. Medido sobre --surface: rojo 6.27, verde 9.02, ambar 10.39. */
  --danger:      #f87171;
  --success:     #34d399;
  --warning:     #fbbf24;
  --on-danger:   #0a0a0a;   /* 7.16:1 sobre el rojo claro  (blanco daria 2.77) */
  --on-success:  #0a0a0a;   /* 10.30:1 */
  --on-warning:  #0a0a0a;   /* 11.86:1 */

  /* Paleta de datos — oscuro. El relleno de los chips es NEUTRO (surface-2):
     un rojo translúcido sobre fondo oscuro da borgoña, así que el color lo
     llevan la tinta y el borde. Contrastes 8,6:1 a 11,9:1. */
  --e-critico-bg:  var(--surface-2);  --e-critico-ink:  #fca5a5;
  --e-grave-bg:    var(--surface-2);  --e-grave-ink:    #fdba74;
  --e-atencion-bg: var(--surface-2);  --e-atencion-ink: #fcd34d;
  --e-aviso-bg:    var(--surface-2);  --e-aviso-ink:    #fde68a;
  --e-bien-bg:     var(--surface-2);  --e-bien-ink:     #6ee7b7;
  --e-info-bg:     var(--surface-2);  --e-info-ink:     #93c5fd;
  --e-neutro-bg:   var(--surface-2);  --e-neutro-ink:   #cbd5e1;

  /* Series: mismos ocho matices, escalonados para la superficie oscura.
     Validado contra #1e293b: daltonismo ΔE 8,4 · visión normal ΔE 19,3. */
  --viz-1: #3987e5;  --viz-2: #d95926;  --viz-3: #199e70;  --viz-4: #c98500;
  --viz-5: #d55181;  --viz-6: #008300;  --viz-7: #9085e9;  --viz-8: #e66767;
}

[data-theme="dark"][data-color="lila"] {
  --primary-bg: rgba(124, 58, 237, 0.15);
}

/* Tema MARCA: paleta oficial orozco&co (azul #4A66F5 + lila #A78BFA) */
[data-color="marca"] {
  /* MORADO de marca (2026-08-31): unificado al morado del ícono/PWA #7C3AED por
     pedido de la usuaria ("unifica el botón de tema a morado"). Antes era azul
     #4159E8 (tuneado el 2026-08-27). El morado #7C3AED PASA AA con MÁS margen que
     el azul anterior en todas las superficies del tema: blanco 5.70:1 (era 5.50),
     --bg #fafaff 5.48 (era 5.28), --primary-bg #f0eeff 4.99 (era 4.81),
     --surface-2 #f5f3ff 5.20 (era 5.01), y texto blanco sobre --primary 5.70.
     Verificado con el calculador de contraste WCAG antes de cambiar. */
  --primary:        #7C3AED;   /* morado de marca, AA-verificado (ver arriba) */
  --primary-light:  #A78BFA;
  --primary-dark:   #6D28D9;   /* hover: oscurece (7.10:1 sobre blanco) */
  --primary-bg:     #f0eeff;
  --primary-muted:  rgba(139, 111, 232, 0.14);

  --bg:             #fafaff;
  --surface:        #ffffff;
  --surface-2:      #f5f3ff;
  --border:         #e6e3f5;
  --border-2:       #d4cfee;

  --text:           #0A0A0F;
  --text-2:         #4a4a5e;
  --text-muted:     #6b6c80;   /* 5.14:1 sobre blanco (antes #8a8ba0 -> 3.34:1) */

  --sidebar-bg:     #ffffff;
  --sidebar-text:   #4a4a5e;
  --sidebar-active: #8B6FE8;
  --sidebar-hover:  rgba(139, 111, 232, 0.08);
  --sidebar-border: #e6e3f5;

  --font:           'Geist', 'Inter', system-ui, sans-serif;
}

/* Tema MONO: blanco/negro puro, neutro sin tinte de color */
[data-color="mono"] {
  --primary:        #000000;
  --primary-light:  #333333;
  --primary-dark:   #000000;
  --primary-bg:     #f5f5f5;
  --primary-muted:  rgba(0, 0, 0, 0.10);

  --bg:             #ffffff;
  --surface:        #ffffff;
  --surface-2:      #fafafa;
  --border:         #e5e5e5;
  --border-2:       #d4d4d4;

  --text:           #000000;
  --text-2:         #333333;
  --text-muted:     #6b6b6b;   /* 4.89:1 sobre --primary-bg (era 4.35) */

  --sidebar-bg:     #ffffff;
  --sidebar-text:   #333333;
  --sidebar-active: #000000;
  --sidebar-hover:  rgba(0, 0, 0, 0.05);
  --sidebar-border: #e5e5e5;
}

/* Marca + oscuro: fondos casi-negros del manual de marca */
[data-theme="dark"][data-color="marca"] {
  --bg:             #07070C;
  --surface:        #12131F;
  --surface-2:      #191A29;
  --border:         rgba(255, 255, 255, 0.08);
  --border-2:       rgba(255, 255, 255, 0.14);

  --text:           #F5F5F7;
  --text-2:         #8A8B9A;
  --text-muted:     #5E5F70;

  --sidebar-bg:     #07070C;
  --sidebar-text:   #8A8B9A;
  --sidebar-hover:  rgba(255, 255, 255, 0.04);
  --sidebar-border: rgba(255, 255, 255, 0.08);

  --primary-bg:     rgba(79, 107, 255, 0.15);
  --primary-muted:  rgba(167, 139, 250, 0.18);
}

/* --------------------------------------------------------------------------
   2. Reset
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--primary); text-decoration: none; }
/* Un <dialog> sin background propio lo pinta el navegador con `Canvas` = BLANCO,
   tambien en tema oscuro. Se notaba poco mientras el texto era oscuro fijo; al
   pasar el texto a tokens quedaba claro sobre blanco. Selector de tipo (la
   especificidad mas baja), asi que cualquier regla de clase de una pagina gana. */
dialog { background: var(--surface); color: var(--text); }
ul, ol { list-style: none; }
table { border-collapse: collapse; width: 100%; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }
fieldset { border: none; }

/* --------------------------------------------------------------------------
   3. Login Page
   -------------------------------------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 1.5rem;
}

.login-container { width: 100%; max-width: 400px; }

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-md);
}

.login-card__header { text-align: center; margin-bottom: 2rem; }

.login-card__logo { margin-bottom: 1rem; }

.login-card__logo-fallback {
  width: 52px;
  height: 52px;
  background: var(--primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}
.login-card__logo-text { color: var(--on-primary, #fff); font-size: 1.1rem; font-weight: 700; letter-spacing: 0.05em; }
.login-card__logo-img { height: 48px; margin: 0 auto; }
.login-card__title { font-size: 1.375rem; font-weight: 700; color: var(--text); margin-bottom: 0.25rem; letter-spacing: -0.02em; }
.login-card__subtitle { font-size: 0.875rem; color: var(--text-2); }

.login-card__form { display: flex; flex-direction: column; gap: 1.25rem; }

.login-card__footer { text-align: center; margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.login-card__copyright { font-size: 0.75rem; color: var(--text-muted); }

/* --------------------------------------------------------------------------
   4. Form elements
   -------------------------------------------------------------------------- */
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.form-label { font-size: 0.8125rem; font-weight: 500; color: var(--text-2); }
.form-input-wrapper { position: relative; }

.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input-wrapper .form-input { padding-right: 2.75rem; }
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-muted);
}
.form-input::placeholder { color: var(--text-muted); }

.form-input-icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
}
.form-input-icon:hover { color: var(--text-2); }

.form-select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  appearance: none;
  cursor: pointer;
}
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-muted);
}

/* --------------------------------------------------------------------------
   5. Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  white-space: nowrap;
  /* Los <button> NO heredan color: el UA les pone `buttontext` (negro). Sin esto,
     un .btn sin variante (o con una variante inexistente como .btn--secondary)
     sale negro sobre el fondo casi negro del tema oscuro. Cada variante define
     su propio color mas abajo, asi que esto solo afecta a los que no tenian. */
  color: var(--text);
}
.btn--primary {
  background: var(--primary);
  color: var(--on-primary, #fff);
  border-color: var(--primary);
}
.btn--primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn--primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn--outline {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border-2);
}
.btn--outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }

.btn--ghost {
  background: transparent;
  color: var(--text-2);
}
.btn--ghost:hover { background: var(--surface-2); }

.btn--danger {
  background: var(--danger);
  color: var(--on-danger, #fff);
  border-color: var(--danger);
}
.btn--danger:hover { background: #991b1b; }

.btn--full { width: 100%; margin-top: 0.5rem; }
.btn--sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn--lg { padding: 0.75rem 1.5rem; font-size: 1rem; }

/* --------------------------------------------------------------------------
   6. Alert
   -------------------------------------------------------------------------- */
.alert { padding: 0.625rem 0.875rem; border-radius: var(--radius-md); font-size: 0.875rem; }
.alert--error { background: var(--danger-bg); border: 1px solid rgba(220,38,38,0.25); color: var(--danger); }
.alert--success { background: var(--success-bg); border: 1px solid rgba(5,150,105,0.25); color: var(--success); }
.alert--warning { background: var(--warning-bg); border: 1px solid rgba(217,119,6,0.25); color: var(--warning); }

/* --------------------------------------------------------------------------
   7. App Layout
   -------------------------------------------------------------------------- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --------------------------------------------------------------------------
   8. Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border, var(--border));
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
  overflow: hidden;
}

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: var(--header-height);
  border-bottom: 1px solid var(--sidebar-border, var(--border));
  flex-shrink: 0;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  overflow: hidden;
}

.sidebar__brand-icon {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--on-primary, #fff);
  flex-shrink: 0;
}

.sidebar__brand-text {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__close-btn {
  color: var(--sidebar-text);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  display: none;
}
.sidebar__close-btn:hover { background: var(--sidebar-hover); }

.sidebar__nav {
  flex: 1;
  padding: 0.75rem 0.75rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar__menu { display: flex; flex-direction: column; gap: 2px; }

.sidebar__item {}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5625rem 0.875rem;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.sidebar__link:hover {
  background: var(--sidebar-hover);
  color: var(--primary);
}
.sidebar__item--active .sidebar__link {
  background: var(--primary);
  color: var(--on-primary, #fff);
}
.sidebar__item--active .sidebar__link:hover {
  background: var(--primary-light);
}

.sidebar__icon {
  flex-shrink: 0;
  opacity: 0.85;
}
.sidebar__item--active .sidebar__icon,
.sidebar__link:hover .sidebar__icon { opacity: 1; }

.sidebar__footer {
  padding: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.sidebar__logout-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.5625rem 0.875rem;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.sidebar__logout-btn:hover { background: rgba(220,38,38,0.15); color: #f87171; }

/* --------------------------------------------------------------------------
   9. Main Wrapper & Header
   -------------------------------------------------------------------------- */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  position: sticky;
  top: 0;
  z-index: 90;
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  gap: 1rem;
}

.header__left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header__menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--text-2);
}
.header__menu-btn:hover { background: var(--surface-2); }

.header__title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
}

.header__right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Theme switcher */
.theme-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 3px;
}

.theme-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}
.theme-btn:hover { transform: scale(1.1); }
.theme-btn--active { border-color: var(--text); }
.theme-btn--blue  { background: #2563eb; }
.theme-btn--lila  { background: #7c3aed; }
.theme-btn--cute  { background: linear-gradient(135deg, #fff3b0 0%, #ffafcc 50%, #cdb4db 100%); }
.theme-btn--marca { background: linear-gradient(135deg, #7C3AED 0%, #A78BFA 100%); }
.theme-btn--mono  { background: linear-gradient(135deg, #ffffff 0% 50%, #000000 50% 100%); }
.theme-btn--dark  { background: #0f172a; }

.header__user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.header__user-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-2);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header__user-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --------------------------------------------------------------------------
   10. Main Content
   -------------------------------------------------------------------------- */
.main-content {
  flex: 1;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 1400px;
  width: 100%;
  background: var(--bg);
}

/* --------------------------------------------------------------------------
   11. KPI Cards
   -------------------------------------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); }

.kpi-card__icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.kpi-card__icon--blue   { background: var(--primary-bg); color: var(--primary); }
.kpi-card__icon--green  { background: var(--success-bg); color: var(--success); }
.kpi-card__icon--yellow { background: var(--warning-bg); color: var(--warning); }
.kpi-card__icon--red    { background: var(--danger-bg);  color: var(--danger);  }

.kpi-card__content { min-width: 0; }
.kpi-card__label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-card__value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
}

/* --------------------------------------------------------------------------
   12. Charts Grid
   -------------------------------------------------------------------------- */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* --------------------------------------------------------------------------
   13. Card
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.card__title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.card__body { padding: 1.25rem; }

.chart-container {
  position: relative;
  height: 220px;
}

/* --------------------------------------------------------------------------
   14. Table
   -------------------------------------------------------------------------- */
.table-responsive { overflow-x: auto; }

.table { width: 100%; }
.table thead tr {
  background: var(--surface-2);
}
.table th {
  padding: 0.625rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }

/* --------------------------------------------------------------------------
   15. Empty State
   -------------------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  gap: 0.75rem;
  text-align: center;
}
.empty-state__text { color: var(--text-muted); font-size: 0.875rem; }

/* --------------------------------------------------------------------------
   16. Badge / Tag
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
}
.badge--blue    { background: var(--primary-bg); color: var(--primary); }
.badge--green   { background: var(--success-bg); color: var(--success); }
.badge--yellow  { background: var(--warning-bg); color: var(--warning); }
.badge--red     { background: var(--danger-bg);  color: var(--danger);  }
.badge--gray    { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }

/* --------------------------------------------------------------------------
   17. Toast notifications
   -------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  color: var(--text);
  animation: toast-in 250ms ease;
  max-width: 360px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(0.5rem); }
  to   { opacity: 1; transform: translateY(0); }
}

.toast--success { border-left: 3px solid var(--success); }
.toast--error   { border-left: 3px solid var(--danger); }
.toast--warning { border-left: 3px solid var(--warning); }
.toast--info    { border-left: 3px solid var(--primary); }

/* --------------------------------------------------------------------------
   18. Modal
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fade-in 200ms ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slide-up 200ms ease;
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(1rem); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal__title { font-size: 1rem; font-weight: 600; color: var(--text); }
.modal__close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.modal__close:hover { background: var(--surface-2); color: var(--text); }
.modal__body { padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   19. Spinner
   -------------------------------------------------------------------------- */
.spinner {
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   20. Sidebar overlay (mobile)
   -------------------------------------------------------------------------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}
/* 2026-08-25: esta regla NO tenía media query -- ".sidebar-overlay--visible"
   quedaba display:block en CUALQUIER ancho de pantalla, incluido desktop,
   donde el sidebar ya está siempre visible (no hay nada que "abrir"). Efecto:
   click en cualquier botón "☰"/#sidebar-toggle en desktop dejaba toda la
   pantalla gris sin forma obvia de cerrarlo. css/responsive.css YA tiene la
   versión correcta de esta regla, scopeada a @media (max-width: 768px) --
   se restringe acá al mismo breakpoint para no duplicar/pisar ese scope.
   Reporte usuaria: "los 3 rayas deja en gris la pantalla" (maximo-pdfs-masivo.html). */
@media (max-width: 768px) {
  .sidebar-overlay--visible { display: block; }
}

/* --------------------------------------------------------------------------
   21. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
  }
  .sidebar--open {
    transform: translateX(0);
  }
  .sidebar__close-btn { display: flex; }
  .main-wrapper { margin-left: 0; }
  .header__menu-btn { display: flex; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .main-content { padding: 1rem; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .header { padding: 0 1rem; }
}

/* --------------------------------------------------------------------------
   22. Sidebar logo & layout alternativo (servicios/calendario/pagos)
   -------------------------------------------------------------------------- */
.sidebar__logo {
  height: 34px;
  width: auto;
  max-width: 170px;
  display: block;
  /* Era #fff fijo, de cuando el sidebar era oscuro. Con --sidebar-bg blanco el
     texto del logo quedaba blanco sobre blanco: 1.0:1, invisible, en 7 paginas
     de Maximo y en los 5 temas. */
  color: var(--sidebar-text, var(--text));
}

/* sidebar__brand directo en <aside> (sin sidebar__header wrapper) */
.sidebar > .sidebar__brand {
  display: flex;
  align-items: center;
  padding: 0 1rem;
  height: var(--header-height);
  border-bottom: 1px solid var(--sidebar-border, var(--border));
  flex-shrink: 0;
}

/* sidebar__link--active (clases directas, sin sidebar__item) */
.sidebar__link--active {
  background: var(--primary) !important;
  color: var(--on-primary, #fff) !important;
}

/* .sidebar ~ .main-content: layout wrapper en servicios/cal/pagos */
.sidebar ~ .main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* .page-content: zona interior de contenido */
.page-content {
  flex: 1;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Header dentro de .main-content directo */
.main-content > .header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* Responsive para sidebar ~ main-content */
@media (max-width: 768px) {
  .sidebar ~ .main-content { margin-left: 0; }
}

/* --------------------------------------------------------------------------
   22b. Navegación MÓVIL — drawer global (js/sidebar-nav.js → initMobileNav)
   Fix 2026-08-31: el hamburguesa ahora se cablea globalmente. Estos estilos
   dan (a) el botón flotante de respaldo cuando la página no tiene .header,
   (b) el bloqueo de scroll del body con el drawer abierto, y (c) redes de
   seguridad contra el scroll horizontal en pantallas chicas.
   -------------------------------------------------------------------------- */
/* Botón flotante de respaldo: oculto en desktop, visible solo en móvil */
.oz-mnav-fab { display: none; }

@media (max-width: 768px) {
  /* Botón hamburguesa (inyectado o existente) SIEMPRE visible y táctil en móvil */
  .header__menu-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text, #1e293b);
    -webkit-tap-highlight-color: transparent;
  }

  /* Botón flotante de respaldo (páginas sin .header) */
  .oz-mnav-fab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1001;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md, 10px);
    border: 1px solid var(--border, #e2e8f0);
    background: var(--surface, #fff);
    color: var(--text, #1e293b);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  }

  /* El overlay del drawer debe tapar todo y quedar sobre el contenido */
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 999;
    display: none;
  }
  .sidebar-overlay--visible { display: block; }
  .sidebar { z-index: 1000; }

  /* Bloquear el scroll del fondo mientras el drawer está abierto */
  body.oz-mnav-open { overflow: hidden; }

  /* Redes de seguridad contra el scroll horizontal en móvil:
     medios/tablas/preformateados largos no deben empujar el layout. */
  .page-content,
  .main-content,
  .card,
  .card__body { max-width: 100%; }
  .page-content img,
  .card img,
  .page-content pre,
  .card pre { max-width: 100%; }
  /* OJO: NO forzar `table{max-width:100%}` — las tablas contables anchas deben
     poder desbordar su contenedor y hacer scroll horizontal (.table-wrapper /
     .table-responsive tienen overflow-x:auto); recortarlas al 100% las apretaría
     ilegiblemente en móvil. */

  /* Tablas anchas: scroll horizontal DENTRO de su contenedor (norma
     "visibilidad-movil"). Estos son los contenedores canónicos; una tabla ancha
     SIEMPRE debe vivir dentro de uno de estos (o de .oz-tabla-scroll). */
  .table-wrapper,
  .table-responsive,
  .tabla-scroll,
  .tabla-responsive,
  .oz-tabla-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  /* La tabla dentro del helper mantiene su ancho natural y scrollea (no se
     comprime ilegible). Solo el helper opt-in — no toca tablas existentes. */
  .oz-tabla-scroll > table { min-width: max-content; }

  /* Tap targets cómodos al dedo (norma "visibilidad-movil": mínimo ~40px) */
  .btn { min-height: 40px; }
  .btn--sm { min-height: 34px; }
  .sidebar__link { padding-top: 0.6rem; padding-bottom: 0.6rem; }
}

/* --------------------------------------------------------------------------
   23. Modal overlay (backdrop para modales custom)
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 300;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.5rem 1rem;
  overflow-y: auto;
}
.modal--large { max-width: 1100px; }
.modal--sm    { max-width: 440px; }

/* --------------------------------------------------------------------------
   24. Toolbar (barra de herramientas: búsqueda + filtros + acciones)
   -------------------------------------------------------------------------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.875rem 1rem;
  box-shadow: var(--shadow-sm);
}
.toolbar__search { flex: 1 1 220px; }
.toolbar__filters { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.toolbar__actions { display: flex; gap: 0.5rem; align-items: center; margin-left: auto; }

/* --------------------------------------------------------------------------
   25. Search box
   -------------------------------------------------------------------------- */
.search-box { position: relative; display: flex; align-items: center; }
.search-box__icon {
  position: absolute;
  left: 0.75rem;
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
}
.search-box__input {
  width: 100%;
  padding: 0.5rem 0.875rem 0.5rem 2.5rem;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-box__input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-muted);
}
.search-box__input::placeholder { color: var(--text-muted); }

/* --------------------------------------------------------------------------
   26. Form layout: rows y anchos relativos
   -------------------------------------------------------------------------- */
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  width: 100%;
}
.form-group--half    { flex: 1 1 calc(50% - 0.5rem);    min-width: 160px; }
.form-group--third   { flex: 1 1 calc(33.333% - 0.67rem); min-width: 130px; }
.form-group--quarter { flex: 1 1 calc(25% - 0.75rem);   min-width: 110px; }
.form-group--sixth   { flex: 0 0 72px; }
.form-group--inline  { display: flex; flex-direction: column; gap: 0.25rem; }
.form-select--sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; height: auto; }
.form-input--sm  { padding: 0.375rem 0.625rem; font-size: 0.8125rem; }
.form-textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface);
  resize: vertical;
  min-height: 80px;
  outline: none;
  font-family: inherit;
  line-height: 1.5;
}
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-muted);
}
.required { color: var(--danger); margin-left: 2px; }

/* --------------------------------------------------------------------------
   27. Collapsible sections (fieldset con legend clickeable)
   -------------------------------------------------------------------------- */
.collapsible-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.collapsible-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  gap: 0.5rem;
  width: 100%;
  text-align: left;
}
.collapsible-section__title { font-size: 0.875rem; font-weight: 600; color: var(--text); }
.collapsible-section__chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform var(--transition);
}
.collapsible-section__content {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--surface);
}
.collapsible-section:not(.collapsible-section--open) .collapsible-section__content { display: none; }
.collapsible-section--open .collapsible-section__chevron { transform: rotate(180deg); }

/* --------------------------------------------------------------------------
   28. Pagination
   -------------------------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0 0;
  gap: 0.75rem;
}
.pagination__btn {
  padding: 0.375rem 0.875rem;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  color: var(--text-2);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
}
.pagination__btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-bg);
}
.pagination__btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination__info { font-size: 0.8125rem; color: var(--text-muted); }

/* --------------------------------------------------------------------------
   29. Checkbox grid (obligaciones tributarias)
   -------------------------------------------------------------------------- */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition);
  font-size: 0.875rem;
  color: var(--text);
}
.checkbox-item:hover { background: var(--surface-2); }
.checkbox-item input[type="checkbox"] { flex-shrink: 0; accent-color: var(--primary); }
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }

/* --------------------------------------------------------------------------
   30. Dynamic entries (matrículas, campos extra)
   -------------------------------------------------------------------------- */
.dynamic-entry {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.dynamic-entry__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.dynamic-entry__title { font-size: 0.875rem; font-weight: 600; color: var(--text); margin: 0; }
.dynamic-entry--inline { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 0.5rem; }

/* --------------------------------------------------------------------------
   31. Upload zone (importar)
   -------------------------------------------------------------------------- */
.upload-zone {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.upload-zone:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }
.upload-zone__text { font-size: 0.875rem; font-weight: 500; color: var(--text-2); }
.upload-zone__hint { font-size: 0.75rem; color: var(--text-muted); }
.upload-zone__input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

/* --------------------------------------------------------------------------
   32. Obligacion items (con campos condicionales)
   -------------------------------------------------------------------------- */
.obligacion-item { margin-bottom: 0.5rem; }
.obligacion-campos { gap: 0.5rem; margin-left: 1.5rem; margin-top: 4px; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   33. Misc utility
   -------------------------------------------------------------------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
.btn--xs { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.empty-state__sub { font-size: 0.8125rem; color: var(--text-muted); }
.btn__loader { display: inline-flex; align-items: center; }
.import-preview { margin-top: 1rem; }
.import-preview__info { font-size: 0.875rem; color: var(--text-2); margin-bottom: 0.5rem; }
.import-preview__errors { background: var(--danger-bg); border: 1px solid rgba(220,38,38,0.2); border-radius: var(--radius-md); padding: 0.75rem; font-size: 0.8125rem; color: var(--danger); }

/* --------------------------------------------------------------------------
   34. Collapsible JS toggle (via data-toggle)
   -------------------------------------------------------------------------- */
[data-toggle] { cursor: pointer; user-select: none; }

@media (max-width: 640px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar__actions { margin-left: 0; }
  .form-group--half, .form-group--third, .form-group--quarter { min-width: 100%; }
}

/* =================================================================
   CALENDARIO TRIBUTARIO — Grid mensual
   ================================================================= */
.calendario__layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  padding: 16px;
}
@media (max-width: 900px) {
  .calendario__layout { grid-template-columns: 1fr; }
}
.calendario__grid { display: flex; flex-direction: column; }
.calendario__header-dias {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-2);
  text-align: center;
}
.calendario__celdas {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-dia {
  aspect-ratio: 1;
  min-height: 70px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: all 0.15s;
  overflow: hidden;
}
.cal-dia:hover:not(.cal-dia--vacio) {
  background: var(--primary-muted);
  border-color: var(--primary);
  transform: translateY(-1px);
}
.cal-dia--vacio { background: transparent; border: none; cursor: default; }
.cal-dia--hoy { border: 2px solid var(--primary); background: var(--primary-muted); }
.cal-dia--con-obligaciones { border-left: 3px solid var(--primary); }
.cal-dia--success { background: var(--success-bg); }
.cal-dia--warning { background: var(--warning-bg); }
.cal-dia--danger  { background: var(--danger-bg); }
.cal-dia__numero { font-weight: 600; font-size: 14px; color: var(--text); }
.cal-dia__badges { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 4px; }
.cal-dia__badge {
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--primary);
  color: var(--on-primary, #fff);
  font-weight: 600;
  line-height: 1.2;
}
.cal-dia__badge--more { background: var(--text-muted); }
.cal-dia__count {
  position: absolute;
  bottom: 4px;
  right: 4px;
  font-size: 10px;
  color: var(--text-2);
  font-weight: 600;
}
.calendario__sidebar {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 12px;
  min-height: 200px;
  max-height: 500px;
  overflow-y: auto;
}
.cal-sidebar__title { margin: 0 0 8px; font-size: 14px; color: var(--text); }
.mes-actual-label {
  font-size: 16px;
  font-weight: 600;
  padding: 0 12px;
  color: var(--text);
}
.tabs__btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
  transition: all 0.15s;
}
.tabs__btn:hover { background: var(--surface-2); }
.tabs__btn--active { background: var(--primary); color: var(--on-primary, #fff); border-color: var(--primary); }
.tabs__list { display: flex; gap: 6px; flex-wrap: wrap; }

/* =================================================================
   GESTIÓN DE SERVICIOS — resaltado suave de filas con valor
   ================================================================= */
.servicio-row--con-valor {
  background: linear-gradient(90deg, rgba(5, 150, 105, 0.08), rgba(5, 150, 105, 0.03));
}
.servicio-row--con-valor td:first-child {
  border-left: 3px solid #059669;
}
[data-color="cute"] .servicio-row--con-valor {
  background: linear-gradient(90deg, rgba(255, 175, 204, 0.18), rgba(255, 243, 176, 0.08));
}
[data-color="cute"] .servicio-row--con-valor td:first-child {
  border-left: 3px solid #d48fb8;
}
[data-theme="dark"] .servicio-row--con-valor {
  background: linear-gradient(90deg, rgba(5, 150, 105, 0.18), rgba(5, 150, 105, 0.05));
}

/* =================================================================
   CONFIG: tablas con scroll horizontal cuando no caben
   ================================================================= */
#config-bancos-tabla,
#config-clasif-gasto-tabla,
#config-grupos-gasto-tabla,
#config-cat-gasto-tabla,
#config-categorias-tabla,
#config-tipos-tabla,
#config-obligaciones-tabla,
#config-estados-tabla,
#config-municipios-tabla,
#config-tiposdoc-tabla {
  overflow-x: auto;
  max-width: 100%;
}
#config-bancos-tabla table,
#config-clasif-gasto-tabla table,
#config-grupos-gasto-tabla table,
#config-cat-gasto-tabla table,
#config-categorias-tabla table,
#config-tipos-tabla table,
#config-obligaciones-tabla table,
#config-estados-tabla table,
#config-municipios-tabla table,
#config-tiposdoc-tabla table {
  min-width: 520px;
}

/* Padding final para evitar que se corte el contenido al hacer scroll */
.finanzas-page .page-content {
  padding-bottom: 60px !important;
}

/* Botones de acción de la última columna: no compactar */
.fin-table th:last-child,
.fin-table td:last-child {
  white-space: nowrap;
  min-width: 80px;
}

/* =================================================================
   CALENDARIO — Toggle de vista (Día / Semana / Mes) + listas
   ================================================================= */
.view-btn {
  border-radius: 0;
  border: none;
  border-right: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.view-btn:last-child { border-right: none; }
.view-btn:hover { background: var(--surface-2); }
.view-btn--active { background: var(--primary); color: var(--on-primary, #fff); }

/* Lista detallada (para vista Día o Semana) */
.cal-lista {
  padding: 12px;
  max-height: 600px;
  overflow-y: auto;
}
.cal-lista__dia {
  margin-bottom: 16px;
  border-left: 3px solid var(--primary);
  padding-left: 10px;
}
.cal-lista__dia--hoy { border-left-color: var(--success); }
.cal-lista__dia-titulo {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  margin: 0 0 6px;
  padding: 6px 10px;
  background: var(--primary-muted);
  border-radius: 6px;
}
.cal-lista__item {
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px dashed var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
}
.cal-lista__item:last-child { border-bottom: none; }
.cal-lista__badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--primary);
  color: var(--on-primary, #fff);
  font-weight: 600;
}

/* =================================================================
   BUSQUEDA GLOBAL (Ctrl+K)
   ================================================================= */
.bg-item:hover, .bg-item--active {
  background: var(--primary-muted);
}
.bg-grupo { margin-bottom: 4px; }
#bg-trigger:hover { transform: translateY(-2px); transition: all 0.15s; }

/* =================================================================
   FIN-CHIP — chips de filtro (CxC, etc.)
   ================================================================= */
.fin-chip {
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.fin-chip:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.fin-chip--active {
  background: var(--primary);
  color: var(--on-primary, #fff);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-muted);
}

/* ==========================================================================
   OROZCO&CO — Sistema de marca (Abril 2026)
   Prefijo "oz-" para aislar estilos — no pisa nada existente.
   Auto-adapta al tema: claro por defecto, oscuro con [data-theme="dark"].
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Playfair+Display:ital,wght@1,400;1,500&display=swap');

.oz-logo {
  display: inline-flex;
  align-items: center;
  position: relative;
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.035em;
  text-decoration: none;
  user-select: none;
  color: var(--text);
}
.oz-logo__text {
  position: relative;
  z-index: 3;
  white-space: nowrap;
}
.oz-logo__amp {
  font-family: 'Playfair Display', 'Georgia', serif;
  font-style: italic;
  font-weight: 500;
  background: linear-gradient(135deg, #7C3AED 0%, #A78BFA 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding: 0 0.02em;
}
.oz-logo__symbol {
  position: absolute;
  right: -0.6em;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  pointer-events: none;
  width: 1.8em;
  height: 2.1em;
}
.oz-logo__symbol svg {
  width: 100%;
  height: 100%;
  display: block;
}
.oz-logo__symbol svg path {
  stroke: #8B6FE8;
  opacity: 0.35;
}

/* Dark: cuando el tema global está en oscuro o un padre lo fuerza */
[data-theme="dark"] .oz-logo,
.oz-logo--dark {
  color: #F5F5F7;
}
[data-theme="dark"] .oz-logo .oz-logo__amp,
.oz-logo--dark .oz-logo__amp {
  background: linear-gradient(135deg, #A78BFA 0%, #C4B5FD 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
[data-theme="dark"] .oz-logo .oz-logo__symbol svg path,
.oz-logo--dark .oz-logo__symbol svg path {
  stroke: #A78BFA;
  opacity: 0.5;
}

/* Light explícito (sobre fondos claros forzados) */
.oz-logo--light { color: var(--text); }
.oz-logo--light .oz-logo__amp {
  background: linear-gradient(135deg, #7C3AED 0%, #A78BFA 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.oz-logo--light .oz-logo__symbol svg path {
  stroke: #8B6FE8;
  opacity: 0.35;
}

/* Tamaños */
.oz-logo--sm { font-size: 1.25rem; }
.oz-logo--md { font-size: 1.5rem; }
.oz-logo--lg { font-size: 2.25rem; }
.oz-logo--xl { font-size: 3.5rem; }

/* Ajuste específico para el sidebar del despacho (navbar lateral fija) */
.sidebar__brand .oz-logo,
.sidebar__logo .oz-logo {
  font-size: 1.35rem;
  padding-right: 1.2em; /* deja aire para el Chōkurei */
}
/* 2026-09-17 — 6 páginas de Máximo (balance-prueba, comprobante-nuevo,
   config-compras, libro-diario, mov-aux-cuenta/tercero) usan `.sidebar__logo`
   (170px, 34px alto) con el wordmark Y un <span> "OrozcoyCo" al lado: el
   símbolo absoluto del wordmark se montaba sobre el texto y se veía "roto".
   El wordmark ya dice la marca; el texto sobra (el despacho no lo lleva). */
.sidebar__logo { display: flex; align-items: center; max-width: none; }
.sidebar__logo .oz-logo + .sidebar__logo-text,
.sidebar__logo .oz-logo + span { display: none; }

/* App icon squircle (favicon-like, opcional) */
.oz-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #7C3AED 0%, #A78BFA 100%);
  border-radius: 25%;
  position: relative;
  box-shadow: 0 10px 30px rgba(124,58,237,0.35),
              inset 0 1px 0 rgba(255,255,255,0.2);
  flex-shrink: 0;
}
.oz-icon::after {
  content: '';
  position: absolute;
  inset: 1.5px;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.15), transparent 50%);
  pointer-events: none;
}
.oz-icon svg {
  position: relative;
  z-index: 2;
  width: 58%;
  height: 68%;
}
.oz-icon svg path { stroke: white; }
.oz-icon--xs { width: 32px; height: 32px; border-radius: 8px; }
.oz-icon--sm { width: 44px; height: 44px; border-radius: 11px; }
.oz-icon--md { width: 64px; height: 64px; border-radius: 16px; }
.oz-icon--lg { width: 96px; height: 96px; border-radius: 24px; }
.oz-icon--xl { width: 128px; height: 128px; border-radius: 32px; }

/* =========================================================================
   TEMA MARCA — overrides globales para colores hardcodeados en JS
   (js/agenda.js, js/dashboard.js, js/clientes.js, js/calendario.js
    usan inline styles con pasteles que no respetan el tema activo)
   ========================================================================= */

/* ── Dashboard KPI cards (js/agenda.js líneas 339-363) ──────────── */
[data-theme="dark"][data-color="marca"] .kpi[style*="#bde0fe"] {
  background: linear-gradient(135deg, #12131F 0%, rgba(99, 102, 241, 0.28) 100%) !important;
  border-color: rgba(167, 139, 250, 0.25) !important;
}
[data-theme="dark"][data-color="marca"] .kpi[style*="#c5f4d4"] {
  background: linear-gradient(135deg, #12131F 0%, rgba(34, 197, 94, 0.25) 100%) !important;
  border-color: rgba(34, 197, 94, 0.40) !important;
}
[data-theme="dark"][data-color="marca"] .kpi[style*="#fff3b0"] {
  background: linear-gradient(135deg, #12131F 0%, rgba(251, 191, 36, 0.25) 100%) !important;
  border-color: rgba(251, 191, 36, 0.40) !important;
}
[data-theme="dark"][data-color="marca"] .kpi[style*="#ffafcc"] {
  background: linear-gradient(135deg, #12131F 0%, rgba(239, 68, 68, 0.25) 100%) !important;
  border-color: rgba(239, 68, 68, 0.40) !important;
}
[data-color="marca"] .kpi[style*="linear-gradient"] > div[style*="color:#334155"] {
  color: #C4B5FD !important;
}
[data-color="marca"] .kpi[style*="linear-gradient"] > div[style*="color:#1e293b"] {
  color: #F5F5F7 !important;
}
[data-theme="dark"][data-color="marca"] .kpi > div[style*="color:#5d4e6d"],
[data-theme="dark"][data-color="marca"] .kpi > div[style*="color:#166534"],
[data-theme="dark"][data-color="marca"] .kpi > div[style*="color:#92400e"],
[data-theme="dark"][data-color="marca"] .kpi > div[style*="color:#9f1239"] {
  color: #8A8B9A !important;
}

/* Light marca: fondos claros con tinte lila en vez de pasteles */
[data-color="marca"]:not([data-theme="dark"]) .kpi[style*="#bde0fe"] {
  background: linear-gradient(135deg, #ffffff 0%, #dce4ff 100%) !important;
}
[data-color="marca"]:not([data-theme="dark"]) .kpi[style*="#c5f4d4"] {
  background: linear-gradient(135deg, #ffffff 0%, #d1fae5 100%) !important;
}
[data-color="marca"]:not([data-theme="dark"]) .kpi[style*="#fff3b0"] {
  background: linear-gradient(135deg, #ffffff 0%, #fef3c7 100%) !important;
}
[data-color="marca"]:not([data-theme="dark"]) .kpi[style*="#ffafcc"] {
  background: linear-gradient(135deg, #ffffff 0%, #fde0ea 100%) !important;
}

/* ── Alertas / banners (js/agenda.js líneas 414, 428) ──────────── */
[data-theme="dark"][data-color="marca"] [style*="background:#fff3b0"][style*="border:2px solid #ffd166"] {
  background: rgba(251, 191, 36, 0.10) !important;
  border-color: rgba(251, 191, 36, 0.40) !important;
  color: #fde68a !important;
}
[data-theme="dark"][data-color="marca"] [style*="background:#ffe4e6"][style*="border:2px solid #f43f5e"] {
  background: rgba(239, 68, 68, 0.10) !important;
  border-color: rgba(239, 68, 68, 0.40) !important;
  color: #fca5a5 !important;
}
[data-theme="dark"][data-color="marca"] [style*="background:#fff3b0"][style*="border:2px solid #ffd166"] a,
[data-theme="dark"][data-color="marca"] [style*="background:#ffe4e6"][style*="border:2px solid #f43f5e"] a {
  color: #F5F5F7 !important;
}

/* ── Badges de entidad y estado inline en agenda.js y calendario.js ── */
[data-theme="dark"][data-color="marca"] .badge[style*="background:#fff3b0"] {
  background: rgba(251, 191, 36, 0.18) !important;
  color: #fde68a !important;
}
[data-theme="dark"][data-color="marca"] .badge[style*="background:#ffafcc"] {
  background: rgba(239, 68, 68, 0.18) !important;
  color: #fca5a5 !important;
}
[data-theme="dark"][data-color="marca"] .badge[style*="background:#bde0fe"] {
  background: rgba(99, 102, 241, 0.20) !important;
  color: #93c5fd !important;
}
[data-theme="dark"][data-color="marca"] .badge[style*="background:#c5f4d4"] {
  background: rgba(34, 197, 94, 0.18) !important;
  color: #86efac !important;
}
[data-theme="dark"][data-color="marca"] .badge[style*="background:#cdb4db"] {
  background: rgba(167, 139, 250, 0.20) !important;
  color: #c4b5fd !important;
}

/* ── Filas de tabla con alerta de vencimiento (js/dashboard.js, js/clientes.js) ── */
[data-theme="dark"][data-color="marca"] tr[style*="background:#fff5f5"],
[data-theme="dark"][data-color="marca"] tr[style*="background:#fff0f2"] {
  background: rgba(239, 68, 68, 0.08) !important;
}

/* ── Modal headers con fondo pastel hardcoded ── */
[data-theme="dark"][data-color="marca"] .modal__header[style*="background:#fff3b0"] {
  background: rgba(251, 191, 36, 0.15) !important;
  color: #fde68a !important;
}

/* ──────────────────────────────────────────────────────────────────
   Sidebar — grupo colapsable (Conciliación, etc.)
   Patrón: <details class="sidebar__group"> con summary + submenu.
   ────────────────────────────────────────────────────────────────── */
.sidebar__group {
    margin: 2px 0;
}
.sidebar__group > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    /* hereda look del sidebar__link via clase compartida en el HTML */
}
.sidebar__group > summary::-webkit-details-marker { display: none; }
.sidebar__group-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.sidebar__group-arrow {
    margin-left: auto;
    font-size: 10px;
    opacity: 0.6;
    transition: transform 0.15s ease;
}
.sidebar__group[open] > summary .sidebar__group-arrow {
    transform: rotate(180deg);
}
.sidebar__submenu {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-left: 12px;
    padding-left: 10px;
    border-left: 2px solid var(--sidebar-hover, rgba(255,255,255,0.08));
    margin-top: 2px;
}
.sidebar__sublink {
    font-size: 0.825rem !important;
    padding: 0.4375rem 0.75rem !important;
    opacity: 0.92;
}
.sidebar__sublink:hover {
    opacity: 1;
}

/* =========================================================================
   DARK MODE "TIPO CÓDIGO" — fondo NEGRO + letras del color del tema
   Pedido literal usuaria 2026-06-13:
   "si lo tengo oscuro en azul entonces todo sea negro y todas las letras
    en azul, y así con el morado y con el rosado [...] tipo código todo
    con fondo negro y letras de colores"
   Aplica a TODOS los temas (blue, lila, cute, marca) en data-theme=dark.
   Va al final del archivo para tener prioridad por orden sobre los bloques
   previos de [data-theme="dark"] (especificidad equivalente).
   ========================================================================= */

/* 1. Fondos base (override del dark anterior) */
[data-theme="dark"] {
  /* Le avisa al navegador que la UI es oscura, y con eso pinta oscuros los
     controles NATIVOS que el CSS no puede tocar: <select> desplegados,
     checkboxes, radios, scrollbars, date pickers, el fondo del autofill.
     Sin esto quedan blancos y cantan sobre el carbón — se veia en el Informe
     Ejecutivo (los selects) y en Clientes (los checkboxes). 2026-08-26. */
  color-scheme: dark;
  --bg:             #121212;
  --surface:        #1a1a1e;
  --surface-2:      #202024;
  --border:         rgba(255, 255, 255, 0.10);
  --border-2:       rgba(255, 255, 255, 0.18);
  --sidebar-bg:     #121212;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-hover:  rgba(255, 255, 255, 0.06);
  --shadow-sm:      0 1px 3px rgba(0, 0, 0, 0.6);
  --shadow-md:      0 4px 6px -1px rgba(0, 0, 0, 0.6);
  --shadow-lg:      0 10px 15px -3px rgba(0, 0, 0, 0.6);
}

/* 2. Letras del color del tema por cada combinación.

   --primary SE ACLARA en oscuro (2026-08-26). Sobre fondo negro el --primary
   claro daba ~3.8:1 como texto (y 3.6:1 sobre --primary-bg): ilegible para
   texto normal. Acá --primary toma el tono "light" de cada tema, así todo
   `color:var(--primary)` pasa AA sobre negro.

   Consecuencia obligatoria: sobre un fondo --primary aclarado el blanco YA NO
   contrasta, así que --on-primary pasa a negro. Todo botón primary debe usar
   `color:var(--on-primary, #fff)` — nunca `color:#fff` hardcodeado (barrido de
   108 sitios el 2026-08-26; lo vigila el test global de hex de marca).

   --primary-dark ACLARA en vez de oscurecer: es el estado :hover, y en fondo
   negro lo idiomático (y lo único que mantiene AA) es que el hover ilumine. */
[data-theme="dark"][data-color="blue"] {
  --text:           #93c5fd;
  --text-2:         #60a5fa;
  --text-muted:     #8794a8;   /* 5.28:1 sobre --surface-2 del carbon suave */
  --sidebar-text:   #60a5fa;
  --primary:        #5b9af8;   /* 5.74:1 sobre --surface-2, 5.03:1 sobre el tinte
                                  --primary-bg apoyado en --surface-2 (era 4.42 con
                                  #4a8ef7); texto negro encima 7.00:1 */
  --primary-light:  #93c5fd;
  --primary-dark:   #60a5fa;   /* hover: ilumina */
  --on-primary:     #0a0a0a;   /* 5.5:1 sobre el nuevo --primary */
  /* 0.08 y no 0.12: `color:var(--primary)` sobre `background:var(--primary-bg)`
     es un par idiomatico que aparece ~31 veces (contadores de Maximo, th de
     tablas, chips). Con 0.12 el tinte subia el fondo a rgb(34,43,56) y el par
     daba 4.43:1 — fallaba AA por un pelo. Con 0.08 da 4.75:1 y el tinte sigue
     siendo visible. Solo blue estaba al limite: lila da 5.15, marca 4.94. */
  --primary-bg:     rgba(96, 165, 250, 0.08);
  --primary-muted:  rgba(96, 165, 250, 0.18);
}

[data-theme="dark"][data-color="lila"] {
  --text:           #c4b5fd;
  --text-2:         #a78bfa;
  --text-muted:     #9a86c9;   /* 6.25:1 sobre negro (antes #6d28d9) */
  --sidebar-text:   #a78bfa;
  --primary:        #a78bfa;   /* 7.24:1 sobre negro (antes #7c3aed → 2.7:1) */
  --primary-light:  #ddd6fe;
  --primary-dark:   #c4b5fd;   /* hover: ilumina */
  --on-primary:     #0a0a0a;
  --primary-bg:     rgba(167, 139, 250, 0.12);
  --primary-muted:  rgba(167, 139, 250, 0.18);
}

[data-theme="dark"][data-color="cute"] {
  --bg:             #121212;
  --surface:        #1a1a1e;
  --surface-2:      #202024;
  --border:         rgba(255, 175, 204, 0.20);
  --text:           #ffafcc;
  --text-2:         #ff85a8;
  --text-muted:     #c9a3bd;   /* 8.92:1 sobre negro (antes #b27293) */
  --sidebar-bg:     #121212;
  --sidebar-text:   #ffafcc;
  --primary:        #ffafcc;   /* 11.6:1 sobre negro (antes #d48fb8 → 6.3:1) */
  --primary-light:  #ffd0e0;
  --primary-dark:   #ffc8dd;   /* hover: ilumina */
  --on-primary:     #2a1e3d;   /* 8.2:1 — lavanda muy oscuro, ya usado en cute */
  --primary-bg:     rgba(255, 175, 204, 0.10);
  --primary-muted:  rgba(255, 175, 204, 0.18);
}

[data-theme="dark"][data-color="marca"] {
  --bg:             #121212;
  --surface:        #1a1a1e;
  --surface-2:      #202024;
  --border:         rgba(167, 139, 250, 0.20);
  --text:           #c4b5fd;
  --text-2:         #a78bfa;
  --text-muted:     #9a9bab;   /* 5.92:1 sobre --surface-2 y 5.10:1 sobre el tinte
                                  lila --primary-bg, donde #8a8b9a daba 4.28 */
  --sidebar-bg:     #121212;
  --sidebar-text:   #a78bfa;
  --primary:        #A78BFA;   /* morado de marca en oscuro (2026-08-31): 6.88:1
                                  sobre --bg #121212 —mejor que el azul #7B92FF
                                  anterior (6.60)—; texto negro sobre primary 7.27.
                                  AA-verificado. */
  --primary-light:  #C4B5FD;
  --primary-dark:   #C4B5FD;   /* hover: ilumina */
  --on-primary:     #0a0a0a;
  --primary-bg:     rgba(167, 139, 250, 0.12);
  --primary-muted:  rgba(167, 139, 250, 0.18);
}

/* Mono + oscuro: fondo NEGRO + letras BLANCAS puras
   (pedido usuaria 2026-06-13: "un tema oscuro con toda la letra blanca") */
[data-theme="dark"][data-color="mono"] {
  --bg:             #121212;
  --surface:        #1a1a1e;
  --surface-2:      #202024;
  --border:         rgba(255, 255, 255, 0.15);
  --border-2:       rgba(255, 255, 255, 0.25);
  --text:           #ffffff;
  --text-2:         #e5e5e5;
  --text-muted:     #a3a3a3;
  --primary:        #ffffff;
  --primary-light:  #f5f5f5;
  --primary-dark:   #e5e5e5;
  --primary-bg:     rgba(255, 255, 255, 0.10);
  --primary-muted:  rgba(255, 255, 255, 0.16);
  --on-primary:     #000000;  /* primary es blanco, el texto sobre primary debe ser negro */
  --sidebar-bg:     #121212;
  --sidebar-text:   #ffffff;
  --sidebar-active: #ffffff;
  --sidebar-hover:  rgba(255, 255, 255, 0.08);
  --sidebar-border: rgba(255, 255, 255, 0.12);
}

/* 3. Backgrounds pastel hardcoded inline → negro con texto del tema.
   Cubre los pasteles más comunes que aparecen en js/*.js como
   <tr style="background:#fff5f8"> o <div style="background:#d1fae5">. */
[data-theme="dark"] [style*="background:#fff5f8"],
[data-theme="dark"] [style*="background:#fff0f2"],
[data-theme="dark"] [style*="background:#fff5f5"],
[data-theme="dark"] [style*="background:#fffbeb"],
[data-theme="dark"] [style*="background:#fff3b0"],
[data-theme="dark"] [style*="background:#fff3e4"],
[data-theme="dark"] [style*="background:#fef3c7"],
[data-theme="dark"] [style*="background:#fde68a"],
[data-theme="dark"] [style*="background:#ffe4ea"],
[data-theme="dark"] [style*="background:#ffe4e6"],
[data-theme="dark"] [style*="background:#ffafcc"],
[data-theme="dark"] [style*="background:#fde0ea"],
[data-theme="dark"] [style*="background:#d1fae5"],
[data-theme="dark"] [style*="background:#ecfdf5"],
[data-theme="dark"] [style*="background:#c5f4d4"],
[data-theme="dark"] [style*="background:var(--primary-bg)"],
[data-theme="dark"] [style*="background:#bde0fe"],
[data-theme="dark"] [style*="background:#cdb4db"],
[data-theme="dark"] [style*="background:#faf5ff"],
[data-theme="dark"] [style*="background:#f5f3ff"],
[data-theme="dark"] [style*="background:#fee2e2"],
[data-theme="dark"] [style*="background:#fef2f2"],
[data-theme="dark"] [style*="background:#fecaca"],
[data-theme="dark"] [style*="background:#fef9c3"],
/* Pastels de los tabs de configuracion.html: se pintan inline, asi que solo
   una regla !important los alcanza. Sin esto el boton queda pastel CLARO con
   --text (que en oscuro es claro) encima: 1.05-1.64:1. 2026-08-27. */
[data-theme="dark"] [style*="background:#67e8f9"],
[data-theme="dark"] [style*="background:#a5f3fc"],
[data-theme="dark"] [style*="background:#bae6fd"],
[data-theme="dark"] [style*="background:#c7d2fe"],
[data-theme="dark"] [style*="background:#cffafe"],
[data-theme="dark"] [style*="background:#dcfce7"],
[data-theme="dark"] [style*="background:#f3e8ff"],
[data-theme="dark"] [style*="background:#fae8ff"],
[data-theme="dark"] [style*="background:#fbcfe8"],
[data-theme="dark"] [style*="background:#fca5a5"],
[data-theme="dark"] [style*="background:#fce7f3"],
[data-theme="dark"] [style*="background:#f0fdf4"],
/* Pastels adicionales encontrados en auditoría 2026-06-16 */
[data-theme="dark"] [style*="background:#fff8eb"],
[data-theme="dark"] [style*="background:#caffbf"],
[data-theme="dark"] [style*="background:#ffd23f"],
[data-theme="dark"] [style*="background:#e2e8f0"],
[data-theme="dark"] [style*="background:var(--surface-2)"],
[data-theme="dark"] [style*="background:var(--surface-2)"],
[data-theme="dark"] [style*="background:var(--surface-2)"],
[data-theme="dark"] [style*="background:var(--surface-2)"],
[data-theme="dark"] [style*="background:#fbbf24"],
[data-theme="dark"] [style*="background:#ffffff"],
[data-theme="dark"] [style*="background: #ffffff"],
[data-theme="dark"] [style*="background:#fff"],
/* Named color "white" + vars indefinidas con fallback pastel */
[data-theme="dark"] [style*="background:white"],
[data-theme="dark"] [style*="background: white"],
[data-theme="dark"] [style*="cute-amarillo"],
[data-theme="dark"] [style*="cute-menta"] {
  background: var(--surface) !important;
  color: var(--text) !important;
}

/* 4. Texto oscuro hardcoded → color del tema activo */
[data-theme="dark"] [style*="color:#5d1232"],
[data-theme="dark"] [style*="color:#92400e"],
[data-theme="dark"] [style*="color:#78350f"],
[data-theme="dark"] [style*="color:#7a4d05"],
[data-theme="dark"] [style*="color:#065f46"],
[data-theme="dark"] [style*="color:#1e293b"],
[data-theme="dark"] [style*="color:#334155"],
[data-theme="dark"] [style*="color:#5d4e6d"],
[data-theme="dark"] [style*="color:#166534"],
[data-theme="dark"] [style*="color:#9f1239"],
[data-theme="dark"] [style*="color:#0f172a"],
[data-theme="dark"] [style*="color:#475569"],
[data-theme="dark"] [style*="color:#1f2937"],
[data-theme="dark"] [style*="color:#111827"] {
  color: var(--text) !important;
}

/* 5. Semánticos en dark: mantener distinguibles pero claros */
[data-theme="dark"] [style*="color:#dc2626"],
[data-theme="dark"] [style*="color:#ef4444"],
[data-theme="dark"] [style*="color:#991b1b"],
[data-theme="dark"] [style*="color:#c53052"] {
  color: #fca5a5 !important;
}
[data-theme="dark"] [style*="color:#059669"],
[data-theme="dark"] [style*="color:#16a34a"],
[data-theme="dark"] [style*="color:#15803d"],
[data-theme="dark"] [style*="color:#2d8f4f"] {
  color: #86efac !important;
}
[data-theme="dark"] [style*="color:#d97706"],
[data-theme="dark"] [style*="color:#fbbf24"],
[data-theme="dark"] [style*="color:#ca8a04"],
[data-theme="dark"] [style*="color:#b45309"] {
  color: #fde68a !important;
}

/* 6. Badges con background pastel inline → outline con texto del tema */
[data-theme="dark"] .fin-badge[style*="background"],
[data-theme="dark"] .badge[style*="background"],
[data-theme="dark"] span[class*="badge"][style*="background"] {
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid var(--text-muted) !important;
  color: var(--text) !important;
}

/* 7. Headers de modal con fondo pastel */
[data-theme="dark"] .modal__header[style*="background"] {
  background: var(--surface) !important;
  border-bottom: 1px solid var(--border) !important;
  color: var(--text) !important;
}

/* 8. Filas <tr> con background inline (rosa/amarillo/lila para alertas).
   Por defecto fondo casi-transparente, pero los semánticos (rojo vencido,
   amarillo warning) conservan tinte para que sigan distinguibles. */
[data-theme="dark"] tr[style*="background"] {
  background: rgba(255, 255, 255, 0.025) !important;
}
[data-theme="dark"] tr[style*="background:#fff5f5"],
[data-theme="dark"] tr[style*="background:#fff0f2"],
[data-theme="dark"] tr[style*="background:#fee2e2"],
[data-theme="dark"] tr[style*="background:#fecaca"] {
  background: rgba(239, 68, 68, 0.10) !important;
  border-left: 3px solid #fca5a5 !important;
}
[data-theme="dark"] tr[style*="background:#fffbeb"],
[data-theme="dark"] tr[style*="background:#fff3b0"],
[data-theme="dark"] tr[style*="background:#fef3c7"],
[data-theme="dark"] tr[style*="background:#fde68a"] {
  background: rgba(251, 191, 36, 0.10) !important;
  border-left: 3px solid #fde68a !important;
}

/* 8.b <code>, <pre> con background hardcoded blanco (modal accesos en
   js/clientes.js): forzar fondo casi-negro + texto del tema para legibilidad. */
[data-theme="dark"] code[style*="background"],
[data-theme="dark"] pre[style*="background"] {
  background: rgba(255, 255, 255, 0.06) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}

/* 9. Cards / divs con gradients pastel hardcoded (KPI no-marca, etc.) */
[data-theme="dark"] [style*="linear-gradient"][style*="#bde0fe"],
[data-theme="dark"] [style*="linear-gradient"][style*="#c5f4d4"],
[data-theme="dark"] [style*="linear-gradient"][style*="#fff3b0"],
[data-theme="dark"] [style*="linear-gradient"][style*="#ffafcc"],
[data-theme="dark"] [style*="linear-gradient"][style*="#cdb4db"],
[data-theme="dark"] [style*="linear-gradient"][style*="#fde68a"],
[data-theme="dark"] [style*="linear-gradient"][style*="#fff5f8"] {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%) !important;
  border: 1px solid var(--text-muted) !important;
  color: var(--text) !important;
}

/* 10. Inputs / selects en dark: fondo casi-negro + texto claro del tema */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background-color: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: var(--text-muted) !important;
  opacity: 0.7;
}

