:root {
  color-scheme: light;
  --paper: #f5f4ee;
  --surface: #fffefa;
  --surface-soft: #f9f8f2;
  --ink: #1e2926;
  --muted: #5e6961;
  --line: #e7e7df;
  --green: #163a32;
  --green-2: #2f6956;
  --sage: #dce9dc;
  --coral: #df8b65;
  --amber: #e7b56a;
  --rose: #b95045;
  --shadow: 0 9px 30px rgb(34 49 41 / 4%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

.app-shell { min-height: 100vh; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 82px;
  padding: 0 clamp(22px, 4.2vw, 72px);
  border-bottom: 1px solid #e6e5dc;
  background: rgb(255 254 250 / 72%);
}
.brand { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.brand-mark { display: block; border-radius: 14px; }
.brand-copy { display: flex; flex-direction: column; gap: 3px; }
.brand-copy strong { font-size: 15px; letter-spacing: -.035em; font-weight: 750; }
.brand-copy small { font-size: 10px; color: var(--muted); letter-spacing: .04em; }
.toolbar { display: flex; align-items: center; gap: 10px; }
.month-control, .currency-control {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 112px;
  padding: 7px 11px 6px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}
.currency-control { min-width: 99px; }
.control-caption { font-size: 8px; color: var(--muted); font-weight: 800; letter-spacing: .12em; }
.month-control input, .currency-control select { border: 0; padding: 0; outline: 0; background: transparent; font-size: 12px; font-weight: 700; }
.currency-control select { appearance: none; cursor: pointer; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 11px;
  line-height: 1;
  font-weight: 750;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button:focus-visible, .text-button:focus-visible, .dialog-close:focus-visible { outline: 3px solid #95bba3; outline-offset: 2px; }
.button-primary { background: var(--green); color: #fffefa; box-shadow: 0 4px 10px rgb(22 58 50 / 12%); }
.button-primary:hover { background: #214c41; box-shadow: 0 6px 15px rgb(22 58 50 / 18%); }
.button-secondary { border-color: var(--line); background: var(--surface); color: var(--ink); }
.button-secondary:hover { background: #f0f0e9; }
.button-accent { background: var(--coral); color: #231f1c; }
.button-accent:hover { background: #e59a75; }
.button-full { width: 100%; }
.import-button { cursor: pointer; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; margin: -1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

.page-content { width: min(100% - 48px, 1370px); margin: 0 auto; padding: 34px 0 26px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin: 2px 4px 24px; }
.eyebrow { margin: 0 0 8px; color: #5b6b5e; font-size: 9px; line-height: 1.25; font-weight: 850; letter-spacing: .14em; }
.eyebrow-dot { display: inline-block; width: 7px; height: 7px; margin: 0 7px 0 0; vertical-align: 1px; border-radius: 50%; background: var(--coral); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-size: clamp(32px, 3.8vw, 48px); line-height: 1.08; letter-spacing: -.055em; }
h1 em { color: var(--green-2); font-weight: 400; }
.intro { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.privacy-note { display: flex; align-items: center; gap: 10px; padding: 10px 13px; color: #6f7d71; font-size: 10px; line-height: 1.55; border: 1px solid #e4e7dc; border-radius: 12px; background: #f0f2e9; }
.privacy-note strong { color: var(--green); font-size: 10px; }
.privacy-icon { display: grid; place-items: center; width: 29px; height: 29px; color: var(--green); border-radius: 10px; background: #dde8dc; font-size: 19px; }

.summary-grid { display: grid; grid-template-columns: 1.25fr 1fr 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.summary-card { min-height: 105px; padding: 18px 20px 17px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.summary-card.balance-card { position: relative; overflow: hidden; border-color: var(--green); background: var(--green); color: #fffefa; }
.balance-card::after { position: absolute; right: -25px; bottom: -48px; width: 134px; height: 134px; content: ""; border: 1px solid rgb(244 230 200 / 20%); border-radius: 50%; box-shadow: 0 0 0 18px rgb(244 230 200 / 4%), 0 0 0 38px rgb(244 230 200 / 3%); }
.summary-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.balance-card .summary-label { color: #c0d1c3; }
.summary-value { margin: 0; font-size: clamp(22px, 2.2vw, 29px); font-weight: 700; line-height: 1; letter-spacing: -.055em; font-variant-numeric: tabular-nums; }
.balance-card .summary-value { position: relative; z-index: 1; color: #fffefa; }
.summary-foot { margin: 8px 0 0; color: var(--muted); font-size: 10px; }
.balance-card .summary-foot { color: #bfd0c3; }
.summary-symbol { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; background: #eef0e9; color: var(--green); font-size: 14px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(330px, .85fr); align-items: start; gap: 16px; }
.main-column, .side-column { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card { min-width: 0; padding: 21px 22px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.section-heading .eyebrow { margin-bottom: 5px; }
h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 20px; font-weight: 400; line-height: 1.15; letter-spacing: -.035em; }
.quiet-tag, .trend-period { padding: 6px 9px; border-radius: 99px; background: #f1f2eb; color: #65766a; font-size: 9px; font-weight: 750; letter-spacing: .05em; white-space: nowrap; }
.trend-period { color: #625f55; background: #f7f5ec; font-size: 8px; letter-spacing: .12em; }
.spending-chart { display: grid; grid-template-columns: 174px minmax(0, 1fr); align-items: center; gap: 23px; min-height: 195px; }
.donut-wrap { position: relative; width: 166px; height: 166px; margin: 0 auto; }
.donut-wrap svg { display: block; width: 100%; height: 100%; overflow: visible; }
.donut-base { fill: none; stroke: #eff0e8; stroke-width: 13; }
.donut-segment { fill: none; stroke-width: 13; stroke-linecap: butt; transition: stroke-dasharray .35s ease; }
.donut-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; pointer-events: none; }
.donut-center strong { max-width: 124px; overflow: hidden; color: var(--green); font-size: 21px; font-weight: 750; letter-spacing: -.06em; text-overflow: ellipsis; }
.donut-center span { margin-top: 4px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.spending-legend { display: flex; flex-direction: column; gap: 10px; }
.legend-row { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; align-items: center; gap: 9px; font-size: 11px; }
.color-chip { width: 8px; height: 8px; border-radius: 3px; }
.legend-name { overflow: hidden; color: #5f6b64; text-overflow: ellipsis; white-space: nowrap; }
.legend-amount { color: #26352e; font-weight: 750; font-variant-numeric: tabular-nums; }
.empty-chart { display: grid; place-items: center; min-height: 160px; padding: 20px; color: var(--muted); border: 1px dashed #dfe2d7; border-radius: 12px; font-size: 11px; text-align: center; }

.inline-form { display: grid; align-items: end; gap: 9px; }
.budget-form { grid-template-columns: minmax(0, 1.2fr) minmax(110px, 1fr) auto; margin-bottom: 1px; }
label > span { display: block; margin-bottom: 6px; color: #59645d; font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
label > span small { text-transform: none; letter-spacing: 0; font-weight: 500; }
input, select { width: 100%; min-width: 0; height: 38px; padding: 0 10px; border: 1px solid #e3e5dc; border-radius: 9px; background: #fff; color: #26352e; font-size: 11px; }
input::placeholder { color: #647168; }
input:focus, select:focus { outline: 2px solid #a9c3ae; outline-offset: 1px; border-color: #799d84; }
.budget-form .button { min-height: 38px; padding: 0 13px; font-size: 10px; }
.form-feedback { min-height: 13px; margin: 6px 0 0; color: var(--rose); font-size: 10px; }
.entry-help { margin: -5px 0 14px; color: #59645c; font-size: 10px; line-height: 1.5; }
.transaction-form-actions { display: flex; gap: 8px; }
.transaction-form-actions .button { flex: 1; width: auto; }
.transaction-form-actions .button[hidden] { display: none; }
.budget-list { display: flex; flex-direction: column; gap: 13px; margin-top: 5px; }
.budget-empty { padding: 16px 14px; border-radius: 11px; background: #f7f7f1; color: #59645c; font-size: 11px; line-height: 1.55; }
.budget-empty strong { color: var(--green); }
.budget-row { padding: 12px 13px; border-radius: 11px; background: #f8f8f3; }
.budget-row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.budget-name { font-size: 11px; font-weight: 750; }
.budget-numbers { color: #59645c; font-size: 10px; font-variant-numeric: tabular-nums; }
.budget-numbers strong { color: #39483f; }
.progress-track { height: 5px; overflow: hidden; border-radius: 9px; background: #e9ebe3; }
.progress-fill { height: 100%; border-radius: inherit; background: #609277; transition: width .35s ease; }
.progress-fill.near { background: var(--amber); }
.progress-fill.over { background: var(--rose); }
.budget-note { margin: 7px 0 0; color: #59645c; font-size: 9px; }
.budget-note.over { color: var(--rose); }
.budget-remove { min-width: 26px; min-height: 26px; padding: 0; border: 0; background: none; color: #59645c; font-size: 16px; line-height: 1; }
.budget-remove:hover { color: var(--rose); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 0 8px 10px; color: #59645c; font-size: 8px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
td { padding: 11px 8px; border-top: 1px solid #efefe9; color: #59645c; font-size: 10px; white-space: nowrap; }
td:first-child { padding-left: 8px; }
.transaction-cell { display: flex; align-items: center; gap: 8px; }
.transaction-cell .transaction-title { min-width: 0; flex: 1; }
.transaction-cell .transaction-title > span { min-width: 0; }
.transaction-title { display: flex; align-items: center; gap: 9px; color: #2f3d35; font-weight: 750; }
.transaction-icon { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 9px; background: #eef3ec; color: #407653; font-size: 13px; }
.transaction-icon.expense { background: #fbefe8; color: #ba704e; }
.transaction-note { display: block; max-width: 155px; overflow: hidden; margin-top: 3px; color: #59645c; font-size: 9px; font-weight: 450; text-overflow: ellipsis; }
.amount-cell { text-align: right; }
td.amount-cell { color: #3a6f50; text-align: right; font-weight: 750; font-variant-numeric: tabular-nums; }
td.amount-cell.expense-amount { color: #343e37; }
.transaction-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.edit-transaction, .delete-transaction { min-width: 34px; min-height: 34px; padding: 0 8px; border: 0; border-radius: 7px; font-size: 10px; font-weight: 700; cursor: pointer; }
.edit-transaction { background: #eef1e9; color: var(--green); }
.edit-transaction:hover { background: #e1e9de; }
.delete-transaction { display: inline-grid; place-items: center; background: transparent; color: #59645c; font-size: 16px; }
.edit-transaction:focus-visible, .delete-transaction:focus-visible { outline: 3px solid #95bba3; outline-offset: 2px; }
.delete-transaction:hover { background: #faeae5; color: var(--rose); }
.empty-transactions td { padding: 20px 9px; color: #59645c; text-align: center; white-space: normal; }

.chart-legend { display: flex; align-items: center; gap: 18px; margin: -3px 0 10px; color: #59645c; font-size: 9px; }
.chart-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { display: inline-block; width: 7px; height: 7px; border-radius: 3px; }
.income-dot { background: #4b8a66; }
.expense-dot { background: #dfa17e; }
.trend-chart { display: flex; align-items: end; justify-content: space-between; gap: 10px; min-height: 138px; padding: 10px 4px 0; border-bottom: 1px solid #ebece4; }
.trend-month { display: flex; align-items: center; flex-direction: column; justify-content: end; flex: 1; height: 128px; gap: 7px; }
.trend-bars { display: flex; align-items: end; justify-content: center; gap: 4px; width: 100%; height: 100px; }
.trend-bar { width: min(13px, 36%); min-height: 3px; border-radius: 4px 4px 1px 1px; transition: height .35s ease; }
.trend-bar.income { background: #4b8a66; }
.trend-bar.expense { background: #dfa17e; }
.trend-month-label { color: #59645c; font-size: 8px; white-space: nowrap; }
.trend-empty { display: grid; place-items: center; width: 100%; min-height: 120px; color: #59645c; font-size: 10px; text-align: center; }

.insights-card { border-color: #e8e7dc; background: #fbfaf4; }
.compact-heading { margin-bottom: 12px; }
.sparkle { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 10px; background: #f4e8d4; color: #c18253; font-size: 16px; }
.insights-list { display: flex; flex-direction: column; gap: 8px; }
.insight-item { display: flex; align-items: start; gap: 9px; padding: 10px 11px; border-radius: 10px; background: #fffefa; color: #5f6c62; font-size: 10px; line-height: 1.5; }
.insight-item.over { background: #fff4ef; color: #995345; }
.insight-item.good { background: #eff5ed; color: #426b4b; }
.insight-marker { flex: 0 0 auto; width: 7px; height: 7px; margin-top: 4px; border-radius: 50%; background: #b9c4b5; }
.insight-item.over .insight-marker { background: #d88067; }
.insight-item.good .insight-marker { background: #5b9068; }

.entry-card { background: #fffefa; }
.stacked-form { display: flex; flex-direction: column; gap: 10px; }
.stacked-form label { min-width: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.stacked-form .form-feedback { margin: -4px 0 -4px; }
.stacked-form .button { margin-top: 2px; }
.category-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 2px 6px 0; }
.category-tools > div { display: flex; align-items: center; gap: 8px; }
.category-tools-title { color: #6e7970; font-size: 10px; font-weight: 750; }
.category-count { color: #59645c; font-size: 9px; }
.text-button { padding: 5px 0 5px 8px; border: 0; background: transparent; color: var(--green-2); font-size: 10px; font-weight: 750; }
.text-button:hover { color: var(--coral); }

.app-footer { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 20px 3px 0; color: #59645c; font-size: 9px; }
.app-footer span:first-child { font-weight: 850; letter-spacing: .13em; }
.app-footer span:last-child { color: #59645c; }

.category-dialog { width: min(100% - 30px, 460px); max-height: min(86vh, 760px); padding: 0; overflow: auto; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: 0 24px 90px rgb(20 37 29 / 22%); }
.category-dialog::backdrop { background: rgb(20 34 27 / 42%); backdrop-filter: blur(3px); }
.dialog-content { position: relative; display: flex; flex-direction: column; gap: 13px; padding: 28px; }
.dialog-content .eyebrow { margin: 0; }
.dialog-content h2 { font-size: 26px; }
.dialog-intro { margin: -5px 0 2px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.dialog-content label > span { margin-bottom: 6px; }
.dialog-close { position: absolute; top: 16px; right: 17px; width: 30px; height: 30px; border: 0; border-radius: 9px; background: #f2f3ed; color: #637067; font-size: 21px; }
.category-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow: auto; margin-top: 4px; }
.category-list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 9px; background: #f7f7f1; color: #48564d; font-size: 10px; }
.category-type-tag { margin-left: auto; color: #59645c; font-size: 8px; text-transform: uppercase; letter-spacing: .08em; }
.category-delete { min-width: 26px; min-height: 26px; border: 0; background: transparent; color: #59645c; font-size: 14px; }
.category-delete:hover { color: var(--rose); }
.toast { position: fixed; right: 24px; bottom: 22px; z-index: 20; max-width: min(360px, calc(100vw - 36px)); padding: 12px 16px; transform: translateY(16px); border: 1px solid #315949; border-radius: 11px; background: var(--green); color: #fffefa; font-size: 11px; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; box-shadow: 0 12px 25px rgb(22 58 50 / 18%); }
.toast.visible { transform: translateY(0); opacity: 1; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 30; padding: 10px 14px; border-radius: 8px; background: var(--green); color: #fffefa; }
.skip-link:focus { top: 12px; }
.import-summary { position: relative; width: min(100% - 48px, 1370px); margin: 12px auto -2px; padding: 13px 46px 13px 16px; border: 1px solid #d9e5d8; border-radius: 12px; background: #edf4eb; color: #42644a; font-size: 10px; line-height: 1.5; }
.import-summary[hidden] { display: none; }
.import-summary strong { display: block; margin-bottom: 3px; color: #274b34; font-size: 11px; }
.import-summary ul { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 6px 0 0; padding-left: 16px; color: #8a554b; }
.dismiss-import { position: absolute; top: 8px; right: 10px; width: 28px; height: 28px; border: 0; border-radius: 8px; background: #dfeade; color: #57735b; font-size: 18px; }
.dismiss-import:hover { background: #d4e3d3; }

@media (min-width: 1500px) {
  .page-content { padding-top: 42px; }
  .card { padding: 24px 26px; }
}
@media (max-width: 1040px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: 13px; padding-top: 15px; padding-bottom: 15px; }
  .toolbar { width: 100%; justify-content: flex-start; }
  .dashboard-grid { grid-template-columns: minmax(0, 1.25fr) minmax(300px, .85fr); }
  .spending-chart { grid-template-columns: 142px minmax(0, 1fr); gap: 14px; }
  .donut-wrap { width: 140px; height: 140px; }
}
@media (max-width: 780px) {
  .page-content { width: min(100% - 30px, 620px); padding-top: 26px; }
  .import-summary { width: calc(100% - 30px); }
  .page-heading { align-items: flex-start; flex-direction: column; margin-bottom: 17px; }
  .privacy-note { align-self: stretch; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .summary-card { min-height: 98px; padding: 15px; }
  .dashboard-grid { grid-template-columns: 1fr; gap: 13px; }
  .main-column, .side-column { gap: 13px; }
  .spending-chart { grid-template-columns: 150px minmax(0, 1fr); }
  .donut-wrap { width: 145px; height: 145px; }
  .toolbar { flex-wrap: wrap; }
  .topbar { padding-right: 15px; padding-left: 15px; }
  .month-control { flex: 1 1 125px; }
  .currency-control { flex: 0 1 100px; }
}
@media (max-width: 480px) {
  .page-content { width: calc(100% - 24px); }
  .topbar { gap: 12px; }
  .toolbar { gap: 7px; }
  .month-control { flex: 1 1 100px; min-width: 100px; }
  .currency-control { min-width: 90px; }
  .toolbar .button, .import-button { min-height: 36px; padding-right: 10px; padding-left: 10px; font-size: 10px; }
  .page-heading { margin-right: 0; margin-left: 0; }
  h1 { font-size: 34px; }
  .summary-card { padding: 14px 12px; }
  .summary-label { font-size: 8px; }
  .summary-value { font-size: 22px; }
  .card { padding: 17px 15px; border-radius: 13px; }
  .spending-chart { grid-template-columns: 1fr; gap: 16px; }
  .donut-wrap { width: 153px; height: 153px; }
  .spending-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 13px; }
  .budget-form { grid-template-columns: 1fr 1fr; }
  .budget-form .button { grid-column: 1 / -1; }
  .form-row { grid-template-columns: 1fr 1fr; }
  .app-footer { align-items: flex-start; flex-direction: column; gap: 6px; }
  .app-footer span:nth-child(2) { order: 3; }
  .dialog-content { padding: 24px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
