/* =========================================================
   Kasboek – stylesheet
   ========================================================= */

/* ── Google Fonts are loaded in index.php via <link> ── */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #222633;
    --bg-hover: #2a2f3d;
    --border: #2e3446;
    --border-light: #3a4058;
    --text-primary: #e8eaf0;
    --text-secondary: #8b91a8;
    --text-muted: #5c6280;
    --accent-green: #34d399;
    --accent-green-dim: #065f46;
    --accent-red: #f87171;
    --accent-red-dim: #7f1d1d;
    --accent-blue: #60a5fa;
    --accent-amber: #fbbf24;
    --accent-purple: #a78bfa;
    --cat-1: #34d399; --cat-2: #60a5fa; --cat-3: #fbbf24; --cat-4: #f87171;
    --cat-5: #a78bfa; --cat-6: #fb923c; --cat-7: #2dd4bf; --cat-8: #e879f9;
    --cat-9: #38bdf8; --cat-10: #a3e635;
    --font-display: 'JetBrains Mono', 'Fira Code', monospace;
    --font-body: 'IBM Plex Sans', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
    --sidebar-w: 220px;
    --sidebar-collapsed-w: 60px;
    --transition: 0.2s ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
}

a { color: var(--accent-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
    cursor: pointer;
    font-family: var(--font-body);
    border: none;
    outline: none;
}

input, select, textarea {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 10px;
    outline: none;
    transition: border-color var(--transition);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent-blue);
}
select option { background: var(--bg-secondary); }

/* ── Layout ── */
#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ── */
#sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width var(--transition), min-width var(--transition);
    overflow: hidden;
    z-index: 100;
}
#sidebar.collapsed {
    width: var(--sidebar-collapsed-w);
    min-width: var(--sidebar-collapsed-w);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 14px;
    border-bottom: 1px solid var(--border);
    min-height: 60px;
}
.sidebar-logo {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-green);
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition);
}
#sidebar.collapsed .sidebar-logo { opacity: 0; width: 0; }

#toggle-sidebar {
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    padding: 4px 6px;
    border-radius: var(--radius);
    flex-shrink: 0;
    line-height: 1;
    transition: background var(--transition), color var(--transition);
}
#toggle-sidebar:hover { background: var(--bg-hover); color: var(--text-primary); }

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--transition), color var(--transition);
    user-select: none;
    text-decoration: none;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-green-dim); color: var(--accent-green); }
.nav-item.disabled { opacity: 0.35; pointer-events: none; }

.nav-icon { font-size: 18px; flex-shrink: 0; width: 24px; text-align: center; }
.nav-label { font-size: 14px; overflow: hidden; transition: opacity var(--transition), width var(--transition); }
#sidebar.collapsed .nav-label { opacity: 0; width: 0; overflow: hidden; }

.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
}
#sidebar.collapsed .sidebar-footer { opacity: 0; }

/* ── Main content ── */
#main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg-primary);
}

.view-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 28px 28px 60px;
}

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}
.card-title {
    font-family: var(--font-display);
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}

/* ── KPI cards ── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
}
.kpi-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 6px;
}
.kpi-value {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}
.kpi-value.positive { color: var(--accent-green); }
.kpi-value.negative { color: var(--accent-red); }
.kpi-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}
.kpi-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 32px;
    opacity: 0.12;
}

/* ── Charts grid ── */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}
.charts-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.chart-container {
    position: relative;
    width: 100%;
    min-height: 260px;
    max-height: 340px;
}
.chart-container canvas { width: 100% !important; }

