:root {
  --bg: #f2f4ef;
  --surface: #ffffff;
  --text: #1f2a22;
  --muted: #607065;
  --brand: #1f8a50;
  --brand-soft: #dff4e8;
  --accent: #d37a2a;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(22, 35, 24, 0.08);
  --radius: 16px;
  --bg-grad-1: #e3f6eb;
  --bg-grad-2: #f6ead9;
  --phone-bg: #fbfcf9;
  --phone-border: #dce4dd;
  --topbar-bg: linear-gradient(160deg, #f5fbf7, #eef4eb);
  --topbar-border: #e0e8e1;
  --tab-bg: #f7faf6;
  --tab-border: #e7eee8;
  --tab-btn-bg: #ffffff;
  --tab-btn-border: #d1ded4;
  --tab-btn-text: #355043;
  --card-border: #dde8df;
  --input-bg: #fcfffc;
  --input-border: #d5e1d8;
  --nav-bg: rgba(251, 253, 250, 0.95);
  --nav-border: #dce7de;
  --ghost-bg: #edf5f0;
  --ghost-text: #2f5540;
  --warn-bg: #fff4eb;
  --warn-border: #ffd3ae;
  --warn-text: #9e4c12;
  --pill-bg: #f5efe7;
  --pill-border: #edd7bf;
  --pill-text: #8a4e1b;
  --chart-border: #cfdfd2;
  --chart-grid: #eef3ef;
  --spark-border: #d8e4da;
  --donut-hole-border: #e5eee7;
}

body[data-theme="dark"] {
  --bg: #111612;
  --surface: #1b2320;
  --text: #e7f1ea;
  --muted: #9fb4a5;
  --brand: #45c97d;
  --brand-soft: #1e3528;
  --accent: #e0a15f;
  --danger: #ff6b61;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  --bg-grad-1: #1d2f25;
  --bg-grad-2: #2a2318;
  --phone-bg: #161d1a;
  --phone-border: #2a3931;
  --topbar-bg: linear-gradient(160deg, #1a241f, #1d241f);
  --topbar-border: #2d3a33;
  --tab-bg: #151c18;
  --tab-border: #2b3931;
  --tab-btn-bg: #1c2621;
  --tab-btn-border: #33463c;
  --tab-btn-text: #bad0c1;
  --card-border: #2b3931;
  --input-bg: #121915;
  --input-border: #32433a;
  --nav-bg: rgba(21, 28, 24, 0.94);
  --nav-border: #2a3831;
  --ghost-bg: #24352d;
  --ghost-text: #b8d8c5;
  --warn-bg: #2e2318;
  --warn-border: #6e4d2f;
  --warn-text: #ffcf9e;
  --pill-bg: #2c261f;
  --pill-border: #5b4a35;
  --pill-text: #f0c390;
  --chart-border: #32423a;
  --chart-grid: #29352f;
  --spark-border: #32423a;
  --donut-hole-border: #3a4b42;
}

/* ========== Color Themes ========== */
/* Green (default) — no extra selector needed */

/* Blue */
body[data-color="blue"] {
  --brand: #2563eb; --brand-soft: #dbeafe;
  --bg-grad-1: #e0ecff; --bg-grad-2: #f0e6d9;
  --ghost-bg: #eaf1fd; --ghost-text: #1e3a5f;
}
body[data-theme="dark"][data-color="blue"] {
  --brand: #60a5fa; --brand-soft: #1e2d44;
  --bg-grad-1: #1a2744; --bg-grad-2: #2a2318;
  --ghost-bg: #1c2d42; --ghost-text: #a8cbf0;
}

/* Purple */
body[data-color="purple"] {
  --brand: #7c3aed; --brand-soft: #ede9fe;
  --bg-grad-1: #ece5ff; --bg-grad-2: #f6ead9;
  --ghost-bg: #f0ebfd; --ghost-text: #3b1d72;
}
body[data-theme="dark"][data-color="purple"] {
  --brand: #a78bfa; --brand-soft: #2d1f57;
  --bg-grad-1: #261d44; --bg-grad-2: #2a2318;
  --ghost-bg: #28204a; --ghost-text: #c4b5f0;
}

/* Orange */
body[data-color="orange"] {
  --brand: #d97706; --brand-soft: #fef3c7;
  --bg-grad-1: #fef0d9; --bg-grad-2: #fde8e8;
  --ghost-bg: #fef6e8; --ghost-text: #6b3a06;
}
body[data-theme="dark"][data-color="orange"] {
  --brand: #fbbf24; --brand-soft: #3d2e10;
  --bg-grad-1: #352a14; --bg-grad-2: #2a2318;
  --ghost-bg: #342a16; --ghost-text: #f0d898;
}

/* Pink */
body[data-color="pink"] {
  --brand: #db2777; --brand-soft: #fce7f3;
  --bg-grad-1: #fde4f0; --bg-grad-2: #f6ead9;
  --ghost-bg: #fdf0f6; --ghost-text: #6b1040;
}
body[data-theme="dark"][data-color="pink"] {
  --brand: #f472b6; --brand-soft: #451230;
  --bg-grad-1: #3a1430; --bg-grad-2: #2a2318;
  --ghost-bg: #3a1530; --ghost-text: #f0a5cd;
}

/* Teal */
body[data-color="teal"] {
  --brand: #0d9488; --brand-soft: #ccfbf1;
  --bg-grad-1: #d5f5f0; --bg-grad-2: #f6ead9;
  --ghost-bg: #e6faf6; --ghost-text: #134e48;
}
body[data-theme="dark"][data-color="teal"] {
  --brand: #2dd4bf; --brand-soft: #123332;
  --bg-grad-1: #142f2e; --bg-grad-2: #2a2318;
  --ghost-bg: #16302f; --ghost-text: #90e8d8;
}

/* ========== Font Themes ========== */
body[data-font="rounded"] {
  font-family: "SF Pro Rounded", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}
body[data-font="serif"] {
  font-family: "Georgia", "Noto Serif SC", "STSongti-SC", "Songti SC", serif;
}
body[data-font="mono"] {
  font-family: "SF Mono", "Menlo", "Noto Sans SC", monospace;
}
body[data-font="fancy"] {
  font-family: "Snell Roundhand", "PingFang SC", "Noto Sans SC", cursive;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 10% 10%, var(--bg-grad-1) 0%, transparent 28%),
    radial-gradient(circle at 92% 18%, var(--bg-grad-2) 0%, transparent 24%),
    var(--bg);
  color: var(--text);
  font-family: "Avenir Next", "PingFang SC", "Noto Sans SC", sans-serif;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.phone {
  width: min(420px, 100%);
  height: min(880px, 92vh);
  background: var(--phone-bg);
  border: 1px solid var(--phone-border);
  border-radius: 32px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 18px 10px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
}

.topbar > button {
  flex-shrink: 0;
}

.title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.3px;
  background: linear-gradient(135deg, #1a7a45, #2eab63);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.badge {
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid #b9e6cb;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
}

.theme-toggle {
  border: 1px solid var(--tab-btn-border);
  background: var(--tab-btn-bg);
  color: var(--tab-btn-text);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: all .2s ease;
}
.theme-toggle:active {
  transform: scale(0.95);
}

.screen {
  display: none;
  height: calc(100% - 86px);
  overflow-y: auto;
  padding: 16px;
  padding-bottom: 90px;
  animation: fade 0.28s ease;
}

.screen.active { display: block; }

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

/* ---- Stagger entrance for cards ---- */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.screen.active .card {
  animation: cardIn .35s cubic-bezier(.22,.61,.36,1) both;
}
.screen.active .card:nth-child(1) { animation-delay: 0s; }
.screen.active .card:nth-child(2) { animation-delay: .06s; }
.screen.active .card:nth-child(3) { animation-delay: .12s; }
.screen.active .card:nth-child(4) { animation-delay: .18s; }
.screen.active .card:nth-child(5) { animation-delay: .24s; }

/* ---- Stagger entrance for list items ---- */
@keyframes itemSlide {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}
.list .item.animate-in {
  animation: itemSlide .3s cubic-bezier(.22,.61,.36,1) both;
}

/* ---- FAB breathing glow ---- */
@keyframes fabGlow {
  0%, 100% { box-shadow: 0 6px 20px rgba(31, 138, 80, 0.4); }
  50% { box-shadow: 0 6px 28px rgba(31, 138, 80, 0.55), 0 0 0 6px rgba(31, 138, 80, 0.08); }
}
.fab { animation: fabGlow 2.8s ease-in-out infinite; }
.fab:active { animation: none; }

/* ---- Number countup visual hint ---- */
@keyframes numPop {
  0% { transform: scale(0.7); opacity: 0; }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}
.num-animate {
  display: inline-block;
  animation: numPop .4s cubic-bezier(.22,.61,.36,1) both;
}

/* ---- Donut spin-in ---- */
@keyframes donutSpin {
  from { transform: rotate(-90deg) scale(0.85); opacity: 0; }
  to { transform: rotate(0) scale(1); opacity: 1; }
}
.donut.animate-in, .month-ring.animate-in {
  animation: donutSpin .6s cubic-bezier(.22,.61,.36,1) both;
}

/* ---- Sparkline draw ---- */
@keyframes sparkDraw {
  from { stroke-dashoffset: 2000; }
  to { stroke-dashoffset: 0; }
}
#reportSparkSvg polyline {
  stroke-dasharray: 2000;
  stroke-dashoffset: 2000;
}
#reportSparkSvg polyline.animate-in {
  animation: sparkDraw 1.2s cubic-bezier(.22,.61,.36,1) forwards;
}

