:root {
  --ink: #17211b;
  --muted: #7b827d;
  --line: #e7e9e6;
  --green: #3f7d60;
  --green-dark: #315f49;
  --green-soft: #eef4ef;
  --cream: #fafbf8;
  --orange: #d8a25d;
  --red: #bf6b5d;
  --shadow: 0 12px 35px rgba(32, 45, 36, 0.07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: #f4f6f2;
  color: var(--ink);
  font-family: "DM Sans", sans-serif;
}

.loading-screen, .auth-screen {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 24px;
}
.loading-screen { color: var(--muted); gap: 10px; }
.loading-screen p { max-width: 440px; margin: 0; text-align: center; font-size: 13px; line-height: 1.6; }
.loading-screen .brand-mark { transform: scale(1.25); }
.auth-screen { background: radial-gradient(ellipse at top, #eaf1eb, #f4f6f2 65%); }
.auth-card {
  width: min(440px, 100%);
  border: 1px solid rgba(231, 233, 230, 0.9);
  border-radius: 18px;
  background: white;
  padding: 34px;
  box-shadow: 0 24px 70px rgba(32, 45, 36, 0.08);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 30px;
  font-family: "Manrope", sans-serif;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.16em;
}
.auth-card > .eyebrow { margin-bottom: 8px; }
.auth-card h1 { font-size: 25px; }
.auth-intro { margin: 8px 0 22px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.auth-submit { width: 100%; margin-top: 2px; }
.auth-toggle {
  border: 0;
  background: transparent;
  color: var(--green-dark);
  padding: 8px;
  font-size: 12px;
  font-weight: 700;
}
.auth-card > .auth-toggle { display: block; margin: 12px auto 0; }
.auth-footnote { margin: 20px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; text-align: center; }
.auth-error { margin: 0; border-radius: 8px; background: #f9e9e6; color: #a95247; padding: 10px 12px; font-size: 12px; line-height: 1.45; }
.auth-success { margin: 0; border-radius: 8px; background: #e8f3eb; color: #34754d; padding: 10px 12px; font-size: 12px; line-height: 1.45; }
.forgot-password { display: block; margin: 8px auto 0; }
.auth-card > .forgot-password + .auth-toggle { display: block; margin: 2px auto 0; }
.device-switch { white-space: nowrap; }

button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 225px minmax(0, 1fr);
}

.sidebar {
  position: fixed;
  width: 225px;
  height: 100vh;
  padding: 34px 22px 24px;
  background: #f9faf7;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.brand {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 10px;
  font-family: "Manrope", sans-serif;
  font-size: 15px;
  letter-spacing: 0.16em;
  font-weight: 800;
}

.brand-mark {
  width: 30px;
  height: 30px;
  position: relative;
  display: inline-block;
}

.brand-mark i {
  position: absolute;
  width: 11px;
  height: 24px;
  border-radius: 10px;
  background: var(--green);
  transform: rotate(34deg);
}
.brand-mark i:first-child { left: 4px; top: 5px; }
.brand-mark i:last-child { right: 4px; top: 1px; height: 18px; background: #91a99b; }

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 46px;
}

.nav-item {
  height: 48px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #747b76;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 13px;
  font-weight: 600;
  text-align: left;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-item:first-child svg { fill: currentColor; stroke: none; }
.nav-item.active { background: var(--green-soft); color: var(--green-dark); }

.profile {
  margin-top: auto;
  height: 64px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 4px 0;
  color: var(--ink);
  text-align: left;
}
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #e5c5ad;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}
.profile-copy { display: flex; flex: 1; flex-direction: column; }
.profile-copy strong { font-size: 13px; }
.profile-copy small { color: var(--muted); margin-top: 2px; }
.profile > svg { width: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; }

.main {
  grid-column: 2;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 42px 48px 55px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
}
.eyebrow {
  margin: 0 0 5px;
  color: #9a9f9b;
  font-size: 10px;
  letter-spacing: 0.16em;
  font-weight: 700;
}
h1, h2 { font-family: "Manrope", sans-serif; }
h1 { margin: 0; font-size: 27px; letter-spacing: -0.03em; }
h2 { margin: 0; font-size: 16px; letter-spacing: -0.02em; }

.primary-button {
  height: 44px;
  border: 0;
  border-radius: 9px;
  background: var(--green);
  color: white;
  padding: 0 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  box-shadow: 0 7px 16px rgba(63, 125, 96, 0.16);
}
.primary-button:hover { background: var(--green-dark); }
.primary-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.balance-card {
  min-height: 152px;
  border-radius: 14px;
  background: var(--green);
  color: white;
  padding: 28px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}
.balance-main { display: flex; flex-direction: column; }
.balance-label { opacity: 0.72; font-size: 13px; margin-bottom: 5px; }
.balance-main strong { font-family: "Manrope", sans-serif; font-size: 34px; letter-spacing: -0.03em; }
.balance-change { margin-top: 6px; font-size: 12px; color: #dce9e1; }
.balance-metrics { display: flex; gap: 28px; margin-right: 4px; }
.balance-metrics div { min-width: 100px; display: flex; flex-direction: column; }
.balance-metrics span { display: flex; align-items: center; gap: 7px; font-size: 12px; opacity: 0.78; }
.balance-metrics strong { margin-top: 7px; font-family: "Manrope", sans-serif; font-size: 16px; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.income { background: #bbd1c2; }
.dot.expense { background: #e0b4a5; }
.dot.open { background: #ead299; }

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.72fr) minmax(260px, 0.82fr);
  gap: 44px;
  margin-top: 34px;
}
.section-heading {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.period-button, .icon-button, .text-button, .month-arrow {
  border: 0;
  background: transparent;
  color: var(--muted);
}
.period-button { display: flex; align-items: center; gap: 5px; font-size: 12px; }
.period-button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.month-picker { display: flex; align-items: center; gap: 9px; }
.month-arrow {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: #5d6860;
  font-size: 20px;
  line-height: 1;
}
.month-arrow:hover { border-color: #b6c8bb; color: var(--green-dark); }
.period-label { min-width: 90px; color: #5e665f; font-size: 12px; text-align: center; text-transform: capitalize; }

.chart-card {
  height: 196px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  display: grid;
  grid-template-columns: 190px 1fr;
  align-items: center;
  padding: 20px 28px 20px 18px;
}
.donut-wrap { display: grid; place-items: center; }
.donut {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: conic-gradient(#e9ece8 0 100%);
  display: grid;
  place-items: center;
  transition: background 300ms ease;
}
.donut-center {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.015);
}
.donut-center span { color: var(--muted); font-size: 11px; }
.donut-center strong { margin-top: 3px; font-family: "Manrope", sans-serif; font-size: 16px; }
.chart-legend { display: grid; grid-template-columns: repeat(2, minmax(80px, 1fr)); gap: 14px 18px; }
.legend-item { display: flex; align-items: center; gap: 8px; min-width: 0; }
.legend-item i { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.legend-copy { display: flex; flex-direction: column; min-width: 0; }
.legend-copy span { color: var(--muted); font-size: 11px; white-space: nowrap; }
.legend-copy strong { margin-top: 2px; font-size: 12px; }

.transactions-heading { margin-top: 24px; }
.text-button { color: var(--green); font-size: 12px; font-weight: 700; }
.transactions-list {
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  overflow: hidden;
}
.transaction {
  min-height: 66px;
  display: flex;
  align-items: center;
  padding: 9px 15px;
  border-bottom: 1px solid #eff0ed;
}
.transaction:last-child { border-bottom: 0; }
.transaction-icon {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  margin-right: 12px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 15px;
  font-weight: 800;
}
.transaction-copy { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.transaction-copy strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.transaction-copy span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.transaction-value { font-family: "Manrope", sans-serif; font-size: 13px; font-weight: 700; }
.transaction-value.income { color: var(--green); }
.empty-state { min-height: 120px; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.payment-status {
  min-width: 68px;
  margin-left: 10px;
  padding: 6px 8px;
  border: 0;
  border-radius: 7px;
  background: #f0f2ef;
  color: #707872;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.payment-status:hover { filter: brightness(0.96); }
.payment-status.paid { background: #e8f3eb; color: #34754d; }
.payment-status.overdue { background: #f9e9e6; color: #b94d42; }
.payment-column { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-left: 10px; }
.payment-column .payment-status { margin-left: 0; }
.paid-by-name { color: #34754d; font-size: 9px; line-height: 1.2; white-space: nowrap; }
.delete-transaction {
  width: 28px;
  height: 28px;
  margin-left: 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #a0a6a1;
  display: grid;
  place-items: center;
}
.delete-transaction svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.delete-transaction:hover { background: #f9eeec; color: var(--red); }

.page-section { margin-top: 12px; }
.page-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-title-row h2 { font-size: 22px; }
.filter-row { display: grid; grid-template-columns: minmax(180px, 1fr) 170px 190px; gap: 10px; margin-bottom: 14px; }
.filter-row input, .filter-row select {
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  outline: none;
}
.filter-row input:focus, .filter-row select:focus { border-color: #91ad9c; box-shadow: 0 0 0 3px #edf3ef; }
.full-list { margin-top: 0; }
.category-summary { border: 1px solid var(--line); border-radius: 12px; background: white; overflow: hidden; }
.category-row { display: flex; align-items: center; gap: 13px; padding: 15px 18px; border-bottom: 1px solid #eff0ed; }
.category-row:last-child { border-bottom: 0; }
.category-row .transaction-icon { flex: 0 0 auto; margin: 0; }
.category-row-copy { flex: 1; min-width: 0; }
.category-row-copy > strong { font-size: 13px; }
.category-row-copy .progress-track { margin-top: 9px; }
.category-row-total { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.category-row-total strong { font-size: 13px; }
.category-row-total span { color: var(--muted); font-size: 11px; }

.icon-button {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}
.icon-button svg { width: 15px; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.budget-card {
  height: 119px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  padding: 20px;
}
.budget-top { display: flex; justify-content: space-between; align-items: center; }
.budget-top span { color: var(--muted); font-size: 11px; }
.budget-top strong { font-size: 12px; }
.progress-track { height: 7px; background: #edf0ec; border-radius: 20px; overflow: hidden; margin-top: 14px; }
.progress-bar { width: 0%; height: 100%; border-radius: 20px; background: var(--green); transition: width 300ms ease; }
.budget-percent { display: block; margin-top: 8px; color: var(--muted); font-size: 11px; }
.insight-heading { margin-top: 24px; }
.insight-card {
  min-height: 92px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fdfefb;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 17px;
}
.insight-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: #edf3ed;
  color: var(--green);
  display: grid;
  place-items: center;
}
.insight-icon svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.insight-card strong { font-size: 12px; }
.insight-card p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(19, 31, 23, 0.32);
  backdrop-filter: blur(3px);
  z-index: 30;
  display: grid;
  place-items: center;
  opacity: 0;
  visibility: hidden;
  transition: 160ms ease;
}
.modal-backdrop.open { opacity: 1; visibility: visible; }
.modal {
  width: min(480px, calc(100vw - 32px));
  border-radius: 16px;
  background: white;
  padding: 26px;
  box-shadow: 0 24px 70px rgba(22, 38, 28, 0.18);
  transform: translateY(8px);
  transition: 160ms ease;
}
.modal-backdrop.open .modal { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; }
.modal-header h2 { font-size: 21px; }
.close-button { width: 34px; height: 34px; border: 0; border-radius: 50%; background: #f3f5f2; color: var(--muted); font-size: 22px; line-height: 1; }
.confirm-modal { width: min(460px, calc(100vw - 32px)); }
.delete-modal-copy { display: grid; grid-template-columns: 42px minmax(0, 1fr) 34px; align-items: start; gap: 12px; margin-bottom: 21px; }
.delete-modal-copy h2 { margin: 3px 0 6px; font-size: 19px; }
.delete-modal-copy p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.delete-warning-icon { width: 40px; height: 40px; border-radius: 11px; background: #f9e9e6; color: var(--red); display: grid; place-items: center; }
.delete-warning-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.delete-options { display: grid; gap: 10px; }
.delete-option-button { padding: 14px 15px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); text-align: left; transition: 140ms ease; }
.delete-option-button:hover, .delete-option-button:focus-visible { border-color: #9cb8a5; background: #f7faf7; outline: none; }
.delete-option-button strong, .delete-option-button span { display: block; }
.delete-option-button strong { font-size: 13px; }
.delete-option-button span { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.delete-footer { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.cancel-delete, .confirm-delete { min-height: 40px; padding: 0 14px; border: 0; border-radius: 8px; font-size: 12px; font-weight: 700; }
.cancel-delete { background: #f1f3f0; color: #626b64; }
.confirm-delete { background: var(--red); color: white; }
.confirm-delete:hover { background: #a95247; }
form { display: flex; flex-direction: column; gap: 15px; }
form label { display: flex; flex-direction: column; gap: 7px; color: #555f58; font-size: 12px; font-weight: 700; }
form input, form select {
  width: 100%;
  height: 46px;
  border: 1px solid #dde1dd;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 0 13px;
  outline: none;
}
form input:focus, form select:focus { border-color: #91ad9c; box-shadow: 0 0 0 3px #edf3ef; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.money-input { position: relative; }
.money-input b { position: absolute; left: 13px; top: 14px; z-index: 1; color: var(--muted); font-size: 13px; }
.money-input input { padding-left: 42px; }
.submit-button { width: 100%; height: 48px; margin-top: 5px; }
[hidden] { display: none !important; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  transform: translate(-50%, 20px);
  border-radius: 8px;
  background: var(--ink);
  color: white;
  padding: 12px 18px;
  font-size: 13px;
  opacity: 0;
  visibility: hidden;
  transition: 180ms ease;
}
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 82px minmax(0, 1fr); }
  .sidebar { width: 82px; padding-inline: 13px; }
  .brand { justify-content: center; padding: 0; }
  .brand > span:last-child, .nav-item span, .profile-copy, .profile > svg { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .profile { justify-content: center; }
  .main { grid-column: 2; padding-inline: 28px; }
  .content-grid { grid-template-columns: minmax(0, 1.5fr) minmax(220px, 0.8fr); gap: 24px; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    width: 100%;
    height: 68px;
    bottom: 0;
    top: auto;
    border-right: 0;
    border-top: 1px solid var(--line);
    padding: 8px 16px;
  }
  .brand, .profile { display: none; }
  .nav-list { height: 100%; margin: 0; flex-direction: row; justify-content: space-around; }
  .nav-item { width: 80px; height: 52px; flex-direction: column; gap: 3px; font-size: 10px; }
  .nav-item span { display: block; }
  .main { padding: 28px 18px 90px; }
  .topbar { margin-bottom: 18px; }
  h1 { font-size: 23px; }
  .primary-button { padding: 0 12px; }
  .balance-card { min-height: 190px; align-items: flex-start; flex-direction: column; padding: 22px; }
  .balance-metrics { width: 100%; justify-content: space-between; gap: 10px; margin: 16px 0 0; }
  .balance-metrics div { min-width: 0; }
  .balance-metrics span { gap: 5px; font-size: 11px; }
  .balance-metrics strong { font-size: 14px; }
  .content-grid { display: flex; flex-direction: column; }
  .right-column { order: 2; }
  .filter-row { grid-template-columns: 1fr 1fr; }
  .filter-row input { grid-column: 1 / -1; }
  .chart-card { grid-template-columns: 150px 1fr; padding-inline: 8px 14px; }
  .donut { width: 132px; height: 132px; }
  .donut-center { width: 92px; height: 92px; }
}

@media (max-width: 480px) {
  .topbar .primary-button { width: 44px; padding: 0; font-size: 0; }
  .topbar .primary-button svg { width: 20px; }
  .topbar { flex-wrap: wrap; gap: 10px; }
  .topbar .device-switch { margin-left: auto; font-size: 11px; }
  .chart-card { height: auto; grid-template-columns: 1fr; padding: 18px; }
  .chart-legend { width: 100%; margin-top: 12px; }
  .form-row { grid-template-columns: 1fr; }
  .page-title-row { align-items: flex-start; gap: 12px; flex-direction: column; }
  .page-title-row .month-picker { align-self: flex-end; }
  .filter-row { grid-template-columns: 1fr; }
  .filter-row input { grid-column: auto; }
  .transaction { padding-inline: 10px; }
  .transaction-icon { margin-right: 9px; }
  .transaction-value { font-size: 12px; }
  .payment-status { min-width: 61px; margin-left: 6px; padding-inline: 6px; }
  .payment-column { margin-left: 6px; }
  .delete-transaction { margin-left: 4px; }
  .balance-metrics strong { font-size: 12px; }
  .balance-metrics span { font-size: 10px; }
  .balance-metrics .dot { width: 6px; height: 6px; }
  .delete-options { gap: 8px; }
  .delete-option-button { padding: 12px; }
}