/* ── Section headings ── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.section-title {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.section-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    transition: background var(--transition), opacity var(--transition);
    white-space: nowrap;
}
.btn-primary {
    background: var(--accent-green);
    color: #000;
}
.btn-primary:hover { background: #2ec68a; }
.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-danger {
    background: var(--accent-red-dim);
    color: var(--accent-red);
    border: 1px solid #7f1d1d;
}
.btn-danger:hover { background: #991b1b; }
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn[disabled] { opacity: 0.4; pointer-events: none; }

/* ── Period selector ── */
.period-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.period-btn {
    padding: 6px 14px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
}
.period-btn:hover { border-color: var(--accent-blue); color: var(--text-primary); }
.period-btn.active { background: var(--accent-blue); color: #000; border-color: var(--accent-blue); font-weight: 600; }

/* ── Tables ── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}
table {
    width: 100%;
    border-collapse: collapse;
}
thead th {
    background: var(--bg-secondary);
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}
thead th:hover { color: var(--text-primary); }
thead th.sorted { color: var(--accent-blue); }
thead th .sort-indicator { margin-left: 4px; font-size: 10px; }
tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
tbody td {
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-primary);
    vertical-align: middle;
}
.td-mono { font-family: var(--font-mono); font-size: 12px; }
.td-amount { font-family: var(--font-mono); font-size: 13px; font-weight: 600; text-align: right; }
.td-amount.positive { color: var(--accent-green); }
.td-amount.negative { color: var(--accent-red); }
.td-amount.transfer { color: var(--text-secondary); }
.td-muted { color: var(--text-muted); font-size: 12px; }

/* ── Category badge ── */
.cat-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 500;
    background: rgba(255,255,255,0.06);
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--transition);
}
.cat-badge:hover { background: rgba(255,255,255,0.12); }
.cat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.cat-badge.uncategorized { color: var(--text-muted); font-style: italic; }

/* ── Inline category select ── */
.inline-cat-select {
    font-size: 12px;
    padding: 3px 6px;
    min-width: 140px;
    border-radius: var(--radius);
}

/* ── Filter bar ── */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    margin-bottom: 16px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
}
.filter-label {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}
.filter-bar input[type="text"],
.filter-bar input[type="date"],
.filter-bar input[type="number"],
.filter-bar select {
    font-size: 12px;
    padding: 5px 8px;
    background: var(--bg-card);
}
.filter-search {
    min-width: 160px;
}
.filter-divider {
    width: 1px;
    height: 28px;
    background: var(--border);
    flex-shrink: 0;
}
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    user-select: none;
}
.toggle-switch input { display: none; }
.toggle-track {
    width: 32px;
    height: 18px;
    background: var(--border);
    border-radius: 9px;
    position: relative;
    transition: background var(--transition);
    flex-shrink: 0;
}
.toggle-track::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: left var(--transition), background var(--transition);
}
.toggle-switch input:checked + .toggle-track { background: var(--accent-green-dim); }
.toggle-switch input:checked + .toggle-track::after { left: 16px; background: var(--accent-green); }

/* ── Status bar ── */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
}
.status-total { font-family: var(--font-mono); font-weight: 600; }

/* ── Virtual scroll container ── */
.virtual-scroll-wrapper {
    position: relative;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.virtual-scroll-spacer {
    position: relative;
}
.virtual-scroll-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
}

/* ── Upload view ── */
.upload-view {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 40px 20px;
}
.upload-center {
    width: 100%;
    max-width: 640px;
}
.upload-logo {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    color: var(--accent-green);
    margin-bottom: 8px;
}
.upload-subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 15px;
}

/* ── Two-source upload layout ── */
.upload-sources {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 0;
    width: 100%;
}
@media (max-width: 640px) {
    .upload-sources { grid-template-columns: 1fr; }
}
.upload-source-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.upload-source-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.upload-source-icon { font-size: 16px; }
.upload-source-badge-opt {
    font-size: 10px;
    font-weight: 500;
    padding: 2px 7px;
    border-radius: 99px;
    background: rgba(251,191,36,0.12);
    color: var(--accent-amber);
    border: 1px solid rgba(251,191,36,0.25);
    margin-left: 2px;
}
.upload-source-status {
    margin-left: auto;
    font-size: 12px;
    font-weight: 500;
}
.upload-source-status.ok      { color: var(--accent-green); }
.upload-source-status.error   { color: var(--accent-red); }
.upload-source-status.loading { color: var(--accent-amber); }

