/* Bricolage Grotesque, self-hosted (SIL Open Font License, see fonts/). The
   Latin Extended file holds the rupee sign. */
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/bricolage-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/bricolage-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light;
  --bg: #fff7ef;
  --ink: #2a1a12;
  --muted: #7a6558;
  --line: rgba(84, 52, 30, 0.12);
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --surface-strong: rgba(255, 255, 255, 0.92);
  --chip: rgba(84, 52, 30, 0.06);
  --primary: #f97316;
  --primary-2: #ec4899;
  --income: #16a34a;
  --expense: #f43f5e;
  --chart-grid: rgba(84, 52, 30, 0.1);
  --shadow: 0 20px 50px -20px rgba(122, 55, 12, 0.28), 0 2px 6px rgba(122, 55, 12, 0.06);
  --blob-1: #ffb37a;
  --blob-2: #ff8fc4;
  --blob-3: #ffd56b;
  --radius: 26px;
  --font: "Bricolage Grotesque", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16111c;
  --ink: #fbefe6;
  --muted: #b4a3b0;
  --line: rgba(255, 236, 222, 0.1);
  --surface: rgba(38, 29, 46, 0.62);
  --surface-solid: #241b2c;
  --surface-strong: rgba(38, 29, 46, 0.94);
  --chip: rgba(255, 236, 222, 0.07);
  --income: #4ade80;
  --expense: #fb7185;
  --chart-grid: rgba(255, 236, 222, 0.08);
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.7), 0 2px 6px rgba(0, 0, 0, 0.25);
  --blob-1: #c2410c;
  --blob-2: #9d174d;
  --blob-3: #6d28d9;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Animated background ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  filter: blur(70px) saturate(1.2);
  opacity: 0.75;
}

:root[data-theme="dark"] .backdrop {
  opacity: 0.5;
}

.blob {
  position: absolute;
  width: 46vmax;
  height: 46vmax;
  border-radius: 50%;
}

.blob-1 {
  top: -18vmax;
  left: -12vmax;
  background: var(--blob-1);
  animation: float-1 22s ease-in-out infinite alternate;
}

.blob-2 {
  top: 10vmax;
  right: -16vmax;
  background: var(--blob-2);
  animation: float-2 26s ease-in-out infinite alternate;
}

.blob-3 {
  bottom: -22vmax;
  left: 24vw;
  background: var(--blob-3);
  animation: float-3 30s ease-in-out infinite alternate;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 20px;
}

.topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(var(--bg), color-mix(in srgb, var(--bg) 0%, transparent));
}

.brand {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-self: start;
  color: inherit;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand img {
  border-radius: 12px;
  box-shadow: 0 8px 20px -8px rgba(243, 156, 18, 0.7);
  transition: transform 500ms var(--ease-spring);
}

.brand:hover img {
  transform: rotate(-8deg) scale(1.06);
}

.month-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.month-label {
  min-width: 150px;
  padding: 6px 10px;
  border: 0;
  border-radius: 999px;
  background: none;
  font-weight: 700;
  text-align: center;
}

.month-label:not(.is-current):hover {
  background: var(--chip);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-strong);
  transition: transform 250ms var(--ease-spring), background 200ms ease;
}

.month-switcher .icon-btn {
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
}

.icon-btn:hover {
  transform: scale(1.08);
  background: var(--chip);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

#themeToggle .icon-sun,
:root[data-theme="dark"] #themeToggle .icon-moon {
  display: none;
}

:root[data-theme="dark"] #themeToggle .icon-sun {
  display: block;
  animation: spin-in 600ms var(--ease-spring);
}

:root:not([data-theme="dark"]) #themeToggle .icon-moon {
  animation: spin-in 600ms var(--ease-spring);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
  transition: transform 250ms var(--ease-spring), box-shadow 250ms ease, filter 200ms ease;
}

.btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.6;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 10px 24px -10px rgba(236, 72, 153, 0.8);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px -12px rgba(236, 72, 153, 0.85);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-ghost {
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.btn-ghost:hover {
  transform: translateY(-2px);
}

.btn-small {
  min-height: 38px;
  padding: 0 16px;
}

.btn-block {
  width: 100%;
  min-height: 52px;
  font-size: 17px;
}

/* Keep the submit button in reach when the sheet scrolls. */
.sheet-form .btn-block {
  position: sticky;
  bottom: 0;
  z-index: 1;
  /* Fades out whatever scrolls underneath. */
  box-shadow:
    0 -18px 18px 6px var(--surface-solid),
    0 10px 24px -10px rgba(236, 72, 153, 0.8);
}

.text-btn {
  padding: 6px 4px;
  border: 0;
  background: none;
  color: var(--primary);
  font-weight: 700;
}

.text-btn:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-btn.danger {
  color: var(--expense);
}

/* ---------- Bento grid ---------- */

.bento {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 20px 40px;
}

.card {
  position: relative;
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.3);
  animation: card-in 800ms var(--ease-out) both;
}

.balance-card {
  grid-column: span 7;
  animation-delay: 60ms;
}

.budget-card {
  grid-column: span 5;
  animation-delay: 140ms;
}

.insights-card {
  grid-column: span 12;
  animation-delay: 220ms;
}

.category-card {
  grid-column: span 5;
  animation-delay: 300ms;
}

.trend-card {
  grid-column: span 7;
  animation-delay: 380ms;
}

.list-card {
  grid-column: span 12;
  animation-delay: 460ms;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card-hint {
  color: var(--muted);
  font-size: 12px;
}

/* ---------- Sample data banner ---------- */

.sample-banner {
  grid-column: span 12;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1.5px dashed color-mix(in srgb, var(--primary) 55%, transparent);
  border-radius: 20px;
  background: color-mix(in srgb, var(--primary) 9%, var(--surface));
  backdrop-filter: blur(18px);
  animation: card-in 800ms var(--ease-out) both;
}

.sample-banner[hidden] {
  display: none;
}

.sample-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
}

.sample-icon svg {
  width: 20px;
  height: 20px;
}

.sample-copy {
  flex: 1;
  min-width: 0;
}

.sample-copy h2 {
  font-size: 16px;
  font-weight: 800;
}

.sample-copy p {
  color: var(--muted);
  font-size: 14px;
}

.sample-banner .btn {
  flex: none;
}

/* ---------- Balance ---------- */

.balance-card {
  overflow: hidden;
  isolation: isolate;
  display: grid;
  align-content: space-between;
  gap: 14px;
  min-height: 260px;
  background:
    linear-gradient(140deg, rgba(249, 115, 22, 0.95), rgba(236, 72, 153, 0.95) 60%, rgba(168, 85, 247, 0.95));
  color: #fff;
  border-color: transparent;
}

.balance-card .card-label {
  color: rgba(255, 255, 255, 0.85);
}

.balance-glow {
  position: absolute;
  inset: -40%;
  z-index: -1;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 220, 150, 0.55), transparent 40%),
    radial-gradient(circle at 70% 60%, rgba(255, 255, 255, 0.25), transparent 35%);
  animation: glow-spin 18s linear infinite;
}

.balance {
  font-size: clamp(42px, 7vw, 72px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}

.odometer {
  display: inline-flex;
  align-items: flex-start;
  font-variant-numeric: tabular-nums;
}

.odo-digit {
  display: inline-block;
  height: 1.1em;
  overflow: hidden;
}

.odo-strip {
  --d: 0;
  display: flex;
  flex-direction: column;
  transform: translateY(calc(var(--d) * -1.1em));
  transition: transform 1100ms cubic-bezier(0.2, 0.9, 0.2, 1);
  transition-delay: calc(var(--k, 0) * 45ms);
}

.odo-strip span,
.odo-symbol {
  display: block;
  height: 1.1em;
  line-height: 1.1em;
}

.balance-note {
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
}

.inline-link {
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.month-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  transition: transform 300ms var(--ease-spring), background 200ms ease;
}

.stat:hover {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, 0.24);
}

.stat > div {
  min-width: 0;
}

.stat-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
}

.stat-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.6;
}

.stat.income .stat-icon {
  color: #16a34a;
}

.stat.expense .stat-icon {
  color: #e11d48;
}

.stat.net .stat-icon {
  color: #7c3aed;
}

.stat-label {
  display: block;
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  font-weight: 600;
}

