:root {
  --ink: #17211b;
  --muted: #718077;
  --subtle: #9aa59f;
  --canvas: #f4f5ef;
  --surface: #ffffff;
  --line: #e5e9e3;
  --green: #1c5c45;
  --green-dark: #154936;
  --green-soft: #e6f1eb;
  --mint: #a7dec0;
  --coral: #e47861;
  --coral-soft: #fbece8;
  --amber: #e2ad57;
  --blue: #6088bd;
  --purple: #8878b7;
  --shadow: 0 1px 2px rgba(25, 45, 35, 0.03), 0 12px 40px rgba(25, 45, 35, 0.05);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --sidebar-width: 244px;
}

* {
  box-sizing: border-box;
}

html {
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip;
  scroll-behavior: smooth;
}

body {
  max-width: 100%;
  margin: 0;
  overflow-x: hidden;
  overflow-x: clip;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  color: white;
  background: var(--green);
  border-radius: 10px;
  transform: translateY(-150%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  z-index: 10;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 30px 20px 24px;
  background: #fbfcf8;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 10px;
  color: var(--ink);
  font-size: 21px;
  font-weight: 750;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--green);
  border-radius: 11px 11px 11px 4px;
  box-shadow: 0 7px 18px rgba(28, 92, 69, 0.22);
}

.brand-mark svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.primary-nav {
  margin-top: 50px;
}

.nav-label {
  margin: 0 12px 12px;
  color: var(--subtle);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 46px;
  margin-bottom: 5px;
  padding: 0 13px;
  color: #66736b;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.nav-link:hover {
  color: var(--ink);
  background: #eff2ec;
  transform: translateX(2px);
}

.nav-link.active {
  color: var(--green);
  background: var(--green-soft);
}

.nav-link svg {
  width: 19px;
  height: 19px;
}

.nav-link:first-of-type svg,
.nav-link:nth-of-type(3) svg {
  fill: currentColor;
  stroke: none;
}

.nav-badge {
  min-width: 23px;
  margin-left: auto;
  padding: 3px 6px;
  color: var(--green);
  background: white;
  border-radius: 99px;
  font-size: 10px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.profile-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: transparent;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
}

.profile-button:hover {
  background: #f0f2ed;
}

.avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: #574c26;
  background: #ebdfa8;
  border: 2px solid white;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 750;
  box-shadow: 0 0 0 1px var(--line);
}

.profile-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.profile-copy strong {
  font-size: 12px;
}

.profile-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-button > svg {
  width: 17px;
  margin-left: auto;
  color: var(--muted);
  fill: currentColor;
  stroke: none;
}

main {
  min-width: 0;
  margin-left: var(--sidebar-width);
  padding: 36px clamp(24px, 3vw, 52px) 64px;
}

.topbar {
  max-width: 1440px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 0 auto 30px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(25px, 2.4vw, 34px);
  font-weight: 690;
  letter-spacing: -0.045em;
  line-height: 1.15;
}