.dropzone {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-card);
    margin-bottom: 0;
    position: relative;
}
.dropzone-secondary {
    border-style: dashed;
    border-color: var(--border);
    background: var(--bg-secondary);
}
.dropzone:hover, .dropzone.drag-over {
    border-color: var(--accent-green);
    background: rgba(52, 211, 153, 0.05);
}
.dropzone-icon { font-size: 48px; margin-bottom: 16px; }
.dropzone-text {
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 8px;
}
.dropzone-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}
#file-input { display: none; }

.privacy-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(52, 211, 153, 0.08);
    border: 1px solid rgba(52, 211, 153, 0.25);
    border-radius: 99px;
    font-size: 12px;
    color: var(--accent-green);
    margin-top: 16px;
}

/* ── Progress steps ── */
.progress-steps {
    display: none;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}
.progress-steps.visible { display: flex; }
.progress-step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-secondary);
    transition: all var(--transition);
}
.progress-step.active { border-color: var(--accent-blue); color: var(--text-primary); }
.progress-step.done { border-color: var(--accent-green-dim); color: var(--accent-green); }
.progress-step .step-icon { font-size: 16px; width: 22px; text-align: center; }

/* ── Account setup ── */
.account-setup {
    display: none;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}
.account-setup.visible { display: flex; }
.account-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
}
.account-card-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}
.account-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.account-row:last-child { border-bottom: none; }
.account-iban {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-primary);
    flex: 1;
}
.account-label-input {
    width: 160px;
    font-size: 12px;
    padding: 4px 8px;
}
.badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 99px;
    white-space: nowrap;
}
.badge-rabo    { background: rgba(96,165,250,0.12); color: var(--accent-blue); border: 1px solid rgba(96,165,250,0.25); }
.badge-revolut { background: rgba(52,211,153,0.12); color: var(--accent-green); border: 1px solid rgba(52,211,153,0.25); }

.transfer-confirm-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: var(--accent-green);
    cursor: pointer;
}

#rabo-file-input, #revolut-file-input { display: none; }

.account-type-select {
    font-size: 12px;
    padding: 4px 8px;
}

/* ── Categories view ── */
.uncategorized-panel {
    background: var(--bg-card);
    border: 1px solid var(--accent-amber);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 24px;
}
.uncat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.uncat-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-amber);
}
.uncat-count {
    font-size: 12px;
    background: rgba(251,191,36,0.12);
    color: var(--accent-amber);
    padding: 3px 8px;
    border-radius: 99px;
}
.uncat-group {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.uncat-group:last-child { border-bottom: none; }
.uncat-name { flex: 1; font-size: 13px; }
.uncat-stats { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.uncat-amount { font-family: var(--font-mono); font-size: 13px; color: var(--accent-red); white-space: nowrap; }
.uncat-assign { font-size: 12px; padding: 4px 6px; min-width: 140px; }

.cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}
.cat-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.cat-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    cursor: pointer;
    transition: background var(--transition);
}
.cat-item-header:hover { background: var(--bg-hover); }
.cat-icon { font-size: 20px; }
.cat-name { flex: 1; font-weight: 500; font-size: 14px; }
.cat-stats { text-align: right; }
.cat-stat-total { font-family: var(--font-mono); font-size: 13px; color: var(--accent-red); }
.cat-stat-total.income { color: var(--accent-green); }
.cat-stat-count { font-size: 11px; color: var(--text-muted); }
.cat-color-bar { height: 3px; width: 100%; }
.cat-budget-bar {
    height: 4px;
    background: var(--bg-secondary);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 16px 12px;
}
.cat-budget-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.4s ease;
}

.cat-rules {
    display: none;
    padding: 0 16px 14px;
    border-top: 1px solid var(--border);
}
.cat-rules.open { display: block; }
.rule-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}
.rule-item:last-child { border-bottom: none; }
.rule-field { color: var(--accent-blue); font-family: var(--font-mono); }
.rule-type { color: var(--text-muted); }
.rule-value { color: var(--text-primary); flex: 1; }
.rule-del { color: var(--accent-red); background: none; font-size: 14px; padding: 2px 6px; border-radius: var(--radius); }
.rule-del:hover { background: var(--accent-red-dim); }