.stat strong {
  display: block;
  overflow: hidden;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Budget ring ---------- */

.budget-card {
  --ring-a: #22c55e;
  --ring-b: #14b8a6;
}

.budget-card[data-level="warn"] {
  --ring-a: #f59e0b;
  --ring-b: #f97316;
}

.budget-card[data-level="over"] {
  --ring-a: #f43f5e;
  --ring-b: #db2777;
}

.budget-body {
  display: flex;
  align-items: center;
  gap: 22px;
}

.ring-wrap {
  position: relative;
  flex: none;
  width: 150px;
  height: 150px;
}

.ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring circle {
  fill: none;
  stroke-width: 12;
}

.ring-track {
  stroke: var(--chip);
}

.ring-fill {
  --value: 0;
  stroke: url(#ringGradient);
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: calc(100 - var(--value));
  transition: stroke-dashoffset 1200ms var(--ease-out) 250ms;
}

.stop-a {
  stop-color: var(--ring-a);
}

.stop-b {
  stop-color: var(--ring-b);
}

.budget-card[data-level="none"] .ring-fill {
  stroke: transparent;
}

.budget-card[data-level="over"] .ring-wrap {
  animation: wobble 900ms var(--ease-out) 700ms;
}

.ring-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.ring-center strong {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
}

.ring-center span {
  color: var(--muted);
  font-size: 13px;
}

.budget-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.budget-headline {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.budget-card[data-level="none"] .budget-headline {
  font-size: 17px;
  font-weight: 700;
}

.budget-card[data-level="over"] .budget-headline {
  color: var(--expense);
}

.budget-detail {
  color: var(--muted);
  font-size: 14px;
}

.budget-form {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  animation: pop-in 300ms var(--ease-spring);
}

.budget-form[hidden] {
  display: none;
}

.budget-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.inline-field {
  display: flex;
  gap: 8px;
}

.inline-field input {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-solid);
}

/* ---------- Insights ---------- */

.insight-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.insight {
  --tone: #8b5cf6;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--tone) 28%, transparent);
  border-radius: 18px;
  background: color-mix(in srgb, var(--tone) 9%, transparent);
  animation: slide-in 500ms var(--ease-out) both;
  animation-delay: calc(var(--i) * 70ms);
  transition: transform 300ms var(--ease-spring);
}

.insight:hover {
  transform: translateY(-3px);
}

.insight.warn {
  --tone: #f97316;
}

.insight.good {
  --tone: #16a34a;
}

:root[data-theme="dark"] .insight.good {
  --tone: #4ade80;
}

.insight-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: var(--tone);
  color: #fff;
}

:root[data-theme="dark"] .insight.good .insight-icon {
  color: #052e16;
}

.insight-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.4;
}

.insight p {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.insight-empty {
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Categories ---------- */

.category-body {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}

.donut-wrap {
  position: relative;
  height: 170px;
}

.donut-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  pointer-events: none;
}

.donut-center span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.donut-center strong {
  font-size: 18px;
  font-weight: 800;
}

.legend {
  display: grid;
  gap: 4px;
  max-height: 230px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.legend li {
  animation: slide-in 500ms var(--ease-out) both;
  animation-delay: calc(var(--i) * 50ms);
}

.legend-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  grid-template-areas:
    "emoji name amount"
    "emoji bar share";
  column-gap: 10px;
  row-gap: 4px;
  align-items: center;
  width: 100%;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: none;
  text-align: left;
  transition: background 200ms ease, border-color 200ms ease;
}

.legend-item:hover {
  background: var(--chip);
}

.legend-item[aria-pressed="true"] {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.legend-emoji {
  grid-area: emoji;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--c) 18%, transparent);
  font-size: 16px;
}

.legend-name {
  grid-area: name;
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-amount {
  grid-area: amount;
  font-size: 14px;
  font-weight: 700;
}

.legend-bar {
  grid-area: bar;
  height: 6px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--chip);
}

.legend-bar i {
  display: block;
  width: var(--w);
  height: 100%;
  border-radius: inherit;
  background: var(--c);
  transform-origin: left;
  animation: grow-x 900ms var(--ease-out) both;
}

