:root {
    --fondo: #f4f6f9; --panel: #fff; --texto: #1d2533; --muted: #6b7486; --borde: #dde2ea;
    --primario: #1f4fbf; --primario-h: #173d96; --ok: #1d7a45; --error: #b42318;
    --radio: 8px; font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", system-ui, sans-serif; background: var(--fondo); color: var(--texto); }
a { color: var(--primario); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
h2 { font-size: 1.1rem; margin: 1.8rem 0 .8rem; }

.barra { display: flex; align-items: center; gap: 2rem; padding: 0 1.5rem; height: 56px; background: #14213d; color: #fff; }
.barra nav { display: flex; gap: .3rem; flex: 1; }
.barra nav a { color: #c9d3e6; padding: .45rem .8rem; border-radius: 6px; }
.barra nav a.activo, .barra nav a:hover { background: #24345c; color: #fff; text-decoration: none; }
.marca { color: #fff; font-size: 1.15rem; letter-spacing: .3px; }
.marca b { color: #7fa6ff; }
.marca.grande { font-size: 1.8rem; color: var(--texto); text-align: center; }
.marca.grande b { color: var(--primario); }
.sesion { display: flex; align-items: center; gap: 1rem; font-size: .9rem; }
.sesion .estudio { background: #24345c; padding: .2rem .6rem; border-radius: 999px; }
.sesion form { margin: 0; }
.enlace { background: none; border: 0; color: #c9d3e6; cursor: pointer; font: inherit; }
.enlace:hover { color: #fff; text-decoration: underline; }

.contenido { max-width: 1180px; margin: 0 auto; padding: 1.8rem 1.5rem 3rem; }
.miga { margin: 0 0 .3rem; color: var(--muted); font-size: .9rem; }
.titulo-seccion { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.titulo-seccion h1, .titulo-seccion h2 { margin-bottom: .8rem; }
.acciones { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.acciones form { margin: 0; }
.titulo-seccion .acciones { margin-top: 0; }

.boton { display: inline-block; padding: .5rem 1rem; border: 1px solid var(--borde); border-radius: 6px; background: var(--panel); color: var(--texto); cursor: pointer; font: inherit; }
.boton:hover { background: #eef1f6; text-decoration: none; }
.boton.primario { background: var(--primario); border-color: var(--primario); color: #fff; }
.boton.primario:hover { background: var(--primario-h); }
.boton.peligro { background: #fff; border-color: var(--error); color: var(--error); }
.boton.ancho { width: 100%; margin-top: 1.2rem; padding: .7rem; }

.aviso { padding: .7rem 1rem; border-radius: var(--radio); margin-bottom: 1rem; }
.aviso.ok { background: #e6f4ec; color: var(--ok); }
.aviso.error { background: #fdecea; color: var(--error); }
.aviso.error ul { margin: 0; padding-left: 1.1rem; }
.validation-summary-valid.vacio-oculto { display: none; }
.err { color: var(--error); font-size: .85rem; }

.tabla { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); overflow: hidden; }
.tabla th, .tabla td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--borde); }
.tabla th { background: #f8f9fc; font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.tabla tr:last-child td { border-bottom: 0; }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabla tr.inactiva td { color: var(--muted); }
.vencida { color: var(--error); font-weight: 600; }
.rut { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); font-size: .88rem; }
.vacio { color: var(--muted); background: var(--panel); border: 1px dashed var(--borde); border-radius: var(--radio); padding: 1.2rem; }

.estado { font-size: .78rem; font-weight: 600; padding: .2rem .6rem; border-radius: 999px; white-space: nowrap; }
.e-planificacion { background: #eef2ff; color: #3b4bb3; }
.e-ejecucion { background: #fff4e0; color: #9a5b00; }
.e-informe { background: #f1e9ff; color: #6a3fb5; }
.e-cerrada { background: #e6f4ec; color: var(--ok); }
.e-anulada { background: #eceef2; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.kpi { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 1rem 1.2rem; }
.kpi span { color: var(--muted); font-size: .85rem; display: block; }
.kpi b { font-size: 1.8rem; font-variant-numeric: tabular-nums; }

.tarjetas { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.tarjeta { display: flex; flex-direction: column; gap: .25rem; background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 1rem 1.2rem; color: var(--texto); }
.tarjeta:hover { border-color: var(--primario); text-decoration: none; }

.ficha { display: grid; grid-template-columns: 200px 1fr; gap: .55rem 1rem; background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 1.2rem; margin: 0; }
.ficha dt { color: var(--muted); }
.ficha dd { margin: 0; }
.ficha .texto { white-space: pre-wrap; }

.ciclo { display: flex; list-style: none; padding: 0; margin: 0 0 1.2rem; gap: .3rem; }
.ciclo li { flex: 1; text-align: center; padding: .5rem; background: #e7eaf0; color: var(--muted); font-size: .88rem; }
.ciclo li:first-child { border-radius: 6px 0 0 6px; }
.ciclo li:last-child { border-radius: 0 6px 6px 0; }
.ciclo li.hecho { background: #c9d7f7; color: var(--primario-h); }
.ciclo li.actual { background: var(--primario); color: #fff; font-weight: 600; }

.formulario { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 1.4rem; max-width: 900px; }
.formulario label, .tarjeta-login label { display: block; font-size: .88rem; color: var(--muted); margin: .9rem 0 .3rem; }
input, select, textarea { width: 100%; padding: .55rem .7rem; border: 1px solid var(--borde); border-radius: 6px; font: inherit; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b8cbf5; border-color: var(--primario); }
.fila { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 1rem; }
.fila .doble { grid-column: span 2; }
label.check { display: flex; align-items: center; gap: .5rem; color: var(--texto); }
label.check input { width: auto; }

body.acceso { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(135deg, #14213d, #1f4fbf); }
.tarjeta-login { background: var(--panel); width: min(380px, 92vw); padding: 2rem; border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.tarjeta-login .sub { text-align: center; color: var(--muted); margin: .3rem 0 1.2rem; }

@media (max-width: 700px) {
    .barra { gap: 1rem; padding: 0 .8rem; }
    .sesion .estudio { display: none; }
    .ficha { grid-template-columns: 1fr; }
    .fila .doble { grid-column: auto; }
}

/* ---- Módulos (íconos BANCO, CARTOLA, ANÁLISIS) ---- */
.modulos { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.modulo { display: flex; flex-direction: column; align-items: center; gap: .35rem; text-align: center; background: var(--panel); border: 1px solid var(--borde); border-radius: 12px; padding: 1.4rem 1rem; color: var(--texto); }
.modulo:hover { border-color: var(--primario); box-shadow: 0 6px 18px rgba(31,79,191,.12); text-decoration: none; }
.modulo svg { width: 52px; height: 52px; fill: var(--primario); }
.modulo b { font-size: 1.05rem; letter-spacing: .5px; }
.modulo span { color: var(--muted); font-size: .85rem; }
.modulo .insignia { background: #fff4e0; color: #9a5b00; border-radius: 999px; padding: .1rem .6rem; font-weight: 600; }
.modulo .insignia.alerta { background: #fdecea; color: var(--error); }

/* ---- Cuadrante de carga ---- */
.cuadrante { display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: 2.4rem 1rem; border: 2px dashed #9fb4e6; border-radius: 12px; background: #f6f8fe; cursor: pointer; text-align: center; transition: background .15s, border-color .15s; }
.cuadrante:hover, .cuadrante.encima { background: #e8eefc; border-color: var(--primario); }
.cuadrante svg { width: 46px; height: 46px; fill: var(--primario); }
.cuadrante span { color: var(--muted); font-size: .88rem; }
.cola { list-style: none; padding: 0; margin: .8rem 0 0; display: grid; gap: .3rem; }
.cola li { padding: .45rem .8rem; border-radius: 6px; background: #eef1f6; font-size: .9rem; }
.cola li.ok { background: #e6f4ec; color: var(--ok); }
.cola li.error { background: #fdecea; color: var(--error); }
.resultados { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: .8rem 1rem; white-space: pre-wrap; font-family: inherit; font-size: .88rem; }
.boton.chico { padding: .25rem .6rem; font-size: .85rem; }
.boton:disabled { opacity: .5; cursor: not-allowed; }
.tabla td.detalle { color: var(--error); font-size: .85rem; max-width: 420px; }
.tabla tr.descuadre td { background: #fdecea; }
.e-error { background: #fdecea; color: var(--error); }

/* ---- Niveles de anomalía ---- */
.sev-alta { background: #fdecea; color: var(--error); }
.sev-media { background: #fff4e0; color: #9a5b00; }
.sev-baja { background: #eef2ff; color: #3b4bb3; }
.sev-info { background: #eceef2; color: var(--muted); }
a.kpi { color: inherit; }
a.kpi:hover, a.kpi.activo { text-decoration: none; outline: 2px solid var(--primario); }

/* ---- Segmentación banco · cuenta · moneda ---- */
.banco { margin-bottom: 1.6rem; }
.banco h3 { font-size: 1rem; margin: 1rem 0 .6rem; padding-bottom: .3rem; border-bottom: 2px solid var(--borde); letter-spacing: .4px; }
.cuentas { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .9rem; }
.cuenta { display: flex; flex-direction: column; gap: .2rem; background: var(--panel); border: 1px solid var(--borde); border-radius: 10px; padding: 1rem 1.1rem; color: var(--texto); }
.cuenta:hover { border-color: var(--primario); text-decoration: none; box-shadow: 0 6px 18px rgba(31,79,191,.10); }
.cuenta-cab { display: flex; align-items: center; gap: .5rem; }
.cuenta-saldo { margin: .4rem 0 .2rem; display: flex; flex-direction: column; }
.cuenta-saldo b { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.cuenta-pie { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .3rem; }
.cuenta .insignia { background: #fff4e0; color: #9a5b00; border-radius: 999px; padding: .1rem .55rem; font-size: .8rem; font-weight: 600; }
.cuenta .insignia.alerta { background: #fdecea; color: var(--error); }
.moneda { font-size: .75rem; font-weight: 700; padding: .15rem .5rem; border-radius: 6px; letter-spacing: .5px; background: #eceef2; color: var(--muted); }
.moneda.grande { font-size: 1rem; padding: .25rem .65rem; }
.m-clp { background: #e6f4ec; color: var(--ok); }
.m-usd { background: #e8eefc; color: var(--primario); }
.m-eur { background: #f1e9ff; color: #6a3fb5; }
.m-uf { background: #fff4e0; color: #9a5b00; }
.titulo-cuenta { display: flex; align-items: center; gap: .5rem; margin: 1rem 0 .5rem; }
.en-linea { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin: .8rem 0; }
.en-linea label { color: var(--muted); font-size: .9rem; }
.en-linea select { width: auto; min-width: 220px; }
.kpi span + span { font-size: .8rem; }

/* ---- Pantalla Banco: bloques por banco ---- */
.bancos { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.panel-banco { background: var(--panel); border: 1px solid var(--borde); border-radius: 10px; overflow: hidden; }
.panel-banco > header { padding: .7rem 1rem; font-weight: 700; border-bottom: 1px solid var(--borde); background: #f8f9fc; }
.fila-cuenta { display: flex; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; border-bottom: 1px solid var(--borde); color: var(--texto); }
.fila-cuenta:last-child { border-bottom: 0; }
.fila-cuenta:hover { background: #f4f7ff; text-decoration: none; }
.fc-izq { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.fc-izq b { font-size: .92rem; margin-left: .3rem; }
.fc-izq .muted { font-size: .8rem; }
.fc-der { display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; }
.fc-der b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.fc-der .muted { font-size: .8rem; }
.fila-cuenta .insignia { background: #fff4e0; color: #9a5b00; border-radius: 999px; padding: .05rem .5rem; font-size: .75rem; font-weight: 600; margin-right: .3rem; }
.fila-cuenta .insignia.alerta { background: #fdecea; color: var(--error); }

/* ---- Grilla anual de cartolas ---- */
.calendario { background: var(--panel); border: 1px solid var(--borde); border-radius: 10px; padding: .4rem 0 .6rem; }
.cal-cab { display: flex; align-items: center; gap: .8rem; padding: .4rem 1rem .6rem; flex-wrap: wrap; }
.cal-cab h2 { margin: 0; font-size: 1.05rem; }
.insignia-cal { background: #eceef2; color: var(--muted); border-radius: 999px; padding: .1rem .6rem; font-size: .78rem; }
.cal-leyenda { margin-left: auto; display: flex; align-items: center; gap: .9rem; font-size: .82rem; color: var(--muted); }
.cal-leyenda select { width: auto; padding: .3rem .5rem; }
.pto { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .3rem; vertical-align: -1px; }
.pto.cargada { background: #22a06b; } .pto.provisoria { background: #e2a400; } .pto.falta { background: #c9ced8; }
.cal-scroll { overflow-x: auto; }
.cal { width: 100%; border-collapse: collapse; min-width: 1100px; }
.cal th { font-size: .72rem; letter-spacing: .5px; color: var(--muted); font-weight: 600; padding: .45rem .3rem; border-bottom: 1px solid var(--borde); text-align: center; }
.cal th:first-child, .cal th:nth-child(2) { text-align: left; padding-left: 1rem; }
.cal td { padding: .35rem .25rem; border-bottom: 1px solid #eef0f4; text-align: center; }
.cal tr.inicio-banco td, .cal tr.inicio-banco th { border-top: 1px solid var(--borde); }
.cal-banco { text-align: left !important; font-size: .85rem !important; color: var(--texto) !important; padding-left: 1rem !important; vertical-align: middle; border-right: 1px solid #eef0f4; }
.cal-cuenta { text-align: left !important; white-space: nowrap; font-size: .85rem; padding-left: .6rem !important; }
.cal-cuenta .moneda { font-size: .65rem; margin-right: .2rem; }
.celda { display: flex; align-items: stretch; min-width: 74px; height: 38px; border-radius: 6px; overflow: hidden; font-variant-numeric: tabular-nums; text-decoration: none !important; }
.celda .num { display: flex; align-items: center; justify-content: center; min-width: 22px; padding: 0 .25rem; font-weight: 700; font-size: .78rem; border-right: 1px solid rgba(0,0,0,.12); }
.celda .saldos { flex: 1; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; padding: 0 .35rem; line-height: 1.05; }
.celda .saldos small { font-size: .62rem; opacity: .85; }
.celda .saldos b { font-size: .78rem; }
.celda.cargada { background: #22a06b; color: #fff; }
.celda.provisoria { background: #f0b400; color: #3b2a00; }
.celda.falta { background: #e3e6ec; color: #8a93a6; justify-content: center; align-items: center; }
.celda.futura { background: transparent; border: 1px dashed #e3e6ec; }
.celda.descuadra { outline: 2px solid var(--error); outline-offset: -2px; }
.celda:hover { filter: brightness(1.07); }
.cal-nota { padding: .6rem 1rem 0; font-size: .8rem; margin: 0; }

/* ---- Selector de empresa en la barra ---- */
.selector-empresa { margin: 0; }
.selector-empresa select { width: auto; min-width: 240px; max-width: 340px; background: #24345c; color: #fff; border: 1px solid #3a4d7d; padding: .4rem .6rem; font-weight: 600; }
.selector-empresa select:focus { outline: 2px solid #7fa6ff; }
.selector-empresa option { background: #fff; color: var(--texto); }
@media (max-width: 900px) { .selector-empresa select { min-width: 150px; } }