/* ── Insights view ── */
.insights-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}
.insights-full { grid-column: 1 / -1; }

.recurring-table tbody td { font-size: 12px; }
.recurring-name { font-weight: 500; }
.freq-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
}
.freq-monthly { background: rgba(96,165,250,0.15); color: var(--accent-blue); }
.freq-quarterly { background: rgba(251,191,36,0.15); color: var(--accent-amber); }
.freq-yearly { background: rgba(167,139,250,0.15); color: var(--accent-purple); }

.lekkage-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.lekkage-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.lekkage-name { flex: 1; font-size: 13px; }
.lekkage-amount { font-family: var(--font-mono); font-size: 13px; color: var(--accent-amber); }
.lekkage-freq { font-size: 11px; color: var(--text-muted); }

/* ── Heatmap ── */
.heatmap-wrapper {
    overflow-x: auto;
}
.heatmap-grid {
    display: grid;
    grid-template-columns: 40px repeat(12, 1fr);
    gap: 3px;
    min-width: 400px;
}
.heatmap-cell {
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-family: var(--font-mono);
    cursor: default;
    transition: transform 0.1s;
}
.heatmap-cell:hover { transform: scale(1.1); }
.heatmap-label {
    color: var(--text-muted);
    font-size: 11px;
    display: flex;
    align-items: center;
}
.heatmap-header {
    color: var(--text-muted);
    font-size: 10px;
    text-align: center;
    padding-bottom: 4px;
}

/* ── Bulk action bar ── */
.bulk-bar {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(96,165,250,0.08);
    border: 1px solid rgba(96,165,250,0.25);
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-primary);
}
.bulk-bar.visible { display: flex; }
.bulk-count { font-weight: 600; color: var(--accent-blue); }
.bulk-spacer { flex: 1; }

/* ── Checkbox ── */
input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--accent-blue);
    cursor: pointer;
    border-radius: 3px;
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 480px;
    max-width: 95vw;
    box-shadow: var(--shadow-lg);
}
.modal-title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; }
.form-control { width: 100%; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── Toast ── */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    padding: 10px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.2s ease;
    pointer-events: auto;
}
.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error { border-left: 3px solid var(--accent-red); }
.toast.info { border-left: 3px solid var(--accent-blue); }

@keyframes slideIn {
    from { transform: translateX(40px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ── Spinner ── */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state-title { font-size: 16px; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state-sub { font-size: 13px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Responsive ── */
@media (max-width: 900px) {
    .charts-grid { grid-template-columns: 1fr; }
    .charts-grid-3 { grid-template-columns: 1fr; }
    .insights-grid { grid-template-columns: 1fr; }
    .cat-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    #app { flex-direction: column; }
    #sidebar {
        width: 100% !important;
        min-width: 100% !important;
        height: auto;
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .sidebar-header { border-bottom: none; }
    .sidebar-nav { flex-direction: row; padding: 6px; overflow-x: auto; }
    .nav-item { padding: 8px 10px; }
    .sidebar-footer { display: none; }
    #main-content { overflow-y: auto; }
    .view-container { padding: 16px 12px 40px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .filter-bar { gap: 6px; }
}
@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
}

/* ── Utility ── */
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--accent-green); }
.text-red { color: var(--accent-red); }
.text-mono { font-family: var(--font-mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ── Budget progress ── */
.budget-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.budget-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.budget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
}
.budget-bar {
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
}
.budget-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}
.budget-fill.over { background: var(--accent-red); }

/* ── Counterparty table ── */
.cp-rank { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.cp-bar-cell { width: 120px; }
.cp-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--accent-blue);
    opacity: 0.5;
    transition: width 0.3s;
}

/* Tab nav for insights */
.tab-nav {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
}
.tab-btn {
    padding: 9px 16px;
    background: none;
    color: var(--text-muted);
    font-size: 13px;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    margin-bottom: -1px;
    white-space: nowrap;
    transition: all var(--transition);
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent-blue); border-bottom-color: var(--accent-blue); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