.legend-share {
  grid-area: share;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.legend-empty {
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Trend ---------- */

.trend-wrap {
  position: relative;
  height: 240px;
}

/* ---------- Transactions ---------- */

.list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.list-head h2 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.list-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.segmented {
  position: relative;
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--chip);
}

.segmented label {
  position: relative;
  z-index: 1;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: block;
  padding: 7px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  transition: color 250ms ease;
}

.segmented input:checked + span {
  color: var(--ink);
}

.segmented input:focus-visible + span {
  outline: 3px solid var(--primary);
  outline-offset: 1px;
}

.segmented-pill {
  position: absolute;
  top: 4px;
  left: 0;
  height: calc(100% - 8px);
  border-radius: 999px;
  background: var(--surface-solid);
  box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.25);
  transition: transform 450ms var(--ease-out), width 450ms var(--ease-out);
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-solid);
}

.search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

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

.search input {
  width: 160px;
  min-height: 40px;
  border: 0;
  outline: none;
  background: transparent;
}

.active-filter:empty {
  display: none;
}

.active-filter {
  margin-bottom: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  border: 1px solid var(--primary);
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  font-size: 14px;
  font-weight: 700;
  animation: pop-in 350ms var(--ease-spring);
}

.chip span {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 20%, transparent);
}

.transaction-list {
  display: grid;
  gap: 18px;
}

.day-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0 6px 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.day-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tx {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  align-items: center;
  gap: 6px;
  padding-right: 8px;
  border-radius: 18px;
  transition: background 200ms ease;
  animation: slide-in 500ms var(--ease-out) both;
  animation-delay: calc(var(--i) * 35ms);
}

.tx-open {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 10px 8px;
  border: 0;
  border-radius: 18px;
  background: none;
  text-align: left;
}

.tx:hover {
  background: var(--chip);
}

.tx.is-new {
  animation: tx-new 1400ms var(--ease-out) both;
}

.tx.is-leaving {
  overflow: hidden;
  animation: tx-leave 420ms ease-in forwards;
}

.tx-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--c) 18%, transparent);
  font-size: 22px;
  transition: transform 300ms var(--ease-spring);
}

.tx:hover .tx-icon {
  transform: rotate(-8deg) scale(1.08);
}

.tx-main {
  display: grid;
  min-width: 0;
}

.tx-main strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-main > span {
  color: var(--muted);
  font-size: 13px;
}

/* Sample entries: a dashed icon and a tag, so they never pass for real ones. */
.tx.is-sample .tx-icon {
  outline: 1.5px dashed color-mix(in srgb, var(--c) 70%, transparent);
  outline-offset: -1.5px;
}

.sample-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 7px;
  border: 1px dashed color-mix(in srgb, var(--primary) 70%, transparent);
  border-radius: 999px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  letter-spacing: 0.02em;
  vertical-align: 1px;
}

.tx-amount {
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
}

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

.tx-delete {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--muted);
  opacity: 0;
  transition: opacity 200ms ease, background 200ms ease, color 200ms ease;
}

.tx:hover .tx-delete,
.tx:focus-within .tx-delete {
  opacity: 1;
}

.tx-delete:hover {
  background: color-mix(in srgb, var(--expense) 15%, transparent);
  color: var(--expense);
}

.tx-delete svg {
  width: 18px;
  height: 18px;
}

@media (hover: none) {
  .tx-delete {
    opacity: 1;
  }
}

.list-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 24px 12px 12px;
  text-align: center;
  animation: pop-in 500ms var(--ease-out);
}

.empty.compact {
  padding: 28px 12px;
}

.empty h3 {
  font-size: 22px;
  font-weight: 800;
}

.empty p {
  max-width: 380px;
  color: var(--muted);
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
}

.empty-art {
  width: 170px;
  height: auto;
  stroke: none;
}

.empty-shadow {
  fill: var(--chip);
}

.empty-wallet {
  fill: #fb923c;
}

.empty-flap {
  fill: #f97316;
}

.empty-clasp {
  fill: #fdba74;
}

.empty-dot {
  fill: #fff;
}

.empty-coin {
  fill: #facc15;
  animation: coin-bob 2.4s ease-in-out infinite;
}

.empty-rupee {
  fill: #a16207;
  font-size: 12px;
  font-weight: 800;
  text-anchor: middle;
  animation: coin-bob 2.4s ease-in-out infinite;
}

/* ---------- Footer, FAB, toasts ---------- */

.footer {
  padding: 0 20px 100px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 20;
  display: none;
  place-items: center;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 14px 30px -10px rgba(236, 72, 153, 0.9);
  transition: transform 300ms var(--ease-spring);
}

.fab svg {
  width: 26px;
  height: 26px;
  stroke-width: 2.6;
}

