:root {
  color-scheme: light;
  --bg: #faf7f1;
  --bg-elevated: #f3eee4;
  --surface: #ffffff;
  --surface-2: #f2ece1;
  --surface-3: #e9e1d3;
  --text: #1c1916;
  --muted: #6f6a62;
  --border: #e5ddcf;
  --border-strong: #cfc4b0;
  --accent: #8a5a00;
  --accent-2: #a06a0a;
  --accent-tint: #f6e7c6;
  --on-accent: #ffffff;
  --on-gold: #1a1305;
  --success: #1d7a4a;
  --success-tint: rgba(29, 122, 74, .14);
  --warning: #9a6700;
  --warning-ink: #7a5200;
  --warning-tint: rgba(154, 103, 0, .16);
  --danger: #b42318;
  --danger-tint: rgba(180, 35, 24, .14);
  --on-danger: #ffffff;
  --cat-1: #8a5a00;
  --cat-2: #6f6a62;
  --cat-3: #9a8f7e;
  --cat-4: #2563eb;
  --cat-5: #1d7a4a;
  --cat-6: #b42318;
  --shadow: 0 1px 2px rgba(28, 25, 22, .04), 0 14px 36px rgba(28, 25, 22, .06);
  --shadow-float: 0 18px 50px rgba(28, 25, 22, .18);
  --radius: 22px;
  --radius-lg: 28px;
  --radius-xl: 32px;
  --tab-bg: rgba(255, 255, 255, .9);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236f6a62' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --date-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236f6a62' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E");
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #050505;
  --bg-elevated: #0c0c0d;
  --surface: #171719;
  --surface-2: #212123;
  --surface-3: #2a2a2c;
  --text: #f7f7f8;
  --muted: #8e8e93;
  --border: #2a2a2c;
  --border-strong: #3b3b3f;
  --accent: #f5bd62;
  --accent-2: #f6c15b;
  --accent-tint: #322816;
  --on-accent: #0b0b0c;
  --on-gold: #15110a;
  --success: #7ed6a5;
  --success-tint: rgba(126, 214, 165, .16);
  --warning: #e0a23c;
  --warning-ink: #ffd48a;
  --warning-tint: rgba(224, 162, 60, .16);
  --danger: #ff7a70;
  --danger-tint: rgba(255, 122, 112, .16);
  --on-danger: #1a0806;
  --cat-1: #f5bd62;
  --cat-2: #86868b;
  --cat-3: #4a4a4e;
  --cat-4: #67b7ff;
  --cat-5: #7ed6a5;
  --cat-6: #ff8f86;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 18px 50px rgba(0, 0, 0, .28);
  --shadow-float: 0 24px 70px rgba(0, 0, 0, .6);
  --tab-bg: rgba(21, 21, 23, .9);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --date-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E");
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  accent-color: var(--accent);
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  min-height: -webkit-fill-available;
  min-height: 100dvh;
  max-width: 100%;
  overflow-x: clip;
  background:
    radial-gradient(1100px 540px at 50% -12%, rgba(245, 189, 98, .09), transparent 62%),
    radial-gradient(700px 420px at 100% 18%, rgba(245, 189, 98, .045), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: contain;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button,
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  -webkit-appearance: none;
  appearance: none;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
}

input::-webkit-search-decoration {
  display: none;
}

input::-webkit-search-cancel-button,
input::-webkit-search-decoration,
input::-webkit-search-results-button,
input::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

input[type="search"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
select {
  min-width: 0;
}

::placeholder {
  color: var(--muted);
  opacity: 1;
}

input:disabled,
select:disabled,
textarea:disabled {
  opacity: .55;
  cursor: default;
  -webkit-text-fill-color: var(--text);
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  -webkit-box-shadow: 0 0 0 100px var(--surface-2) inset;
  transition: background-color 9999s ease-out 0s;
}

/* Native selects get the Mini App chevron; the native glyph is suppressed. */
select {
  padding-right: 38px;
  background-color: var(--surface-2);
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px 18px;
}

input[type="date"],
input[type="time"],
input[type="datetime-local"] {
  position: relative;
  padding-right: 38px;
  background-image: var(--date-icon);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px 18px;
}

input[type="date"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value {
  display: flex;
  align-items: center;
  min-height: 1em;
  text-align: left;
}

/* Let the whole date field open the picker instead of a tiny malformed glyph. */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a[href]:focus-visible,
[tabindex]:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

svg {
  display: block;
}

.app {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding:
    0
    max(16px, env(safe-area-inset-right, 0px))
    calc(132px + env(safe-area-inset-bottom, 0px))
    max(16px, env(safe-area-inset-left, 0px));
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 0 10px;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--bg) 96%, transparent) 0%,
    color-mix(in srgb, var(--bg) 82%, transparent) 72%,
    transparent 100%
  );
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.wallet-btn {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.wallet-btn__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface);
  color: var(--accent);
}

.wallet-btn__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.wallet-btn__eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .02em;
}

.wallet-btn strong {
  max-width: 200px;
  overflow: hidden;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.35px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}

.topbar__actions[hidden] {
  display: none !important;
}

.topbar__more {
  position: relative;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 120ms ease, opacity 120ms ease;
}

.icon-btn--soft {
  border-color: transparent;
  background: color-mix(in srgb, var(--surface) 76%, transparent);
}

.icon-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.icon-btn:active {
  transform: scale(.96);
}

.icon-btn:disabled {
  opacity: .35;
  cursor: default;
}

.icon-btn.spinning svg {
  animation: spin .8s linear infinite;
}

.overflow-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  width: 232px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-float);
  animation: menu-in 140ms ease both;
}

.overflow-menu[hidden] {
  display: none;
}

.overflow-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.overflow-menu button:hover {
  background: var(--surface-2);
}

