/* =====================================================================
   ESTILOS — Sistema de Gestión Económica · Colegio Gonzaga
   ===================================================================== */

:root {
  /* ============ 🎨 CAMBIAR COLOR PRINCIPAL AQUÍ ============ */
  --color-primary:       #123F85;  /* Azul profundo - principal */
  --color-primary-dark:  #0C2F66;  /* Versión oscura del primario */
  --color-accent:        #C11734;  /* Rojo - acentos */
  --color-accent-light:  #E84A66;  /* Rojo claro */
  --color-bg:            #FAF7F2;  /* Crema - fondo general */
  --color-bg-alt:        #F2EDE3;  /* Crema alternativo */
  --color-text:          #2A2A2A;  /* Texto principal */
  --color-text-soft:     #5A5A5A;  /* Texto secundario */
  --color-border:        #E5DED1;  /* Bordes suaves */
  --color-success:       #4A8B6F;  /* Verde para éxito */
  --color-error:         #B85450;  /* Rojo para errores */

  /* Tonos auxiliares para el oro institucional (uso decorativo opcional) */
  --color-oro:           #C9A227;
  --color-oro-oscuro:    #a8871f;

  /* ============ 📝 CAMBIAR TIPOGRAFÍA AQUÍ ============ */
  --font-display: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body:    'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;

  --radio: 14px;
  --sombra: 0 6px 24px rgba(18, 63, 133, 0.08);
  --sombra-fuerte: 0 10px 30px rgba(18, 63, 133, 0.14);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--color-text);
  /* >>> CAMBIAR FONDO AQUÍ <<< (degradados sutiles con la paleta) */
  background:
    radial-gradient(1200px 500px at 100% -10%, rgba(18,63,133,0.05), transparent 60%),
    radial-gradient(900px 400px at -10% 110%, rgba(193,23,52,0.04), transparent 60%),
    var(--color-bg);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.contenedor { width: min(1180px, 92vw); margin: 0 auto; }

h1, h2, h3, h4 { font-family: var(--font-display); color: var(--color-primary-dark); margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 1.7rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-dark); }
small { color: var(--color-text-soft); }

