:root {
  --ink: #18342d;
  --muted: #74827d;
  --canvas: #f5f7f3;
  --surface: #ffffff;
  --line: #e8ece8;
  --green: #18694f;
  --green-dark: #104e3b;
  --green-soft: #e2f1e9;
  --red: #c75c52;
  --red-soft: #fcedeb;
  --shadow: 0 10px 30px rgba(25, 55, 45, .07);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid #82bba1;
  outline-offset: 2px;
}
.app-shell { width: min(100%, 760px); margin: 0 auto; padding: 21px 16px 42px; }
.topbar, .brand, .period-controls, .date-navigation, .balance-card-top, .balance-details, .section-heading, .category-main, .transaction-row, .transaction-leading, .dialog-heading { display: flex; align-items: center; }
.topbar, .period-controls, .balance-card-top, .section-heading, .dialog-heading { justify-content: space-between; }
.brand { gap: 10px; }
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px;
  background: var(--green); color: #fff; font-family: Georgia, serif; font-weight: 800; font-size: 21px;
}
h1, h2, p { margin: 0; }
h1 { font-size: 18px; line-height: 1.15; letter-spacing: -.4px; }
h2 { font-size: 18px; letter-spacing: -.45px; }
.eyebrow { margin-bottom: 3px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: 1.1px; }
.icon-button, .nav-button, .period-label, .period-tab, .close-button {
  border: 0; background: transparent; color: var(--ink); font-weight: 700;
}
.icon-button { padding: 8px 10px; border-radius: 9px; background: #eaf0eb; font-size: 12px; }
.period-section { margin: 27px 0 16px; }
.period-controls { gap: 15px; }
.segmented-control { display: flex; padding: 3px; border-radius: 10px; background: #e5ebe6; }
.period-tab { padding: 7px 12px; border-radius: 8px; color: #66736d; font-size: 12px; }
.period-tab.is-active { background: #fff; color: var(--green-dark); box-shadow: 0 1px 4px rgba(0,0,0,.09); }
.date-navigation { gap: 4px; }
.nav-button { width: 28px; height: 30px; color: var(--green); font-size: 25px; line-height: 20px; }
.period-label { min-width: 128px; padding: 6px 3px; font-size: 12px; }
.balance-card {
  padding: 23px 20px 19px; border-radius: 18px; color: #fff; overflow: hidden;
  background: linear-gradient(135deg, #135c46, #0d4032); box-shadow: 0 14px 27px rgba(13, 64, 50, .18);
}
.balance-card-top p { color: #b7d6c9; font-size: 12px; }
.balance-card-top strong { display: block; margin-top: 4px; font-size: 31px; letter-spacing: -1.3px; }
.balance-status { padding: 6px 9px; border-radius: 30px; background: rgba(227, 248, 236, .15); color: #d4ecdf; font-size: 10px; font-weight: 700; }
.balance-status.is-alert { background: rgba(255, 211, 203, .2); color: #ffdbd5; }
.budget-line { display: flex; justify-content: space-between; margin-top: 24px; color: #bed8cc; font-size: 11px; }
.budget-line strong { color: #fff; }
.progress-track { height: 6px; margin-top: 8px; border-radius: 99px; background: rgba(255,255,255,.18); overflow: hidden; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: #a8e1c4; transition: width .3s; }
.balance-details { gap: 27px; margin-top: 19px; }
.balance-details > div { display: flex; align-items: flex-start; gap: 7px; }
.legend { width: 7px; height: 7px; margin-top: 4px; border-radius: 50%; }
.income-dot { background: #9fdfc0; }.expense-dot { background: #f5a8a1; }
.balance-details p { color: #b8d6c9; font-size: 10px; }
.balance-details strong { display: block; margin-top: 2px; color: #fff; font-size: 13px; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 28px; }
.action-button { min-height: 47px; border: 1px solid; border-radius: 12px; font-size: 12px; font-weight: 800; }
.action-button span { margin-right: 5px; font-size: 16px; vertical-align: -1px; }
.income-action { border-color: #bddccc; background: var(--green-soft); color: var(--green-dark); }
.expense-action { border-color: #f2d1cc; background: #fff; color: #a34e46; }
.content-section { margin-top: 28px; }
.section-heading { margin-bottom: 13px; }
.muted, .transaction-count { color: var(--muted); font-size: 11px; font-weight: 600; }
.categories-list { display: grid; gap: 10px; }
.category-item {
  display: grid; grid-template-columns: 35px 1fr auto; gap: 9px; align-items: center;
  padding: 11px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface);
}
.category-icon, .transaction-icon { display: grid; place-items: center; flex: 0 0 auto; border-radius: 10px; }
.category-icon { width: 35px; height: 35px; background: #f2f5f1; font-size: 17px; }
.category-main { justify-content: space-between; gap: 7px; }
.category-main p { font-size: 12px; font-weight: 750; text-transform: capitalize; }
.category-main span { color: var(--muted); font-size: 10px; white-space: nowrap; }
.category-bar { grid-column: 2 / 4; height: 4px; margin-top: -4px; border-radius: 99px; overflow: hidden; background: #edf1ed; }
.category-bar i { display: block; height: 100%; border-radius: inherit; background: #78ad93; }
.category-value { color: #334b42; font-size: 12px; font-weight: 800; }
.empty-state {
  padding: 24px 18px; border: 1px dashed #cbd5ce; border-radius: 14px; color: var(--muted); text-align: center; font-size: 13px; line-height: 1.5;
}
.transactions-list { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.transaction-row { min-height: 67px; gap: 10px; padding: 10px 11px; border-bottom: 1px solid var(--line); }
.transaction-row:last-child { border-bottom: 0; }
.transaction-icon { width: 37px; height: 37px; background: #f2f5f1; font-size: 17px; }
.transaction-icon.income { background: var(--green-soft); }
.transaction-leading { min-width: 0; flex: 1; gap: 10px; }
.transaction-info { min-width: 0; }
.transaction-info p { overflow: hidden; font-size: 13px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.transaction-info span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; text-transform: capitalize; }
.transaction-amount { color: #ae5148; font-size: 13px; font-weight: 800; white-space: nowrap; }
.transaction-amount.income { color: var(--green); }
.delete-button { width: 25px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: #98a29d; font-size: 16px; opacity: .7; }
.delete-button:hover { background: var(--red-soft); color: var(--red); opacity: 1; }
.transaction-dialog {
  width: min(calc(100% - 28px), 430px); padding: 0; border: 0; border-radius: 18px; color: var(--ink); box-shadow: 0 20px 60px rgba(17, 37, 31, .3);
}
.transaction-dialog::backdrop { background: rgba(15, 38, 31, .48); }
.transaction-dialog form { padding: 21px; }
.dialog-heading { margin-bottom: 20px; }
.close-button { width: 31px; height: 31px; border-radius: 8px; background: #f0f3f0; font-size: 24px; font-weight: 400; line-height: 20px; }
.field { display: block; margin: 14px 0; color: #3d5149; font-size: 12px; font-weight: 750; }
.optional { color: var(--muted); font-size: 10px; font-weight: 500; }
.field input, .field select {
  width: 100%; height: 43px; margin-top: 6px; padding: 0 11px; border: 1px solid #dfe6e0; border-radius: 9px; outline: none; background: #fff; color: var(--ink); font-size: 14px;
}
.field input:focus, .field select:focus { border-color: #57977d; box-shadow: 0 0 0 3px #dff0e7; }
.currency-input { display: flex; align-items: center; height: 43px; margin-top: 6px; border: 1px solid #dfe6e0; border-radius: 9px; overflow: hidden; }
.currency-input:focus-within { border-color: #57977d; box-shadow: 0 0 0 3px #dff0e7; }
.currency-input span { padding-left: 12px; color: var(--muted); font-size: 13px; }
.currency-input input { height: 41px; margin: 0; border: 0; box-shadow: none !important; }
.form-error { min-height: 16px; margin: 3px 0 7px; color: #b24941; font-size: 11px; font-weight: 650; }
.save-button { width: 100%; height: 46px; border: 0; border-radius: 10px; background: var(--green); color: #fff; font-size: 13px; font-weight: 800; }
.save-button:hover { background: var(--green-dark); }

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

@media (min-width: 640px) {
  .app-shell { padding: 31px 24px 55px; }
  .topbar { padding: 0 4px; }
  .period-section { margin-top: 35px; }
  .balance-card { padding: 28px 27px 23px; }
  .balance-card-top strong { font-size: 38px; }
  .categories-list { grid-template-columns: 1fr 1fr; }
  .content-section { margin-top: 35px; }
  .delete-button { opacity: 0; }
  .transaction-row:hover .delete-button, .delete-button:focus { opacity: 1; }
}