.topbar > div:first-child > p:last-child {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.period-toolbar {
  max-width: 1440px;
  min-height: 70px;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto minmax(190px, 1fr);
  align-items: center;
  gap: 18px;
  margin: -8px auto 20px;
  padding: 12px 14px 12px 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 17px;
  box-shadow: 0 8px 30px rgba(25, 45, 35, 0.035);
}

.period-copy {
  min-width: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 2px 8px;
}

.period-copy > span {
  color: var(--subtle);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.period-copy strong {
  font-size: 13px;
}

.period-copy small {
  grid-column: 1 / -1;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.period-controls {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px;
  background: #f1f3ef;
  border-radius: 12px;
}

.period-arrow,
.this-month-button {
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
}

.period-arrow {
  width: 34px;
}

.period-arrow svg {
  width: 15px;
  height: 15px;
}

.period-arrow:hover,
.this-month-button:hover {
  color: var(--ink);
  background: white;
}

.period-arrow:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.month-picker {
  height: 34px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  background: white;
  border-radius: 9px;
  box-shadow: 0 2px 8px rgba(24, 44, 34, 0.06);
}

.month-picker svg {
  width: 14px;
  height: 14px;
  color: var(--green);
}

.month-picker input {
  width: 116px;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 10px;
  font-weight: 650;
  cursor: pointer;
}

.this-month-button {
  display: none;
  padding: 0 10px;
  font-size: 9px;
  font-weight: 700;
}

.period-toolbar:not(.is-current) .this-month-button {
  display: grid;
}

.export-button {
  justify-self: end;
}

.icon-button,
.primary-button,
.secondary-button,
.text-button {
  border: 0;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.icon-button {
  position: relative;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
}

.icon-button:hover,
.secondary-button:hover {
  background: #fafbf8;
  border-color: #cbd3cc;
}

.notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  background: var(--coral);
  border: 2px solid white;
  border-radius: 50%;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 17px;
  border-radius: 13px;
  font-size: 13px;
  font-weight: 700;
}

.primary-button {
  color: white;
  background: var(--green);
  box-shadow: 0 8px 22px rgba(28, 92, 69, 0.17);
}

.primary-button:hover {
  background: var(--green-dark);
  box-shadow: 0 10px 28px rgba(28, 92, 69, 0.25);
  transform: translateY(-1px);
}

.primary-button svg,
.secondary-button svg {
  width: 17px;
  height: 17px;
}

.secondary-button {
  background: white;
  border: 1px solid var(--line);
}

.text-button {
  padding: 5px 0;
  color: var(--green);
  background: transparent;
  font-size: 12px;
  font-weight: 750;
}

.text-button:hover {
  color: var(--green-dark);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(28, 92, 69, 0.22);
  outline-offset: 2px;
}

.dashboard {
  max-width: 1440px;
  display: grid;
  grid-template-columns: minmax(280px, 0.92fr) minmax(420px, 1.45fr) minmax(280px, 0.95fr);
  gap: 18px;
  margin: 0 auto;
}

.card,
.balance-card {
  min-width: 0;
  min-height: 340px;
  border-radius: var(--radius-lg);
}

.card {
  padding: 24px;
  background: var(--surface);
  border: 1px solid rgba(223, 228, 222, 0.9);
  box-shadow: var(--shadow);
}

.balance-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 27px;
  color: white;
  background: linear-gradient(145deg, #205f48 0%, #164c39 52%, #123e30 100%);
  box-shadow: 0 18px 50px rgba(20, 73, 53, 0.17);
}

.balance-orb {
  position: absolute;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 50%;
  pointer-events: none;
}

.orb-one {
  width: 245px;
  height: 245px;
  top: -135px;
  right: -90px;
  box-shadow: 0 0 0 38px rgba(255,255,255,.025), 0 0 0 76px rgba(255,255,255,.018);
}

.orb-two {
  width: 130px;
  height: 130px;
  bottom: -78px;
  left: -45px;
}

.balance-heading,
.balance-heading > div {
  position: relative;
  display: flex;
  align-items: center;
}

.balance-heading {
  justify-content: space-between;
  gap: 10px;
}

.balance-heading > div {
  gap: 7px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  font-weight: 600;
}

.visibility-button {
  padding: 2px;
  color: rgba(255, 255, 255, 0.62);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.visibility-button svg {
  width: 16px;
  height: 16px;
}

.eye-closed,
.balance-hidden .eye-open {
  display: none;
}

.balance-hidden .eye-closed {
  display: block;
}

.trend-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 5px 8px;
  color: #d5f7e3;
  background: rgba(203, 245, 221, 0.12);
  border: 1px solid rgba(203, 245, 221, 0.12);
  border-radius: 99px;
  font-size: 10px;
  font-weight: 700;
}

.trend-pill svg {
  width: 12px;
  height: 12px;
}

.trend-pill.negative {
  color: #ffd1c8;
  background: rgba(239, 139, 117, .14);
}

.trend-pill.negative svg {
  transform: rotate(180deg);
}

.trend-pill.neutral svg {
  display: none;
}

.balance-value {
  position: relative;
  margin: 42px 0 3px;
  font-size: clamp(34px, 3vw, 46px);
  font-weight: 660;
  letter-spacing: -0.055em;
  line-height: 1;
}

.balance-comparison {
  position: relative;
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.5);
  font-size: 10px;
}

.balance-breakdown {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: auto;
  padding-top: 23px;
  border-top: 1px solid rgba(255,255,255,.12);
}

.balance-breakdown > div {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.balance-breakdown > div + div {
  padding-left: 12px;
  border-left: 1px solid rgba(255,255,255,.12);
}

.mini-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
}

.mini-icon svg {
  width: 15px;
  height: 15px;
}

.income-icon {
  color: #bceccc;
  background: rgba(169, 225, 191, 0.13);
}

.expense-icon {
  color: #f5b6a8;
  background: rgba(239, 139, 117, 0.13);
}

.savings-icon {
  color: #b9d7ff;
  background: rgba(150, 195, 255, 0.14);
}

.balance-breakdown .savings-summary {
  grid-column: 1 / -1;
  padding-top: 12px;
  padding-left: 0;
  border-top: 1px solid rgba(255,255,255,.1);
  border-left: 0;
}

.balance-breakdown span:last-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.balance-breakdown small {
  color: rgba(255,255,255,.5);
  font-size: 9px;
}

.balance-breakdown strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.card-header h2,
.transactions-heading h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.section-kicker {
  margin-bottom: 5px;
  color: var(--subtle);
  font-size: 9px;
}

.segmented-control {
  display: flex;
  padding: 3px;
  background: #f3f5f1;
  border-radius: 10px;
}

.segmented-control button,
.transaction-tabs button {
  border: 0;
  cursor: pointer;
}

.segmented-control button {
  padding: 6px 9px;
  color: var(--muted);
  background: transparent;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 650;
}

.segmented-control button.active {
  color: var(--ink);
  background: white;
  box-shadow: 0 2px 8px rgba(24, 44, 34, 0.08);
}

.chart-summary {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin: 26px 0 15px 42px;
}

.chart-summary div {
  display: grid;
  gap: 3px;
}

.chart-summary span {
  color: var(--muted);
  font-size: 9px;
}

.chart-summary strong {
  font-size: 24px;
  letter-spacing: -0.04em;
}

.comparison-positive {
  padding: 5px 8px;
  color: var(--green) !important;
  background: var(--green-soft);
  border-radius: 99px;
  font-weight: 700;
}

.comparison-positive.warning {
  color: #a84f3f !important;
  background: var(--coral-soft);
}

.chart-wrap {
  height: 188px;
  display: flex;
  gap: 12px;
}

.chart-y-axis {
  width: 30px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1px 0 22px;
  color: #000;
  font-size: 8px;
  text-align: right;
}

.bar-chart {
  position: relative;
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: clamp(5px, 1vw, 14px);
  padding: 0 4px 21px;
  background: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px 41px);
}

.chart-bar-group {
  position: relative;
  height: 100%;
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.chart-bar {
  width: min(26px, 72%);
  min-height: 5px;
  background: #bcd7c9;
  border-radius: 7px 7px 3px 3px;
  cursor: pointer;
  transition: height 350ms cubic-bezier(.2,.8,.2,1), background 150ms ease, transform 150ms ease;
}

.chart-bar:hover,
.chart-bar.highlight {
  background: var(--green);
  transform: scaleX(1.06);
}

.chart-bar-group label {
  position: absolute;
  bottom: -17px;
  color: var(--subtle);
  font-size: 8px;
  white-space: nowrap;
}

.chart-tooltip {
  position: absolute;
  z-index: 3;
  bottom: calc(var(--height) + 8px);
  left: 50%;
  display: none;
  padding: 5px 7px;
  color: white;
  background: var(--ink);
  border-radius: 7px;
  font-size: 8px;
  font-weight: 700;
  transform: translateX(-50%);
  white-space: nowrap;
}

.chart-bar-group:hover .chart-tooltip,
.chart-bar:focus + .chart-tooltip {
  display: block;
}

.budget-score {
  display: flex;
  align-items: center;
  gap: 15px;
  margin: 24px 0 20px;
  padding: 17px;
  background: #f5f7f3;
  border-radius: 16px;
}

.budget-ring {
  position: relative;
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--green) calc(var(--progress) * 1%), #dfe6df 0);
  border-radius: 50%;
}

.budget-ring::before {
  content: "";
  position: absolute;
  width: 44px;
  height: 44px;
  background: #f5f7f3;
  border-radius: 50%;
}

.budget-ring span {
  position: relative;
  z-index: 1;
  font-size: 13px;
  font-weight: 750;
}

.budget-ring small {
  font-size: 8px;
}

.budget-score strong {
  font-size: 12px;
}

.budget-score p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.budget-score p span {
  color: var(--ink);
  font-weight: 700;
}

.budget-list {
  display: grid;
  gap: 16px;
}

.budget-item-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.budget-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.budget-item-heading strong {
  font-size: 10px;
  font-weight: 650;
}

.budget-item-heading span:last-child {
  margin-left: auto;
  color: var(--muted);
  font-size: 9px;
}

.budget-item-heading b {
  color: var(--ink);
  font-weight: 700;
}

.progress-track {
  height: 6px;
  overflow: hidden;
  background: #edf0eb;
  border-radius: 99px;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  transition: width 400ms ease;
}

.transactions-section {
  max-width: 1440px;
  margin: 28px auto 0;
}

.transactions-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 17px;
}