.fab:active {
  transform: scale(0.92) rotate(90deg);
}

.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 60;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 12px 18px;
  border-radius: 18px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.45);
  font-size: 14px;
  font-weight: 600;
  pointer-events: auto;
  animation: toast-in 450ms var(--ease-spring);
}

.toast.is-leaving {
  animation: toast-out 250ms ease-in forwards;
}

.toast button {
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 18%, transparent);
  color: var(--bg);
  font-weight: 800;
}

.particle {
  position: fixed;
  z-index: 70;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  pointer-events: none;
}

/* ---------- Sheet ---------- */

.sheet {
  width: min(480px, calc(100vw - 24px));
  max-height: min(92vh, 760px);
  padding: 0;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--surface-solid);
  color: var(--ink);
  box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.45);
}

.sheet[open] {
  animation: sheet-in 480ms var(--ease-spring);
}

.sheet.is-closing {
  animation: sheet-out 240ms ease-in forwards;
}

.sheet::backdrop {
  background: rgba(30, 14, 20, 0.45);
  backdrop-filter: blur(6px);
  animation: fade-in 300ms ease;
}

.sheet.is-closing::backdrop {
  animation: fade-out 240ms ease forwards;
}

.sheet-form {
  display: grid;
  gap: 16px;
  max-height: min(92vh, 760px);
  padding: 18px 22px 22px;
  overflow-y: auto;
}