/* ---------------- Barra superior ---------------- */
.barra-superior {
  background: linear-gradient(120deg, var(--color-primary-dark), var(--color-primary));
  color: #fff;
  box-shadow: var(--sombra);
  position: sticky; top: 0; z-index: 50;
}
.barra-flex { display: flex; align-items: center; gap: 1rem; padding: .6rem 0; flex-wrap: wrap; }
.marca { display: flex; align-items: center; gap: .7rem; color: #fff; }
.marca:hover { color: #fff; }
.logo { width: 40px; height: 40px; border-radius: 8px; background: #fff; padding: 4px; }
.marca-texto { display: flex; flex-direction: column; line-height: 1.1; }
.marca-texto strong { font-family: var(--font-display); font-size: .98rem; }
.marca-texto small { color: rgba(255,255,255,.78); font-size: .72rem; }

.nav-principal { display: flex; gap: .25rem; margin-left: auto; flex-wrap: wrap; }
.nav-principal a {
  color: rgba(255,255,255,.85); padding: .42rem .7rem; border-radius: 9px;
  font-size: .88rem; font-weight: 500; transition: background .15s, color .15s;
}
.nav-principal a:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav-principal a.activo { background: #fff; color: var(--color-primary-dark); font-weight: 600; }

.barra-derecha { display: flex; align-items: center; gap: .6rem; }
.usuario { font-size: .82rem; color: rgba(255,255,255,.9); }
.salir { color: #fff; font-size: .82rem; border: 1px solid rgba(255,255,255,.4); padding: .25rem .6rem; border-radius: 8px; }
.salir:hover { background: rgba(255,255,255,.15); color: #fff; }

.chip-alerta { font-size: .78rem; font-weight: 700; padding: .25rem .55rem; border-radius: 20px; color: #fff; }
.chip-alerta.ok      { background: rgba(74,139,111,.9); }
.chip-alerta.aviso   { background: rgba(201,162,39,.95); color: #3a2e00; }
.chip-alerta.critico { background: var(--color-accent); }

.menu-toggle { display: none; background: rgba(255,255,255,.15); color: #fff; border: 0; font-size: 1.3rem; padding: .2rem .6rem; border-radius: 8px; cursor: pointer; }

/* ---------------- Contenido ---------------- */
.contenido { padding: 1.6rem 0 2.5rem; flex: 1; }
.encabezado-pagina { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.encabezado-pagina p { margin: .2rem 0 0; color: var(--color-text-soft); max-width: 62ch; }

/* ---------------- Tarjetas / KPIs ---------------- */
.grid { display: grid; gap: 1rem; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.tarjeta {
  background: #fff; border: 1px solid var(--color-border); border-radius: var(--radio);
  padding: 1.1rem 1.2rem; box-shadow: var(--sombra);
  animation: aparecer .5s ease both;
}
.tarjeta h3 { margin-top: 0; }

.kpi { position: relative; overflow: hidden; }
.kpi .kpi-label { font-size: .8rem; color: var(--color-text-soft); font-weight: 500; text-transform: uppercase; letter-spacing: .03em; }
.kpi .kpi-valor { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; color: var(--color-primary-dark); margin: .25rem 0; }
.kpi .kpi-sub { font-size: .82rem; color: var(--color-text-soft); }
.kpi::after { content: ""; position: absolute; right: -20px; top: -20px; width: 80px; height: 80px; border-radius: 50%; background: radial-gradient(circle, rgba(18,63,133,.07), transparent 70%); }
.kpi.acento .kpi-valor { color: var(--color-accent); }
.kpi.verde .kpi-valor { color: var(--color-success); }

/* ---------------- Tablas ---------------- */
.tabla-envoltura { overflow-x: auto; border-radius: var(--radio); border: 1px solid var(--color-border); background: #fff; box-shadow: var(--sombra); }
table.datos { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.datos thead th {
  background: var(--color-primary-dark); color: #fff; text-align: left;
  padding: .65rem .8rem; font-weight: 600; font-size: .82rem; white-space: nowrap;
}
table.datos tbody td { padding: .55rem .8rem; border-top: 1px solid var(--color-border); }
table.datos tbody tr:nth-child(even) { background: var(--color-bg-alt); }
table.datos tbody tr:hover { background: rgba(18,63,133,.05); }
table.datos tfoot td { padding: .65rem .8rem; border-top: 2px solid var(--color-primary); font-weight: 700; background: #fff; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fila-subtotal td { background: rgba(18,63,133,.06); font-weight: 600; }
.fila-grupo td { background: var(--color-primary); color: #fff; font-weight: 600; font-family: var(--font-display); }

.positivo { color: var(--color-success); font-weight: 600; }
.negativo { color: var(--color-accent); font-weight: 600; }
.cero { color: var(--color-text-soft); }

.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: .15rem .5rem; border-radius: 20px; }
.badge-ab  { background: rgba(18,63,133,.12); color: var(--color-primary-dark); }
.badge-cg  { background: rgba(74,139,111,.15); color: var(--color-success); }
.badge-dir { background: rgba(201,162,39,.18); color: #6b5200; }
.badge-fya { background: rgba(193,23,52,.12); color: var(--color-accent); }

/* ---------------- Alertas ---------------- */
.alerta { display: flex; gap: .8rem; align-items: flex-start; padding: .85rem 1rem; border-radius: 12px; margin-bottom: .7rem; border-left: 5px solid; animation: aparecer .4s ease both; }
.alerta .ico { font-size: 1.2rem; line-height: 1; }
.alerta h4 { margin: 0 0 .15rem; font-size: .95rem; }
.alerta p { margin: 0; font-size: .86rem; color: var(--color-text-soft); }
.alerta a { font-size: .82rem; font-weight: 600; }
.alerta.critico { background: #fdecee; border-color: var(--color-accent); }
.alerta.aviso   { background: #fbf4dd; border-color: var(--color-oro); }
.alerta.ok      { background: #eaf5ef; border-color: var(--color-success); }

.sin-datos { text-align: center; padding: 2.5rem 1rem; color: var(--color-text-soft); }
.sin-datos .emoji { font-size: 2.2rem; display: block; margin-bottom: .5rem; opacity: .6; }

/* ---------------- Formularios ---------------- */
form .campo { margin-bottom: .9rem; }
label { display: block; font-size: .85rem; font-weight: 600; color: var(--color-primary-dark); margin-bottom: .25rem; }
input[type=text], input[type=number], input[type=date], input[type=password], input[type=file], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--color-border); border-radius: 10px;
  font-family: var(--font-body); font-size: .92rem; background: #fff; color: var(--color-text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(18,63,133,.12); }
.campo-error input, .campo-error select { border-color: var(--color-error); }
.mensaje-error { color: var(--color-error); font-size: .8rem; margin-top: .2rem; }

.fila-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; align-items: end; }

/* ---------------- Botones ---------------- */
.btn { display: inline-flex; align-items: center; gap: .4rem; border: 0; cursor: pointer; font-family: var(--font-display); font-weight: 600; font-size: .9rem; padding: .55rem 1.05rem; border-radius: 10px; transition: background .15s, transform .1s; }
.btn:active { transform: translateY(1px); }
.btn-primario { background: var(--color-primary); color: #fff; }
.btn-primario:hover { background: var(--color-primary-dark); color: #fff; }
.btn-acento { background: var(--color-accent); color: #fff; }
.btn-acento:hover { background: var(--color-accent-light); color: #fff; }
.btn-suave { background: var(--color-bg-alt); color: var(--color-primary-dark); border: 1px solid var(--color-border); }
.btn-suave:hover { background: #e9e2d4; }
.btn-mini { font-size: .78rem; padding: .3rem .6rem; border-radius: 8px; }

.acciones { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

/* ---------------- Selector de período ---------------- */
.selector-periodo { display: flex; align-items: center; gap: .5rem; }
.selector-periodo select { width: auto; }

/* ---------------- Pestañas / chips ---------------- */
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chips a { font-size: .82rem; padding: .35rem .75rem; border-radius: 20px; background: #fff; border: 1px solid var(--color-border); color: var(--color-primary-dark); }
.chips a.activo { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ---------------- Pie ---------------- */
.pie { margin-top: auto; background: var(--color-primary-dark); color: rgba(255,255,255,.85); text-align: center; padding: 1.2rem 0; font-size: .82rem; }
.pie p { margin: .15rem 0; }
.pie-lema { font-style: italic; color: var(--color-oro); }

/* ---------------- Flash ---------------- */
.flash { padding: .75rem 1rem; border-radius: 10px; margin: 1rem 0 0; font-size: .9rem; animation: aparecer .4s ease both; }
.flash-ok    { background: #eaf5ef; color: var(--color-success); border: 1px solid #cfe8db; }
.flash-error { background: #fdecee; color: var(--color-error); border: 1px solid #f3d2d4; }
.flash-aviso { background: #fbf4dd; color: #6b5200; border: 1px solid #efe2b6; }

/* ---------------- Login ---------------- */
.login-pantalla { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-tarjeta { width: min(420px, 100%); background: #fff; border-radius: 18px; box-shadow: var(--sombra-fuerte); padding: 2rem; border: 1px solid var(--color-border); animation: aparecer .5s ease both; }
.login-tarjeta .logo-grande { width: 64px; height: 64px; display: block; margin: 0 auto 1rem; }
.login-tarjeta h1 { text-align: center; font-size: 1.3rem; }
.login-tarjeta .sub { text-align: center; color: var(--color-text-soft); margin-bottom: 1.4rem; font-size: .88rem; }

/* ---------------- Marca de agua institucional (el águila) ----------------
   >>> CAMBIAR SELLO: reemplaza /assets/img/sello.png <<< */
body::after {
  content: ''; position: fixed; right: -6vmin; bottom: -8vmin;
  width: 64vmin; height: 76vmin;
  background: url('../img/sello.png') center/contain no-repeat;
  opacity: .05; pointer-events: none; z-index: 0; filter: grayscale(1);
}
main, section, header, nav, footer { position: relative; z-index: 1; }
@media print { body::after { opacity: .04; } }

/* ---------------- Alto desempeño: números de contador ----------------
   Cifras tabulares (todas las columnas de dinero alinean dígito a dígito,
   como en un libro contable bien llevado). */
.num, .kpi-valor, table.datos td, table.datos th { font-variant-numeric: tabular-nums; }

/* ---------------- Tablas: lectura gerencial ---------------- */
table.datos tbody tr:nth-child(even) { background: rgba(242, 237, 227, 0.45); }
table.datos tbody tr:hover { background: rgba(18, 63, 133, 0.05); }
.tabla-envoltura { max-height: 72vh; overflow: auto; }
.tabla-envoltura table.datos thead th { position: sticky; top: 0; z-index: 2; }

/* ---------------- Tarjetas KPI: respiración y foco ---------------- */
.tarjeta.kpi { transition: transform .18s ease, box-shadow .18s ease; }
.tarjeta.kpi:hover { transform: translateY(-2px); box-shadow: var(--sombra-fuerte); }
.kpi-valor { letter-spacing: -0.5px; }

/* ---------------- Botones: respuesta al tacto ---------------- */
.btn { transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.btn:active { transform: translateY(1px); }

/* ---------------- Ayuda pedagógica: ¿cómo leer esta pantalla? -------- */
details.ayuda {
  margin: 0 0 1.1rem;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-oro);
  border-radius: 10px;
  background: var(--color-bg-alt);
  padding: .55rem .9rem;
  font-size: .88rem;
}
details.ayuda summary { cursor: pointer; font-weight: 600; color: var(--color-primary-dark); }
details.ayuda[open] summary { margin-bottom: .35rem; }
details.ayuda p { margin: 0; color: var(--color-text-soft); }

/* ---------------- Enfoque visible (teclado) ---------------- */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

button.badge-boton { border: 0; cursor: pointer; font: inherit; }

/* ---------------- Tarjetas de acceso del panel ----------------
   La tarjeta entera es clicable con una capa que la cubre; el título y
   el microfonito quedan POR ENCIMA (nada de enlaces anidados). */
.tarjeta-acceso { position: relative; }
.tarjeta-acceso .tarjeta-cubre { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.tarjeta-acceso h3 { position: relative; z-index: 2; }
.tarjeta-acceso h3 a { color: var(--color-primary-dark); }
.tarjeta-acceso .mic-pregunta { position: relative; z-index: 3; }

/* ---------------- El microfonito de cada casilla ---------------- */
.mic-pregunta {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5em; height: 1.5em; margin-left: .35rem;
  font-size: .8em; border-radius: 50%; vertical-align: middle;
  background: rgba(18, 63, 133, 0.08); text-decoration: none;
  transition: background .15s ease, transform .15s ease;
}
.mic-pregunta:hover { background: rgba(18, 63, 133, 0.18); transform: scale(1.15); }

/* ---------------- Azules suavizados (pedido del Rector) ----------------
   Las bandas de los libros de números ya no van en azul marino pleno:
   banda clara con letra oscura — suave a la vista y siempre legible. */
table.datos thead th {
  background: rgba(18, 63, 133, 0.09) !important;
  color: var(--color-primary-dark) !important;
  border-bottom: 2px solid rgba(18, 63, 133, 0.25);
}
table.datos thead th a { color: var(--color-primary-dark); text-decoration: underline; }
.tabla-envoltura table.datos thead th { position: sticky; top: 0; z-index: 2; }
.fila-grupo td { background: rgba(18, 63, 133, 0.06) !important; color: var(--color-primary-dark); }

/* ---------------- Pregunta contextual (micrófono en cada pantalla) ------ */
.pregunta-contextual {
  position: fixed; right: 18px; bottom: 18px; z-index: 40;
  background: var(--color-primary); color: #fff;
  padding: .55rem .95rem; border-radius: 999px;
  font-size: .85rem; font-weight: 600;
  box-shadow: var(--sombra-fuerte);
  transition: transform .15s ease, background .15s ease;
}
.pregunta-contextual:hover { background: var(--color-primary-dark); color: #fff; transform: translateY(-2px); }

/* ---------------- Impresión editorial (no una foto de pantalla) --------- */
.solo-imprimir { display: none; }
@media print {
  .solo-imprimir { display: block; }
  /* Hoja limpia: todo apilado, nada flotante, nada animado, nada pegajoso */
  .grid, .grid-kpi, .grid-2 { display: block !important; }
  .grid .tarjeta, .grid-kpi .tarjeta, .grid-2 .tarjeta { margin-bottom: 8pt; width: auto !important; }
  .escalonado > * { animation: none !important; opacity: 1 !important; transform: none !important; }
  .tabla-envoltura table.datos thead th { position: static !important; }
  .mic-pregunta, .chips, .menu-toggle, details.ayuda { display: none !important; }
  .encabezado-pagina { display: block; }
  .tarjeta.kpi:hover { transform: none; }
  .kpi-valor { font-size: 14pt; }
  .fila-form, button:not(.badge-boton) { display: none !important; }
  button.badge-boton { background: #eef1f6 !important; color: var(--color-primary-dark) !important; }
  table input, table select { border: none !important; background: transparent !important; }
  body { font-size: 12.5pt; }                 /* letra un poco más grande */
  h1 { font-size: 17pt; } h2 { font-size: 14pt; } h3 { font-size: 12.5pt; }
  table.datos { font-size: 10.5pt; }
  table.datos thead th { background: #eef1f6 !important; color: var(--color-primary-dark) !important; }  /* suave, no marcado */
  .tarjeta, .tabla-envoltura { box-shadow: none; border: 1px solid #ddd; page-break-inside: avoid; }
  .tabla-envoltura { max-height: none; overflow: visible; }
  .tabla-semana td { min-width: 0 !important; font-size: 9pt; }
  .pie-auditoria { font-size: 8.5pt; color: #777; border-top: 1px solid #ccc; padding-top: 4pt; margin-top: 8pt; }
  .pregunta-contextual { display: none; }
}

/* ---------------- Chat de conversaciones ---------------- */
.chat-mensajes { max-height: 380px; overflow: auto; border: 1px solid var(--color-border); border-radius: 8px; padding: 10px; margin-bottom: 12px; }
.chat-linea { margin: 8px 0; }
.chat-linea.mia { text-align: right; }
.chat-burbuja {
  display: inline-block; max-width: 85%; text-align: left;
  background: var(--color-bg-alt); border-radius: 10px; padding: 8px 12px;
}
.chat-linea.mia .chat-burbuja {
  background: rgba(18, 63, 133, 0.09); /* respaldo */
  background: color-mix(in srgb, var(--color-primary) 10%, white);
}
.hilo-item { margin: 6px 0; border-bottom: 1px solid var(--color-border); padding-bottom: 6px; }
.etiqueta-transcripcion { color: var(--color-oro); }

/* ---------------- Animaciones ---------------- */
@keyframes aparecer { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.escalonado > * { animation: aparecer .45s ease both; }
.escalonado > *:nth-child(1){animation-delay:.02s}
.escalonado > *:nth-child(2){animation-delay:.06s}
.escalonado > *:nth-child(3){animation-delay:.10s}
.escalonado > *:nth-child(4){animation-delay:.14s}
.escalonado > *:nth-child(5){animation-delay:.18s}
.escalonado > *:nth-child(6){animation-delay:.22s}
.escalonado > *:nth-child(7){animation-delay:.26s}
.escalonado > *:nth-child(8){animation-delay:.30s}
.escalonado > *:nth-child(n+9){animation-delay:.34s}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

/* ---------------- Responsive ---------------- */
@media (max-width: 860px) {
  .menu-toggle { display: inline-block; order: 3; margin-left: auto; }
  .nav-principal { display: none; width: 100%; flex-direction: column; margin: .5rem 0 0; }
  .nav-principal.abierto { display: flex; }
  .nav-principal a { width: 100%; }
  .barra-derecha { order: 2; }
  .marca-texto small { display: none; }
}
@media (max-width: 600px) {
  h1 { font-size: 1.4rem; }
  .contenido { padding: 1.1rem 0 2rem; }
  table.datos { font-size: .82rem; }
  .kpi .kpi-valor { font-size: 1.35rem; }
}

/* ---------------- Impresión ---------------- */
@media print {
  .barra-superior, .pie, .acciones, .menu-toggle, .chips, .no-imprimir { display: none !important; }
  body { background: #fff; }
  .tarjeta, .tabla-envoltura { box-shadow: none; border-color: #ccc; }
  /* (la banda del thead la gobierna el bloque editorial de arriba) */
  table.datos thead th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: #000; }
  .contenido { padding: 0; }
}

/* =====================================================================
   FICHAS DE OBRA (Ficha del Día · Entrega de Ala · Morteros del Ala)
   — calcadas de los formatos de papel; números de sección como en la
   ficha impresa, grandes y azul institucional.
   ===================================================================== */
.ficha-seccion h3 { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.num-seccion {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 1.7em; height: 1.7em; border-radius: 6px; flex: none;
    background: var(--color-primary, #123F85); color: #fff;
    font-size: .85em; font-weight: 700;
}
.ficha-seccion small { font-weight: 400; color: var(--color-text-soft); }
.ficha-seccion textarea, .ficha-seccion input, .ficha-seccion select { font-size: 1rem; }
.boton-dictar { font-size: 1.05rem; }
@media (max-width: 600px) {
    .ficha-seccion form { flex-direction: column; align-items: stretch !important; }
    .ficha-seccion form label { width: 100%; }
    .boton-dictar { padding: .8rem 1.2rem; }   /* dedo de obrero con guante */
}
@media print {
    .ficha-seccion { break-inside: avoid; }
    .num-seccion { background: #eef2fa !important; color: var(--color-primary-dark, #0d2f66) !important; border: 1px solid var(--color-primary-dark, #0d2f66); }
}