.transactions-heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.data-button {
  min-width: 0;
  padding-inline: 12px;
}

.mobile-add {
  display: none;
}

.transaction-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 12px;
}

.transaction-tabs {
  display: flex;
  align-items: center;
  gap: 3px;
}

.transaction-tabs button {
  padding: 8px 12px;
  color: var(--muted);
  background: transparent;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 650;
}

.transaction-tabs button.active {
  color: var(--green);
  background: var(--green-soft);
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.search-field,
.select-field {
  height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.search-field:focus-within,
.select-field:focus-within {
  border-color: rgba(28, 92, 69, 0.55);
  box-shadow: 0 0 0 3px rgba(28, 92, 69, 0.08);
}

.search-field svg,
.select-field svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.search-field input,
.select-field select {
  height: 100%;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 10px;
}

.search-field input {
  width: 150px;
}

.search-field input::placeholder {
  color: var(--subtle);
}

.select-field select {
  width: 112px;
  cursor: pointer;
}

.table-card {
  overflow: hidden;
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  padding: 13px 18px;
  color: var(--subtle);
  background: #fafbf8;
  border-bottom: 1px solid var(--line);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-align: left;
  text-transform: uppercase;
}

th:nth-child(4),
td:nth-child(4) {
  text-align: right;
}

th:last-child {
  width: 54px;
}

td {
  padding: 13px 18px;
  border-bottom: 1px solid #edf0ec;
  color: var(--muted);
  font-size: 11px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover {
  background: #fbfcfa;
}

.merchant-cell {
  display: flex;
  align-items: center;
  gap: 11px;
}

.category-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--icon-color);
  background: var(--icon-bg);
  border-radius: 10px;
}

.category-icon svg {
  width: 16px;
  height: 16px;
}

.category-icon.food svg,
.category-icon.shopping svg,
.category-icon.housing svg {
  fill: none;
}

.merchant-copy {
  display: grid;
  gap: 3px;
}

.merchant-copy strong {
  color: var(--ink);
  font-size: 11px;
  font-weight: 650;
}

.merchant-copy small {
  color: var(--subtle);
  font-size: 9px;
}

.category-tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 8px;
  color: #5f6d64;
  background: #f2f4f0;
  border-radius: 99px;
  font-size: 9px;
  font-weight: 600;
}

