<?php
require_once '../../core/config.php';
require_once '../../core/session.php';
require_once '../../core/database.php';
require_once '../../core/permissions.php';
require_once '../../core/format.php';
require_once '../../services/treasury/TreasuryAccess.php';

require_login();
if(!treasury_can('treasury.view')){http_response_code(403);die('No tienes permisos para acceder al módulo de tesorería.');}
$page_title='Tesorería y flujo de caja';
$initialStart=isset($_GET['start'])&&preg_match('/^\d{4}-\d{2}-\d{2}$/',(string)$_GET['start'])?(string)$_GET['start']:date('Y-m-d');
require_once '../../layouts/header.php';require_once '../../layouts/sidebar.php';
?>

<main class="app-main" id="treasuryMain" data-spa-module="treasury:cashflow">
    <?php require_once '../../layouts/topbar.php'; ?>
    <section class="content treasury-shell">
        <header class="page-header treasury-header">
            <div class="page-header-content"><span class="label">FINANZAS · FASE 3</span><h1>Tesorería y flujo de caja</h1><p>Disponibilidad bruta, conciliación bancaria y forecast de 13 semanas.</p></div>
            <div class="treasury-controls">
                <label><span>Semana inicial</span><input class="input" id="treasuryStart" type="date" value="<?php echo safe_text($initialStart); ?>"></label>
                <label><span>Escenario</span><select class="select" id="treasuryScenario"><option value="conservative">Conservador</option><option value="base" selected>Base</option><option value="optimistic">Optimista</option></select></label>
                <label><span>Filtro libro/cartola</span><select class="select" id="treasuryAccount"><option value="">Todas las cuentas</option></select></label>
                <button class="btn btn-outline" type="button" id="treasuryRefresh"><i data-lucide="refresh-cw"></i><span>Actualizar</span></button>
            </div>
        </header>

        <div class="treasury-notice" id="treasuryNotice" hidden></div>
        <div class="treasury-quality" id="treasuryQuality"><i data-lucide="loader-circle"></i><span>Construyendo cobertura de caja…</span></div>
        <section class="treasury-kpis" id="treasuryKpis"></section>

        <nav class="treasury-tabs" aria-label="Secciones de tesorería">
            <button class="is-active" type="button" data-treasury-tab="forecast"><i data-lucide="chart-no-axes-combined"></i><span>Forecast 13 semanas</span></button>
            <button type="button" data-treasury-tab="ledger"><i data-lucide="book-open"></i><span>Libro de caja</span></button>
            <button type="button" data-treasury-tab="accounts"><i data-lucide="landmark"></i><span>Saldos y cuentas</span></button>
            <button type="button" data-treasury-tab="reconciliation"><i data-lucide="list-checks"></i><span>Conciliación</span></button>
            <button type="button" data-treasury-tab="scenarios"><i data-lucide="git-branch"></i><span>Escenarios</span></button>
        </nav>

        <section class="treasury-panel is-active" data-treasury-panel="forecast">
            <article class="card treasury-card forecast-card">
                <header><div><span class="label">PROYECCIÓN BRUTA</span><h3>Posición semanal consolidada</h3><p>Realizado + compromisos registrados + partidas ponderadas del escenario.</p></div><div class="forecast-legend"><span class="realized">Realizado</span><span class="committed">Comprometido</span><span class="scenario">Escenario</span></div></header>
                <div class="treasury-table-scroll"><table class="treasury-table forecast-table"><thead><tr><th>Semana</th><th class="number">Saldo inicial</th><th class="number">Entradas realizadas</th><th class="number">Salidas realizadas</th><th class="number">Entradas comprometidas</th><th class="number">Salidas comprometidas</th><th class="number">Escenario neto</th><th class="number">Flujo neto</th><th class="number">Saldo final</th></tr></thead><tbody id="forecastBody"></tbody></table></div>
            </article>
            <section class="forecast-foot-grid"><article class="card treasury-info-card"><header><i data-lucide="layers-3"></i><strong>Fuentes incluidas</strong></header><div id="coverageSources"></div></article><article class="card treasury-info-card"><header><i data-lucide="triangle-alert"></i><strong>Reglas de control</strong></header><p>Las transferencias internas se compensan en el consolidado. Las cartolas no crean caja por sí solas: primero se concilian o convierten en un movimiento confirmado.</p><div id="coverageStatus" class="coverage-status"></div><button class="btn btn-outline" type="button" id="coverageBtn"><i data-lucide="clipboard-check"></i><span>Confirmar cobertura</span></button></article></section>
        </section>

        <section class="treasury-panel" data-treasury-panel="ledger">
            <article class="card treasury-card"><header><div><h3>Libro de caja realizado</h3><p>Cobros, pagos y movimientos manuales confirmados.</p></div><div class="card-actions"><input class="input" id="ledgerSearch" type="search" placeholder="Buscar referencia o descripción"><button class="btn btn-primary" type="button" id="newMovementBtn"><i data-lucide="plus"></i><span>Movimiento</span></button><button class="btn btn-outline" type="button" id="newTransferBtn"><i data-lucide="arrow-left-right"></i><span>Transferencia</span></button></div></header><div class="treasury-table-scroll"><table class="treasury-table"><thead><tr><th>Fecha</th><th>Cuenta / fuente</th><th>Detalle</th><th>Centro</th><th class="number">Entrada</th><th class="number">Salida</th><th></th></tr></thead><tbody id="ledgerBody"></tbody></table></div></article>
        </section>

        <section class="treasury-panel" data-treasury-panel="accounts">
            <div class="account-grid" id="accountCards"></div>
            <article class="card treasury-card"><header><div><h3>Saldos iniciales</h3><p>Cada cuenta requiere una fecha de corte. Marcar conciliado habilita la validación del KPI.</p></div><button class="btn btn-primary" type="button" id="newOpeningBtn"><i data-lucide="plus"></i><span>Ingresar saldo</span></button></header><div class="treasury-table-scroll"><table class="treasury-table"><thead><tr><th>Fecha de corte</th><th>Cuenta</th><th>Moneda</th><th>Estado</th><th class="number">Saldo</th><th>Notas</th></tr></thead><tbody id="openingBody"></tbody></table></div></article>
        </section>

        <section class="treasury-panel" data-treasury-panel="reconciliation">
            <section class="reconciliation-grid"><article class="card statement-upload"><header><i data-lucide="file-up"></i><div><h3>Importar cartola</h3><p>CSV/TXT hasta 5 MB. Columnas: Fecha y Monto, o Fecha/Cargo/Abono.</p></div></header><form id="statementForm"><input type="hidden" name="action" value="import_statement"><label><span>Cuenta bancaria</span><select class="select" name="cash_account_id" id="statementAccount" required></select></label><label><span>Archivo CSV</span><input class="input" type="file" name="statement_file" accept=".csv,.txt,text/csv,text/plain" required></label><button class="btn btn-primary" type="submit"><i data-lucide="upload"></i><span>Importar sin duplicar</span></button></form></article><article class="card reconciliation-summary"><span class="label">ESTADO</span><div id="reconciliationSummary"></div><button class="btn btn-outline" id="autoReconcileBtn" type="button"><i data-lucide="wand-sparkles"></i><span>Conciliar coincidencias exactas</span></button></article></section>
            <article class="card treasury-card"><header><div><h3>Movimientos de cartola</h3><p>Coincidencia automática: misma cuenta, importe y fecha con tolerancia de ±3 días.</p></div><select class="select compact-select" id="statementStatusFilter"><option value="pending">Pendientes</option><option value="">Todos</option><option value="matched">Conciliados</option><option value="converted">Convertidos</option><option value="ignored">Ignorados</option></select></header><div class="treasury-table-scroll"><table class="treasury-table"><thead><tr><th>Fecha</th><th>Cuenta</th><th>Glosa / referencia</th><th>Estado</th><th class="number">Importe</th><th></th></tr></thead><tbody id="statementBody"></tbody></table></div></article>
        </section>

        <section class="treasury-panel" data-treasury-panel="scenarios">
            <article class="card treasury-card"><header><div><h3>Partidas de escenario</h3><p>Solo afectan el escenario seleccionado; el importe se pondera por probabilidad.</p></div><button class="btn btn-primary" type="button" id="newScenarioItemBtn"><i data-lucide="plus"></i><span>Nueva partida</span></button></header><div class="treasury-table-scroll"><table class="treasury-table"><thead><tr><th>Fecha</th><th>Escenario</th><th>Partida</th><th>Actividad / centro</th><th>Probabilidad</th><th class="number">Importe bruto</th><th></th></tr></thead><tbody id="scenarioBody"></tbody></table></div></article>
        </section>
    </section>

    <div class="treasury-modal" id="openingModal" aria-hidden="true"><div class="treasury-modal-box compact" role="dialog" aria-modal="true"><header><div><span class="label">CUENTA DE CAJA</span><h2>Saldo inicial</h2></div><button class="btn btn-outline modal-close" type="button" data-close="openingModal"><i data-lucide="x"></i></button></header><form id="openingForm"><input type="hidden" name="action" value="save_opening"><div class="treasury-form"><label><span>Cuenta</span><select class="select" name="cash_account_id" id="openingAccount" required></select></label><label><span>Fecha de corte</span><input class="input" type="date" name="balance_date" id="openingDate" required></label><label><span>Saldo bruto</span><input class="input" type="number" step="0.01" name="amount" required></label><label><span>Moneda</span><input class="input" name="currency_code" value="CLP" maxlength="10"></label><label class="check wide"><input type="checkbox" name="is_reconciled" value="1"><span>Saldo contrastado con cartola o certificado bancario</span></label><label class="wide"><span>Notas</span><textarea class="input" name="notes" rows="2"></textarea></label></div></form><footer><button class="btn btn-outline" type="button" data-close="openingModal">Cancelar</button><button class="btn btn-primary" type="submit" form="openingForm">Guardar saldo</button></footer></div></div>

    <div class="treasury-modal" id="movementModal" aria-hidden="true"><div class="treasury-modal-box" role="dialog" aria-modal="true"><header><div><span class="label">LIBRO DE CAJA</span><h2>Movimiento manual</h2></div><button class="btn btn-outline modal-close" type="button" data-close="movementModal"><i data-lucide="x"></i></button></header><form id="movementForm"><input type="hidden" name="action" value="save_movement"><input type="hidden" name="id"><div class="treasury-form"><label class="wide"><span>Descripción</span><input class="input" name="description" maxlength="255" required></label><label><span>Cuenta</span><select class="select" name="cash_account_id" id="movementAccount" required></select></label><label><span>Fecha efectiva</span><input class="input" type="date" name="movement_date" id="movementDate" required></label><label><span>Tipo</span><select class="select" name="direction"><option value="inflow">Entrada</option><option value="outflow">Salida</option></select></label><label><span>Importe bruto</span><input class="input" type="number" min="0.01" step="0.01" name="amount" required></label><label><span>Actividad de caja</span><select class="select" name="cash_activity"><option value="operations">Operación</option><option value="investment">Inversión</option><option value="financing">Financiamiento</option></select></label><label><span>Centro financiero</span><select class="select" name="finance_center_id" id="movementCenter"></select></label><label><span>Contraparte</span><input class="input" name="counterparty" maxlength="190"></label><label><span>Referencia</span><input class="input" name="external_reference" maxlength="120"></label><label><span>Estado</span><select class="select" name="status"><option value="confirmed">Confirmado</option><option value="draft">Borrador</option></select></label><label class="wide"><span>Notas</span><textarea class="input" name="notes" rows="2"></textarea></label></div></form><footer><button class="btn btn-outline" type="button" data-close="movementModal">Cancelar</button><button class="btn btn-primary" type="submit" form="movementForm">Guardar movimiento</button></footer></div></div>

    <div class="treasury-modal" id="transferModal" aria-hidden="true"><div class="treasury-modal-box compact" role="dialog" aria-modal="true"><header><div><span class="label">SIN DOBLE CONTEO</span><h2>Transferencia interna</h2></div><button class="btn btn-outline modal-close" type="button" data-close="transferModal"><i data-lucide="x"></i></button></header><form id="transferForm"><input type="hidden" name="action" value="save_transfer"><div class="treasury-form"><label><span>Desde</span><select class="select" name="from_account_id" id="transferFrom" required></select></label><label><span>Hacia</span><select class="select" name="to_account_id" id="transferTo" required></select></label><label><span>Fecha</span><input class="input" type="date" name="movement_date" id="transferDate" required></label><label><span>Importe</span><input class="input" type="number" min="0.01" step="0.01" name="amount" required></label><label class="wide"><span>Descripción</span><input class="input" name="description" value="Transferencia interna" required></label><label class="wide"><span>Referencia</span><input class="input" name="external_reference"></label></div></form><footer><button class="btn btn-outline" type="button" data-close="transferModal">Cancelar</button><button class="btn btn-primary" type="submit" form="transferForm">Registrar par de movimientos</button></footer></div></div>

    <div class="treasury-modal" id="scenarioModal" aria-hidden="true"><div class="treasury-modal-box" role="dialog" aria-modal="true"><header><div><span class="label">SENSIBILIZACIÓN</span><h2>Partida de escenario</h2></div><button class="btn btn-outline modal-close" type="button" data-close="scenarioModal"><i data-lucide="x"></i></button></header><form id="scenarioForm"><input type="hidden" name="action" value="save_scenario_item"><input type="hidden" name="id"><div class="treasury-form"><label class="wide"><span>Descripción</span><input class="input" name="description" maxlength="255" required></label><label><span>Escenario</span><select class="select" name="scenario_id" id="scenarioItemScenario" required></select></label><label><span>Fecha esperada</span><input class="input" type="date" name="expected_date" id="scenarioItemDate" required></label><label><span>Tipo</span><select class="select" name="item_type"><option value="inflow">Entrada</option><option value="outflow">Salida</option></select></label><label><span>Importe bruto</span><input class="input" type="number" min="0.01" step="0.01" name="amount" required></label><label><span>Probabilidad %</span><input class="input" type="number" min="0" max="100" step="0.01" name="probability_pct" value="100" required></label><label><span>Actividad</span><select class="select" name="cash_activity"><option value="operations">Operación</option><option value="investment">Inversión</option><option value="financing">Financiamiento</option></select></label><label><span>Centro financiero</span><select class="select" name="finance_center_id" id="scenarioCenter"></select></label><label><span>Contraparte</span><input class="input" name="counterparty"></label><label class="wide"><span>Notas</span><textarea class="input" name="notes" rows="2"></textarea></label></div></form><footer><button class="btn btn-outline" type="button" data-close="scenarioModal">Cancelar</button><button class="btn btn-primary" type="submit" form="scenarioForm">Guardar partida</button></footer></div></div>

    <div class="treasury-modal" id="coverageModal" aria-hidden="true"><div class="treasury-modal-box compact" role="dialog" aria-modal="true"><header><div><span class="label">CALIDAD DEL FORECAST</span><h2>Confirmar cobertura operativa</h2></div><button class="btn btn-outline modal-close" type="button" data-close="coverageModal"><i data-lucide="x"></i></button></header><form id="coverageForm"><input type="hidden" name="action" value="save_forecast_coverage"><div class="treasury-form"><label class="check wide"><input type="checkbox" name="payroll_complete" value="1"><span>Remuneraciones y costo empresa están completos</span></label><label class="check wide"><input type="checkbox" name="taxes_complete" value="1"><span>Impuestos y obligaciones fiscales están cubiertos</span></label><label class="check wide"><input type="checkbox" name="financing_complete" value="1"><span>Créditos, cuotas y financiamiento están cubiertos</span></label><label class="check wide"><input type="checkbox" name="other_expenses_complete" value="1"><span>Otros gastos sin DTE están cubiertos</span></label><label class="wide"><span>Cobertura revisada hasta</span><input class="input" type="date" name="confirmed_through" required></label><label class="wide"><span>Notas de revisión</span><textarea class="input" name="notes" rows="3"></textarea></label></div></form><footer><button class="btn btn-outline" type="button" data-close="coverageModal">Cancelar</button><button class="btn btn-primary" type="submit" form="coverageForm">Guardar confirmación</button></footer></div></div>

    <style>
    #treasuryMain{height:100dvh;max-height:100dvh;overflow:hidden;display:flex;flex-direction:column}#treasuryMain .treasury-shell{width:min(100%,1900px);max-width:none!important;margin:0 auto;flex:1 1 0;min-height:0;overflow:auto;padding-bottom:26px}.treasury-header{display:flex;align-items:flex-end;justify-content:space-between;gap:24px;margin-bottom:12px}.treasury-header h1{margin:3px 0 4px}.treasury-header p{margin:0;color:var(--text-secondary)}.treasury-controls{display:flex;align-items:flex-end;justify-content:flex-end;gap:8px;flex-wrap:wrap}.treasury-controls label,.statement-upload label,.treasury-form label{display:grid;gap:5px}.treasury-controls label>span,.statement-upload label>span,.treasury-form label>span{font-size:.68rem;color:var(--text-muted);font-weight:700}.treasury-controls .input{width:150px}.treasury-controls .select{min-width:140px}.treasury-notice{margin-bottom:10px;padding:11px 13px;border:1px solid var(--border-default);border-radius:var(--radius-md);background:var(--surface-1)}.treasury-notice.is-error{color:var(--color-error)}.treasury-notice.is-success{color:var(--color-success)}.treasury-quality{display:flex;align-items:center;gap:9px;padding:10px 12px;margin-bottom:10px;border:1px solid var(--border-subtle);border-radius:var(--radius-md);background:var(--surface-1);font-size:.78rem}.treasury-quality svg{width:18px;color:var(--color-primary)}.treasury-quality.is-validated{border-color:color-mix(in srgb,var(--color-success) 38%,var(--border-subtle));color:var(--color-success)}.treasury-quality.is-provisional{border-color:color-mix(in srgb,#f6b84a 42%,var(--border-subtle));color:#dca137}.treasury-kpis{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:10px;margin-bottom:10px}.treasury-kpi{padding:14px;border:1px solid var(--border-subtle);border-radius:var(--radius-lg);background:var(--surface-1);min-width:0}.treasury-kpi span{display:block;color:var(--text-muted);font-size:.67rem;font-weight:700;text-transform:uppercase}.treasury-kpi strong{display:block;margin-top:6px;font-size:1.18rem;overflow:hidden;text-overflow:ellipsis}.treasury-kpi small{display:block;margin-top:4px;color:var(--text-muted);font-size:.67rem}.treasury-kpi.is-danger strong{color:var(--color-error)}.treasury-tabs{display:flex;gap:5px;overflow:auto;padding:5px;margin-bottom:12px;border:1px solid var(--border-subtle);border-radius:var(--radius-lg);background:var(--surface-1)}.treasury-tabs button{display:flex;align-items:center;justify-content:center;gap:7px;min-width:145px;padding:9px 12px;border:0;border-radius:var(--radius-md);background:transparent;color:var(--text-secondary);font:inherit;font-size:.8rem;cursor:pointer}.treasury-tabs button svg{width:17px}.treasury-tabs button.is-active{background:var(--surface-3);color:var(--text-primary);font-weight:650}.treasury-panel{display:none}.treasury-panel.is-active{display:block}.treasury-card{overflow:hidden;padding:0}.treasury-card>header{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px 16px;border-bottom:1px solid var(--border-subtle)}.treasury-card h3,.treasury-card p{margin:0}.treasury-card p{margin-top:3px;color:var(--text-muted);font-size:.74rem}.card-actions{display:flex;gap:7px}.card-actions input{min-width:230px}.forecast-legend{display:flex;gap:6px;flex-wrap:wrap}.forecast-legend span{padding:5px 8px;border-radius:99px;font-size:.68rem;background:var(--surface-3)}.forecast-legend .realized{color:#68b6ff}.forecast-legend .committed{color:#e8b252}.forecast-legend .scenario{color:#bc8cff}.treasury-table-scroll{overflow:auto;max-height:calc(100dvh - 330px)}.treasury-table{width:100%;border-collapse:separate;border-spacing:0;min-width:880px}.forecast-table{min-width:1250px}.treasury-table th{position:sticky;top:0;z-index:2;padding:10px 12px;background:var(--surface-2);border-bottom:1px solid var(--border-default);color:var(--text-muted);font-size:.66rem;text-transform:uppercase;text-align:left;white-space:nowrap}.treasury-table td{padding:10px 12px;border-bottom:1px solid var(--border-subtle);vertical-align:middle;font-size:.78rem}.treasury-table tr:hover td{background:var(--surface-2)}.treasury-table td small{display:block;margin-top:3px;color:var(--text-muted);font-size:.67rem}.treasury-table .number{text-align:right;font-variant-numeric:tabular-nums}.treasury-table tr.is-negative td:last-child,.negative{color:var(--color-error)!important}.row-actions{display:flex;justify-content:flex-end;gap:5px}.row-actions .btn{min-width:34px;padding:0 7px}.treasury-empty{text-align:center!important;color:var(--text-muted);padding:30px!important}.forecast-foot-grid,.reconciliation-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:10px}.treasury-info-card,.statement-upload,.reconciliation-summary{padding:15px}.treasury-info-card header,.statement-upload header{display:flex;align-items:flex-start;gap:10px}.treasury-info-card header svg,.statement-upload header svg{width:20px;color:var(--color-primary)}.treasury-info-card p,.statement-upload p{margin:5px 0 0;color:var(--text-secondary);font-size:.75rem}.source-chips{display:flex;gap:7px;flex-wrap:wrap;margin-top:12px}.source-chips span{padding:7px 9px;border-radius:var(--radius-md);background:var(--surface-2);font-size:.72rem}.account-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin-bottom:10px}.account-card{padding:15px;border:1px solid var(--border-subtle);border-radius:var(--radius-lg);background:var(--surface-1)}.account-card header{display:flex;align-items:center;justify-content:space-between;gap:10px}.account-card header svg{width:20px;color:var(--color-primary)}.account-card strong{display:block;margin-top:12px}.account-card small{display:block;margin-top:4px;color:var(--text-muted)}.statement-upload form{display:grid;grid-template-columns:1fr 1fr auto;align-items:end;gap:9px;margin-top:15px}.reconciliation-summary{display:flex;flex-direction:column;justify-content:space-between}.reconciliation-summary>div{display:grid;grid-template-columns:repeat(4,1fr);gap:8px;margin:10px 0}.reconciliation-stat{padding:10px;border-radius:var(--radius-md);background:var(--surface-2);text-align:center}.reconciliation-stat strong,.reconciliation-stat small{display:block}.reconciliation-stat small{margin-top:3px;color:var(--text-muted);font-size:.65rem}.compact-select{max-width:150px}.status-pill{display:inline-flex;padding:4px 7px;border-radius:99px;background:var(--surface-3);font-size:.67rem}.status-pill.matched,.status-pill.converted{color:var(--color-success)}.status-pill.pending{color:#e8b252}.treasury-modal{position:fixed;inset:0;z-index:1100;display:none;align-items:center;justify-content:center;padding:24px;background:rgba(0,0,0,.72);backdrop-filter:blur(5px)}.treasury-modal.is-open{display:flex}.treasury-modal-box{width:min(900px,calc(100vw - 48px));max-height:calc(100dvh - 48px);display:flex;flex-direction:column;overflow:hidden;border:1px solid var(--border-default);border-radius:var(--radius-xl);background:var(--surface-1);box-shadow:var(--shadow-lg)}.treasury-modal-box.compact{width:min(720px,calc(100vw - 48px))}.treasury-modal-box>header,.treasury-modal-box>footer{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:15px 19px}.treasury-modal-box>header{border-bottom:1px solid var(--border-subtle)}.treasury-modal-box>header h2{margin:2px 0 0;font-size:1.15rem}.treasury-modal-box>footer{justify-content:flex-end;border-top:1px solid var(--border-subtle);background:var(--surface-0)}.treasury-modal-box>form{padding:18px 19px;overflow:auto}.modal-close{width:40px;padding:0}.treasury-form{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.treasury-form .wide{grid-column:1/-1}.treasury-form textarea.input{height:auto;resize:vertical}.treasury-form .check{display:flex;align-items:center;gap:9px}.treasury-form .check input{width:17px;height:17px}.treasury-form .check span{font-size:.75rem}
    .coverage-status{margin:11px 0;color:var(--text-muted);font-size:.72rem}
    @media(max-width:1350px){.treasury-kpis{grid-template-columns:repeat(3,minmax(0,1fr))}.account-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:850px){#treasuryMain{height:auto;max-height:none;overflow:visible}#treasuryMain .treasury-shell{overflow:visible;padding:12px}.treasury-header{align-items:flex-start;flex-direction:column}.treasury-controls{width:100%;justify-content:flex-start}.treasury-controls label{flex:1}.treasury-controls .input,.treasury-controls .select{width:100%;min-width:130px}.treasury-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}.forecast-foot-grid,.reconciliation-grid{grid-template-columns:1fr}.statement-upload form{grid-template-columns:1fr}.account-grid{grid-template-columns:1fr}.treasury-card>header{align-items:flex-start;flex-direction:column}.card-actions{width:100%;flex-wrap:wrap}.card-actions input{min-width:0;flex:1}.treasury-table-scroll{max-height:none}.treasury-modal{padding:0}.treasury-modal-box,.treasury-modal-box.compact{width:100vw;height:100dvh;max-height:100dvh;border-radius:0}.treasury-form{grid-template-columns:1fr}.treasury-form .wide{grid-column:auto}}
    </style>
    <script>window.ICY_TREASURY_INITIAL_START=<?php echo json_encode($initialStart); ?>;</script>
    <script src="/modules/treasury/treasury.js?v=9.0"></script>
</main>
<?php require_once '../../layouts/footer.php'; ?>
