:root {
    color-scheme: light;
    --ink: #1b2538;
    --muted: #57657e;
    --canvas: #f4f6fb;
    --panel: #fff;
    --line: #e1e7f2;
    --brand: #4349bb;
    --brand-dark: #3439a1;
    --nav: #15213a;
    --green: #13795d;
    --red: #a63c4c;
    --amber: #87510c;
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 16px;
    color: var(--ink);
    background: var(--canvas);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
button, select, input, textarea { font: inherit; }
button, summary { cursor: pointer; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible { outline: 2px solid #6870f0; outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.8rem, 3vw, 2.45rem); line-height: 1.1; letter-spacing: -.035em; }
h2 { font-size: 1.12rem; line-height: 1.32; letter-spacing: -.015em; }
small { font-size: .82rem; }
[hidden] { display: none !important; }
.sr-only, .skip:not(:focus) { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; }
.skip:focus { position: fixed; z-index: 10; padding: 10px 16px; background: white; }

.sidebar { position: fixed; inset: 0 auto 0 0; width: 232px; display: flex; flex-direction: column; padding: 26px 17px 17px; background: var(--nav); color: #fff; overflow-y: auto; }
.brand { display: flex; gap: 12px; align-items: center; margin: 0 8px 34px; color: #fff; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-icon { width: 40px; height: 40px; border-radius: 11px; display: inline-grid; place-items: center; background: #5258d6; color: white; font-size: 24px; font-weight: 700; flex: 0 0 auto; }
.brand strong { display: block; font-size: 1.08rem; letter-spacing: .07em; }
.brand small, .sidebar-footer small { color: #adbad4; display: block; }
.nav { display: grid; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 11px 9px 11px 12px; border-radius: 8px; color: #c1cde2; font-size: .89rem; font-weight: 600; }
.nav a span { display: inline-block; color: #b4bffa; width: 18px; font-size: 1.06rem; text-align: center; }
.nav a:hover, .nav a[aria-current] { color: white; background: #2b3a64; text-decoration: none; }
.nav a[aria-current] { box-shadow: inset 3px 0 #a1a5ff; }
.sidebar-footer { display: flex; align-items: center; gap: 9px; margin-top: auto; padding-top: 19px; }
.avatar { display: grid; flex: 0 0 auto; place-items: center; width: 31px; height: 31px; border-radius: 50%; color: #e0e2ff; background: #334267; font-weight: 700; }
.profile { min-width: 0; flex: 1; font-size: .88rem; overflow-wrap: anywhere; }
.sidebar-footer button { background: none; border: 0; color: #c1cde2; border-radius: 6px; padding: 5px; }

.main { margin-left: 232px; max-width: 1710px; padding: 34px clamp(20px, 3.2vw, 48px) 48px; }
.heading { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 18px; margin-bottom: 25px; }
.heading p, .panel-header p { color: var(--muted); margin-top: 6px; }
.panel-header p { font-size: .88rem; }
.actions, .inline-form, .row-actions, .form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-form { gap: 7px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 39px; padding: 8px 13px; border: 1px solid #d3dbea; color: #293653; background: white; border-radius: 8px; font-size: .89rem; font-weight: 650; text-decoration: none; text-align: center; white-space: nowrap; }
.button:hover { background: #eef1fe; text-decoration: none; }
.button.primary { background: var(--brand); border-color: var(--brand); color: white; }
.button.primary:hover { background: var(--brand-dark); }
.button.destructive { background: #aa3447; border-color: #aa3447; color: #fff; }
.button.destructive:hover { background: #8d293a; }
.button.compact { min-height: 33px; padding: 5px 9px; font-size: .83rem; }
.back { display: inline-block; font-size: .87rem; margin-bottom: 8px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 20px; }
.metric { display: flex; flex-direction: column; gap: 10px; padding: 16px 17px 17px; background: var(--panel); border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 2px 6px #1b253807; }
.metric-top { display: flex; justify-content: space-between; gap: 5px; align-items: center; color: var(--muted); min-height: 32px; font-size: .875rem; font-weight: 650; }
.metric-icon { flex: 0 0 auto; display: grid; place-items: center; width: 29px; height: 29px; border-radius: 8px; font-size: 1rem; }
.metric strong { font-size: clamp(1.28rem, 2vw, 2rem); line-height: 1.13; letter-spacing: -.03em; overflow-wrap: anywhere; }
.metric small { color: var(--muted); margin-top: auto; }
.featured { border-color: #4247b5; color: #fff; background: linear-gradient(135deg, #3c42b4, #494dc8 72%, #5152c9); }
.featured small, .featured .metric-top { color: #f0efff; }
.featured .metric-icon { background: #ffffff29; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.52fr) minmax(0, 1fr); gap: 17px; margin-bottom: 18px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 13px; min-width: 0; box-shadow: 0 2px 6px #1b253806; }
.panel-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 11px; padding: 17px 19px; }
.panel-header > a:not(.button) { font-size: .86rem; font-weight: 650; }
.chart { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 8px 22px 19px; }
.chart-column { min-width: 0; text-align: center; color: var(--muted); font-size: .82rem; }
.bars { height: 143px; display: flex; align-items: flex-end; justify-content: center; gap: 4px; background: repeating-linear-gradient(to top, var(--line) 0 1px, transparent 1px 35px); border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.bar { width: min(17px, 33%); height: max(2px, var(--height)); border-radius: 4px 4px 0 0; }
.bar.in, .legend span:first-child i { background: #444bc3; }
.bar.out, .legend span:last-child i { background: #aab5dd; }
.legend { display: flex; flex-wrap: wrap; gap: 11px; font-size: .81rem; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 4px; }
.summary-list { margin: 0 19px 12px; }
.summary-list div { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.summary-list dt { color: var(--muted); font-size: .9rem; }
.summary-list dd, .tax-detail dd { margin: 0; font-weight: 700; }
.reserve { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-radius: 8px; margin: 0 18px 17px; padding: 10px; background: #eef0ff; font-size: .86rem; font-weight: 650; }
.reserve small { display: block; color: var(--muted); margin-top: 3px; font-weight: 400; }
.activity { display: flex; gap: 10px; align-items: center; border-top: 1px solid var(--line); padding: 11px 19px; }
.activity > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.activity small, td small, .file-row small { display: block; color: var(--muted); margin-top: 3px; }
.activity strong { white-space: nowrap; font-size: .93rem; }
.activity-icon { flex: 0 0 auto; border-radius: 8px; display: grid; place-items: center; width: 31px; height: 31px; font-weight: 650; }
.green, .income { color: var(--green); background: #e6f6ef; }
.red, .expense { color: var(--red); background: #fcedee; }
.amber, .tax { color: var(--amber); background: #fff2d9; }
.blue { color: var(--brand-dark); background: #eef0ff; }
.positive { color: var(--green); }
.negative, .danger-link { color: var(--red); }
.empty { padding: 24px 19px; color: var(--muted); font-size: .91rem; }

.filters { display: flex; gap: 11px; flex-wrap: wrap; align-items: flex-end; padding: 17px 19px; }
.filters label { display: grid; gap: 5px; color: var(--muted); font-size: .83rem; font-weight: 650; }
.filters label:has(input[type='search']) { flex: 1; min-width: 170px; }
.subtle-link { padding: 8px 0; font-size: .88rem; }
input:not([type='checkbox']), select, textarea { width: 100%; min-height: 39px; border: 1px solid #cdd7e8; border-radius: 7px; padding: 7px 9px; color: var(--ink); background: white; }
input[type='file'] { font-size: .86rem; }
input[type='file']::file-selector-button { border: 0; background: #e9ecfb; color: #303686; border-radius: 4px; padding: 4px 8px; margin-right: 8px; cursor: pointer; }
.inline-form input, .inline-form select { width: auto; }
textarea { resize: vertical; }
.totals-strip { display: flex; flex-wrap: wrap; gap: 10px 22px; padding: 12px 19px; border-top: 1px solid var(--line); background: #f9faff; font-size: .88rem; }
.totals-strip strong { margin-left: 5px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 12px 15px; border-top: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .81rem; font-weight: 650; color: var(--muted); background: #f6f8fd; white-space: nowrap; }
th:first-child, td:first-child { padding-left: 19px; }
th:last-child, td:last-child { padding-right: 19px; }
tbody tr:hover { background: #fafbff; }
.record-link { color: #242f50; font-weight: 650; }
.numeric { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.badge { display: inline-block; font-size: .8rem; line-height: 1.3; font-weight: 650; padding: 4px 7px; background-color: var(--badge-bg, #eef2fa); border-radius: 6px; white-space: nowrap; }
.badge.green, .badge.income { --badge-bg: #e6f6ef; }
.badge.red, .badge.expense { --badge-bg: #fcedee; }
.badge.amber, .badge.tax { --badge-bg: #fff2d9; }
.badge.blue { --badge-bg: #eef0ff; }
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 11px; padding: 12px 19px; border-top: 1px solid var(--line); font-size: .9rem; }

.notice { padding: 11px 14px; margin-bottom: 15px; border: 1px solid #b6e4d0; border-radius: 8px; color: #146a50; background: #e9f8f0; }
.notice.error { border-color: #f0c5ca; color: var(--red); background: #fff2f3; }
.record-layout { display: flex; flex-wrap: wrap; gap: 17px; align-items: flex-start; }
.record-form { flex: 1 1 490px; max-width: 780px; padding: 21px; }
.files-panel { flex: 1 1 260px; max-width: 430px; }
.record-totals { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: .9rem; font-weight: 650; }
.field label span { color: var(--brand-dark); }
.field .checkbox-label { display: inline-flex; align-items: center; gap: 7px; width: fit-content; }
.field .checkbox-label input { align-self: center; }
.legacy-income ul { margin: 6px 0 0; padding-left: 21px; }
.field input[type='checkbox'] { align-self: flex-start; }
.field small, .form-note { color: var(--muted); }
.form-note, .form-actions { margin-top: 17px; }
.errorlist { padding-left: 19px; margin: 0; color: var(--red); font-size: .88rem; }
.record-form > .errorlist { margin-bottom: 14px; }
.file-row { padding: 12px 19px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.confirmation { max-width: 560px; }
.tax-panel { margin-bottom: 18px; }
.tax-detail { display: flex; flex-wrap: wrap; gap: 15px 33px; margin: 0; padding: 0 19px 17px; }
.tax-detail dt { color: var(--muted); font-size: .86rem; }
.tax-detail dd { margin-top: 3px; }
.tax-month { border-top: 1px solid var(--line); }
.tax-month summary { padding: 12px 19px; font-weight: 650; }
.tax-month summary span { margin-left: 8px; color: var(--muted); font-size: .84rem; font-weight: 400; }
.month-actions { padding: 0 19px 10px; display: flex; justify-content: flex-end; }

.login-page { min-height: 100vh; display: grid; place-items: center; background: #15213a; }
.login-main { width: min(100% - 32px, 415px); }
.login-card { border-radius: 16px; padding: 28px; background: white; box-shadow: 0 15px 35px #09102355; }
.login-brand { display: flex; gap: 10px; align-items: center; font-weight: 700; margin-bottom: 18px; }
.login-card h1 { font-size: 1.7rem; margin-bottom: 18px; }
.login-card form { display: grid; gap: 13px; }

@media (max-width: 1180px) {
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 930px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .sidebar { position: static; width: auto; padding: 11px 12px; overflow-y: visible; }
    .brand { margin: 0 0 9px; }
    .brand small, .avatar, .sidebar-footer small { display: none; }
    .brand-icon { width: 33px; height: 33px; font-size: 20px; }
    .nav { display: flex; flex-wrap: wrap; }
    .nav a { padding: 6px 7px; font-size: .82rem; gap: 4px; }
    .sidebar-footer { position: absolute; top: 12px; right: 12px; padding: 0; max-width: 42%; }
    .main { margin-left: 0; padding: 23px 12px 36px; }
    .metric { padding: 12px; }
    .heading { gap: 12px; }
    .form-grid { grid-template-columns: 1fr; }
}