.amount {
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.amount.income {
  color: var(--green);
}

.amount.savings {
  color: var(--blue);
}

.edit-button,
.delete-button {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  opacity: 1;
  transition: opacity 140ms ease, color 140ms ease, background 140ms ease;
}

.edit-button {
  width: auto;
  padding: 0 8px;
  font: inherit;
  color: var(--green);
}

.edit-button:hover {
  background: var(--green-soft);
}

tr:hover .delete-button,
.delete-button:focus-visible {
  opacity: 1;
}

.delete-button:hover {
  color: #b04a3e;
  background: var(--coral-soft);
}

.delete-button svg {
  width: 15px;
  height: 15px;
}

.transaction-total {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--green);
  font-size: 13px;
}

.transaction-total[hidden] {
  display: none;
}

.transaction-total strong {
  font-size: 18px;
  overflow-wrap: anywhere;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  padding: 0 18px;
  background: #fafbf8;
  border-top: 1px solid var(--line);
}

.table-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 9px;
}

.empty-state {
  padding: 50px 20px;
  text-align: center;
}

.empty-state > span {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 15px;
}

.empty-state h3 {
  margin: 0;
  font-size: 14px;
}

.empty-state p {
  margin: 7px 0 18px;
  color: var(--muted);
  font-size: 11px;
}

