:root {
    --azul: #0f2f4f; --azul-2: #1d4f7f; --acento: #0b7d73; --fondo: #f3f5f8; --tarjeta: #fff; --borde: #e1e6ed;
    --texto: #1f2933; --tenue: #6b7785; --verde: #1e8449; --rojo: #c0392b; --amarillo: #b7791f;
    --c1: #2f80c0; --c2: #0b7d73; --c3: #d68910; --c4: #8e5ea2;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", Arial, sans-serif; font-size: 14px; color: var(--texto); background: var(--fondo); }
a { color: var(--azul-2); }
h1 { font-size: 22px; margin: 4px 0 16px; color: var(--azul); }
h2 { font-size: 16px; margin: 22px 0 10px; color: var(--azul); }
h3 { font-size: 14.5px; margin: 0 0 12px; color: var(--azul); }
.tenue { color: var(--tenue); } .rojo { color: var(--rojo); } .verde { color: var(--verde); } .fuerte { font-weight: 700; }
.nowrap { white-space: nowrap; }

/* Barra superior */
.barra { background: var(--azul); color: #fff; display: flex; align-items: center; gap: 18px; padding: 0 20px; min-height: 54px; position: sticky; top: 0; z-index: 10; }
.marca { font-weight: 700; font-size: 17px; white-space: nowrap; }
.marca span { font-weight: 400; font-size: 12px; opacity: .7; margin-left: 6px; }
.barra nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.barra nav a { color: #d6e2ef; text-decoration: none; padding: 17px 12px; font-size: 13.5px; border-bottom: 3px solid transparent; }
.barra nav a:hover { color: #fff; }
.barra nav a.activo { color: #fff; border-bottom-color: #4fd1c5; font-weight: 600; }
.barra nav a.salir { margin-left: auto; opacity: .8; }
.btn-menu { display: none; background: none; border: 0; color: #fff; font-size: 22px; margin-left: auto; cursor: pointer; }

.contenido { max-width: 1250px; margin: 0 auto; padding: 22px 20px 50px; }

/* Avisos */
.aviso { padding: 11px 14px; border-radius: 7px; margin-bottom: 16px; font-size: 13.5px; }
.aviso-ok { background: #e6f4ea; color: #1e6b37; border: 1px solid #b7dfc2; }
.aviso-error { background: #fdecea; color: #a52a1f; border: 1px solid #f3c1bb; }
.aviso-info { background: #eef4fb; color: #1d3d6b; border: 1px solid #c9daef; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 10px; padding: 14px 16px; }
.kpi span { display: block; font-size: 12px; color: var(--tenue); margin-bottom: 6px; }
.kpi strong { font-size: 21px; color: var(--azul); }
.kpi-destacado { background: var(--azul); border-color: var(--azul); }
.kpi-destacado span { color: #b9cde2; } .kpi-destacado strong { color: #fff; }

/* Tarjetas y formularios */
.tarjeta { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 10px; padding: 18px; margin: 18px 0; }
.tarjeta h2:first-child { margin-top: 0; }
details.tarjeta > summary { cursor: pointer; font-weight: 600; color: var(--azul-2); }
details.tarjeta[open] > summary { margin-bottom: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px 14px; }
.grid .ancho { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: #4a5562; }
label.check { flex-direction: row; align-items: center; gap: 7px; font-weight: 500; }
input, select { font: inherit; padding: 9px 10px; border: 1px solid #c9d1dc; border-radius: 7px; background: #fff; color: var(--texto); width: 100%; }
label.check input { width: auto; }
input:focus, select:focus { outline: 2px solid #9cc3e6; border-color: var(--azul-2); }
.acciones { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.btn { display: inline-block; background: var(--azul); color: #fff; border: 0; border-radius: 7px; padding: 10px 20px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--azul-2); }
.btn:disabled { opacity: .6; }
.btn-gris { background: #5f6b78; } .btn-rojo { background: var(--rojo); } .btn-chico { padding: 7px 12px; font-size: 12.5px; }
.form-mov { background: var(--tarjeta); border: 1px solid var(--borde); border-left: 4px solid var(--acento); border-radius: 10px; padding: 18px; margin: 0 0 18px; }
.zona-peligro { border-color: #f1c6c0; }
.filtros { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 12px; align-items: end; background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 10px; padding: 14px; margin-bottom: 16px; }
.filtros .acciones { margin: 0; justify-content: flex-start; }
.fila-edicion { display: grid; grid-template-columns: 2fr 1.2fr 1fr .7fr auto auto; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--borde); }

/* Tablas */
.tabla-scroll { overflow-x: auto; background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 10px; }
.tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla th { background: #f0f3f7; color: #4a5562; text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .3px; padding: 10px 12px; white-space: nowrap; border-bottom: 1px solid var(--borde); }
.tabla td { padding: 10px 12px; border-bottom: 1px solid #eef1f5; vertical-align: top; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla .num { text-align: right; white-space: nowrap; }
.num.mas { color: var(--verde); } .num.menos { color: #34495e; }
tr.anulado td { text-decoration: line-through; color: #9aa5b1; }
tr.anulado td small { text-decoration: none; display: inline-block; }
tr.inactivo td { opacity: .55; }
.chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: #edf1f6; color: #4a5562; white-space: nowrap; }
.chip-ingreso_persona { background: #e3f4e8; color: #1e6b37; }
.chip-pago_por_persona { background: #e6f0fa; color: #1d4f91; }
.chip-devolucion_persona { background: #e0f2f0; color: #0b6a62; }
.chip-cuota_prestamo { background: #fdf0dc; color: #8a5a00; }
.chip-gasto_fijo { background: #f1e9f6; color: #6a3f82; }

/* Conciliación de una persona */
.conciliacion { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 10px; padding: 16px 20px; max-width: 560px; margin-bottom: 14px; }
.conciliacion .linea { display: flex; justify-content: space-between; gap: 20px; padding: 6px 0; font-size: 14px; }
.conciliacion .linea.total { border-top: 1px solid var(--borde); margin-top: 4px; padding-top: 9px; font-weight: 600; }
.conciliacion .linea.saldo { background: var(--azul); color: #fff; margin: 10px -20px; padding: 12px 20px; font-size: 17px; }
.conciliacion .linea.saldo.negativo { background: var(--rojo); }
.barra-avance { height: 7px; background: #e5eaf0; border-radius: 4px; overflow: hidden; min-width: 80px; }
.barra-avance > div { height: 100%; background: var(--acento); }
.barra-avance.grande { height: 10px; margin-top: 6px; }

.pestanas { display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0 0; }
.pestanas button { font: inherit; font-size: 13px; font-weight: 600; padding: 9px 14px; border: 1px solid var(--borde); border-bottom: 0; border-radius: 8px 8px 0 0; background: #e9edf2; color: #4a5562; cursor: pointer; }
.pestanas button.activa { background: var(--tarjeta); color: var(--azul); }
.pestanas + div .form-mov { border-top-left-radius: 0; }

/* Resumen */
.recordatorios { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.rec { text-decoration: none; padding: 9px 13px; border-radius: 7px; font-size: 13px; border-left: 4px solid; }
.rec-rojo { background: #fdecea; color: #8e2318; border-color: var(--rojo); }
.rec-amarillo { background: #fff6e0; color: #7a5300; border-color: #e0a800; }
.rec-gris { background: #eef1f5; color: #4a5562; border-color: #9aa5b1; }
.dos-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }
.dos-col .tarjeta { margin: 18px 0 0; }
.leyenda { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--tenue); margin-bottom: 10px; }
.leyenda i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.c1 { background: var(--c1); } .c2 { background: var(--c2); } .c3 { background: var(--c3); } .c4 { background: var(--c4); }
.grafico-meses { display: flex; align-items: flex-end; gap: 6px; height: 210px; padding-top: 10px; }
.grafico-meses .mes { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.grafico-meses .columna { width: 100%; max-width: 38px; display: flex; flex-direction: column-reverse; border-radius: 4px 4px 0 0; overflow: hidden; min-height: 1px; background: #eef1f5; }
.grafico-meses small { font-size: 11px; color: var(--tenue); margin-top: 4px; }
.grafico-meses small.valor { margin-top: 0; font-size: 10px; }
.fila-persona { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid #eef1f5; text-decoration: none; color: inherit; }
.fila-persona .barra-avance { grid-column: 1 / -1; }
.lista-simple { padding-left: 18px; line-height: 1.8; }
.selector-mes { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; font-size: 16px; }
.selector-mes a { text-decoration: none; background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 6px; padding: 4px 11px; }

/* Login */
.pagina-login { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--azul); padding: 16px; }
.caja-login { background: #fff; padding: 30px; border-radius: 12px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.caja-login h1 { margin: 0; }
.caja-login p { margin: 0; }

/* Teléfono */
@media (max-width: 900px) {
    .dos-col { grid-template-columns: 1fr; }
    .btn-menu { display: block; }
    .barra { flex-wrap: wrap; padding: 0 16px; }
    .barra nav { display: none; flex-basis: 100%; flex-direction: column; padding-bottom: 8px; }
    .menu-abierto .barra nav { display: flex; }
    .barra nav a { padding: 11px 4px; border-bottom: 0; }
    .barra nav a.activo { color: #4fd1c5; }
    .barra nav a.salir { margin-left: 0; }
    .contenido { padding: 16px 16px 40px; }
    .fila-edicion { grid-template-columns: 1fr 1fr; }
    .conciliacion { max-width: none; }
}

/* Imprimir estado de cuenta */
@media print {
    .barra, .no-imprimir, .aviso { display: none !important; }
    body { background: #fff; }
    .contenido { padding: 0; max-width: none; }
    .tabla-scroll, .conciliacion { border: 1px solid #ccc; }
    .conciliacion .linea.saldo { background: #eee !important; color: #000; }
}
.clave-en-linea { display: flex; gap: 6px; }
.clave-en-linea input { min-width: 130px; }
.tabla td input, .tabla td select { padding: 6px 8px; font-size: 13px; }
