:root {
    --ink: #17283a;
    --ink-soft: #536579;
    --paper: #f5f7f6;
    --panel: #ffffff;
    --line: #dfe7e8;
    --accent: #24b8b3;
    --accent-dark: #087d82;
    --accent-pale: #dff5f1;
    --coral: #e56e58;
    --gold: #c99131;
    --shadow: 0 18px 50px rgba(28, 54, 70, .08);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font-size: 15px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar { position: sticky; top: 0; width: 250px; height: 100vh; overflow-y: auto; background: #102434; color: #dcecef; padding: 30px 18px 22px; display: flex; flex-direction: column; flex-shrink: 0; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: #fff; font-size: 18px; font-weight: 750; letter-spacing: -.03em; }
.brand small { display: block; color: #8fb5ba; font-size: 10px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; margin-top: 3px; }
.brand-mark { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 11px; background: var(--accent); color: #082a32; font-size: 21px; }
.main-nav { display: grid; gap: 7px; margin-top: 55px; }
.nav-link { display: flex; align-items: center; gap: 13px; padding: 12px 13px; border-radius: 10px; color: #9cb7bd; transition: .2s ease; }
.nav-link span { width: 18px; color: #6f9fa5; text-align: center; }
.nav-link:hover, .nav-link.active { color: white; background: rgba(36, 184, 179, .18); }
.nav-link.active span { color: var(--accent); }
.sidebar-foot { margin-top: auto; padding-top: 22px; border-top: 1px solid rgba(255,255,255,.1); }
.user-chip { display: flex; align-items: center; gap: 9px; color: #bdd1d4; font-size: 12px; overflow: hidden; }
.user-chip > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: #285469; color: #fff; font-weight: 700; }
.logout-link { display: inline-block; margin: 18px 0 0 37px; color: #73949a; font-size: 12px; }
.logout-link:hover { color: #fff; }
.main-content { width: min(100%, 1440px); min-width: 0; padding: 42px 52px 70px; }
.mobile-topbar { display: none; }
.mobile-topbar-actions { display: flex; align-items: center; gap: 8px; }
.mobile-menu { position: relative; }
.mobile-menu summary { list-style: none; cursor: pointer; }
.mobile-menu summary::-webkit-details-marker { display: none; }
.mobile-nav { position: absolute; top: 44px; right: 0; z-index: 50; display: flex; flex-direction: column; width: 235px; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow); }
.mobile-nav a { display: flex; align-items: center; gap: 10px; padding: 11px 10px; color: var(--ink-soft); border-radius: 7px; font-size: 13px; font-weight: 700; }
.mobile-nav a span { width: 18px; color: var(--accent-dark); text-align: center; }
.mobile-nav a:hover, .mobile-nav a.active { color: var(--ink); background: var(--accent-pale); }
.mobile-nav a.logout { margin-top: 8px; padding-top: 13px; color: #a63d31; border-top: 1px solid var(--line); border-radius: 7px; }
.mobile-nav a.logout span { color: #a63d31; }
.mobile-nav a.logout:hover { background: #fff0ed; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; margin-bottom: 30px; }
.eyebrow { color: var(--accent-dark); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 3.3vw, 42px); letter-spacing: -.05em; line-height: 1.05; }
h2 { margin-bottom: 6px; font-size: 23px; letter-spacing: -.04em; }
h3 { margin-bottom: 8px; font-size: 16px; }
.muted { color: var(--ink-soft); }
.page-header p { margin: 0; color: var(--ink-soft); }
.accent-text { color: var(--accent-dark); }
.page-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 40px; padding: 0 15px; border: 1px solid transparent; border-radius: 8px; font-weight: 750; font-size: 13px; transition: .2s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--accent); color: #072e35; }
.button-primary:hover { background: #37cbc4; }
.button-secondary { background: #eef3f3; color: var(--ink); border-color: var(--line); }
.button-danger { background: #fff0ed; color: #a63d31; border-color: #f1cbc5; }
.button-quiet { background: transparent; color: var(--accent-dark); padding-inline: 8px; }
.button-wide { width: 100%; }
.button-small { min-height: 32px; padding: 0 10px; font-size: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.card-pad { padding: 22px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, .85fr); align-items: start; }
.grid-main > * { min-width: 0; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; margin-bottom: 20px; }
.metric { min-height: 126px; padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 13px; }
.metric-label { color: var(--ink-soft); font-size: 12px; font-weight: 650; }
.metric-value { margin-top: 13px; font-size: 26px; font-weight: 780; letter-spacing: -.04em; }
.metric-value.positive { color: var(--accent-dark); }
.metric-value.negative { color: var(--coral); }
.metric-note { margin-top: 5px; color: var(--ink-soft); font-size: 11px; }
.account-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 13px; }
.account-tile { min-height: 138px; padding: 17px; border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(135deg, #fff, #f5fbfa); }
.account-tile:hover { border-color: #95dcd7; }
.account-name { font-weight: 750; }
.account-meta { color: var(--ink-soft); font-size: 11px; margin-top: 3px; }
.account-balance { margin-top: 28px; font-size: 21px; font-weight: 780; letter-spacing: -.04em; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.section-title h2 { margin: 0; }
.table-wrap { overflow-x: auto; }
.center { text-align: center; }
.account-scope-table th { white-space: normal; vertical-align: middle; }
.account-scope-table td { min-width: 145px; }
.account-scope-table td:first-child { min-width: 180px; }
.scope-check { display: inline-flex; align-items: center; justify-content: center; width: 100%; cursor: pointer; }
.scope-check input { width: 18px; min-height: 18px; margin: 0; accent-color: var(--accent-dark); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 12px; color: var(--ink-soft); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-align: left; text-transform: uppercase; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 13px 12px; border-bottom: 1px solid #edf1f1; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.amount { font-weight: 760; white-space: nowrap; text-align: right; }
th.num, td.num { text-align: right; }
.amount.income { color: var(--accent-dark); }
.amount.expense { color: var(--coral); }
.date-cell { color: var(--ink-soft); font-size: 12px; white-space: nowrap; }
.operation-main { font-weight: 700; }
.operation-sub { color: var(--ink-soft); font-size: 11px; margin-top: 3px; }
.status { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.status::before { content: ''; display: block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-open { color: #9c6a17; background: #fff5d9; }
.status-pointed { color: #3377a0; background: #e5f2fa; }
.status-reconciled { color: #228474; background: #e1f5ef; }
.category-bar { display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: minmax(100px, 1fr) 2fr 78px; align-items: center; gap: 10px; font-size: 12px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; overflow: hidden; border-radius: 20px; background: #edf2f1; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #86d9c7); }
.income-fill { background: linear-gradient(90deg, #7e9be4, #b6c7f4); }
.bar-amount { color: var(--ink-soft); text-align: right; white-space: nowrap; }
.balance-chart { display: flex; align-items: end; gap: 8px; height: 150px; padding: 15px 5px 0; border-bottom: 1px solid var(--line); }
.balance-column { position: relative; display: flex; flex: 1; align-items: end; justify-content: center; height: 100%; min-width: 12px; }
.balance-bar { width: min(24px, 70%); min-height: 8px; border-radius: 6px 6px 0 0; background: linear-gradient(180deg, var(--accent), #b3e6d5); }
.balance-bar.negative-bar { background: linear-gradient(180deg, var(--coral), #f5b4a5); }
.balance-column span { position: absolute; bottom: -22px; color: var(--ink-soft); font-size: 10px; }
.chart-caption { display: flex; justify-content: space-between; gap: 10px; margin-top: 29px; color: var(--ink-soft); font-size: 11px; }
.chart-caption strong { color: var(--ink); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.field-full { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: var(--ink); font-size: 12px; font-weight: 750; }
.radio-line { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.radio-line input { width: 16px; min-height: 16px; margin: 0; }
label small, small { color: var(--ink-soft); font-size: 11px; font-weight: 450; }
input, select, textarea { width: 100%; min-height: 42px; padding: 9px 11px; color: var(--ink); background: #fff; border: 1px solid #cddadb; border-radius: 7px; outline: none; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(36,184,179,.13); }
.password-field { position: relative; }
.password-field input { padding-right: 48px; }
.password-toggle { position: absolute; top: 50%; right: 8px; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; color: var(--ink-soft); background: transparent; border: 0; border-radius: 6px; transform: translateY(-50%); }
.password-toggle:hover, .password-toggle:focus-visible { color: var(--accent-dark); background: var(--accent-pale); outline: none; }
.password-toggle svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.stack-form { display: grid; gap: 16px; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.inline-form { display: inline; }
.filter-bar { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; padding: 14px; margin-bottom: 16px; background: #f7faf9; border: 1px solid var(--line); border-radius: 10px; }
.filter-bar label { min-width: 140px; }
.filter-bar .filter-grow { flex: 1; min-width: 180px; }
.analysis-filters { margin-bottom: 18px; }
.analysis-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.analysis-tabs a { padding: 10px 14px; color: var(--ink-soft); background: #eef3f3; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-weight: 750; }
.analysis-tabs a:hover { color: #07333b; background: var(--accent-pale); border-color: #8bd8d0; }
.analysis-tabs a.active { color: #fff; background: var(--accent-dark); border-color: var(--accent-dark); box-shadow: 0 5px 14px rgba(8, 125, 130, .24); }
.analysis-filter-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.analysis-filter-row .is-hidden { display: none; }
.analysis-accounts { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--line); }
.analysis-accounts .section-title { margin-bottom: 9px; }
.analysis-account-list { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.analysis-account-list .checkbox-line { display: inline-grid; }
.analysis-metrics { margin-top: 18px; }
.analysis-chart { display: flex; align-items: end; gap: 9px; height: 210px; padding: 15px 7px 0; border-bottom: 1px solid var(--line); }
.analysis-column { position: relative; display: flex; flex: 1; align-items: end; justify-content: center; height: 100%; min-width: 18px; }
.analysis-column-bar { width: min(38px, 72%); min-height: 7px; border-radius: 7px 7px 0 0; background: linear-gradient(180deg, var(--accent), #a9e1d3); }
.analysis-column-bar.negative-bar { background: linear-gradient(180deg, var(--coral), #f4b0a2); }
.analysis-column span, .analysis-flow-column > span { position: absolute; bottom: -23px; color: var(--ink-soft); font-size: 10px; white-space: nowrap; }
.analysis-table { margin-top: 31px; }
.analysis-flow-chart { display: flex; align-items: end; gap: 9px; height: 210px; padding: 15px 7px 0; border-bottom: 1px solid var(--line); }
.analysis-flow-column { position: relative; display: flex; flex: 1; align-items: end; justify-content: center; height: 100%; min-width: 26px; }
.flow-pair { display: flex; align-items: end; justify-content: center; gap: 3px; width: 100%; height: 100%; }
.flow-bar { width: min(17px, 38%); min-height: 5px; border-radius: 5px 5px 0 0; }
.income-flow { background: linear-gradient(180deg, #7e9be4, #b6c7f4); }
.expense-flow { background: linear-gradient(180deg, var(--coral), #f5b4a5); }
.analysis-legend { display: flex; justify-content: center; gap: 18px; margin-top: 29px; color: var(--ink-soft); font-size: 12px; }
.analysis-legend i { display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 2px; vertical-align: -1px; }
.legend-income { background: #7e9be4; }
.legend-expense { background: var(--coral); }
.analysis-category-bars { margin-bottom: 24px; }
.balance-line-chart { padding: 8px 0 0; }
.balance-line-chart svg { display: block; width: 100%; height: 280px; min-height: 220px; overflow: visible; }
.chart-axis { stroke: var(--line); stroke-width: 1; }
.balance-line { fill: none; stroke: var(--accent-dark); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.balance-point { fill: #fff; stroke: var(--accent-dark); stroke-width: 3; }
.income-line { fill: none; stroke: #657fd4; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.expense-line { fill: none; stroke: var(--coral); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.income-point { fill: #fff; stroke: #657fd4; stroke-width: 3; }
.expense-point { fill: #fff; stroke: var(--coral); stroke-width: 3; }
.line-chart-labels { display: flex; justify-content: space-between; gap: 8px; margin: 8px 22px 0; color: var(--ink-soft); font-size: 10px; }
.analysis-category-tree { display: grid; gap: 5px; }
.analysis-category-node { border-bottom: 1px solid #edf1f1; }
.analysis-category-node > summary { position: relative; list-style: none; cursor: pointer; padding-left: 22px; }
.analysis-category-node > summary::-webkit-details-marker { display: none; }
.analysis-category-node > summary::before { content: '▸'; position: absolute; left: 4px; top: 9px; color: var(--accent-dark); font-weight: 800; }
.analysis-category-node[open] > summary::before { content: '▾'; }
.analysis-category-row { display: grid; grid-template-columns: minmax(130px, 1fr) 2fr 90px; align-items: center; gap: 10px; padding: 8px 8px 8px calc(8px + (var(--category-level) * 20px)); }
.analysis-category-node > summary:hover, .analysis-category-row:hover { background: #f7faf9; border-radius: 7px; }
.analysis-category-children { padding-left: 18px; border-left: 1px dashed var(--line); margin-left: 15px; }
.analysis-category-table { overflow-x: auto; }
.analysis-category-table-row { display: grid; grid-template-columns: minmax(220px, 1fr) 130px 130px 130px; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid #edf1f1; }
.analysis-category-table-row > div:not(:first-child) { text-align: right; }
.analysis-category-table-header { color: var(--ink-soft); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.analysis-category-table-node > summary { position: relative; list-style: none; cursor: pointer; padding-left: 22px; }
.analysis-category-table-node > summary::-webkit-details-marker { display: none; }
.analysis-category-table-node > summary::before { content: '▸'; position: absolute; left: 4px; top: 10px; color: var(--accent-dark); font-weight: 800; }
.analysis-category-table-node[open] > summary::before { content: '▾'; }
.analysis-category-table-children { padding-left: 18px; border-left: 1px dashed var(--line); margin-left: 15px; }
.alert { padding: 12px 15px; margin-bottom: 18px; border-radius: 9px; font-size: 13px; font-weight: 650; }
.alert-success { color: #1e7566; background: #ddf5ec; border: 1px solid #b6e6d7; }
.alert-error { color: #9b3c31; background: #fff0ed; border: 1px solid #f0c5be; }
.alert-warning { color: #855c11; background: #fff5d9; border: 1px solid #f0dc9b; }
.empty-state { padding: 38px 20px; color: var(--ink-soft); text-align: center; }
.empty-state strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 7px; }
.actions-cell { text-align: right; white-space: nowrap; }
.actions-cell a, .actions-cell button { margin-left: 5px; }
.pill { display: inline-flex; padding: 4px 8px; border-radius: 999px; color: var(--accent-dark); background: var(--accent-pale); font-size: 11px; font-weight: 750; }
.notice { padding: 13px 15px; color: #52666c; background: #f0f7f6; border-left: 3px solid var(--accent); border-radius: 4px; font-size: 13px; }
.auth-card { width: min(100%, 440px); margin: 9vh auto 0; padding: 35px; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.auth-card h1 { margin-top: 18px; }
.public-page { min-height: 100vh; background: radial-gradient(circle at 70% 10%, #d9f3ee 0, transparent 31%), var(--paper); }
.public-wrap { width: min(100% - 32px, 920px); margin: auto; padding-top: 38px; }
.public-brand { color: var(--ink); }
.public-brand .brand-mark { color: #fff; }
.reconcile-summary { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 15px; padding: 18px; margin-bottom: 16px; background: #eff9f7; border: 1px solid #caebe4; border-radius: 11px; }
.difference-ok { color: var(--accent-dark); font-weight: 800; }
.difference-bad { color: var(--coral); font-weight: 800; }
.split-list { display: grid; gap: 8px; }
.split-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px 1fr auto; align-items: end; gap: 8px; }
.split-row .remove-split { min-height: 42px; }
.qif-preview { max-height: 530px; overflow: auto; }
.import-row-duplicate { background: #fffaf0; }
.patrimony-total { padding: 24px; color: #fff; background: linear-gradient(135deg, #123c4b, #087d82); border-radius: 14px; }
.patrimony-total .metric-value { color: #fff; }
.list-clean { display: grid; gap: 0; padding: 0; margin: 0; list-style: none; }
.list-clean li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid #edf1f1; }
.list-clean li:last-child { border-bottom: 0; }
.subtle-rule { height: 1px; margin: 22px 0; background: var(--line); border: 0; }

.bulk-bar { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-bottom: 10px; }

.category-tree-wrap { max-height: 520px; overflow: auto; padding-right: 6px; }

.category-tree { list-style: none; margin: 0; padding: 0; }
.category-tree .category-tree { padding-left: 20px; margin-left: 7px; border-left: 1px dashed var(--line); }
.tree-item { padding: 2px 0; }
.tree-row { display: flex; align-items: flex-start; gap: 10px; }
.tree-toggle { flex: 1; min-width: 0; }
.tree-has-children > .tree-row > details > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 10px 6px; border-radius: 8px; }
.tree-has-children > .tree-row > details > summary::-webkit-details-marker { display: none; }
.tree-has-children > .tree-row > details > summary::before { content: '▸'; color: var(--accent-dark); font-weight: 800; transition: transform .15s ease; }
.tree-has-children > .tree-row > details[open] > summary::before { content: '▾'; }
.tree-has-children > .tree-row > details > summary:hover { background: #f6faf9; }
.tree-has-children .pill { flex-shrink: 0; margin-left: auto; }
.tree-leaf { padding: 10px 6px; color: var(--ink-soft); }
.tree-leaf .tree-name { flex: 1; min-width: 0; }
.tree-name { font-weight: 700; color: var(--ink); }
.tree-row .tree-delete-form { flex-shrink: 0; margin-left: auto; padding-top: 10px; }
.tree-delete { border: 0; background: transparent; color: #a63d31; font-size: 12px; font-weight: 700; cursor: pointer; padding: 5px 9px; border-radius: 6px; }
.tree-delete:hover { background: #fff0ed; }

.forecast-layout { overflow: hidden; }
.forecast-layout .card { box-shadow: none; }
.forecast-layout > aside { float: right; width: 300px; max-width: 100%; margin-left: 22px; }
.forecast-layout > .forecast-columns { overflow: hidden; }
.forecast-layout > .forecast-columns > .card + .card { margin-top: 18px; }
.forecast-account-group { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.forecast-account-group:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.forecast-account-group h3 { display: flex; align-items: center; gap: 9px; margin: 0 0 10px; font-size: 15px; }
.forecast-account-group h3 .pill { margin-left: auto; }
.month-short { width: 96px; min-height: 32px; padding: 5px 8px; margin-right: 5px; vertical-align: middle; }

.forecast-layout .table-wrap table { font-size: 13px; }
.forecast-layout .table-wrap thead th { padding-top: 8px; padding-bottom: 8px; }
.forecast-layout .table-wrap td { padding: 8px 11px; }
.forecast-layout .table-wrap .actions-cell { white-space: nowrap; }
.forecast-layout .table-wrap .button-small { padding: 0 7px; font-size: 11px; white-space: nowrap; }

.accounts-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.accounts-layout > aside { grid-column: 2; grid-row: 1; width: auto; max-width: none; margin: 0; }
.accounts-layout > .accounts-columns { grid-column: 1; grid-row: 1; min-width: 0; overflow: visible; }
.accounts-layout > .accounts-columns > .card + .card { margin-top: 18px; }

.accounts-layout .table-wrap { max-width: 100%; overflow-x: auto; }
.accounts-layout .accounts-table { width: 100%; min-width: 0; table-layout: auto; font-size: 13px; }
.accounts-layout .accounts-table th,
.accounts-layout .accounts-table td { padding: 7px 8px; }
.accounts-layout .accounts-table tr.group-section-row td { padding-top: 9px; padding-bottom: 9px; background: #f2f7f6; font-weight: 800; }
.accounts-layout .accounts-table td.account-name a { font-weight: 400; }
.accounts-layout .accounts-table .group-select { min-width: 110px; }
.accounts-layout .accounts-table .actions-cell { white-space: nowrap; }
.accounts-layout .accounts-table .button-small { padding-inline: 7px; font-size: 11px; white-space: nowrap; }
.accounts-layout .accounts-table th:nth-child(2),
.accounts-layout .accounts-table td:nth-child(2) { width: 104px; padding-inline: 5px; white-space: nowrap; }
.accounts-layout .accounts-table th:nth-child(3),
.accounts-layout .accounts-table td:nth-child(3) { width: 112px; padding-inline: 5px; }
.accounts-layout .accounts-table tr.group-subtotal-row th,
.accounts-layout .accounts-table tr.group-subtotal-row td { padding-top: 8px; padding-bottom: 8px; border-top: 1px solid var(--line); font-weight: 700; }
.accounts-layout .accounts-table tr.grand-total-row th,
.accounts-layout .accounts-table tr.grand-total-row td { font-weight: 800; }

.operations-table thead th { padding-top: 8px; padding-bottom: 8px; }
.operations-table td { padding: 8px 12px; }

tr.group-row th { background: #f2f7f6; color: var(--ink); padding-top: 12px; border-bottom: 1px solid var(--line); }
tr.subtotal-row th { color: var(--ink-soft); }
tr.subtotal-row td, tr.subtotal-row th { border-top: 1px solid var(--line); }
tr.total-row th, tr.total-row td { background: #f7faf9; border-top: 2px solid var(--line); font-weight: 800; }
tr.total-row td.amount { color: var(--ink); }

.accounts-overview table { font-size: 13px; }
.accounts-overview thead th { padding-top: 7px; padding-bottom: 7px; }
.accounts-overview td { padding: 6px 12px; }
.accounts-overview tr.group-row th { padding: 6px 12px; font-size: 12px; font-weight: 800; letter-spacing: .02em; text-transform: none; }
.accounts-overview td.account-name { padding-left: 28px; }
.accounts-overview td.account-name a { font-weight: 400; color: var(--ink); }

.accounts-group-rows tr.group-section-row th { font-weight: 700; }
.accounts-group-rows td.account-name a { font-weight: 400; }
.accounts-group-rows tr.group-subtotal-row th { font-weight: 700; }
.accounts-group-rows tr.grand-total-row th, .accounts-group-rows tr.grand-total-row td { font-weight: 800; }
.accounts-group-rows .actions-cell { white-space: nowrap; }
.accounts-group-rows table { min-width: 720px; }

.month-stats { display: grid; gap: 10px; }
.month-stat { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 13px; background: #f7faf9; border: 1px solid var(--line); border-radius: 9px; font-size: 13px; }
.month-stat strong { font-size: 15px; }
.positive { color: var(--accent-dark); }
.negative { color: var(--coral); }

.account-select-form { display: grid; gap: 12px; margin-top: 16px; }
.account-select-form fieldset { margin: 0; padding: 0; border: 0; display: grid; gap: 7px; }
.account-select-form legend { padding: 0; margin-bottom: 3px; color: var(--ink-soft); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.checkbox-line { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center; font-size: 13px; font-weight: 650; }
.checkbox-line input[type='checkbox'] { width: auto; min-height: 0; padding: 0; margin: 0; }

.title-tools { display: inline-flex; align-items: center; gap: 8px; }
.icon-button { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; padding: 0; color: var(--ink-soft); background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.icon-button:hover { color: var(--accent-dark); border-color: var(--accent); }
.modal-toggle { display: none; }
.modal-backdrop { display: none; position: fixed; inset: 0; z-index: 60; padding: 32px 16px; background: rgba(16, 36, 52, .45); align-items: center; justify-content: center; overflow-y: auto; }
#account-select-toggle:checked ~ .modal-backdrop { display: flex; }
.modal-card { width: min(100%, 440px); margin: auto; padding: 26px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.modal-card .stack-form { gap: 13px; }
.modal-card p { margin-bottom: 0; }
.modal-accounts { display: grid; gap: 8px; margin: 4px 0 0; }
.modal-accounts .checkbox-line { width: 100%; }

.group-select { width: auto; min-width: 130px; min-height: 32px; padding: 4px 8px; font-size: 12px; }
.input-inline { width: 160px; min-height: 32px; padding: 4px 8px; font-size: 12px; }
.group-edit { display: inline-flex; gap: 6px; align-items: center; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .inline-form, .row-actions > form { display: inline-flex; margin-left: 5px; }

@media (max-width: 980px) {
    .sidebar { width: 210px; }
    .main-content { padding: 34px 27px 55px; }
    .grid-main { grid-template-columns: 1fr; }
    .analysis-filter-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .forecast-layout > aside { float: none; width: auto; max-width: none; margin-left: 0; }
    .accounts-layout { grid-template-columns: 1fr; }
    .accounts-layout > aside { grid-column: 1; grid-row: 1; }
    .accounts-layout > .accounts-columns { grid-column: 1; grid-row: 2; }
}
@media (max-width: 720px) {
    .app-shell { display: block; }
    .sidebar { display: none; }
    .main-content { padding: 18px 15px 45px; }
    .mobile-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 30px; }
    .mobile-topbar .brand { color: var(--ink); font-size: 16px; }
    .mobile-topbar .brand-mark { color: #fff; }
    .icon-link { width: 35px; height: 35px; display: grid; place-items: center; color: var(--accent-dark); background: var(--accent-pale); border-radius: 50%; }
    .page-header { display: block; }
    .page-actions { justify-content: flex-start; margin-top: 18px; }
    .metric-grid, .grid-2, .grid-3, .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
    .analysis-filter-row { grid-template-columns: 1fr; }
    .metric-grid { gap: 10px; }
    .metric { min-height: auto; }
    .card-pad { padding: 16px; }
    .split-row { grid-template-columns: 1fr 1fr auto; }
    .split-row label:first-child { grid-column: 1 / -1; }
    .split-row label:nth-child(3) { grid-column: 1 / 3; }
    .auth-card { padding: 25px 20px; margin-top: 5vh; }
    .public-wrap { width: min(100% - 24px, 920px); padding-top: 24px; }
    th, td { padding-inline: 8px; }