.sheet-grabber {
  display: none;
  justify-self: center;
  width: 44px;
  height: 5px;
  border-radius: 99px;
  background: var(--line);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet-head h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

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

.sheet-actions .text-btn {
  padding: 8px 12px;
  border-radius: 999px;
}

.sheet-actions .text-btn:hover {
  background: color-mix(in srgb, var(--expense) 12%, transparent);
  text-decoration: none;
}

.type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.type-toggle span {
  text-align: center;
  font-size: 15px;
}

.sheet[data-type="expense"] .type-toggle .segmented-pill {
  background: linear-gradient(135deg, #fb7185, #f43f5e);
}

.sheet[data-type="income"] .type-toggle .segmented-pill {
  background: linear-gradient(135deg, #4ade80, #16a34a);
}

.type-toggle input:checked + span {
  color: #fff;
}

.amount-field {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 0 4px;
  cursor: text;
}

.currency {
  color: var(--muted);
  font-size: 34px;
  font-weight: 700;
}

.amount-field input {
  width: 100%;
  max-width: 280px;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 54px;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-align: center;
  -moz-appearance: textfield;
}

.amount-field input::-webkit-outer-spin-button,
.amount-field input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.amount-field:focus-within {
  border-radius: 20px;
  box-shadow: inset 0 -3px 0 var(--primary);
}

.category-picker {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.category-picker legend {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 8px;
}

.category-option {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 10px 6px;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  cursor: pointer;
  text-align: center;
  animation: pop-in 420ms var(--ease-spring) both;
  animation-delay: calc(var(--i) * 25ms);
  transition: border-color 200ms ease, background 200ms ease, transform 250ms var(--ease-spring);
}

.category-option:hover {
  transform: translateY(-2px);
}

.category-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.category-option:has(input:checked) {
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
}

.category-option:has(input:focus-visible) {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.category-emoji {
  font-size: 24px;
  transition: transform 300ms var(--ease-spring);
}

.category-option:has(input:checked) .category-emoji {
  transform: scale(1.2);
}

.category-name {
  max-width: 100%;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
  hyphens: auto;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input {
  min-height: 46px;
  min-width: 0;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
}

.field input:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

.form-error {
  color: var(--expense);
  font-size: 14px;
  font-weight: 600;
}

.form-error:empty {
  display: none;
}

/* ---------- Theme switch ---------- */

.theme-transition * {
  transition: none !important;
}

.theme-transition::view-transition-old(root),
.theme-transition::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

.theme-transition::view-transition-new(root) {
  animation: theme-reveal 700ms cubic-bezier(0.65, 0, 0.35, 1);
}

/* ---------- Keyframes ---------- */

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.98);
  }
}

@keyframes float-1 {
  to {
    transform: translate(18vw, 12vh) scale(1.15);
  }
}

@keyframes float-2 {
  to {
    transform: translate(-14vw, 18vh) scale(0.9);
  }
}

@keyframes float-3 {
  to {
    transform: translate(10vw, -16vh) scale(1.1);
  }
}

@keyframes glow-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes spin-in {
  from {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@keyframes grow-x {
  from {
    transform: scaleX(0);
  }
}

@keyframes tx-new {
  0% {
    opacity: 0;
    transform: translateY(-14px) scale(0.96);
    background: color-mix(in srgb, var(--primary) 22%, transparent);
  }
  40% {
    opacity: 1;
    transform: none;
    background: color-mix(in srgb, var(--primary) 22%, transparent);
  }
  100% {
    background: transparent;
  }
}

@keyframes tx-leave {
  to {
    height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    transform: translateX(40px);
  }
}

@keyframes wobble {
  20% {
    transform: rotate(-6deg);
  }
  40% {
    transform: rotate(5deg);
  }
  60% {
    transform: rotate(-3deg);
  }
  80% {
    transform: rotate(2deg);
  }
}

@keyframes coin-bob {
  50% {
    transform: translateY(-6px);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.95);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.96);
  }
}

@keyframes sheet-out {
  to {
    opacity: 0;
    transform: translateY(20px) scale(0.97);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

@keyframes theme-reveal {
  from {
    clip-path: circle(0 at var(--vt-x, 50%) var(--vt-y, 50%));
  }
  to {
    clip-path: circle(var(--vt-r, 150%) at var(--vt-x, 50%) var(--vt-y, 50%));
  }
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}

@keyframes sheet-down {
  to {
    transform: translateY(100%);
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .add-btn {
    width: 44px;
    padding: 0;
  }

  .add-btn span {
    display: none;
  }
}

@media (max-width: 960px) {
  .balance-card,
  .budget-card,
  .category-card,
  .trend-card {
    grid-column: span 12;
  }
}

@media (max-width: 640px) {
  .topbar {
    grid-template-columns: 1fr auto;
    padding: 12px 16px;
  }

  .brand span {
    display: none;
  }

  .month-switcher {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    justify-content: space-between;
  }

  .topbar-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .add-btn {
    display: none;
  }

  .fab {
    display: grid;
  }

  .bento {
    gap: 14px;
    padding: 4px 16px 32px;
  }

  .card {
    padding: 18px;
  }

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

  .month-stats {
    gap: 8px;
  }

  .stat {
    display: grid;
    gap: 6px;
    padding: 10px;
  }

  .stat strong {
    font-size: 15px;
  }

  .budget-body {
    gap: 16px;
  }

  .ring-wrap {
    width: 120px;
    height: 120px;
  }

  .ring-center strong {
    font-size: 26px;
  }

  .budget-headline {
    font-size: 19px;
  }

  .category-body {
    grid-template-columns: 1fr;
  }

  .donut-wrap {
    width: 190px;
    height: 190px;
    margin: 0 auto;
  }

  .card-hint {
    display: none;
  }

  .list-tools,
  .search {
    width: 100%;
  }

  .search input {
    width: 100%;
  }

  .tx {
    grid-template-columns: minmax(0, 1fr) 34px;
    gap: 2px;
    padding-right: 2px;
  }

  .tx-open {
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 8px 4px;
  }

  .sample-banner {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
  }

  .sample-icon {
    width: 34px;
    height: 34px;
    border-radius: 12px;
  }

  .sample-copy {
    flex-basis: calc(100% - 46px);
  }

  .sample-copy p {
    font-size: 13px;
  }

  .sample-banner .btn {
    width: 100%;
  }

  .tx-icon {
    width: 42px;
    height: 42px;
    font-size: 20px;
  }

  /* The add form slides up from the bottom like a native sheet. */
  .sheet {
    width: 100vw;
    max-width: 100vw;
    margin: auto 0 0;
    border-radius: 28px 28px 0 0;
    border-bottom: 0;
  }

  .sheet[open] {
    animation: sheet-up 420ms var(--ease-out);
  }

  .sheet.is-closing {
    animation: sheet-down 240ms ease-in forwards;
  }

  .sheet-form {
    padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
  }

  .sheet-grabber {
    display: block;
  }

  .amount-field input {
    font-size: 46px;
  }

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

  .category-name {
    font-size: 11px;
  }

  .field-row {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }

  .blob {
    animation: none;
  }
}
