/* ============================================================
   Finanzas — estilos del modulo (usa tokens de marca de tokens.css)
   Prefijo .fin-* para no chocar con v1/v2. Iconos .msr requieren
   un ancestro .v2-scope (lo proveen MainLayout y PortalLayout).
   ============================================================ */

.fin-page {
    padding: 28px 32px;
    max-width: 1200px;
    margin: 0 auto;
    font-family: var(--font-sans, "Figtree", sans-serif);
    color: var(--text-primary, #1A1C1F);
}

.fin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.fin-title {
    font-family: var(--font-serif, "Fraunces", serif);
    font-size: 28px;
    font-weight: 600;
    margin: 0;
}

.fin-subtitle { color: #6b7177; font-size: 14px; margin-top: 2px; }

.fin-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }

.fin-card {
    background: #fff;
    border: 1px solid var(--border, #e7e2d6);
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
    padding: 18px;
}

/* ---- Tabla ---- */
.fin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.fin-table th {
    text-align: left; padding: 10px 12px; color: #6b7177; font-weight: 600;
    border-bottom: 2px solid var(--border, #e7e2d6); white-space: nowrap;
}
.fin-table td { padding: 11px 12px; border-bottom: 1px solid #efece3; }
.fin-table tr:hover td { background: #faf8f2; }
.fin-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Botones ---- */
.fin-btn {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid var(--border, #e7e2d6); background: #fff; color: #1A1C1F;
    padding: 9px 14px; border-radius: 10px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all .15s ease; font-family: inherit;
}
.fin-btn:hover { background: #f4f0e6; }
.fin-btn:disabled { opacity: .55; cursor: not-allowed; }
.fin-btn-primary { background: var(--brand-teal, #6DC7D0); border-color: var(--brand-teal, #6DC7D0); color: #06363b; }
.fin-btn-primary:hover { filter: brightness(.96); background: var(--brand-teal, #6DC7D0); }
.fin-btn-danger { color: #b42318; border-color: #f3c6c0; background: #fff5f4; }
.fin-btn-danger:hover { background: #fdecea; }
.fin-btn-sm { padding: 5px 9px; border-radius: 8px; font-size: 13px; }
.fin-icon-btn { border: none; background: transparent; cursor: pointer; color: #6b7177; padding: 6px; border-radius: 8px; }
.fin-icon-btn:hover { background: #efece3; color: #1A1C1F; }
.fin-icon-btn.danger:hover { background: #fdecea; color: #b42318; }

/* ---- Formularios ---- */
.fin-field { margin-bottom: 14px; }
.fin-label { display: block; font-size: 13px; font-weight: 600; color: #44494e; margin-bottom: 6px; }
.fin-input, .fin-select {
    width: 100%; box-sizing: border-box; padding: 10px 12px; font-size: 14px;
    border: 1px solid var(--border, #d9d3c5); border-radius: 10px; background: #fff;
    font-family: inherit; color: #1A1C1F;
}
.fin-input:focus, .fin-select:focus { outline: none; border-color: var(--brand-teal, #6DC7D0); box-shadow: 0 0 0 3px rgba(109,199,208,.25); }
.fin-input-error { border-color: #e0584b; }
.fin-error { color: #b42318; font-size: 12px; margin-top: 4px; }
.fin-row { display: flex; gap: 14px; flex-wrap: wrap; }
.fin-row > .fin-field { flex: 1; min-width: 160px; }

/* ---- Modal ---- */
.fin-modal-overlay {
    position: fixed; inset: 0; background: rgba(20,22,25,.5);
    display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px;
}
.fin-modal {
    background: #fff; border-radius: 16px; width: 100%; max-width: 520px;
    max-height: 90vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.fin-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid #efece3; }
.fin-modal-header h2 { font-family: var(--font-serif, "Fraunces", serif); font-size: 20px; margin: 0; }
.fin-modal-body { padding: 20px; }
.fin-modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid #efece3; }

/* ---- Side panel (drawer) — alta de catalogos ---- */
.fin-drawer-overlay {
    position: fixed; inset: 0; background: rgba(20,22,25,.45);
    z-index: 1000; display: flex; justify-content: flex-end;
    animation: fin-fade-in .18s ease;
}
.fin-drawer {
    background: #fff; width: 100%; max-width: 470px; height: 100%;
    display: flex; flex-direction: column; box-shadow: -16px 0 48px rgba(0,0,0,.22);
    animation: fin-drawer-in .24s cubic-bezier(.22,.61,.36,1);
}
@keyframes fin-drawer-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes fin-fade-in { from { opacity: 0; } to { opacity: 1; } }
.fin-drawer-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 22px; border-bottom: 1px solid #efece3;
    background: linear-gradient(180deg, #faf8f2, #fff);
}
.fin-drawer-titlewrap { display: flex; align-items: center; gap: 12px; }
.fin-drawer-icon {
    width: 40px; height: 40px; border-radius: 11px; flex: 0 0 40px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(109,199,208,.18); color: #06363b; font-size: 22px;
}
.fin-drawer-header h2 { font-family: var(--font-serif, "Fraunces", serif); font-size: 21px; margin: 0; line-height: 1.1; }
.fin-drawer-sub { font-size: 12.5px; color: #6b7177; margin-top: 2px; }
.fin-drawer-body { padding: 22px; overflow: auto; flex: 1; }
.fin-drawer-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid #efece3; }
.fin-drawer-section {
    font-size: 12px; font-weight: 700; color: #8b9197; text-transform: uppercase;
    letter-spacing: .04em; margin: 18px 0 10px; padding-top: 12px; border-top: 1px dashed #ece7db;
}

/* Switch / toggle */
.fin-switch { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #44494e; cursor: pointer; margin: 4px 0 2px; }
.fin-switch input { width: 18px; height: 18px; accent-color: var(--brand-teal, #6DC7D0); }

/* Input con prefijo (ej. $) */
.fin-input-prefix { display: flex; align-items: stretch; }
.fin-input-prefix > span {
    display: inline-flex; align-items: center; padding: 0 12px;
    background: #f4f0e6; border: 1px solid var(--border, #d9d3c5); border-right: none;
    border-radius: 10px 0 0 10px; color: #6b7177; font-weight: 600;
}
.fin-input-prefix > .fin-input { border-radius: 0 10px 10px 0; }

@media (max-width: 640px) { .fin-drawer { max-width: 100%; } }

/* ---- Badges de estado ---- */
.fin-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.fin-badge.pendiente { background: #fff4e0; color: #9a6700; }
.fin-badge.parcial   { background: #e7f0ff; color: #1d4ed8; }
.fin-badge.pagado    { background: #e6f6ec; color: #157347; }
.fin-badge.cancelado { background: #efeae0; color: #6b7177; }
.fin-badge.vencido   { background: #fdecea; color: #b42318; }

/* ---- Estados ---- */
.fin-empty { text-align: center; padding: 48px 20px; color: #8b9197; }
.fin-empty .msr { font-size: 40px; opacity: .5; display: block; margin-bottom: 8px; }
.fin-loading { padding: 40px; text-align: center; color: #8b9197; }
.fin-amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.fin-saldo-pill { font-size: 22px; font-weight: 700; font-family: var(--font-serif, "Fraunces", serif); }

/* ============================================================
   Portal de padres
   ============================================================ */
.portal-shell { min-height: 100vh; background: var(--bg, #F4F0E6); font-family: var(--font-sans, "Figtree", sans-serif); color: var(--text-primary, #1A1C1F); }
.portal-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 22px; background: #1E2126; color: #fff;
}
.portal-brand { font-family: var(--font-serif, "Fraunces", serif); font-style: italic; font-size: 20px; }
.portal-brand b { font-style: normal; color: var(--brand-teal, #6DC7D0); }
.portal-main { max-width: 880px; margin: 0 auto; padding: 24px 18px 60px; }
.portal-auth { max-width: 420px; margin: 8vh auto 0; padding: 0 18px; }
.portal-auth-card { background: #fff; border-radius: 18px; padding: 28px; box-shadow: 0 10px 40px rgba(0,0,0,.08); }
.portal-auth-title { font-family: var(--font-serif, "Fraunces", serif); font-size: 26px; margin: 0 0 4px; }
.portal-alumno-card {
    background: #fff; border: 1px solid var(--border, #e7e2d6); border-radius: 14px;
    padding: 16px 18px; display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 12px; cursor: pointer; transition: box-shadow .15s ease;
}
.portal-alumno-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); }

/* ============================================================
   Operacion de pagos: buscador, stats, recibo, toast, etc.
   ============================================================ */

/* ---- Estado de cuenta: header + saldo semantico ---- */
.fin-ec-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.fin-saldo-box { text-align: right; }
.fin-saldo-box.deuda .fin-saldo-pill { color: var(--danger, #b42318); }
.fin-saldo-box.alcorriente .fin-saldo-pill { color: #157347; }
.fin-saldo-label { font-size: 12px; color: #6b7177; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }

.fin-chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.fin-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.fin-chip .msr { font-size: 16px; }
.fin-chip.danger { background: #fdecea; color: #b42318; }
.fin-chip.warn { background: #fff4e0; color: #9a6700; }
.fin-chip.ok { background: #e6f6ec; color: #157347; }

/* ---- AlumnoPicker / autocomplete ---- */
.fin-picker { position: relative; }
.fin-field-grow { flex: 2 1 240px; }
.fin-search-wrap { position: relative; display: flex; align-items: center; }
.fin-search-icon { position: absolute; left: 10px; color: #8b9197; font-size: 20px; pointer-events: none; }
.fin-search-input { padding-left: 38px; padding-right: 34px; }
.fin-search-clear { position: absolute; right: 6px; border: none; background: transparent; cursor: pointer; color: #8b9197; padding: 4px; border-radius: 6px; }
.fin-search-clear:hover { background: #efece3; color: #1A1C1F; }
.fin-autocomplete {
    position: absolute; z-index: 50; left: 0; right: 0; margin-top: 4px;
    background: #fff; border: 1px solid var(--border, #e7e2d6); border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0,0,0,.14); max-height: 340px; overflow: auto;
}
.fin-ac-msg { padding: 16px; text-align: center; color: #8b9197; font-size: 14px; }
.fin-ac-msg .msr { vertical-align: middle; margin-right: 6px; }
.fin-ac-item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
    border: none; background: transparent; cursor: pointer; text-align: left;
    padding: 10px 14px; min-height: 44px; border-bottom: 1px solid #f3f0e8; font-family: inherit;
}
.fin-ac-item:last-child { border-bottom: none; }
.fin-ac-item:hover { background: #faf8f2; }
.fin-ac-main { display: flex; flex-direction: column; }
.fin-ac-nombre { font-weight: 600; font-size: 15px; color: #1A1C1F; }
.fin-ac-sub { font-size: 12.5px; color: #6b7177; }
.fin-ac-saldo { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fin-ac-saldo.deuda { color: var(--danger, #b42318); }
.fin-ac-saldo.ok { color: #157347; }

/* ---- Stats / corte de caja ---- */
.fin-stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.fin-stat { background: #fff; border: 1px solid var(--border, #e7e2d6); border-radius: 14px; padding: 14px 16px; }
.fin-stat-lbl { font-size: 12.5px; color: #6b7177; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.fin-stat-lbl .msr { font-size: 18px; }
.fin-stat-val { font-family: var(--font-serif, "Fraunces", serif); font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.fin-stat-sub { font-size: 12px; color: #8b9197; }
.fin-stat-total { background: #06363b; border-color: #06363b; color: #fff; }
.fin-stat-total .fin-stat-lbl, .fin-stat-total .fin-stat-sub { color: #bfe6ea; }
.fin-stat-efectivo { border-left: 4px solid #157347; }
.fin-stat-deposito { border-left: 4px solid #1d4ed8; }
.fin-stat-spei { border-left: 4px solid var(--brand-teal, #6DC7D0); }
.fin-chip-btns { display: flex; gap: 6px; }
.fin-field-chips { display: flex; flex-direction: column; }

/* ---- Dialogo de pago: acciones + total fijo ---- */
.fin-modal-pago { max-width: 640px; }
.fin-pago-acciones { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.fin-pago-card { padding: 0; overflow: hidden; }
.fin-input-monto { max-width: 130px; text-align: right; display: inline-block; }
.fin-row-sel td { background: #f3fbfc; }
.fin-sticky-total { position: sticky; bottom: 0; background: #fff; flex-direction: column; align-items: stretch; gap: 10px; }
.fin-total-lbl { font-size: 15px; color: #44494e; }
.fin-total-lbl b { font-family: var(--font-serif, "Fraunces", serif); font-size: 20px; color: #1A1C1F; margin-left: 6px; }
.fin-modal-footer-btns { display: flex; justify-content: flex-end; gap: 10px; }

/* ---- Modal de exito ---- */
.fin-modal-exito { max-width: 380px; text-align: center; }
.fin-exito-body { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 28px; }
.fin-exito-icon { font-size: 56px; color: #157347; }
.fin-exito-folio { font-size: 13px; color: #6b7177; font-weight: 600; }
.fin-exito-monto { font-family: var(--font-serif, "Fraunces", serif); font-size: 30px; font-weight: 700; }

/* ---- Toast ---- */
.fin-toast {
    position: fixed; bottom: 22px; right: 22px; z-index: 2000;
    display: flex; align-items: center; gap: 9px; padding: 12px 16px; border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,.18); font-weight: 600; font-size: 14px;
    animation: fin-toast-in .2s ease;
}
.fin-toast .msr { font-size: 20px; }
.fin-toast.success { background: #06363b; color: #d7f5f8; }
.fin-toast.success .msr { color: #6DC7D0; }
.fin-toast.error { background: #b42318; color: #fff; }
@keyframes fin-toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Misc ---- */
.fin-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.fin-amount-deuda { color: var(--danger, #b42318); }
.portal-saldo-wrap { display: flex; flex-direction: column; align-items: flex-end; }
.portal-saldo-deuda { color: var(--danger, #c0392b); }
.portal-saldo-ok { color: #157347; }
.portal-saldo-tag { font-size: 12px; color: #6b7177; font-weight: 600; }

/* ---- Recibo (ticket ~80mm) ---- */
.fin-print-host { position: absolute; left: -9999px; top: 0; }
.fin-recibo { width: 300px; margin: 0 auto; font-family: var(--font-sans, "Figtree", sans-serif); color: #111; background: #fff; padding: 10px 14px; font-size: 12.5px; }
.fin-recibo-head { text-align: center; border-bottom: 1px dashed #999; padding-bottom: 8px; margin-bottom: 8px; }
.fin-recibo-escuela { font-family: var(--font-serif, "Fraunces", serif); font-size: 16px; font-weight: 700; }
.fin-recibo-tipo { font-size: 11px; letter-spacing: .12em; color: #555; margin-top: 2px; }
.fin-recibo-folio { font-size: 13px; font-weight: 700; margin-top: 4px; }
.fin-recibo-meta { display: flex; flex-direction: column; gap: 3px; margin: 8px 0; }
.fin-recibo-meta > div { display: flex; justify-content: space-between; gap: 10px; }
.fin-recibo-meta span { color: #777; }
.fin-recibo-meta b { text-align: right; }
.fin-recibo-table { width: 100%; border-collapse: collapse; margin: 6px 0; border-top: 1px dashed #999; }
.fin-recibo-table th { text-align: left; font-size: 11px; color: #777; padding: 4px 0; }
.fin-recibo-table td { padding: 3px 0; border-bottom: 1px dotted #ddd; }
.fin-recibo-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.fin-recibo-table tfoot td { border-top: 1px solid #333; border-bottom: none; padding-top: 6px; }
.fin-recibo-letra { font-size: 11.5px; font-style: italic; color: #444; margin: 4px 0 10px; }
.fin-recibo-nota { text-align: center; font-size: 10.5px; color: #888; border-top: 1px dashed #999; padding-top: 8px; margin-top: 8px; }
.fin-corte-print-head { text-align: center; margin-bottom: 12px; }
.fin-corte-print-head h2 { font-family: var(--font-serif, "Fraunces", serif); margin: 0; }
.fin-corte-firma { display: flex; justify-content: space-around; margin-top: 40px; font-size: 13px; }

/* ---- Print ---- */
.fin-print-only { display: none; }
@media print {
    .fin-print-only { display: block; }
    .fin-noprint { display: none !important; }
}

/* ============================================================
   Responsive — tablas como cards apiladas (nunca ocultar saldo)
   Solo en pantalla: al imprimir (popup de ~420px) se conserva la tabla.
   ============================================================ */
@media screen and (max-width: 640px) {
    .fin-page { padding: 18px 14px; }
    .fin-title { font-size: 23px; }
    .fin-row { flex-direction: column; }
    .fin-row > .fin-field { min-width: 100%; flex: 1 1 100%; }
    .fin-stat-row { grid-template-columns: 1fr 1fr; }
    .fin-ec-head { flex-direction: column; }
    .fin-saldo-box { text-align: left; }
    .fin-input-monto { max-width: 100%; }

    .fin-table-cards thead { display: none; }
    .fin-table-cards, .fin-table-cards tbody, .fin-table-cards tr, .fin-table-cards td { display: block; width: 100%; }
    .fin-table-cards tr {
        border: 1px solid var(--border, #e7e2d6); border-radius: 12px;
        padding: 8px 12px; margin-bottom: 10px; background: #fff;
    }
    .fin-table-cards tr:hover td { background: transparent; }
    .fin-table-cards td {
        border: none; padding: 5px 0; display: flex; justify-content: space-between;
        gap: 12px; text-align: right; align-items: center;
    }
    .fin-table-cards td::before {
        content: attr(data-label); color: #6b7177; font-weight: 600; text-align: left;
    }
    .fin-table-cards td[data-label=""]::before { content: ""; }
}