.overflow-menu button:disabled {
  opacity: .45;
  cursor: default;
}

.overflow-menu svg {
  color: var(--muted);
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.month-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 36px;
  margin: 0 auto 14px;
  width: fit-content;
  max-width: calc(100% - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
}

.month-strip[hidden] {
  display: none;
}

.month-strip__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.month-strip__btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.month-strip__btn:disabled {
  opacity: .3;
  cursor: default;
}

.month-strip__label {
  min-width: 128px;
  padding: 0 6px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .01em;
  text-align: center;
  text-transform: capitalize;
}

/* ---------- Layout ---------- */

main {
  min-height: 50vh;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: rise 190ms ease both;
}

.view[hidden] {
  display: none !important;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.view-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 0;
}

.view-title__main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.view-title h2 {
  margin: 0;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -1px;
  line-height: 1.1;
}

.view-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.view-title__count {
  flex: 0 0 auto;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section--tight {
  gap: 8px;
}

.section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 32px;
  padding: 0 2px;
}

.section__head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -.35px;
}

.section__note {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--accent-2);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

/* ---------- Hero / KPI ---------- */

.hero {
  position: relative;
  padding: 22px;
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  right: -46px;
  top: -70px;
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 16%, transparent), transparent 68%);
  pointer-events: none;
}

.hero--gold .hero-value {
  color: var(--accent);
}

.hero--danger {
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--danger-tint) 78%, var(--surface)), var(--surface));
  border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
}

.hero--danger::after {
  background: radial-gradient(circle, color-mix(in srgb, var(--danger) 18%, transparent), transparent 68%);
}

.hero--danger .hero-value,
.hero--danger .eyebrow {
  color: var(--danger);
}

.hero--danger .hero-meta {
  color: color-mix(in srgb, var(--danger) 58%, var(--text));
}

.hero-calc {
  margin-top: 10px;
  padding: 0;
  color: var(--danger);
}

.hero-calc:hover {
  color: color-mix(in srgb, var(--danger) 80%, var(--text));
}

#planCalc {
  scroll-margin-top: 84px;
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.hero-value {
  position: relative;
  margin-top: 6px;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 42px;
  font-weight: 600;
  letter-spacing: -1.8px;
  line-height: 1.02;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.hero-meta .up {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--success);
  font-weight: 600;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.pill.warn {
  background: color-mix(in srgb, var(--warning) 16%, transparent);
  color: var(--warning-ink);
}

.spark {
  position: relative;
  margin-top: 14px;
  height: 52px;
}

.spark svg {
  width: 100%;
  height: 100%;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  padding: 16px 17px;
  border-radius: var(--radius);
}

.stat__label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.stat__label svg {
  color: var(--muted);
}

.stat__value {
  margin-top: 7px;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.6px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.stat__value.danger { color: var(--danger); }
.stat__value.success { color: var(--success); }
.stat__value.gold { color: var(--accent); }

.summary-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--border);
  box-shadow: var(--shadow);
}

.summary-tile {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 18px 18px 17px;
  background: var(--surface);
}

.summary-tile:nth-child(2n) {
  background: color-mix(in srgb, var(--surface) 82%, var(--surface-2));
}

.summary-tile__label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}

.summary-tile__hint {
  margin-top: -2px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.25;
}

.summary-tile__value {
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.6px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.summary-tile__value.gold { color: var(--accent); }
.summary-tile__value.income,
.summary-tile__value.balance { color: var(--accent); }
.summary-tile__value.expense { color: var(--text); }

/* ---------- Chips / filters ---------- */

.chip-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 1px 1px 2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.chip--ghost.active {
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
}

.chip-row .chip.active {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--border));
  background: var(--accent-tint);
  color: var(--accent);
}

.period-chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.period-chips::-webkit-scrollbar {
  display: none;
}

.period-chips .chip {
  border-color: transparent;
  background: transparent;
  padding: 0 10px;
}

.period-chips .chip.active {
  border-color: transparent;
  background: transparent;
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* ---------- Operations ---------- */

.ops-surface {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ops-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius);
}

.ops-search {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-2);
  color: var(--muted);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

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

.ops-search input {
  width: 100%;
  height: 40px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.ops-search input::placeholder {
  color: var(--muted);
}

.ops-search input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-radius: 8px;
}

.ops-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.ops-chips::-webkit-scrollbar {
  display: none;
}

.ops-select {
  width: 100%;
  min-height: 44px;
  padding: 0 38px 0 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background-color: var(--surface-2);
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px 18px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  -webkit-appearance: none;
  appearance: none;
}

.ops-select:focus-visible {
  border-color: var(--accent);
}

.day-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.day-group__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.day-group__head span:last-child {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-transform: none;
}

.tx-card {
  overflow: hidden;
}

.tx-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 66px;
  padding: 11px 16px;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

.tx-row:first-child {
  border-top: 0;
}

.tx-row--button {
  cursor: pointer;
}

.tx-row--button:active {
  background: var(--surface-2);
}

.tx-row--button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.tx-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 15px;
  background: var(--surface-2);
  color: var(--accent);
}

.tx-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  overflow: hidden;
}