.transaction-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: auto;
  background: white;
  border: 0;
  border-radius: 24px;
  box-shadow: 0 30px 90px rgba(20, 40, 30, 0.24);
}

.transaction-dialog::backdrop {
  background: rgba(20, 31, 25, 0.48);
  backdrop-filter: blur(5px);
}

.transaction-dialog[open] {
  animation: dialog-in 200ms ease both;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.transaction-dialog form {
  padding: 26px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.035em;
}

.close-button {
  width: 38px;
  height: 38px;
  background: #f5f6f3;
}

.type-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

.type-picker legend {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 650;
}

.type-picker input {
  position: absolute;
  opacity: 0;
}

.type-picker label span {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  background: #f7f8f5;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.type-picker label span svg {
  width: 16px;
  height: 16px;
}

.type-picker input:checked + span {
  color: var(--green);
  background: var(--green-soft);
  border-color: #bcd8c8;
}

.type-picker input:focus-visible + span {
  outline: 3px solid rgba(28, 92, 69, 0.18);
}

.form-field {
  display: grid;
  gap: 7px;
}

.form-field > span,
.category-field > label:first-child,
.type-picker legend {
  color: #4e5c53;
  font-size: 10px;
  font-weight: 700;
}

.form-field > span small {
  margin-left: 3px;
  color: var(--subtle);
  font-size: 8px;
  font-weight: 500;
}

.form-field input,
.form-field select {
  width: 100%;
  height: 43px;
  padding: 0 12px;
  color: var(--ink);
  background: #fafbf8;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
  font-size: 11px;
}

.form-field input:focus,
.form-field select:focus,
.amount-field > div:focus-within {
  background: white;
  border-color: rgba(28, 92, 69, 0.55);
  box-shadow: 0 0 0 3px rgba(28, 92, 69, 0.08);
}

.custom-category-field {
  display: grid;
  gap: 7px;
  margin-top: 3px;
}

.custom-category-field[hidden] {
  display: none;
}

.custom-category-field > span {
  color: #4e5c53;
  font-size: 10px;
  font-weight: 700;
}

.amount-field {
  margin-bottom: 18px;
}

.amount-field > div {
  height: 62px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 17px;
  background: #fafbf8;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.amount-field > div > span {
  color: var(--muted);
  font-size: 20px;
}

.amount-field input {
  height: auto;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  font-size: 27px;
  font-weight: 680;
  letter-spacing: -0.04em;
}

.amount-field input:focus {
  background: transparent;
  box-shadow: none;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 25px;
  padding-top: 19px;
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  z-index: 50;
  right: 24px;
  bottom: 24px;
  min-width: 280px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 16px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: 0 20px 55px rgba(20, 40, 30, 0.16);
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 10px;
}

.toast-icon svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.2;
}

.toast strong {
  font-size: 11px;
}

.toast p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.toast-action {
  margin-left: auto;
  padding: 7px 9px;
  color: var(--green);
  background: var(--green-soft);
  border: 0;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 750;
  cursor: pointer;
}

