/* Personal Finance OS — design system (off-white, dark green accent) */
:root {
  --bg: #F7F6F2;
  --surface: #FFFFFF;
  --surface-2: #FBFAF7;
  --line: #E7E4DC;
  --line-strong: #D6D2C7;
  --text: #16181D;
  --text-2: #3F4550;
  --muted: #6B7280;
  --accent: #1F5135;
  --accent-600: #184129;
  --accent-50: #EAF2EC;
  --accent-100: #D5E6DA;
  --pos: #2F7A4F;
  --neg: #B42318;
  --warn: #B45309;
  --info: #1E40AF;
  --danger-50: #FDECEA;
  --warn-50: #FDF3E6;
  --info-50: #EBF0FC;
  --success-50: #E8F3EC;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 1px 1px rgba(17, 24, 39, .02);
  --shadow-lg: 0 12px 32px rgba(17, 24, 39, .12);
  --sidebar: 248px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
body.no-scroll { overflow: hidden; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 650; }
h2 { font-size: 1.05rem; font-weight: 620; }
h3 { font-size: .98rem; font-weight: 600; }
p { margin: .4rem 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .85em; background: #F1EFE9; padding: .1em .35em; border-radius: 6px; word-break: break-all; }
img, svg { vertical-align: middle; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 8px; }
.skip-link:focus { left: 12px; }
.icon { width: 18px; height: 18px; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.pos { color: var(--pos); }
.neg, .danger { color: var(--neg); }
.warning { color: var(--warn); }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pad { padding: 16px 20px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.inline { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

/* ------------------------------------------------------------------ layout */
.app { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 14px; gap: 14px; z-index: 30; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 650; padding: 4px 6px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; background: var(--accent); color: #fff; display: inline-grid; place-items: center; font-weight: 700; font-size: 1rem; flex-shrink: 0; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-add { margin: 4px 0; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--text-2); font-weight: 520; font-size: .93rem; background: none; border: 0; width: 100%; text-align: left; cursor: pointer; font-family: inherit; }
.nav-link:hover { background: #F2F0EA; color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-50); color: var(--accent); }
.nav-link.active .icon { color: var(--accent); }
.nav-badge { margin-left: auto; background: var(--neg); color: #fff; font-size: .72rem; font-weight: 650; padding: 1px 7px; border-radius: 999px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line); padding-top: 10px; }
.sidebar-foot form { margin: 0; }
.main-wrap { flex: 1; margin-left: var(--sidebar); min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.main { padding: 28px 32px 48px; max-width: 1320px; width: 100%; margin: 0 auto; outline: none; }
.main > * + * { margin-top: 18px; }

/* ------------------------------------------------------------------ page header, period bar, tabs */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-header p { margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-actions form { margin: 0; }
.crumb { font-size: .85rem; color: var(--muted); }
.period-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--text-2); font-size: .85rem; font-weight: 520; white-space: nowrap; }
.chip:hover { border-color: var(--line-strong); text-decoration: none; color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.custom-range { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.custom-range input { width: auto; padding: 6px 8px; font-size: .85rem; }
.period-label { margin: 4px 0 0 !important; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 10px 14px; color: var(--muted); font-weight: 560; font-size: .92rem; border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ------------------------------------------------------------------ cards & grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card-flush { padding: 0; overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-flush .card-header { margin-bottom: 0; border-bottom: 1px solid var(--line); }
.card-title { font-size: 1rem; font-weight: 620; }
.card-header form { margin: 0; }
.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-wide-left { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.span-2 { grid-column: span 2; }
.grid > .card, .grid > section { margin: 0; }

/* ------------------------------------------------------------------ KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.kpi-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: inherit; box-shadow: var(--shadow); min-width: 0; }
a.kpi:hover { border-color: var(--accent-100); text-decoration: none; box-shadow: 0 4px 14px rgba(31, 81, 53, .08); }
.kpi-label { font-size: .8rem; color: var(--muted); font-weight: 540; }
.kpi-value { font-size: 1.32rem; font-weight: 660; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-sub { font-size: .78rem; color: var(--muted); }
.kpi-pos .kpi-value { color: var(--pos); }
.kpi-neg .kpi-value { color: var(--neg); }
.hint { color: var(--muted); cursor: help; font-size: .8rem; }
.card .kpi-grid .kpi { box-shadow: none; background: var(--surface-2); }

/* ------------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; font-weight: 560; cursor: pointer; line-height: 1.2; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { text-decoration: none; background: #F4F2EC; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-600); border-color: var(--accent-600); }
.btn-danger { background: var(--neg); border-color: var(--neg); color: #fff; }
.btn-danger:hover { background: #912018; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: #F0EEE7; }
.btn-ghost.danger { color: var(--neg); }
.btn-sm { padding: 6px 10px; font-size: .82rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn .icon { width: 16px; height: 16px; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: var(--text-2); }
.icon-btn:hover { background: #F0EEE7; }
.dot { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--neg); color: #fff; font-size: .68rem; font-weight: 700; display: grid; place-items: center; }

/* ------------------------------------------------------------------ alerts & flash */
.flash-stack { position: fixed; top: 16px; right: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(440px, calc(100vw - 32px)); }
.flash { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); font-size: .9rem; transition: opacity .35s, transform .35s; }
.flash > span { flex: 1; }
.flash form { margin: 0; }
.flash-success { border-left: 4px solid var(--pos); }
.flash-error { border-left: 4px solid var(--neg); }
.flash-info { border-left: 4px solid var(--info); }
.flash-hide { opacity: 0; transform: translateY(-6px); }
.flash-close { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; }
.flash-close:hover { background: #F0EEE7; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: .9rem; border: 1px solid transparent; }
.alert .icon { margin-top: 1px; }
.alert-error, .alert-danger { background: var(--danger-50); border-color: #F5C2BC; color: #7A1A12; }
.alert-info { background: var(--info-50); border-color: #CBD7F5; color: #1E3A8A; }
.alert-success { background: var(--success-50); border-color: #BFDCC9; color: #1D4D31; }
.alert-warning { background: var(--warn-50); border-color: #F3D3A8; color: #7C3A06; }
.alert-link { font-weight: 600; color: inherit; text-decoration: underline; }

/* ------------------------------------------------------------------ badges & progress */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: .74rem; font-weight: 600; white-space: nowrap; background: #F0EEE7; color: var(--text-2); vertical-align: middle; }
.badge-success { background: var(--success-50); color: var(--pos); }
.badge-danger { background: var(--danger-50); color: var(--neg); }
.badge-warning { background: var(--warn-50); color: var(--warn); }
.badge-info { background: var(--info-50); color: var(--info); }
.badge-muted { background: #F0EEE7; color: var(--muted); }
.progress { height: 8px; background: #EEEBE4; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--pos); transition: width .4s; }
.progress-warning > span { background: var(--warn); }
.progress-danger > span { background: var(--neg); }
.progress-cell { min-width: 120px; }
.progress-cell .progress { margin-bottom: 2px; }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid #F0EDE6; vertical-align: middle; }
.table tbody tr:hover { background: #FBFAF6; }
.table tfoot th { background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 0; color: var(--text); text-transform: none; font-size: .88rem; letter-spacing: 0; }
.table th.right, .table td.right { text-align: right; }
.table .actions { display: flex; gap: 2px; justify-content: flex-end; align-items: center; flex-wrap: nowrap; }
.actions form { margin: 0; display: inline; }
.row-muted { opacity: .6; }
.cell-title { font-weight: 560; color: var(--text); }
.cat-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: middle; flex-shrink: 0; }
.pagination { display: flex; gap: 4px; justify-content: center; align-items: center; padding: 14px; flex-wrap: wrap; }
.pagination .page { min-width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); color: var(--text-2); font-size: .88rem; padding: 0 8px; }
.pagination .page:hover { text-decoration: none; background: #F4F2EC; }
.pagination .current { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ------------------------------------------------------------------ filters & totals */
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.filters > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
.filters > summary::-webkit-details-marker { display: none; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-top: 12px; }
.filter-actions { display: flex; gap: 8px; align-items: flex-end; }
.totals-bar { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-size: .88rem; }
.totals-bar strong { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ forms */
label, .label { display: block; font-size: .84rem; font-weight: 580; color: var(--text-2); margin-bottom: 5px; }
.field label > input, .field label > select, .field label > textarea { margin-top: 5px; font-weight: 400; }
input, select, textarea { width: 100%; font: inherit; font-size: .93rem; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 11px; transition: border-color .15s, box-shadow .15s; min-height: 40px; }
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31, 81, 53, .14); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--accent); }
input[type="color"] { padding: 3px; height: 40px; cursor: pointer; }
input[type="file"] { padding: 7px; }
input:disabled, select:disabled { background: #F4F2EC; color: var(--muted); }
.invalid, input.invalid, select.invalid { border-color: var(--neg) !important; }
.field { min-width: 0; }
.field.is-disabled { opacity: .6; }
.field-sm { max-width: 120px; }
.help { font-size: .8rem; color: var(--muted); margin: 5px 0 0; }
.error { font-size: .8rem; color: var(--neg); margin: 5px 0 0; font-weight: 520; }
.form-card { max-width: 860px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.compact { gap: 10px 12px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.form-card .form-actions { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin: 10px 0 0; }
.inline-form .field { flex: 1 1 140px; }
.inline-form .field-sm { flex: 0 0 110px; }
.add-row { padding-top: 12px; border-top: 1px dashed var(--line); margin-top: 12px; }
.switch { display: inline-flex; align-items: flex-start; gap: 9px; font-weight: 500; color: var(--text); cursor: pointer; margin: 2px 0; font-size: .9rem; }
.switch input { margin-top: 3px; width: 17px; height: 17px; flex-shrink: 0; }
.input-amount { font-size: 1.25rem; font-weight: 620; font-variant-numeric: tabular-nums; }
.segmented { display: flex; flex-wrap: wrap; gap: 6px; border: 0; padding: 0; margin: 0 0 6px; }
.seg { position: relative; margin: 0; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: inline-block; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font-size: .87rem; font-weight: 560; color: var(--text-2); transition: all .15s; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg input:checked + span { color: #fff; border-color: transparent; }
.seg-income input:checked + span { background: var(--pos); }
.seg-expense input:checked + span { background: var(--neg); }
.seg-invest input:checked + span, .seg-divest input:checked + span { background: var(--info); }
.seg-transfer input:checked + span { background: #475569; }
.type-help { min-height: 1.2em; margin-bottom: 14px; }
.recurring-box { border: 1px dashed var(--line-strong); border-radius: 12px; padding: 14px 16px; margin: 18px 0 0; background: var(--surface-2); }
.recurring-box .form-grid { margin-top: 14px; }
.danger-zone { border: 1px solid #F5C2BC; border-radius: 12px; padding: 14px 16px; background: #FFFBFA; }
.danger-zone > summary { cursor: pointer; color: var(--neg); font-weight: 600; }
.copy-row { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.copy-row code { flex: 1; background: none; padding: 0; font-size: .82rem; }

/* ------------------------------------------------------------------ charts */
.chart-box { position: relative; width: 100%; }
.chart-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 180px; color: var(--muted); font-size: .88rem; text-align: center; background: var(--surface-2); border: 1px dashed var(--line); border-radius: 12px; padding: 20px; }
.chart-empty .icon { width: 26px; height: 26px; opacity: .6; }

/* ------------------------------------------------------------------ insights & guidance */
.insights { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.insight { display: flex; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.insight p { margin: 2px 0 0; font-size: .88rem; color: var(--text-2); }
.insight strong { font-size: .92rem; }
.insight-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; background: var(--info-50); color: var(--info); }
.insight-success .insight-icon { background: var(--success-50); color: var(--pos); }
.insight-warning .insight-icon { background: var(--warn-50); color: var(--warn); }
.insight-danger .insight-icon { background: var(--danger-50); color: var(--neg); }
.insight-danger { border-color: #F5D0CB; }
.insight-action { font-weight: 560; color: var(--accent) !important; }
.guide { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.card > .guide:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.guide summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.guide ul, .guide ol, .defs, .steps-list { padding-left: 1.2rem; margin: 8px 0; font-size: .9rem; color: var(--text-2); }
.guide li, .defs li, .steps-list li { margin: 4px 0; }
.onboarding { border-color: var(--accent-100); background: linear-gradient(180deg, var(--accent-50), var(--surface)); }
.steps { display: grid; gap: 10px; counter-reset: step; padding: 0; list-style: none; }
.steps li { counter-increment: step; display: flex; gap: 10px; align-items: flex-start; }
.steps li::before { content: counter(step); width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-size: .78rem; font-weight: 700; display: grid; place-items: center; flex-shrink: 0; }

/* ------------------------------------------------------------------ payments & lists */
.list-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 0 8px; font-weight: 650; }
.list-title.danger { color: var(--neg); }
.list-title.warning { color: var(--warn); }
.pay-list, .occ-list, .simple-list { list-style: none; margin: 0; padding: 0; }
.pay-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #F0EDE6; }
.pay-row:last-child { border-bottom: 0; }
.pay-main { min-width: 0; }
.pay-name { font-weight: 560; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pay-side { text-align: right; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.pay-side form { margin: 0; }
.occ { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid #F0EDE6; flex-wrap: wrap; scroll-margin-top: 80px; }
.occ:last-child { border-bottom: 0; }
.occ:target { background: #FFFBEA; }
.occ-body { flex: 1 1 260px; min-width: 0; }
.occ-secondary { font-size: .82rem; color: var(--muted); }
.occ .actions { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.occ .actions form { margin: 0; }
.mini { margin-top: 8px; }
.mini > summary { cursor: pointer; font-size: .84rem; color: var(--accent); font-weight: 560; }
.mini[open] > summary { margin-bottom: 8px; }
.simple-list li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid #F0EDE6; font-size: .88rem; }
.simple-list li:last-child { border-bottom: 0; }
.simple-list form { display: inline; margin: 0; }
.kv { display: grid; gap: 8px; margin: 0 0 12px; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; font-size: .9rem; border-bottom: 1px solid #F0EDE6; padding-bottom: 6px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 560; text-align: right; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ budgets & goals */
.budget-row { padding: 9px 0; }
.budget-row + .budget-row { border-top: 1px solid #F0EDE6; }
.budget-head { display: flex; justify-content: space-between; gap: 10px; font-size: .88rem; margin-bottom: 6px; }
.budget-head span:last-child { font-variant-numeric: tabular-nums; color: var(--text-2); }
.budget-total { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.budget-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.goal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.goal { display: flex; flex-direction: column; gap: 10px; }
.goal-muted { opacity: .72; }
.goal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.goal-head h3 { margin-top: 6px; font-size: 1.05rem; }
.goal-pct { font-size: 1.4rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.goal-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.goal-stats div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.goal-stats dt { font-size: .74rem; color: var(--muted); }
.goal-stats dd { margin: 0; font-weight: 620; font-variant-numeric: tabular-nums; font-size: .92rem; }
.goal-actions { display: flex; gap: 4px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 8px; margin-top: auto; }
.goal-actions form { margin: 0; }
.emergency-out { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.emergency-out > div { background: var(--accent-50); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.emergency-out strong { font-size: 1.15rem; color: var(--accent); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ settings */
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-item { padding: 9px 0; border-bottom: 1px solid #F0EDE6; }
.cat-item:last-child { border-bottom: 0; }
.cat-child { padding-left: 26px; }
.cat-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cat-name { font-weight: 560; }
.cat-child .cat-name { font-weight: 480; }
.cat-line .actions { margin-left: auto; display: flex; gap: 2px; }
.cat-line .actions form { margin: 0; }
.inline-details { display: inline-block; position: relative; }
.inline-details > summary { list-style: none; }
.inline-details > summary::-webkit-details-marker { display: none; }
.popover { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 260px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 12px; }

/* ------------------------------------------------------------------ notifications */
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif { display: flex; gap: 12px; align-items: flex-start; padding: 14px 18px; border-bottom: 1px solid #F0EDE6; }
.notif:last-child { border-bottom: 0; }
.notif-body { flex: 1; min-width: 0; }
.notif-body p { margin: 2px 0; font-size: .88rem; color: var(--text-2); }
.notif .actions { display: flex; gap: 4px; }
.notif .actions form { margin: 0; }
.notif-danger .insight-icon { background: var(--danger-50); color: var(--neg); }
.notif-warning .insight-icon { background: var(--warn-50); color: var(--warn); }
.notif-success .insight-icon { background: var(--success-50); color: var(--pos); }
.is-read { opacity: .62; }
.is-read strong { font-weight: 520; }

/* ------------------------------------------------------------------ empty states */
.empty { text-align: center; padding: 36px 20px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty-icon { width: 52px; height: 52px; border-radius: 16px; background: var(--accent-50); color: var(--accent); display: grid; place-items: center; margin-bottom: 4px; }
.empty-icon .icon { width: 26px; height: 26px; }
.empty .btn { margin-top: 8px; }

/* ------------------------------------------------------------------ auth & installer */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 500px at 50% -10%, var(--accent-50), var(--bg)); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 28px; box-shadow: var(--shadow-lg); }
.auth-card h1 { font-size: 1.4rem; margin: 14px 0 4px; }
.auth-card .stack { margin-top: 18px; }
.auth-card .alert { margin-top: 12px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 650; padding: 0; }
.install-card { max-width: 640px; }
.install-steps { list-style: none; display: flex; gap: 6px; padding: 0; margin: 20px 0 6px; flex-wrap: wrap; }
.install-steps li { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); padding: 4px 10px 4px 4px; border-radius: 999px; background: #F2F0EA; }
.install-steps li span { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: #E2DED3; font-weight: 700; font-size: .72rem; }
.install-steps li.current { background: var(--accent-50); color: var(--accent); font-weight: 600; }
.install-steps li.current span { background: var(--accent); color: #fff; }
.install-steps li.done span { background: var(--pos); color: #fff; }
.req-list { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 8px; }
.req-list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: .9rem; }
.req-mark { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex-shrink: 0; }
.req-list .ok .req-mark { background: var(--success-50); color: var(--pos); }
.req-list .fail { border-color: #F5C2BC; background: #FFFBFA; }
.req-list .fail .req-mark { background: var(--danger-50); color: var(--neg); }
.req-list .warn .req-mark { background: var(--warn-50); color: var(--warn); }
.install-option { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin: 14px 0; }
.install-option h2 { font-size: 1rem; margin-bottom: 4px; }

/* ------------------------------------------------------------------ mobile navigation */
.bottom-nav, .sheet { display: none; }

@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-wide-left { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  body { font-size: 15px; }
  .sidebar { display: none; }
  .main-wrap { margin-left: 0; }
  .topbar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 25; background: rgba(247, 246, 242, .92); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top)); }
  .main { padding: 18px 14px calc(96px + env(safe-area-inset-bottom)); }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 13px; }
  .kpi-value { font-size: 1.12rem; }
  h1 { font-size: 1.35rem; }
  .flash-stack { top: auto; bottom: calc(84px + env(safe-area-inset-bottom)); right: 12px; left: 12px; max-width: none; }

  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: rgba(255, 255, 255, .96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav > a, .bottom-nav > button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .68rem; font-weight: 560; color: var(--muted); padding: 6px 2px; background: none; border: 0; font-family: inherit; cursor: pointer; }
  .bottom-nav > a:hover { text-decoration: none; }
  .bottom-nav .active { color: var(--accent); }
  .bottom-nav .icon { width: 22px; height: 22px; }
  .bottom-nav .dot { top: 0; right: calc(50% - 22px); }
  .bottom-nav .fab { width: 52px; height: 52px; border-radius: 18px; background: var(--accent); color: #fff; justify-self: center; display: grid; place-items: center; margin-top: -18px; box-shadow: 0 8px 20px rgba(31, 81, 53, .35); padding: 0; }
  .bottom-nav .fab .icon { width: 26px; height: 26px; }
  .sheet:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 50; }
  .sheet-backdrop { position: absolute; inset: 0; background: rgba(17, 24, 39, .35); }
  .sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; background: var(--surface); border-radius: 20px 20px 0 0; padding: 10px 12px calc(16px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg); animation: sheet-up .2s ease-out; }
  .sheet-panel::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 4px auto 10px; }
  .sheet-panel form { margin: 0; }
  .sheet-link { display: flex; align-items: center; gap: 12px; padding: 13px 12px; border-radius: 12px; color: var(--text); font-weight: 540; font-size: .98rem; width: 100%; background: none; border: 0; font-family: inherit; cursor: pointer; text-align: left; }
  .sheet-link:hover, .sheet-link.active { background: var(--accent-50); color: var(--accent); text-decoration: none; }

  .table-responsive thead { display: none; }
  .table-responsive, .table-responsive tbody, .table-responsive tr, .table-responsive td { display: block; width: 100%; }
  .table-responsive tfoot { display: block; }
  .table-responsive tfoot tr { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding: 10px 14px; }
  .table-responsive tfoot th { padding: 0; border: 0; background: none; }
  .table-responsive tr { padding: 10px 14px; border-bottom: 1px solid #F0EDE6; }
  .table-responsive td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0; text-align: right; }
  .table-responsive td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; flex-shrink: 0; }
  .table-responsive td:not([data-label])::before { content: none; }
  .table-responsive td.actions { justify-content: flex-end; padding-top: 8px; }
  .table-responsive td.right { text-align: right; }

  .form-grid, .budget-form { grid-template-columns: minmax(0, 1fr); }
  .field-sm { max-width: none; }
  .period-bar { flex-direction: column; align-items: stretch; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .chips::-webkit-scrollbar { display: none; }
  .custom-range input { flex: 1; }
  .page-header { align-items: flex-start; }
  .goal-grid { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 16px; }
  .popover { position: fixed; left: 12px; right: 12px; top: auto; bottom: calc(90px + env(safe-area-inset-bottom)); width: auto; }
  input, select, textarea { font-size: 16px; }
}

@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ------------------------------------------------------------------ print */
.print-view .sidebar, .print-view .topbar, .print-view .bottom-nav, .print-view .sheet, .print-view .flash-stack, .print-view .no-print { display: none !important; }
.print-view .main-wrap { margin-left: 0; }
.print-view .main { max-width: 1000px; }

@media print {
  @page { margin: 14mm; }
  body { background: #fff; font-size: 11pt; color: #000; }
  .sidebar, .topbar, .bottom-nav, .sheet, .flash-stack, .no-print, .page-actions, .period-bar form, .btn, .mini, .skip-link { display: none !important; }
  .main-wrap { margin-left: 0 !important; }
  .main { padding: 0 !important; max-width: none; }
  .card, .kpi { box-shadow: none !important; break-inside: avoid; border-color: #ccc; }
  .grid-2, .grid-3 { grid-template-columns: 1fr 1fr; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .chart-box { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
  .table th { background: #f3f3f3 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .table-responsive { display: table !important; }
  .table-responsive thead { display: table-header-group !important; }
  .table-responsive tbody { display: table-row-group !important; }
  .table-responsive tfoot { display: table-footer-group !important; }
  .table-responsive tr { display: table-row !important; }
  .table-responsive td, .table-responsive th { display: table-cell !important; padding: 6px 8px !important; text-align: left; }
  .table-responsive td.right, .table-responsive th.right { text-align: right; }
  .table-responsive td::before { content: none !important; }
  details { display: block; }
  details > summary { list-style: none; }
}