.tx-title {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.1px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-sub {
  display: block;
  max-width: 100%;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-amount {
  flex: 0 0 auto;
  justify-self: end;
  padding-left: 8px;
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

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

.ops-skeleton {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.ops-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 2px 2px;
}

.ops-count {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.ops-more__btn {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.ops-more__btn:hover {
  border-color: var(--border-strong);
}

.ops-more__btn:disabled {
  cursor: progress;
  opacity: .75;
}

/* ---------- Operations: list / calendar switch ---------- */

.ops-mode {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  max-width: 460px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
}

.ops-mode__chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border-color: transparent;
  background: transparent;
}

.ops-mode__chip svg {
  flex: 0 0 auto;
}

.ops-mode__chip.active {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--border));
  background: var(--accent-tint);
  color: var(--accent);
}

.ops-mode__chip.active:hover {
  color: var(--accent);
}

@media (max-width: 360px) {
  .ops-mode {
    gap: 4px;
    padding: 3px;
  }

  .ops-mode__chip {
    gap: 5px;
    padding: 0 7px;
    font-size: 9px;
  }
}

.summary-card--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.calendar-summary .summary-tile {
  padding: 14px 10px 13px;
}

.calendar-summary .summary-tile__value {
  font-size: clamp(14px, 4.5vw, 20px);
  letter-spacing: -.03em;
  overflow-wrap: normal;
  white-space: nowrap;
}

.calendar-summary .summary-tile__value.positive {
  color: var(--accent);
}

.calendar-summary .summary-tile__value.negative {
  color: var(--danger);
}

.calendar.card {
  padding: 10px;
  overflow: hidden;
}

.calendar__weekdays,
.calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar__weekdays {
  gap: 4px;
  padding: 2px 0 8px;
}

.calendar__weekdays span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .08em;
  text-align: center;
  text-transform: uppercase;
}

.calendar__grid {
  gap: 4px;
}

.calendar-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-width: 0;
  min-height: 66px;
  padding: 6px 3px;
  border: 1px solid var(--border-strong);
  border-color: color-mix(in srgb, var(--border-strong) 74%, var(--text) 26%);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.calendar-day:hover {
  border-color: color-mix(in srgb, var(--accent) 36%, var(--border-strong));
  background: var(--surface-2);
}

.calendar-day:active {
  transform: scale(.98);
}

.calendar-day:focus-visible {
  outline-offset: -2px;
}

.calendar-day.is-today {
  border-color: var(--accent);
  background: var(--accent-tint);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.calendar-day.is-today .calendar-day__num {
  color: var(--accent);
}

.calendar-day--outside {
  border-color: transparent;
  background: transparent;
  cursor: default;
  opacity: .32;
}

.calendar-day--outside:hover {
  background: transparent;
}

.calendar-day--outside .calendar-day__num {
  color: var(--muted);
}

.calendar-day__num {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.calendar-day.is-weekend .calendar-day__num {
  color: var(--muted);
}

.calendar-day.is-today .calendar-day__num,
.calendar-day.is-today.is-weekend .calendar-day__num {
  color: var(--accent);
}

.calendar-day__amounts {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  min-width: 0;
}

.calendar-day__sum {
  display: block;
  max-width: 100%;
  overflow: hidden;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-day__sum.is-income {
  color: var(--accent);
}

.calendar-day__sum.is-expense {
  color: var(--danger);
}

.calendar-day__sum.is-net {
  color: var(--text);
}

.calendar-day__sum.is-total {
  display: none;
}

.calendar-day__payday {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-tint);
}

.calendar__legend {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 4px 0;
  color: var(--muted);
  font-size: 11px;
}

.calendar__legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.calendar__payday-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
  padding: 7px 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 36%, var(--border));
  border-radius: 10px;
  background: var(--accent-tint);
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
}

.calendar__payday-hint {
  color: var(--muted);
  font-weight: 500;
}

.calendar__notices {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.calendar__note {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
}

.calendar__note--empty {
  text-align: center;
}

.calendar__note--filters {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
  background: color-mix(in srgb, var(--accent-tint) 55%, var(--surface));
  color: var(--text);
}

.calendar__note--warn {
  border-color: color-mix(in srgb, var(--warning-ink) 42%, var(--border));
  background: var(--warning-tint);
  color: var(--warning-ink);
}

.calendar__note--overdue {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--border));
  background: var(--danger-tint);
  color: var(--danger);
  font-weight: 600;
}

.calendar__note--paid {
  border-color: color-mix(in srgb, var(--success) 38%, var(--border));
  background: var(--success-tint);
  color: var(--success);
}

.calendar__sk {
  min-height: 66px;
  border-radius: 12px;
}

.sheet__panel > .calendar-summary {
  margin-bottom: 10px;
}

.calendar-day-sheet {
  margin-top: 2px;
}

.calendar-day--planned.has-ops {
  background: color-mix(in srgb, var(--danger-tint) 38%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 24%, var(--border));
}

.calendar-day--planned.has-overdue {
  background: color-mix(in srgb, var(--danger-tint) 72%, var(--surface));
  border-color: var(--danger);
}

.calendar-day--planned .calendar-day__sum {
  color: var(--danger);
  font-weight: 650;
}

.calendar-day__planned-count {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: var(--on-danger);
  font-size: 9px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
}

.calendar__legend--planned .calendar__legend-dot {
  background: var(--danger);
}

.calendar__note--loading {
  text-align: center;
}

@media (max-width: 360px) {
  .calendar-day:not(.calendar-day--planned) .calendar-day__amounts .is-income,
  .calendar-day:not(.calendar-day--planned) .calendar-day__amounts .is-expense,
  .calendar-day:not(.calendar-day--planned) .calendar-day__amounts .is-net {
    display: none;
  }

  .calendar-day:not(.calendar-day--planned) .calendar-day__amounts .is-total {
    display: block;
  }

  .calendar-day__sum,
  .calendar-day__planned-count {
    font-size: 10px;
  }
}

.planned-day-list {
  margin-top: 10px;
  padding: 4px 16px;
}

.planned-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.planned-row:first-child {
  border-top: 0;
}

.planned-row__badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--danger-tint);
  color: var(--danger);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.planned-row--overdue .planned-row__amount {
  color: var(--danger);
}

.planned-row__badge--paid {
  background: var(--success-tint);
  color: var(--success);
}