/* ---- Spark area fade ---- */
@keyframes areaFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
#sparkArea {
  animation: areaFade .8s .4s cubic-bezier(.22,.61,.36,1) both;
}

/* ---- Budget bar fill ---- */
@keyframes barGrow {
  from { width: 0%; }
}
.budget-bar-fill.animate-in {
  animation: barGrow .6s cubic-bezier(.22,.61,.36,1) both;
}

/* ---- Date group header entrance ---- */
@keyframes headerFade {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.date-group-header.animate-in {
  animation: headerFade .25s cubic-bezier(.22,.61,.36,1) both;
}

/* ---- Chip pop on select ---- */
@keyframes chipPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.1); }
  100% { transform: scale(1); }
}
.chip.active { animation: chipPop .25s ease; }

/* ---- Nav icon bounce on active ---- */
@keyframes navBounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  70% { transform: scale(0.92); }
  100% { transform: scale(1); }
}
.bottom button.active .nav-icon {
  animation: navBounce .35s cubic-bezier(.22,.61,.36,1);
}

/* ---- Warn text slide ---- */
@keyframes warnSlide {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.warn.animate-in {
  animation: warnSlide .35s .15s cubic-bezier(.22,.61,.36,1) both;
}

/* ---- Category-chart-item stagger ---- */
@keyframes budgetItemIn {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}
.category-chart-item.animate-in {
  animation: budgetItemIn .35s cubic-bezier(.22,.61,.36,1) both;
}

/* ---- Legend items stagger ---- */
@keyframes legendFade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
#reportLegend > div {
  animation: legendFade .3s cubic-bezier(.22,.61,.36,1) both;
}
#reportLegend > div:nth-child(1) { animation-delay: .05s; }
#reportLegend > div:nth-child(2) { animation-delay: .1s; }
#reportLegend > div:nth-child(3) { animation-delay: .15s; }
#reportLegend > div:nth-child(4) { animation-delay: .2s; }
#reportLegend > div:nth-child(5) { animation-delay: .25s; }
#reportLegend > div:nth-child(6) { animation-delay: .3s; }
#reportLegend > div:nth-child(7) { animation-delay: .35s; }

