:root {
  color-scheme: light;
  --surface: #fff;
  --bg: #f3f6f3;
  --ink: #172820;
  --muted: #586961;
  --line: #e2e9e3;
  --green: #1c6748;
  --green-dark: #154735;
  --mint: #e6f2e8;
  --coral: #a94e3e;
  --pink: #faede8;
  --radius: 20px;
  --shadow: 0 3px 9px #1b362b06;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); }
button, input, select, textarea { color: inherit; font: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
button:disabled { opacity: .4; cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid #238a60; outline-offset: 3px; }
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.skip:focus { position: fixed; z-index: 10; top: 8px; left: 8px; background: white; padding: 10px; border-radius: 10px; }
.shell { min-height: 100dvh; display: grid; grid-template-columns: 225px minmax(0,1fr); }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; background: #fcfdfb; padding: 27px 16px 20px; border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; margin: 0 0 34px 7px; width: max-content; }
.brand img { border-radius: 13px; flex: none; }
.brand strong { display: block; font-weight: 780; letter-spacing: -.05em; font-size: 22px; line-height: 1.03; }
.brand small { display: block; font-weight: 750; color: var(--muted); font-size: 9px; letter-spacing: .16em; margin-top: 4px; }
.brand-dot { color: #2d8b5e; }
#nav { display: grid; gap: 5px; }
#nav a { display: flex; align-items: center; gap: 11px; border-radius: 11px; padding: 13px 11px; color: var(--muted); font-size: 14px; font-weight: 650; min-height: 46px; }
#nav a:hover { background: #f1f5ef; }
#nav a[aria-current] { background: var(--mint); color: #145438; }
.sidebar-note { margin-top: auto; display: flex; gap: 9px; align-items: flex-start; padding: 13px 8px; color: var(--green); border-top: 1px solid var(--line); }
.sidebar-note svg { flex: none; }
.sidebar-note b, .sidebar-note small { display: block; }
.sidebar-note b { color: var(--ink); font-size: 12px; }
.sidebar-note small { color: var(--muted); font-size: 11px; margin-top: 5px; }
.workspace { min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; min-height: 75px; padding: 12px clamp(22px, 4vw, 58px); background: #fcfdfb; border-bottom: 1px solid var(--line); }
.breadcrumbs { color: var(--muted); font-size: 13px; }
.breadcrumbs span { margin: 0 8px; color: #7b8b81; }
.breadcrumbs strong { color: var(--ink); }
.mobile-brand { display: none; }
main { max-width: 1450px; padding: 35px clamp(22px, 4vw, 58px) 45px; margin: auto; outline: none; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 15px; margin-bottom: 24px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(29px, 3.35vw, 45px); font-weight: 760; line-height: 1.06; letter-spacing: -.052em; }
.page-heading p { margin-top: 9px; color: var(--muted); font-size: 14px; line-height: 1.48; }
.month-control { display: flex; align-items: center; background: white; border: 1px solid var(--line); border-radius: 12px; flex: none; min-height: 44px; }
.icon-button { display: inline-grid; place-items: center; width: 44px; height: 44px; background: transparent; border: 0; border-radius: 11px; flex: none; }
.icon-button:hover { background: #e8f1e9; }
.month-label { display: flex; align-items: center; justify-content: center; gap: 8px; background: none; border: 0; padding: 0 7px; font-size: 13px; font-weight: 670; min-height: 44px; white-space: nowrap; }
.month-label span::first-letter { text-transform: uppercase; }
.month-label svg { color: var(--green); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border: 1px solid transparent; border-radius: 11px; min-height: 44px; font-size: 13px; font-weight: 710; line-height: 1.2; text-align: center; }
.button svg { flex: none; }
.primary { color: white; background: var(--green-dark); }
.primary:hover { background: #0d3c2b; }
.secondary { color: var(--green-dark); background: #f4f8f3; border-color: #dbe8db; }
.secondary:hover { background: var(--mint); }
.top-add > span:first-child { display: grid; place-items: center; }
.overview { display: grid; grid-template-columns: minmax(0,1.5fr) repeat(2,minmax(0,1fr)); gap: 13px; margin-bottom: 15px; }
.balance, .metric { min-width: 0; position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; min-height: 151px; padding: 17px 19px; border: 1px solid var(--line); border-radius: var(--radius); }
.balance { isolation: isolate; overflow: hidden; color: #fff; background: radial-gradient(ellipse at 103% 70%, #2c6445, transparent 62%), #163c2e; border-color: transparent; padding-inline: 21px; }
.balance::after { content: ""; position: absolute; z-index: -1; width: 185px; height: 185px; right: -56px; bottom: -115px; border-radius: 50%; box-shadow: 0 0 0 18px #d2f1c216, 0 0 0 39px #d2f1c212, 0 0 0 64px #d2f1c212, 0 0 0 90px #d2f1c211; pointer-events: none; }
.balance-top, .metric-title { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 650; min-width: 0; }
.balance-top { width: 100%; min-height: 36px; }
.balance-icon, .metric-icon, .section-icon { display: inline-grid; place-items: center; flex: none; }
.balance-icon, .metric-icon { width: 36px; height: 36px; border-radius: 11px; }
.balance-icon { color: #c6ecb5; background: #ffffff17; }
.balance-toggle { width: 44px; height: 40px; margin: -4px -7px -4px auto; color: #e5f1e6; }
.balance-toggle:hover { background: #ffffff20; }
.balance-value, .metric > strong { max-width: 100%; margin-top: 10px; letter-spacing: -.055em; font-variant-numeric: tabular-nums; font-size: clamp(23px, 3vw, 38px); line-height: 1.1; font-weight: 760; overflow-wrap: anywhere; }
.balance-value { font-size: clamp(28px, 3.5vw, 46px); }
.balance-footer, .metric p { margin-top: 8px; font-size: 12px; line-height: 1.38; }
.balance-footer { color: #cee2d5; }
.balance-footer b { color: #fff; margin-left: 4px; }
.metric { background: white; box-shadow: var(--shadow); }
.metric p { color: var(--muted); }
.metric p b { color: var(--ink); margin-left: 3px; }
.metric-icon { color: var(--green); background: var(--mint); }
.spent .metric-icon { color: var(--coral); background: var(--pink); }
.panel-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; margin-bottom: 15px; }
.card { min-width: 0; background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 17px; box-shadow: var(--shadow); }
.card-heading, .card-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.card-heading { justify-content: space-between; min-height: 44px; }
.card-title h2 { font-size: 16px; font-weight: 750; letter-spacing: -.022em; line-height: 1.25; }
.card-title p { color: var(--muted); font-size: 12px; line-height: 1.35; margin-top: 4px; }
.section-icon { width: 33px; height: 33px; border-radius: 10px; background: #edf4eb; color: var(--green); }
.chart-card { min-height: 248px; }
.category-body { display: flex; align-items: center; justify-content: center; gap: clamp(12px, 2vw, 26px); min-height: 166px; padding: 14px 0 6px; }
.donut { width: clamp(109px, 12vw, 148px); aspect-ratio: 1; flex: none; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--segments, #eaf1e9 0% 100%)); }
.donut > div { display: grid; place-items: center; align-content: center; gap: 4px; background: white; border-radius: 50%; width: 78%; aspect-ratio: 1; text-align: center; }
.donut small { color: var(--muted); font-size: 10px; }
.donut b { font-size: clamp(12px, 1.35vw, 18px); letter-spacing: -.035em; line-height: 1.1; overflow-wrap: anywhere; padding: 0 5px; }
.chart-empty { max-width: 168px; }
.chart-empty strong { font-size: 13px; }
.chart-empty p { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.legend { padding: 0; margin: 0; list-style: none; flex: 1; min-width: 0; }
.legend li { display: grid; grid-template-columns: 8px minmax(0,1fr) auto; align-items: start; gap: 7px; padding: 5px 0; font-size: 12px; line-height: 1.3; }
.legend li span:nth-child(2) { overflow-wrap: anywhere; }
.legend b { font-variant-numeric: tabular-nums; text-align: right; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--dot, #85ab7b); flex: none; }
.legend .dot { margin-top: 4px; }
.timeline { display: grid; grid-template-columns: repeat(6,1fr); gap: 5px; padding-top: 12px; }
.month-bars { display: grid; grid-template-rows: 102px 22px; text-align: center; min-width: 0; }
.bar-pair { display: flex; align-items: flex-end; justify-content: center; gap: 4px; padding: 5px 2px 0; border-bottom: 1px solid #dce7df; background: repeating-linear-gradient(to top,#f0f4f0 0 1px,transparent 1px 25px); }
.bar { display: block; width: min(28%, 17px); height: var(--height); border-radius: 4px 4px 0 0; }
.earned, .earned-dot { background: #318762; }
.spent-bar, .spent-dot { background: #d68d77; }
.month-bars small { padding-top: 5px; font-size: 11px; color: var(--muted); }
.month-bars.last small { font-weight: 800; color: var(--green-dark); }
.timeline-legend { display: flex; flex-wrap: wrap; gap: 15px; margin-top: 10px; color: var(--muted); font-size: 11px; }
.timeline-legend span { display: inline-flex; align-items: center; gap: 5px; }
.text-link { color: var(--green-dark); font-size: 12px; font-weight: 720; min-height: 44px; display: flex; align-items: center; white-space: nowrap; }
.text-link:hover { text-decoration: underline; }
.empty { display: grid; justify-items: center; align-content: center; text-align: center; gap: 6px; color: var(--muted); padding: 20px 11px 10px; min-height: 145px; }
.empty-icon { color: var(--green); display: grid; place-items: center; border-radius: 15px; width: 44px; height: 44px; background: #edf5eb; margin-bottom: 3px; }
.empty strong { color: var(--ink); font-size: 14px; }
.empty p { font-size: 12px; line-height: 1.4; max-width: 270px; }
.empty .button { margin-top: 5px; }
.record-list { margin-top: 7px; }
.record { display: flex; align-items: center; gap: 9px; width: 100%; background: none; border: 0; border-top: 1px solid #ecf0eb; text-align: left; min-height: 61px; padding: 8px 0; }
.record:hover { background: #f7faf6; }
.record-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: #edf2ed; color: var(--green); flex: none; }
.record-icon.income, .form-type.income:has(:checked) { background: var(--mint); color: var(--green); }
.record-icon.expense, .form-type.expense:has(:checked) { background: var(--pink); color: var(--coral); }
.record-text { display: grid; gap: 3px; flex: 1; min-width: 0; }
.record-text strong, .record-text small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.record-text strong, .record-amount strong { font-size: 13px; }
.record small { font-size: 11px; color: var(--muted); }
.record-amount { display: grid; text-align: right; gap: 3px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.record-amount.income strong, .record small.done { color: var(--green); }
.record small.late { color: #a63831; font-weight: 700; }
.record-date { color: var(--muted); font-size: 11px; }
.record-arrow { display: grid; color: #697a6f; }
.filters { display: grid; grid-template-columns: minmax(0,2fr) repeat(2,minmax(0,1fr)); gap: 8px; margin: 12px 0 15px; }
.search { display: flex; align-items: center; gap: 7px; background: #fbfdfb; border: 1px solid #d9e4db; border-radius: 10px; padding: 0 10px; }
.search svg { flex: none; color: var(--green); }
.search input { width: 100%; min-width: 0; padding: 8px 0; background: transparent; border: 0; min-height: 44px; }
.small-count { color: var(--muted); font-size: 12px; text-align: right; }
.planning-top { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; margin-bottom: 15px; }
.setting-body { margin-top: 11px; display: grid; justify-items: start; gap: 12px; }
.setting-body p, .form > p { color: var(--muted); font-size: 14px; line-height: 1.5; }
.setting-buttons, .chips { display: flex; flex-wrap: wrap; gap: 7px; }
.setting-body details p { margin-top: 8px; }
.category-settings { grid-template-columns: repeat(2,minmax(0,1fr)); }
.category-setting h3 { font-size: 14px; margin-bottom: 9px; }
.chips span { display: inline-flex; background: #edf3ed; color: #365346; font-size: 12px; border-radius: 999px; padding: 6px 9px; overflow-wrap: anywhere; }
.alert, .form-error { color: #863b32 !important; background: #fff2ed; border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.alert { margin-bottom: 14px; }
dialog { width: min(480px,calc(100% - 30px)); max-height: calc(100dvh - 28px); border: 1px solid var(--line); padding: 19px 22px 0; color: var(--ink); border-radius: 23px; box-shadow: 0 20px 65px #18291e3d; background: white; overscroll-behavior: contain; }
dialog.compact { width: min(418px,calc(100% - 30px)); }
dialog::backdrop { background: #0d241db3; }
body:has(dialog[open]) { overflow: hidden; }
.handle { display: none; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 7px; margin-bottom: 7px; }
.dialog-heading h2 { font-size: 23px; line-height: 1.14; letter-spacing: -.035em; }
.close { color: var(--muted); }
.form { display: grid; gap: 13px; }
.form > label, .form-grid > label { display: grid; gap: 5px; min-width: 0; font-size: 13px; font-weight: 690; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0, 1fr)); gap: 10px; }
.form-grid > label:only-child, .form-grid:has(> #installment-count[hidden]) > label:first-child { grid-column: span 2; }
.form input:not([type=radio],[type=checkbox]), .form select, .form textarea, .filters select {
  display: block; width: 100%; min-width: 0; min-height: 45px; border: 1px solid #d9e4db; background: #fbfdfb; padding: 9px 9px; border-radius: 10px; font-size: 16px; color: var(--ink);
}
.form textarea { margin-top: 6px; resize: vertical; }
.form input[type=date], .form input[type=month] { min-inline-size: 0; -webkit-appearance: none; }
.form input::-webkit-date-and-time-value { text-align: left; }
.form input::placeholder, .search input::placeholder { color: #697a70; }
.filters select { font-size: 13px; }
.input-prefix { display: flex; align-items: center; border: 1px solid #d9e4db; border-radius: 10px; background: #fbfdfb; }
.input-prefix > span { color: var(--muted); padding-left: 10px; }
.input-prefix input { border: 0 !important; background: none !important; }
.type-control { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; margin: 0; padding: 0; border: none; }
.form-type { display: flex; position: relative; justify-content: center; align-items: center; gap: 7px; border-radius: 10px; background: #f4f6f4; padding: 10px 5px; min-height: 45px; cursor: pointer; font-size: 14px; font-weight: 710; }
.form-type input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.form-type:has(:focus-visible) { outline: 2px solid #238a60; outline-offset: 2px; }
.checkbox { display: flex !important; align-items: center; gap: 9px !important; min-height: 36px; width: max-content; cursor: pointer; }
.checkbox input { width: 19px; height: 19px; accent-color: var(--green); margin: 0; }
.form details, .setting-body details { font-size: 13px; color: var(--green-dark); }
summary { padding: 6px 0; cursor: pointer; font-weight: 650; }
.form .form-hint { font-size: 12px; margin-top: -5px; }
.form-footer { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 7px; padding: 10px 0 max(15px,env(safe-area-inset-bottom)); background: white; border-top: 1px solid var(--line); z-index: 1; }
.form-footer .primary { flex: 1; }
.danger { background: #972f28; color: white; }
.danger-text { color: #983b31; background: #fff2ed; }
.rule-summary { display: grid; gap: 5px; background: #eff5ee; padding: 11px 12px; border-radius: 10px; }
.rule-summary span { color: var(--muted); font-size: 12px; }
.install-guide { padding-bottom: 18px; }
.toast { position: fixed; z-index: 10; bottom: 20px; right: 20px; max-width: min(370px, calc(100% - 30px)); background: #153d2d; color: white; border-radius: 12px; padding: 12px 15px; font-size: 14px; box-shadow: 0 6px 20px #0d221e38; opacity: 0; transform: translateY(5px); transition: opacity .15s,transform .15s; pointer-events: none; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: #842d26; }
@media (max-width: 1040px) and (min-width: 771px) {
  .shell { grid-template-columns: 178px minmax(0,1fr); }
  .sidebar { padding-inline: 11px; }
  .topbar, main { padding-inline: 22px; }
  .overview, .panel-grid { gap: 10px; }
  .card { padding-inline: 13px; }
  .balance, .metric { padding-inline: 13px; }
}
@media (max-width: 770px) {
  .shell { display: block; }
  .sidebar { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; padding: 4px max(7px,env(safe-area-inset-right)) max(4px,env(safe-area-inset-bottom)) max(7px,env(safe-area-inset-left)); border: 0; border-top: 1px solid var(--line); z-index: 3; background: #fff; }
  .sidebar .brand, .sidebar-note, .breadcrumbs { display: none; }
  #nav { grid-template-columns: repeat(4, minmax(0,1fr)); gap: 2px; }
  #nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 5px 0; font-size: 10px; min-height: 48px; }
  #nav a svg { width: 19px; height: 19px; }
  .topbar { position: sticky; top: 0; z-index: 2; padding: max(7px,env(safe-area-inset-top)) max(14px,env(safe-area-inset-right)) 7px max(14px,env(safe-area-inset-left)); min-height: 59px; }
  .mobile-brand { display: flex; margin: 0; gap: 8px; }
  .mobile-brand img { border-radius: 10px; }
  .mobile-brand strong { font-size: 20px; }
  .mobile-brand small { font-size: 8px; }
  .top-add { padding-inline: 11px; font-size: 12px; gap: 5px; }
  main { max-width: 570px; padding: 16px max(13px,env(safe-area-inset-right)) calc(85px + env(safe-area-inset-bottom)) max(13px,env(safe-area-inset-left)); }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 10px; margin-bottom: 11px; }
  h1 { font-size: clamp(26px, 7.8vw, 36px); }
  .page-heading p { font-size: 13px; margin-top: 6px; }
  .month-control { width: 100%; min-height: 40px; justify-content: space-between; }
  .month-label { width: 100%; }
  .overview, .planning-top { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-bottom: 10px; }
  .balance { grid-column: span 2; }
  .balance, .metric { min-height: auto; padding: 11px 13px; border-radius: 16px; }
  .balance { padding: 12px 15px; }
  .balance-value { margin-top: 6px; font-size: 33px; }
  .balance-footer { margin-top: 5px; }
  .metric-title { gap: 5px; font-size: 12px; }
  .metric-icon, .balance-icon { width: 31px; height: 31px; border-radius: 9px; }
  .metric > strong { margin-top: 4px; font-size: clamp(19px,5.2vw,27px); }
  .metric p { margin-top: 4px; font-size: 11px; }
  .panel-grid { grid-template-columns: minmax(0,1fr); gap: 10px; margin-bottom: 10px; }
  .card { padding: 12px 13px; border-radius: 16px; }
  .chart-card { min-height: auto; }
  .category-body { gap: 14px; min-height: 134px; padding: 6px 0 2px; }
  .donut { width: clamp(92px,29vw,128px); }
  .donut b { font-size: clamp(11px,3.7vw,16px); }
  .category-settings { grid-template-columns: minmax(0,1fr); }
  .legend li { gap: 5px; font-size: 11px; }
  .filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .search { grid-column: span 2; }
  .search input, .filters select { font-size: 16px; }
  dialog, dialog.compact { position: fixed; inset: auto 0 0; margin: 0 auto; width: min(100%, 570px); max-height: calc(94dvh - env(safe-area-inset-top)); padding: 7px max(15px,env(safe-area-inset-right)) 0 max(15px,env(safe-area-inset-left)); border-radius: 21px 21px 0 0; border-bottom: none; }
  .handle { display: block; width: 36px; height: 4px; background: #d5e1d8; border-radius: 99px; margin: 0 auto 3px; }
  .dialog-heading h2 { font-size: 22px; }
  .form { gap: 11px; }
  .form-grid.has-count { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .toast { bottom: calc(63px + env(safe-area-inset-bottom)); right: 13px; }
}
@media (max-width: 355px) {
  .top-add { font-size: 11px; padding-inline: 8px; }
  #nav a { font-size: 9px; }
  .record { gap: 6px; }
  .record-arrow { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

.dialog-toast { display: none; }
.dialog-toast.visible { display: block; margin: 0 0 8px; border-radius: 8px; padding: 8px 10px; color: #842d26; background: #fff2ed; font-size: 13px; }

.legend-more { color: var(--green-dark); font-size: 12px; padding: 0 0 4px; }
.legend-more > summary { min-height: 36px; display: list-item; padding-block: 9px; }