.planned-row--paid .planned-row__amount {
  color: var(--success);
}

.planned-row__body {
  flex: 1 1 auto;
  min-width: 0;
}

.planned-row__body strong {
  display: block;
  overflow: hidden;
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.planned-row__body span {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.planned-row__right {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.planned-row__amount {
  color: var(--danger);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.planned-day-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px 0;
  color: var(--muted);
  font-size: 12px;
}

.planned-day-total b {
  color: var(--danger);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Report ---------- */

.report-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.report-tab {
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.report-tab:hover {
  color: var(--text);
}

.report-tab.active {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 22%, transparent);
}

.report-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.report-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.report-panel:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 18px;
}

.report-period-note {
  margin: -6px 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.report-hero {
  padding: 22px 22px 18px;
  border-radius: var(--radius-xl);
}

.report-hero__total {
  margin-top: 6px;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 38px;
  font-weight: 600;
  letter-spacing: -1.5px;
  line-height: 1.04;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.report-hero__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.donut-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 22px 18px 18px;
}

.donut-panel .donut {
  width: 218px;
  height: 218px;
  flex-basis: 218px;
}

.donut-panel .donut svg {
  width: 218px;
  height: 218px;
}

.donut-panel .donut__center strong {
  font-size: 20px;
  letter-spacing: -.7px;
}

.report-legend {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
}

.legend__row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 6px;
  border-top: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
}

.legend__row:first-child {
  border-top: 0;
}

.legend__row--active {
  background: var(--accent-tint);
}

.legend__row--active .legend__name {
  color: var(--text);
  font-weight: 650;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 9px;
}

.legend__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend__share {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.legend__amount {
  margin-left: 10px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.categories {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
}

.donut {
  position: relative;
  width: 128px;
  height: 128px;
  flex: 0 0 128px;
}

.donut svg {
  width: 128px;
  height: 128px;
  transform: rotate(-90deg);
}

.donut__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.donut__center strong {
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -.4px;
  font-variant-numeric: tabular-nums;
}

.donut__center span {
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
}

.legend {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.chart-card {
  padding: 16px 16px 12px;
}

.chart-card svg {
  width: 100%;
  height: 132px;
  display: block;
  overflow: visible;
}

.chart-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.insight {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 17px;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border));
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, var(--surface)), color-mix(in srgb, var(--accent) 4%, var(--surface)));
}

.insight__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: var(--accent);
}

.insight__label {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.insight__text {
  margin-top: 2px;
  font-size: 14px;
  line-height: 1.45;
}

.insight__text + .insight__text {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.goal {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
}

.goal__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 14px;
  background: var(--accent-tint);
  color: var(--accent);
}

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

.goal__text {
  margin-top: 2px;
  display: -webkit-box;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.4;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ---------- Budgets / progress ---------- */

.budgets {
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 18px;
}

.budget {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.budget__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
}

.budget__head span:first-child {
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.budget__head span:last-child {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.budget__meta {
  margin-top: 0;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.budget__action {
  align-self: flex-start;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 11px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}

.track {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 280ms ease;
}

.track i.warn { background: var(--warning); }
.track i.danger { background: var(--danger); }

.goal-card {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.goal-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 15px;
}

.goal-card__head span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.goal-card__meta {
  color: var(--muted);
  font-size: 11px;
}

.plan-meta {
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.plan-details {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.plan-details summary {
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.plan-details summary:focus-visible {
  border-radius: 4px;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.plan-details .plan-meta {
  margin-top: 6px;
}

.plan-savings-summary {
  margin-top: 8px;
  padding: 0 16px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.cashflow-badge {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.cashflow-card {
  padding: 4px 16px;
}

.cashflow-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
}

.cashflow-row:first-child {
  border-top: 0;
}

.cashflow-row span {
  min-width: 0;
  color: var(--muted);
}

.cashflow-row b {
  flex: 0 0 auto;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cashflow-row b.positive { color: var(--success); }
.cashflow-row b.negative { color: var(--danger); }

.cashflow-row--total {
  border-top-color: color-mix(in srgb, var(--accent) 38%, var(--border));
}

.cashflow-row--total span,
.cashflow-row--total b {
  color: var(--text);
  font-weight: 700;
}

.cashflow-row--total b {
  color: var(--accent);
  font-size: 15px;
}

.cashflow-row--list span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cashflow-shortfall {
  margin: 2px 0 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--danger-tint);
  color: var(--danger);
  font-size: 11px;
}

.income-list {
  padding: 4px 16px;
}

.income-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.income-row:first-child {
  border-top: 0;
}

.income-row__body {
  min-width: 0;
}

.income-row__body strong,
.income-row__amount b {
  display: block;
  font-size: 13px;
}

.income-row__body strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.income-row__body span,
.income-row__amount span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.income-row__amount {
  flex: 0 0 auto;
  text-align: right;
}

.income-row__amount b {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.plan-note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.cat-bars {
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 18px;
}

.cat-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cat-bar__head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.cat-bar__head span:last-child {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Forms ---------- */

.afford {
  padding: 18px;
}

.afford__form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.afford__input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.afford__input::placeholder {
  color: var(--muted);
}

.afford__input:focus-visible {
  border-color: var(--accent);
}

.afford__button {
  flex: 0 0 auto;
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 650;
  cursor: pointer;
  transition: filter 120ms ease, transform 120ms ease;
}

.afford__button:hover {
  filter: brightness(1.04);
}

.afford__button:active {
  transform: scale(.98);
}

.afford__result {
  min-height: 20px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.afford__form .field-error {
  flex-basis: 100%;
}

.afford__form .afford__button {
  width: auto;
}

.afford__result.yes { color: var(--success); }
.afford__result.caution { color: var(--warning-ink); }
.afford__result.no { color: var(--danger); }

.plan-form {
  margin-top: 2px;
}

.whatif-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
}

.whatif-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.whatif-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 8px;
  min-width: 0;
}

.whatif-form input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

.whatif-result {
  padding: 13px;
  border-radius: 16px;
  background: var(--surface-2);
  font-size: 12px;
  line-height: 1.5;
}

.whatif-result strong {
  display: block;
  margin-bottom: 3px;
  color: var(--accent);
  font-size: 15px;
}

.whatif-result.no strong { color: var(--danger); }
.whatif-result p { margin: 0; }
.whatif-result .whatif-meta { margin-top: 6px; color: var(--muted); font-size: 10px; }
.whatif-result:empty { display: none; }

/* ---------- Debts / piggy / subscriptions ---------- */

.debts-card {
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 18px;
}

.debts-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.debts-summary > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.debts-summary span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.debts-summary strong {
  font-family: "Space Grotesk", sans-serif;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.debts-summary strong.danger { color: var(--danger); }
.debts-summary strong.success { color: var(--success); }

.debts-note {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.debts-list {
  display: flex;
  flex-direction: column;
}

.debt-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 0;
  border-top: 1px solid var(--border);
}

.debt-row:first-child {
  padding-top: 0;
  border-top: 0;
}

.debt-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 13px;
}

.debt-icon.is-borrowed {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
}

.debt-icon.is-lent {
  background: color-mix(in srgb, var(--success) 14%, transparent);
  color: var(--success);
}

.debt-main {
  flex: 1;
  min-width: 0;
}

.debt-title {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.debt-sub {
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.debt-amount {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.debt-row--overdue .debt-amount { color: var(--danger); }

.debt-row--action {
  cursor: pointer;
  border-radius: 14px;
}

.debt-row--action:active { background: var(--surface-2); }

.debt-row--action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.piggy-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

.piggy-summary {
  font-family: "Space Grotesk", sans-serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.piggy-summary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.piggy-row {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.piggy-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.piggy-title {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.piggy-meta {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.piggy-foot {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.subs-summary .summary-tile {
  padding: 14px 12px 13px;
}

.subs-summary .summary-tile__value {
  font-size: clamp(15px, 4.4vw, 20px);
  letter-spacing: -.03em;
  overflow-wrap: normal;
  white-space: nowrap;
}

.subs-list-card {
  padding: 4px 16px;
}

.sub-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.sub-item:first-child {
  border-top: 0;
}

.sub-item__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--accent-tint);
  color: var(--accent);
}

.sub-item__body {
  flex: 1 1 auto;
  min-width: 0;
}

.sub-item__title {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.sub-item__title strong {
  overflow: hidden;
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sub-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 9px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.sub-item__amount {
  flex: 0 0 auto;
  text-align: right;
}

.sub-item__amount b {
  display: block;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sub-item__amount span {
  color: var(--muted);
  font-size: 10px;
}

.sub-item--paused {
  opacity: .72;
}

.sub-pill {
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.subs-note {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
}

.link-btn:disabled {
  opacity: .45;
  cursor: default;
}

/* ---------- Empty / errors / skeleton ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 30px 20px;
  text-align: center;
}

.empty__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: var(--surface-2);
  color: var(--accent);
}

.empty p {
  margin: 2px 0 0;
  font-size: 15px;
  font-weight: 650;
}

.empty small {
  max-width: 290px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.empty__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  margin-top: 6px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  transition: filter 120ms ease, transform 120ms ease;
}

.empty__cta:hover {
  filter: brightness(1.04);
}

.empty__cta:active {
  transform: scale(.98);
}

.empty-inline {
  padding: 4px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.budgets .empty-inline {
  padding: 0;
}

.empty-inline strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  font-size: 14px;
}

.error-card {
  padding: 26px 20px;
  text-align: center;
}

.error-card h2 {
  margin: 0 0 6px;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 20px;
  letter-spacing: -.5px;
}

.error-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.error-card button {
  margin-top: 16px;
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 650;
  cursor: pointer;
}

.skeleton-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sk {
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

.sk-hero { height: 210px; }
.sk-stat { height: 96px; }
.sk-block { height: 180px; }

.sk-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}

/* ---------- Feedback ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(106px + env(safe-area-inset-bottom, 0px));
  z-index: 120;
  transform: translateX(-50%);
  max-width: min(
    calc(100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)),
    420px
  );
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  box-shadow: var(--shadow-float);
}

.toast[hidden] { display: none; }

.toast.error {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--border));
  background: var(--danger);
  color: var(--on-danger);
  font-weight: 600;
}

.undo-banner {
  position: fixed;
  right: max(14px, env(safe-area-inset-right, 0px));
  bottom: calc(106px + env(safe-area-inset-bottom, 0px));
  left: max(14px, env(safe-area-inset-left, 0px));
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 444px;
  margin: 0 auto;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-float);
  color: var(--text);
  font-size: 12px;
}

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

.undo-banner button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.pull-indicator {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 50%;
  z-index: 130;
  transform: translateX(-50%);
  padding: 9px 15px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 650;
  box-shadow: var(--shadow-float);
}

.field-error {
  color: var(--danger);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
}

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

.detail-form input.is-invalid,
.detail-form select.is-invalid,
.ops-select.is-invalid,
.afford__input.is-invalid {
  border-color: var(--danger);
}

.error-inline {
  padding: 13px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

button:disabled {
  cursor: default;
}

button.is-busy {
  position: relative;
  cursor: progress;
  opacity: .85;
}

button.is-busy::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -1px;
  animation: spin .7s linear infinite;
}

button.is-busy:disabled {
  cursor: progress;
}

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

/* ---------- Navigation ---------- */

.dock {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: min(
    calc(
      100% - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)
    ),
    430px
  );
  transform: translateX(-50%);
  transition: opacity 160ms ease, transform 180ms ease;
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  flex: 1 1 auto;
  min-width: 0;
  gap: 2px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--tab-bg);
  box-shadow: 0 18px 46px rgba(0, 0, 0, .32);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.tabbar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 54px;
  padding: 4px 2px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0;
  cursor: pointer;
  transition: color 140ms ease, background 140ms ease;
}

.tabbar button span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.15;
}

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

.tabbar button.active {
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  color: var(--accent);
}

.fab {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 16px 40px color-mix(in srgb, var(--accent) 32%, transparent), 0 2px 0 rgba(255, 255, 255, .18) inset;
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease;
}

.fab:hover {
  filter: brightness(1.05);
}

.fab:active {
  transform: scale(.96);
}

/* ---------- Settings view ---------- */

.profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
}

.profile-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--border));
  border-radius: 20px;
  background: var(--accent-tint);
  color: var(--accent);
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -.5px;
}

.profile-main {
  min-width: 0;
  flex: 1;
}

.profile-name {
  overflow: hidden;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -.2px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  opacity: .6;
}

.settings-card {
  overflow: hidden;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 10px 16px;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
}

.settings-row:first-child {
  border-top: 0;
}

button.settings-row {
  cursor: pointer;
}

button.settings-row:hover {
  background: var(--surface-2);
}

.settings-row__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--accent);
}

.settings-row__label {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.settings-row__label strong {
  font-size: 15px;
  font-weight: 600;
}

.settings-row__label span {
  color: var(--muted);
  font-size: 12px;
}

.settings-row__value {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.settings-row__chev {
  flex: 0 0 auto;
  color: var(--muted);
}

.settings-row__swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
}

.settings-group-label {
  padding: 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.settings-version {
  padding: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  letter-spacing: .02em;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
}

.settings-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.settings-tabs {
  display: flex;
  gap: 4px;
  margin: 12px 0 16px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}

.settings-tabs button {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
}

.settings-tabs button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}

.segmented button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.segmented button.active {
  background: var(--surface);
  color: var(--text);
}

.accent-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.accent-swatch {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.accent-swatch span {
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 50%;
}

.accent-swatch.active {
  border-color: var(--text);
}

/* ---------- AI settings ---------- */

.ai-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}

.ai-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ai-main strong,
.ai-main span,
.ai-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-main strong { font-size: 13px; }
.ai-main span { color: var(--muted); font-size: 10px; }
.ai-main small { color: var(--muted); font-size: 10px; }

.ai-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ai-delete {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--danger);
  font-size: 20px;
  cursor: pointer;
}

.ai-form {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-chip {
  min-height: 34px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--accent);
  font: inherit;
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
}

.preset-chip:active {
  background: var(--accent-tint);
}

.ai-form .afford__button { width: 100%; }

.ai-form__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-check {
  margin-top: 10px;
  padding: 11px 13px;
  border-radius: 14px;
  font-size: 12px;
  line-height: 1.45;
}

.ai-check[hidden] {
  display: none;
}

.ai-check.ok {
  background: color-mix(in srgb, var(--success) 14%, transparent);
  color: var(--success);
}

.ai-check.err {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}

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

.sheet {
  position: fixed;
  top: var(--app-vv-top, 0px);
  right: 0;
  left: 0;
  height: var(--app-vvh, 100vh);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

body.sheet-open {
  overflow: hidden;
  overscroll-behavior: none;
}

html.sheet-open {
  overflow: hidden;
  overscroll-behavior: none;
}

.sheet[hidden] { display: none; }

.sheet__scrim {
  position: absolute;
  top: calc(-1 * env(safe-area-inset-top, 0px));
  right: calc(-1 * env(safe-area-inset-right, 0px));
  bottom: calc(-1 * env(safe-area-inset-bottom, 0px));
  left: calc(-1 * env(safe-area-inset-left, 0px));
  touch-action: none;
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.sheet__panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  max-height: 90vh;
  max-height: 90%;
  overflow: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 30px 30px 0 0;
  background: var(--bg-elevated);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, .55);
  animation: sheet-in .24s cubic-bezier(.2, .8, .2, 1);
}

.sheet__panel:focus {
  outline: none;
}

.sheet__panel::before {
  content: "";
  display: block;
  width: 38px;
  height: 4px;
  margin: 0 auto 8px;
  border-radius: 999px;
  background: var(--surface-3);
}

@keyframes sheet-in {
  from { transform: translateY(24px); opacity: .5; }
  to { transform: translateY(0); opacity: 1; }
}

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

.sheet__head > div:first-child {
  min-width: 0;
}

.sheet__head strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet__head .icon-btn {
  border-color: var(--border);
  background: var(--surface);
}

.sheet__hint {
  margin: 4px 0 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.sheet__skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 12px;
}

.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.quick-action {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: 64px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.quick-action:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.quick-action__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: var(--accent-tint);
  color: var(--accent);
}

.quick-action__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.quick-action__text strong {
  font-size: 15px;
  font-weight: 600;
}

.quick-action__text span {
  color: var(--muted);
  font-size: 12px;
}

.quick-action__chev {
  color: var(--muted);
}

.info-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  margin-bottom: 12px;
}

.info-card p {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.info-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.accounts-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.accounts-total {
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.account-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.account-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.account-main strong {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-main span {
  color: var(--muted);
  font-size: 11px;
}

.account-amount {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* ---------- Detail sheet ---------- */

.sheet__top {
  position: sticky;
  top: -10px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -10px 0 10px;
  padding: 10px 0 8px;
  background: var(--bg-elevated);
}

.sheet__top .sheet-type-tabs {
  flex: 1;
}

.sheet-type-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.sheet-type-tab {
  min-height: 36px;
  padding: 0 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.sheet-type-tab.active {
  background: var(--accent-tint);
  color: var(--accent);
}

.sheet-type-tab:disabled {
  opacity: .5;
  cursor: default;
}

.sheet-check {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 28%, transparent);
}

.detail-total {
  margin: 4px 0 14px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}

.detail-journals {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.detail-journal,
.attachment {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}

.detail-journal span,
.attachment {
  color: var(--muted);
  font-size: 11px;
}

.attachment-thumb {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 10px;
  object-fit: cover;
}

.attachment {
  min-width: 0;
  justify-content: flex-start;
  overflow: hidden;
}

.attachment-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-journal strong {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
  font-size: 13px;
}

.detail-journal b {
  flex: 0 0 auto;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.detail-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.detail-label,
.detail-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.detail-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-form input {
  width: 100%;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.detail-form input:focus-visible,
.detail-form select:focus-visible {
  border-color: var(--accent);
}

.detail-form__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.detail-form__row > * {
  min-width: 0;
}

.amount-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
}

.amount-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
}

.amount-card input {
  width: 100%;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -1.4px;
  font-variant-numeric: tabular-nums;
}

.amount-card input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

.detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.detail-actions .afford__button {
  flex: 1;
  min-height: 50px;
}

.danger-btn {
  flex: 1;
  min-height: 50px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border));
  border-radius: 999px;
  background: transparent;
  color: var(--danger);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.checkbox-row,
.detail-form .checkbox-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.checkbox-row input,
.detail-form .checkbox-row input {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

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

@media (min-width: 600px) {
  .sheet {
    align-items: center;
    justify-content: center;
    padding:
      max(24px, env(safe-area-inset-top, 0px))
      max(24px, env(safe-area-inset-right, 0px))
      max(24px, env(safe-area-inset-bottom, 0px))
      max(24px, env(safe-area-inset-left, 0px));
  }
  .sheet__panel {
    width: min(480px, 100%);
    max-height: min(88vh, 780px);
    max-height: min(88%, 780px);
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
    border: 1px solid var(--border);
    border-radius: 30px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, .55);
  }
  .sheet__panel::before {
    display: none;
  }
  .calendar.card {
    padding: 14px;
  }
  .calendar__weekdays,
  .calendar__grid {
    gap: 6px;
  }
  .calendar-day {
    min-height: 84px;
    padding: 8px;
  }
  .calendar-day__num {
    font-size: 13px;
  }
  .calendar-day__sum {
    font-size: 11px;
  }
  .calendar-day__payday {
    top: 8px;
    right: 8px;
  }
  .calendar__sk {
    min-height: 84px;
  }
}

@media (min-width: 900px) {
  .app {
    max-width: 920px;
    padding:
      0
      max(28px, env(safe-area-inset-right, 0px))
      calc(132px + env(safe-area-inset-bottom, 0px))
      max(28px, env(safe-area-inset-left, 0px));
  }
  .view {
    max-width: 100%;
    margin: 0;
  }
  .topbar {
    max-width: 100%;
    margin: 0;
  }
  .dock {
    width: 452px;
  }
  .hero-value {
    font-size: 48px;
  }
  .report-hero__total {
    font-size: 44px;
  }
  .donut-panel {
    flex-direction: row;
    align-items: center;
    gap: 26px;
  }
  .donut-panel .donut {
    width: 250px;
    height: 250px;
    flex-basis: 250px;
  }
  .donut-panel .donut svg {
    width: 250px;
    height: 250px;
  }
}

@media (min-width: 1024px) {
  .app {
    max-width: 1240px;
    padding:
      0
      max(40px, env(safe-area-inset-right, 0px))
      64px
      calc(168px + env(safe-area-inset-left, 0px));
  }
  .dock {
    top: 50%;
    left: max(20px, calc((100vw - 1240px) / 2 + 16px));
    bottom: auto;
    flex-direction: column;
    align-items: stretch;
    width: 112px;
    transform: translateY(-50%);
    gap: 12px;
  }
  .tabbar {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 8px;
    border-radius: 28px;
  }
  .tabbar button {
    min-height: 58px;
    font-size: 11px;
    border-radius: 20px;
  }
  .fab {
    align-self: center;
    flex-basis: 62px;
    width: 62px;
    height: 62px;
  }
  .summary-card {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .summary-card.summary-card--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .calendar.card {
    padding: 18px;
  }
  .calendar__weekdays,
  .calendar__grid {
    gap: 8px;
  }
  .calendar-day {
    min-height: 104px;
    gap: 4px;
    padding: 10px;
    border-radius: 14px;
  }
  .calendar-day__num {
    font-size: 14px;
  }
  .calendar-day__sum {
    font-size: 12px;
  }
  .calendar-day__payday {
    top: 10px;
    right: 10px;
  }
  .calendar__sk {
    min-height: 104px;
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ops-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px 16px;
  }
  .ops-toolbar .ops-search {
    grid-column: 1 / -1;
  }
  .ops-toolbar .ops-select {
    min-width: 200px;
  }
}

@media (max-width: 899px) {
  html {
    scrollbar-width: none;
  }
  html::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 380px) {
  .app {
    padding-left: max(13px, env(safe-area-inset-left, 0px));
    padding-right: max(13px, env(safe-area-inset-right, 0px));
  }
  .hero-value,
  .report-hero__total {
    font-size: 36px;
  }
  .whatif-row {
    grid-template-columns: 1fr;
  }
  .categories {
    flex-direction: column;
    align-items: flex-start;
  }
  .stats {
    gap: 8px;
  }
  .summary-tile {
    padding: 15px;
  }
  .summary-tile__value {
    font-size: 18px;
  }
  .calendar.card {
    padding: 7px;
  }
  .calendar__weekdays,
  .calendar__grid {
    gap: 3px;
  }
  .calendar__weekdays span {
    font-size: 9px;
  }
  .calendar-day {
    min-height: 60px;
    padding: 5px 3px;
    border-radius: 10px;
  }
  .calendar-day__num {
    font-size: 11px;
  }
  .calendar-day__sum {
    font-size: 11px;
    letter-spacing: -.02em;
  }
  .calendar-day__payday {
    top: 4px;
    right: 4px;
    width: 6px;
    height: 6px;
  }
  .calendar__sk {
    min-height: 60px;
    border-radius: 10px;
  }
  .calendar-summary .summary-tile {
    padding: 13px 10px;
  }
  .fab {
    flex-basis: 60px;
    width: 60px;
    height: 60px;
  }
  .dock {
    width: min(
      calc(
        100% - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)
      ),
      430px
    );
    gap: 6px;
  }
  .tabbar {
    gap: 1px;
    padding: 5px;
  }
  .tabbar button {
    min-height: 52px;
    padding: 4px 1px;
    font-size: 8.5px;
    letter-spacing: 0;
  }
}

@media (max-width: 340px) {
  .wallet-btn strong {
    max-width: 132px;
  }
  .view-title h2 {
    font-size: 24px;
  }
  .calendar-day {
    padding: 5px 1px;
  }
  .calendar-day__sum--millions {
    font-size: 10px;
  }
  .fab {
    flex-basis: 56px;
    width: 56px;
    height: 56px;
  }
  .tabbar button {
    font-size: 8px;
  }
}

/* ---------- iOS / Safari: fields, touch targets, keyboard ---------- */

/* Re-assert the custom date indicator after the form background shorthands. */
input[type="date"],
input[type="time"],
input[type="datetime-local"] {
  padding-right: 38px;
  background-image: var(--date-icon);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px 18px;
}

@media (max-width: 1023px) {
  /* The dock would otherwise float over the field the keyboard is editing. */
  body.keyboard-open .dock {
    opacity: 0;
    transform: translate(-50%, calc(100% + 24px));
    pointer-events: none;
  }
}

/* Small-viewport fallback keeps a keyboard-sized sheet usable if JS has not set --app-vvh. */
@supports (height: 100svh) {
  .sheet {
    height: var(--app-vvh, 100svh);
  }
}

@media (max-width: 899px), (hover: none) and (pointer: coarse) {
  /* iOS zooms any focused field below 16px. Keep every editable field at
     16px on phones/tablets; the 36px amount hero keeps its own size. */
  .ops-search input,
  .ops-select,
  .afford__input,
  .whatif-form input,
  .whatif-form select,
  .detail-form label input,
  .detail-form label select,
  .detail-form > input,
  .detail-form > select {
    font-size: 16px;
  }

  .ops-search {
    min-height: 48px;
  }

  /* Comfortable touch targets where the layout has room for them. */
  .link-btn,
  .chip,
  .budget__action,
  .sheet-type-tab,
  .settings-tabs button,
  .undo-banner button,
  .ops-more__btn,
  .preset-chip {
    min-height: 44px;
  }

  .ai-delete {
    width: 44px;
    height: 44px;
  }

  .whatif-form input[type="date"] {
    padding-right: 32px;
    background-position: right 8px center;
    background-size: 16px 16px;
  }

  .detail-form input[type="date"] {
    padding-right: 36px;
  }
}

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

/* iOS < 16.2 has no color-mix(): keep the surfaces visible with token/plain
   fallbacks instead of dropping the whole declaration. Supporting browsers
   keep the exact color-mix() values above. */
@supports not (color: color-mix(in srgb, #000 50%, #fff)) {
  .icon-btn--soft {
    background: var(--surface);
  }

  .topbar {
    background: linear-gradient(180deg, var(--bg) 0%, var(--bg) 72%, transparent 100%);
  }

  .month-strip {
    background: var(--surface);
  }

  .pill.warn {
    background: var(--warning-tint);
  }

  .summary-tile:nth-child(2n) {
    background: var(--surface-2);
  }

  .chip-row .chip.active {
    border-color: var(--border-strong);
  }

  .ops-mode {
    background: var(--surface-2);
  }

  .calendar-day {
    border-color: var(--border-strong);
    background: var(--surface-2);
  }

  .calendar__payday-note {
    border-color: var(--border-strong);
  }

  .calendar__note--filters {
    background: var(--surface-2);
  }

  .calendar__note--warn {
    border-color: var(--warning-ink);
  }

  .ops-mode__chip.active {
    border-color: var(--border-strong);
  }

  .report-tab.active {
    box-shadow: 0 8px 20px rgba(0, 0, 0, .22);
  }

  .insight {
    border-color: var(--border);
    background: var(--surface);
  }

  .insight__icon {
    background: var(--accent-tint);
  }

  .debt-icon.is-borrowed {
    background: var(--danger-tint);
  }

  .debt-icon.is-lent {
    background: var(--success-tint);
  }

  .subs-warn {
    background: var(--warning-tint);
  }

  .toast.error {
    border-color: var(--danger);
  }

  .error-inline {
    background: var(--danger-tint);
  }

  .tabbar button.active {
    background: var(--accent-tint);
  }

  .fab {
    box-shadow: 0 16px 40px rgba(0, 0, 0, .35), 0 2px 0 rgba(255, 255, 255, .18) inset;
  }

  .profile-avatar {
    border-color: var(--border-strong);
  }

  .ai-check.ok {
    background: var(--success-tint);
  }

  .ai-check.err {
    background: var(--danger-tint);
  }

  .sheet-check {
    box-shadow: 0 10px 24px rgba(0, 0, 0, .28);
  }

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

  .ops-search:focus-within {
    box-shadow: 0 0 0 3px var(--accent-tint);
  }
}