/* ---- Toast notification ---- */
@keyframes toastIn {
  0% { transform: translateY(20px) scale(0.9); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes toastOut {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-12px) scale(0.9); opacity: 0; }
}
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(31, 138, 80, 0.92);
  color: white;
  padding: 12px 28px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  z-index: 999;
  pointer-events: none;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(31, 138, 80, 0.3);
  animation: toastIn .25s cubic-bezier(.22,.61,.36,1), toastOut .25s 1s cubic-bezier(.22,.61,.36,1) forwards;
}

/* ---- Screen slide for month switch ---- */
@keyframes slideLeft {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slideRight {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}
.screen.slide-left { animation: slideLeft .3s cubic-bezier(.22,.61,.36,1); }
.screen.slide-right { animation: slideRight .3s cubic-bezier(.22,.61,.36,1); }

/* ========== Theme Picker ========== */
.theme-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 12px 0 8px;
}
.theme-section-title:first-child { margin-top: 0; }
.settings-group-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.settings-subhint {
  margin-top: 4px;
  margin-bottom: 2px;
  font-size: 12px;
  color: var(--muted);
}
.settings-link-item {
  cursor: pointer;
}
.settings-link-item strong {
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}
.color-swatches {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  position: relative;
  transition: transform .15s, border-color .2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.color-swatch:active { transform: scale(0.9); }
.color-swatch.active {
  border-color: var(--text);
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.color-swatch.active::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.font-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.font-option {
  border: 1.5px solid var(--card-border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.font-option:active { transform: scale(0.96); }
.font-option.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  font-weight: 600;
}
.font-option[data-font="default"] { font-family: "Avenir Next", "PingFang SC", sans-serif; }
.font-option[data-font="rounded"] { font-family: "SF Pro Rounded", "PingFang SC", system-ui, sans-serif; }
.font-option[data-font="serif"] { font-family: "Georgia", "Noto Serif SC", serif; }
.font-option[data-font="mono"] { font-family: "SF Mono", "Menlo", monospace; }
.mode-toggle-row {
  display: flex;
  gap: 8px;
}
.mode-btn {
  flex: 1;
  border: 1.5px solid var(--card-border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}
.mode-btn:active { transform: scale(0.97); }
.mode-btn.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}
.theme-preview {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--card-border);
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
}
.theme-preview-brand {
  display: inline-block;
  background: var(--brand);
  color: white;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 4px;
}

/* ========== Onboarding Guide ========== */
.onboard-overlay {
  position: absolute;
  inset: 0;
  z-index: 1000;
  pointer-events: auto;
  transition: opacity .35s ease;
}
.onboard-overlay[hidden] { display: none !important; }
.onboard-overlay.fade-out { opacity: 0; pointer-events: none; }

.onboard-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 16, 10, 0.35);
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
  transition: background .35s ease;
}