@media (max-width: 1180px) {
  .dashboard {
    grid-template-columns: minmax(280px, 0.85fr) minmax(420px, 1.35fr);
  }

  .budget-card {
    grid-column: 1 / -1;
    min-height: 0;
  }

  .budget-card .budget-score {
    max-width: 340px;
  }

  .budget-list {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 900px) {
  :root {
    --sidebar-width: 78px;
  }

  .sidebar {
    align-items: center;
    padding: 25px 12px 20px;
  }

  .brand {
    padding: 0;
  }

  .brand > span:last-child,
  .nav-label,
  .nav-link:not(.active) .nav-badge,
  .nav-link::after,
  .profile-copy,
  .profile-button > svg {
    display: none;
  }

  .primary-nav {
    width: 100%;
    margin-top: 45px;
  }

  .nav-link {
    justify-content: center;
    padding: 0;
    font-size: 0;
  }

  .profile-button {
    justify-content: center;
    padding: 8px 0;
  }

  .dashboard {
    grid-template-columns: minmax(0, 1fr);
  }

  .period-toolbar {
    grid-template-columns: 1fr auto;
  }

  .period-controls {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
  }

  .budget-card {
    grid-column: auto;
  }

  .balance-card,
  .card {
    min-height: 330px;
  }
}

@media (max-width: 700px) {
  :root {
    --sidebar-width: 0px;
  }

  .sidebar {
    inset: auto 10px 10px;
    width: auto;
    height: 64px;
    flex-direction: row;
    padding: 7px;
    background: rgba(250, 251, 248, 0.94);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(20, 40, 30, .16);
    backdrop-filter: blur(16px);
  }

  .brand,
  .sidebar-footer,
  .nav-label {
    display: none;
  }

  .primary-nav {
    height: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
    margin: 0;
  }

  .nav-link {
    min-height: 48px;
    margin: 0;
  }

  .nav-link:hover {
    transform: none;
  }

  main {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 24px 16px 100px;
  }

  .topbar,
  .period-toolbar,
  .dashboard,
  .transactions-section {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: flex-start;
    margin-bottom: 23px;
  }

  .topbar > div:first-child,
  .transactions-heading > div:first-child {
    min-width: 0;
  }

  .topbar h1 {
    font-size: clamp(23px, 7vw, 27px);
    overflow-wrap: anywhere;
  }

  .topbar-actions .primary-button {
    display: none;
  }

  .dashboard {
    gap: 14px;
  }

  .period-toolbar {
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin-top: -4px;
    padding: 12px;
  }

  .period-copy strong {
    font-size: 12px;
  }

  .period-copy small {
    max-width: 205px;
  }

  .period-controls {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 34px;
  }

  .month-picker {
    min-width: 0;
    justify-content: center;
  }

  .month-picker input {
    width: 100%;
    min-width: 0;
  }

  .this-month-button {
    width: 100%;
    grid-column: 1 / -1;
  }

  .export-button {
    min-width: 42px;
    padding: 0 12px;
    font-size: 0;
  }

  .balance-card,
  .card {
    min-height: 0;
  }

  .balance-card {
    min-height: 310px;
  }

  .spending-card {
    min-height: 350px;
  }

  .budget-list {
    grid-template-columns: 1fr;
  }

  .transactions-section {
    min-width: 0;
    margin-top: 25px;
  }

  .transactions-heading {
    min-width: 0;
    align-items: center;
  }

  .transactions-heading h2 {
    overflow-wrap: anywhere;
  }

  .mobile-add {
    display: inline-flex;
  }

  .transaction-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .transaction-tabs {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: 1.2fr .8fr;
  }

  .search-field input,
  .select-field select {
    width: 100%;
    min-width: 0;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  tbody tr {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px 12px;
    padding: 14px 50px 14px 15px;
    border-bottom: 1px solid var(--line);
  }

  tbody tr:last-child {
    border-bottom: 0;
  }

  td {
    padding: 0;
    border: 0;
  }

  td:first-child {
    grid-row: span 2;
  }

  td:nth-child(2) {
    display: none;
  }

  td:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
    font-size: 9px;
    text-align: right;
  }

  td:nth-child(4) {
    grid-column: 2;
    grid-row: 1;
    align-self: end;
  }

  td:last-child {
    position: static;
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    transform: none;
  }

  .delete-button {
    opacity: 1;
  }

  .merchant-copy strong {
    max-width: min(130px, 36vw);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .table-footer {
    padding: 0 15px;
  }

  .transaction-dialog {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    border-radius: 20px;
  }

  .transaction-dialog form {
    padding: 21px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .toast {
    right: 12px;
    bottom: 86px;
    left: 12px;
    min-width: 0;
  }
}

@media (max-width: 430px) {
  .data-button {
    width: 42px;
    padding: 0;
  }

  .data-button span {
    display: none;
  }

  .topbar > div:first-child > p:last-child {
    max-width: 220px;
  }

  .transactions-heading {
    gap: 10px;
  }

  .balance-card {
    min-height: 390px;
    padding: 23px;
  }

  .balance-value {
    margin-top: 28px;
  }

  .balance-breakdown {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .balance-breakdown > div + div,
  .balance-breakdown .savings-summary {
    grid-column: auto;
    padding: 10px 0 0;
    margin-top: 10px;
    border-top: 1px solid rgba(255,255,255,.1);
    border-left: 0;
  }

  .spending-card .card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .spending-card .segmented-control {
    align-self: flex-start;
  }

  .card {
    padding: 20px;
  }

  .card-header {
    gap: 10px;
  }

  .segmented-control button {
    padding-inline: 7px;
  }

  .chart-summary {
    margin-left: 38px;
  }

  .comparison-positive {
    display: none;
  }

  .toolbar-actions {
    grid-template-columns: 1fr;
  }

  .select-field {
    display: none;
  }

  .table-footer {
    flex-wrap: wrap;
    gap: 4px 16px;
    padding-block: 8px;
  }

  .table-footer .text-button {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
.loan-status-button {
  padding: 6px 8px;
  border: 1px solid currentColor;
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--green);
  cursor: pointer;
  white-space: nowrap;
}

.account-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}
.account-banner p, .plan-note, #account-message {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
.account-dialog { width: min(680px, calc(100vw - 24px)); }
.account-dialog-content { padding: 26px; }
.account-dialog form { display: grid; gap: 14px; padding: 0; margin: 18px 0; }
#sign-in-form .primary-button { margin-top: 12px; }
.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 22px 0 14px; }
.plan-card { display: flex; flex-direction: column; padding: 20px; border: 1px solid var(--line); border-radius: 16px; }
.plan-card h3 { margin: 0; }
.plan-card p { font-size: 12px; line-height: 1.6; }
.plan-card .plan-price { margin: 12px 0 0; font-size: 30px; font-weight: 700; }
.plan-price span { font-size: 12px; font-weight: 400; }
.plan-card button { margin-top: auto; }
.premium-plan { border-color: var(--green); background: var(--green-soft); }
.account-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 20px; }
.account-dialog button:disabled { opacity: .55; cursor: not-allowed; }
.account-dialog [hidden] { display: none; }
.billing-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 20px 0; }
.billing-summary dt { font-size: 11px; color: var(--muted); }
.billing-summary dd { margin: 4px 0 0; font-size: 13px; font-weight: 650; overflow-wrap: anywhere; }
.pricing-page { max-width: 960px; margin: 0 auto; padding: 40px 24px; }
.pricing-page header { margin: 44px 0 24px; }
.pricing-page h1 { font-size: clamp(28px, 5vw, 44px); letter-spacing: -.035em; }
.pricing-page header > p, .pricing-free p { line-height: 1.7; color: var(--muted); }
.pricing-page .plan-grid { gap: 24px; }
.pricing-page .plan-card { padding: 28px; }
.pricing-page .plan-card h2 { margin: 0; }
.pricing-page .plan-card ul { padding-left: 20px; font-size: 13px; line-height: 2; }
.pricing-page .plan-card > a { margin-top: auto; text-decoration: none; justify-content: center; }
.pricing-free { margin: 28px 0; padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: white; }
@media (max-width: 600px) {
  .billing-summary { grid-template-columns: 1fr; }
  .pricing-page { padding: 24px 16px; }
}
#profile-name { max-width: 145px; overflow: hidden; text-overflow: ellipsis; }
/* Let native controls shrink inside grids, including Safari date inputs. */
.form-field, .custom-category-field, .form-field input, .form-field select,
.search-field, .select-field { min-width: 0; }
#account-message { overflow-wrap: anywhere; }
@media (max-width: 700px) {
  .toolbar-actions { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .search-field, .select-field { height: 48px; }
  .search-field svg, .select-field svg { flex-shrink: 0; }
  .search-field input, .select-field select,
  .form-field input, .form-field select, .month-picker input { font-size: 16px; }
  .form-field input, .form-field select { min-height: 48px; }
  .amount-field input { font-size: 28px; }
  .form-field > span, .category-field > label:first-child,
  .custom-category-field > span, .type-picker legend { font-size: 13px; }
  .transaction-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .transaction-tabs button { min-height: 44px; padding: 8px 4px; font-size: 12px; }
  .type-picker { min-width: 0; gap: 6px; }
  .type-picker label span { gap: 4px; }
  .transaction-dialog { max-height: calc(100dvh - 24px); }
  .dialog-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  .dialog-actions button, .account-dialog button { min-height: 44px; }
  .dialog-actions .primary-button { grid-row: 1; }
}
@media (max-width: 600px) {
  .account-banner { align-items: flex-start; flex-direction: column; }
  .plan-grid { grid-template-columns: 1fr; }
  .account-dialog-content { padding: 20px; }
}
