:root {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --border: #e0e0e0;
    --text: #1a1a1a;
    --text-muted: #666;
    --primary: #2d6a4f;
    --primary-hover: #1b4332;
    --positive: #2d6a4f;
    --negative: #c1121f;
    --warn: #e09f3e;
    --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.navbar {
    background: var(--primary);
    color: white;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand { font-weight: 700; font-size: 1.1rem; }

.nav-links { display: flex; gap: 0.25rem; }

.nav-link {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: background 0.15s;
}

.nav-link:hover { background: rgba(255,255,255,0.15); color: white; }
.nav-link.active { background: rgba(255,255,255,0.2); color: white; }
.nav-logout { margin-left: 1rem; opacity: 0.7; }

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h1 { font-size: 1.5rem; }

.cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.cards-2 { grid-template-columns: repeat(2, 1fr); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.card-header { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.card-value { font-size: 1.75rem; font-weight: 700; }
.card-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

.positive { color: var(--positive); }
.negative { color: var(--negative); }

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.panel h2 { font-size: 1.1rem; margin-bottom: 1rem; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th, .table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    background: #fafafa;
}

.table .num { text-align: right; font-variant-numeric: tabular-nums; }

.table-compact td, .table-compact th { padding: 0.35rem 0.75rem; }

.row-total td { font-weight: 700; border-top: 2px solid var(--text); }
.row-overdue { background: #fff5f5; }

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-ok { background: #d4edda; color: #155724; }
.badge-err { background: #f8d7da; color: #721c24; }
.badge-warn { background: #fff3cd; color: #856404; }
.badge-er { background: #f8d7da; color: #721c24; }
.badge-ar { background: #d4edda; color: #155724; }

.btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.15s;
}

.btn:hover { background: #f0f0f0; }

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    cursor: pointer;
}

.btn-danger { color: var(--negative); border-color: var(--negative); }
.btn-danger:hover { background: #fff5f5; }

select {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.tab {
    padding: 0.5rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    font-size: 0.9rem;
}

.tab.active { background: var(--primary); color: white; border-color: var(--primary); }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 2rem;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal h2 { margin-bottom: 1.5rem; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.3rem; }
.form-group label { font-size: 0.85rem; font-weight: 500; }
.form-group.full-width { grid-column: 1 / -1; }

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.alert-error { background: #f8d7da; color: #721c24; }

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 360px;
    text-align: center;
}

.login-card h1 { font-size: 1.3rem; margin-bottom: 1.5rem; color: var(--primary); }

.login-card input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    margin-bottom: 1rem;
}

.login-card button {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
}

.login-card button:hover { background: var(--primary-hover); }

details { margin-bottom: 0.5rem; }
details summary {
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
}
details summary:hover { background: #f5f5f5; }
details[open] summary { margin-bottom: 0.5rem; }
details h4 { font-size: 0.9rem; margin: 0.75rem 0 0.25rem; color: var(--text-muted); }

.card-highlight { border-left: 4px solid var(--primary); }

.chart-container { position: relative; height: 320px; }

.filter-bar {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

.filter-bar input[type="text"] {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    width: 250px;
}

.filter-check {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.er-summary {
    font-size: 0.9rem;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.date-picker {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
    width: 130px;
    background: var(--surface);
}

.overdue-critical { background: #fff0f0; }
.overdue-critical td:last-child { color: var(--negative); font-weight: 600; }
.overdue-warning { background: #fffbf0; }
.overdue-warning td:last-child { color: var(--warn); }

.panel-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-style: italic;
}

.tab-content { min-height: 200px; }

/* Liquidity table */
.liquidity-scroll { overflow-x: auto; }

.table-liquidity { min-width: 900px; }
.table-liquidity td, .table-liquidity th { text-align: right; padding: 0.5rem 0.6rem; font-size: 0.85rem; white-space: nowrap; }
.table-liquidity .sticky-col { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 140px; font-weight: 500; }
.table-liquidity thead th { background: #fafafa; }
.table-liquidity thead .sticky-col { background: #fafafa; }

.row-section td { font-weight: 600; }
.row-delta td { font-size: 0.8rem; font-style: italic; }
.row-spacer td { padding: 0.25rem; border: none; }
.row-result td { font-weight: 700; border-top: 1px solid var(--border); }
.row-cumul td { font-weight: 600; background: #f8f9fa; }
.row-cumul .sticky-col { background: #f8f9fa; }

@media (max-width: 768px) {
    .cards-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .navbar { padding: 0 1rem; }
    .container { padding: 1rem; }
    .chart-container { height: 250px; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar input[type="text"] { width: 100%; }
}