/* Welcome: bottom card floating over the real app */
.onboard-welcome {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 24px calc(env(safe-area-inset-bottom, 0px) + 24px);
  background: white;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.12);
  animation: onboardSheetUp .45s cubic-bezier(.22,.61,.36,1);
}
body[data-theme="dark"] .onboard-welcome {
  background: #1a2a1e;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.35);
}
.onboard-welcome-handle {
  width: 36px;
  height: 4px;
  border-radius: 4px;
  background: var(--muted, #b0c4b5);
  opacity: 0.3;
  margin-bottom: 16px;
}
.onboard-welcome-emoji {
  font-size: 52px;
  animation: onboardBounce .8s .2s ease both;
}
.onboard-welcome h2 {
  font-size: 22px;
  font-weight: 800;
  margin: 12px 0 6px;
  color: var(--text, #1f2a22);
  background: linear-gradient(135deg, #1a7a45, #3eaf6a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.onboard-welcome > p {
  font-size: 13px;
  color: var(--muted, #607065);
  line-height: 1.6;
  margin: 0 0 18px;
  max-width: 260px;
}
.onboard-features {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
}
.onboard-feat {
  background: var(--bg, #f0f6f2);
  border: 1px solid var(--card-border, rgba(30,56,38,0.06));
  border-radius: 14px;
  padding: 12px 10px 8px;
  width: 86px;
  text-align: center;
  opacity: 0;
  animation: onboardFeatIn .35s ease forwards;
}
body[data-theme="dark"] .onboard-feat {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.08);
}
.onboard-feat:nth-child(1) { animation-delay: .35s; }
.onboard-feat:nth-child(2) { animation-delay: .48s; }
.onboard-feat:nth-child(3) { animation-delay: .61s; }
.onboard-feat-icon { font-size: 26px; margin-bottom: 5px; }
.onboard-feat-label { font-size: 11px; color: var(--muted, #607065); font-weight: 600; }
.onboard-btn {
  border: 0;
  background: linear-gradient(135deg, #1f8a50, #3eaf6a);
  color: white;
  font-size: 16px;
  font-weight: 700;
  padding: 14px 48px;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(31,138,80,0.35);
  transition: transform .12s, box-shadow .12s;
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 300px;
}
.onboard-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  transform: translateX(-100%);
  animation: onboardShimmer 2s 1s ease infinite;
}
.onboard-btn:active { transform: scale(0.97); box-shadow: 0 3px 14px rgba(31,138,80,0.25); }
.onboard-btn-skip {
  border: 0;
  background: transparent;
  color: var(--muted, #8fa897);
  font-size: 13px;
  margin-top: 12px;
  cursor: pointer;
  padding: 6px 16px;
  transition: color .15s;
}
.onboard-btn-skip:active { color: var(--brand, #1f8a50); }

/* Step spotlight with glow */
.onboard-spot {
  position: absolute;
  border-radius: 16px;
  box-shadow: 0 0 0 4000px rgba(8, 16, 10, 0.42),
              0 0 0 3px rgba(126,232,168,0.55),
              0 0 24px 6px rgba(31,138,80,0.2);
  transition: all .4s cubic-bezier(.22,.61,.36,1);
  z-index: 1001;
  pointer-events: none;
  animation: onboardSpotPulse 2s ease-in-out infinite;
}
.onboard-spot.circle { border-radius: 50%; }

/* Tooltip bubble */
.onboard-tip {
  position: absolute;
  z-index: 1002;
  background: white;
  border-radius: 18px;
  padding: 20px 22px 14px;
  max-width: 280px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.04);
  animation: onboardFadeUp .35s cubic-bezier(.22,.61,.36,1) both;
}
body[data-theme="dark"] .onboard-tip {
  background: #1e2a22;
  box-shadow: 0 16px 48px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.06);
}
.onboard-tip::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background: inherit;
  border-radius: 2px;
  transform: rotate(45deg);
}
.onboard-tip.arrow-top::before {
  top: -6px;
  left: 32px;
  box-shadow: -1px -1px 1px rgba(0,0,0,0.04);
}
.onboard-tip.arrow-bottom::before {
  bottom: -6px;
  left: 32px;
  box-shadow: 1px 1px 1px rgba(0,0,0,0.04);
}
.onboard-tip-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.onboard-tip-emoji {
  font-size: 30px;
  line-height: 1;
}
.onboard-tip-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #1f2a22;
}
body[data-theme="dark"] .onboard-tip-header h3 { color: #e8f5ec; }
.onboard-tip-step {
  font-size: 11px;
  color: #1f8a50;
  font-weight: 600;
  background: rgba(31,138,80,0.08);
  padding: 2px 8px;
  border-radius: 6px;
  margin-left: auto;
  white-space: nowrap;
}
.onboard-tip p {
  margin: 0 0 14px;
  font-size: 13px;
  color: #607065;
  line-height: 1.6;
}
body[data-theme="dark"] .onboard-tip p { color: #9bb3a2; }
.onboard-tip-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.onboard-tip-btns {
  display: flex;
  gap: 8px;
  align-items: center;
}
.onboard-dots {
  display: flex;
  gap: 5px;
}
.onboard-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d1ded4;
  transition: all .25s cubic-bezier(.22,.61,.36,1);
}
body[data-theme="dark"] .onboard-dots span { background: #3a4e3f; }
.onboard-dots span.active {
  background: #1f8a50;
  width: 20px;
  border-radius: 4px;
}
.onboard-tip-back {
  border: 0;
  background: transparent;
  color: #8fa897;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: color .12s;
}
.onboard-tip-back:active { color: #1f8a50; }
.onboard-tip-next {
  border: 0;
  background: linear-gradient(135deg, #1f8a50, #2ea85e);
  color: white;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 20px;
  border-radius: 11px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(31,138,80,0.25);
  transition: transform .12s;
}
.onboard-tip-next:active { transform: scale(0.95); }
.onboard-tip-skip {
  border: 0;
  background: transparent;
  color: #b0c4b5;
  font-size: 12px;
  padding: 4px 0;
  cursor: pointer;
  margin-top: 8px;
  text-align: center;
  display: block;
  width: 100%;
}
body[data-theme="dark"] .onboard-tip-skip { color: #5a7360; }

@keyframes onboardFadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes onboardBounce {
  0% { transform: scale(0) rotate(-15deg); }
  50% { transform: scale(1.15) rotate(5deg); }
  70% { transform: scale(0.9) rotate(-3deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes onboardFeatIn {
  from { opacity: 0; transform: translateY(12px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes onboardShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
@keyframes onboardSheetUp {
  from { opacity: 0; transform: translateY(100%); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes onboardSpotPulse {
  0%, 100% { box-shadow: 0 0 0 4000px rgba(8,16,10,0.42), 0 0 0 3px rgba(126,232,168,0.55), 0 0 24px 6px rgba(31,138,80,0.2); }
  50% { box-shadow: 0 0 0 4000px rgba(8,16,10,0.42), 0 0 0 5px rgba(126,232,168,0.35), 0 0 32px 10px rgba(31,138,80,0.15); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(30, 56, 38, 0.04), 0 0 0 0.5px rgba(30, 56, 38, 0.02);
  transition: transform .15s ease, box-shadow .15s ease;
}

.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.muted { color: var(--muted); font-size: 13px; }
.money { font-weight: 700; font-size: 22px; letter-spacing: 0.2px; }
.money.small { font-size: 17px; }

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.pill {
  display: inline-block;
  background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 10%, var(--pill-bg)), var(--pill-bg));
  color: var(--pill-text);
  border: 1px solid var(--pill-border);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
  line-height: 1.5;
}

.list .item {
  border-top: 1px solid color-mix(in srgb, var(--card-border) 60%, transparent);
  padding: 12px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background .12s;
}
.list .item:active {
  background: color-mix(in srgb, var(--brand) 5%, transparent);
}

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

.item-emoji {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 10%, white), color-mix(in srgb, var(--brand) 5%, white));
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}
[data-theme="dark"] .item-emoji {
  background: linear-gradient(135deg, #2a3d2e, #233028);
}
.item-body {
  flex: 1;
  min-width: 0;
}
.item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.item-note {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-amount {
  font-size: 16px;
  font-weight: 700;
  color: #d35a2a;
  white-space: nowrap;
}

.fab {
  position: absolute;
  bottom: 58px;
  right: 16px;
  border: 0;
  background: linear-gradient(140deg, #1f8a50, #3e9f67);
  color: white;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 28px;
  line-height: 0;
  box-shadow: 0 6px 20px rgba(31, 138, 80, 0.4);
  cursor: pointer;
  z-index: 10;
  transition: transform .15s ease, box-shadow .15s ease;
}
.fab:active {
  transform: scale(0.92);
  box-shadow: 0 3px 12px rgba(31, 138, 80, 0.3);
}

.bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  border-top: 1px solid var(--nav-border);
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  justify-content: space-around;
  padding: 6px 4px 8px;
  gap: 2px;
}

.bottom button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  padding: 4px 0 2px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all .15s ease;
}
.bottom button .nav-icon {
  font-size: 20px;
  line-height: 1;
}

.bottom button.active {
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 8%, transparent);
}

.input {
  width: 100%;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 6px;
  margin-bottom: 10px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent);
}

.btn {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.btn.primary { background: linear-gradient(135deg, #1f8a50, #2ea85e); color: white; box-shadow: 0 3px 10px rgba(31, 138, 80, 0.25); }
.btn.primary:active { transform: scale(0.98); }
.btn.ghost { background: var(--ghost-bg); color: var(--ghost-text); margin-top: 8px; }
.btn.ghost:active { transform: scale(0.98); }

.bars {
  display: grid;
  gap: 8px;
}

.bar {
  width: 100%;
  height: 8px;
  border-radius: 99px;
  background: #ecf1ed;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #3ea868, #209c56);
}

.bar > span.warned { background: linear-gradient(90deg, #d37a2a, #c26012); }

.clickable-card {
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.clickable-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(30, 56, 38, 0.10);
}

.month-chart {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}

.month-ring {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: conic-gradient(#1f8a50 0 67%, color-mix(in srgb, var(--brand) 20%, #e1ebe3) 67% 100%);
  position: relative;
  margin: 0 auto;
  box-shadow: 0 4px 15px rgba(31, 138, 80, 0.12);
  transition: background .5s ease;
}

.month-ring::after {
  content: "";
  position: absolute;
  inset: 16px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--donut-hole-border);
}

.month-ring-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 1;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.jump-link {
  margin-top: 10px;
  width: 100%;
  border: 1px dashed color-mix(in srgb, var(--brand) 40%, var(--tab-btn-border));
  background: color-mix(in srgb, var(--brand) 4%, var(--ghost-bg));
  color: var(--brand);
  border-radius: 10px;
  padding: 9px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s ease;
}
.jump-link:active {
  transform: scale(0.98);
  background: color-mix(in srgb, var(--brand) 8%, var(--ghost-bg));
}

.category-chart-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.category-chart-item {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--input-bg);
  cursor: pointer;
  transition: box-shadow .15s;
}
.category-chart-item:active {
  box-shadow: 0 0 0 2px var(--brand);
}

.budget-bar-wrap {
  height: 22px;
  border-radius: 99px;
  background: #e7eee9;
  overflow: hidden;
  margin-top: 8px;
  position: relative;
}
[data-theme="dark"] .budget-bar-wrap {
  background: #2a3a2e;
}
.budget-bar-fill {
  height: 100%;
  border-radius: 99px;
  min-width: 2px;
  transition: width .4s ease;
}
.budget-bar-fill.normal {
  background: linear-gradient(90deg, #3ea868, #209c56);
}
.budget-bar-fill.warn {
  background: linear-gradient(90deg, #e8a838, #d38a2a);
}
.budget-bar-fill.over {
  background: linear-gradient(90deg, #d35a2a, #c23012);
}
.budget-bar-label {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 600;
  color: #555;
}
[data-theme="dark"] .budget-bar-label {
  color: #bbb;
}

.budget-cat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
}
.budget-cat-name {
  font-size: 15px;
  font-weight: 600;
}
.budget-cat-nums {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  line-height: 1.4;
}
.budget-cat-remain {
  font-size: 14px;
  font-weight: 700;
}
.budget-cat-remain.positive { color: var(--brand); }
.budget-cat-remain.negative { color: #d35a2a; }
.budget-cat-remain.zero { color: var(--muted); }

.chart {
  height: 160px;
  border: 1px dashed var(--chart-border);
  border-radius: 12px;
  background:
    linear-gradient(to top, color-mix(in srgb, var(--brand) 10%, transparent) 0 40%, var(--surface) 40% 100%),
    repeating-linear-gradient(90deg, transparent, transparent 20px, var(--chart-grid) 20px, var(--chart-grid) 21px);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.donut-wrap {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
}

.donut {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: conic-gradient(
    #1f8a50 0 42%,
    #4aa66e 42% 66%,
    #d37a2a 66% 86%,
    #a5b6aa 86% 100%
  );
  position: relative;
  margin: 0 auto;
  box-shadow: 0 4px 15px rgba(31, 138, 80, 0.12);
  transition: background .5s ease;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 18px;
  background: var(--surface);
  border-radius: 50%;
  border: 1px solid var(--donut-hole-border);
}

.legend {
  display: grid;
  gap: 7px;
  font-size: 12px;
  color: #4d6357;
}

.legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.spark {
  height: 120px;
  border-radius: 12px;
  border: 1px solid var(--spark-border);
  background:
    linear-gradient(to top, rgba(31, 138, 80, 0.10), rgba(31, 138, 80, 0.02)),
    linear-gradient(to right, var(--chart-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--chart-grid) 1px, transparent 1px),
    var(--surface);
  background-size: auto, 24px 100%, 100% 24px, auto;
  position: relative;
  overflow: hidden;
}

.spark svg {
  position: absolute;
  inset: 0;
}

.mini-bars {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  height: 90px;
}

.mini-bars span {
  width: 12%;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, #3ca76a, #1f8a50);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.chip {
  text-align: center;
  padding: 10px 4px;
  border: 1px solid var(--tab-btn-border);
  border-radius: 12px;
  background: var(--tab-btn-bg);
  color: var(--tab-btn-text);
  font-size: 12px;
  line-height: 1.25;
  cursor: pointer;
  transition: all .15s ease;
}
.chip:active {
  transform: scale(0.95);
}

.chip.active {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 8%, var(--tab-btn-bg));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 25%, transparent);
  color: var(--brand);
  font-weight: 700;
}

.inline-form {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}

.mini-btn {
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  padding: 10px 12px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 700;
}

.mini-btn.ghost {
  background: transparent;
  border: 1px solid var(--tab-btn-border);
  color: var(--muted);
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  border: 1px solid var(--tab-btn-border);
  border-radius: 999px;
  width: 28px;
  height: 28px;
  background: var(--tab-btn-bg);
  color: var(--tab-btn-text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(11, 19, 14, 0.38);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 99;
}

.modal-mask[hidden] {
  display: none !important;
}

.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(11, 19, 14, 0.32);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: end;
  justify-content: center;
  padding: 10px;
  z-index: 98;
}

.sheet-mask[hidden] {
  display: none !important;
}

.sheet-panel {
  width: min(420px, 100%);
  max-height: min(86vh, 720px);
  overflow-y: auto;
  background: var(--phone-bg);
  border: 1px solid var(--phone-border);
  border-radius: 20px 20px 12px 12px;
  padding: 12px 12px 84px;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.12);
  animation: sheetUp 0.28s cubic-bezier(.22,.61,.36,1);
}

@keyframes sheetUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  animation: modalPop 0.2s cubic-bezier(.22,.61,.36,1);
}

@keyframes modalPop {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-actions {
  display: flex;
  justify-content: end;
  gap: 8px;
  margin-top: 10px;
}

.category-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.category-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--input-bg);
  font-size: 13px;
  transition: box-shadow .12s ease;
}
.category-item:active {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 15%, transparent);
}

.remove-btn {
  border: 1px solid var(--tab-btn-border);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
}

@media (max-width: 360px) {
  .inline-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  body { padding: 0; }
  .phone {
    width: 100%;
    height: 100vh;
    border-radius: 0;
    border: 0;
  }
  .fab { right: 16px; }
}

.month-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.month-switcher #currentMonthLabel {
  font-size: 14px;
  font-weight: 700;
  color: var(--brand);
  min-width: 80px;
  text-align: center;
}
.month-arrow {
  border: 1px solid var(--tab-btn-border);
  background: var(--tab-btn-bg);
  color: var(--tab-btn-text);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 14px;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  position: relative;
  z-index: 2;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: all .12s ease;
}
.month-arrow:active {
  transform: scale(0.92);
  background: color-mix(in srgb, var(--brand) 10%, var(--tab-btn-bg));
}
.date-group-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  padding: 14px 0 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  letter-spacing: 0.3px;
}
.date-group-header .day-total {
  font-size: 12px;
  color: var(--brand);
  font-weight: 700;
  background: color-mix(in srgb, var(--brand) 8%, transparent);
  padding: 2px 8px;
  border-radius: 99px;
}
