:root {
  --bg: #f7f1e7;
  --bg-deep: #efe4d5;
  --surface: rgba(255, 251, 245, 0.9);
  --surface-strong: #fffaf1;
  --line: rgba(117, 93, 67, 0.12);
  --ink: #2f2318;
  --muted: #8f7863;
  --accent: #f0cf77;
  --accent-strong: #d89a1d;
  --success: #14936b;
  --expense: #d35745;
  --income: #2f9e61;
  --shadow: 0 20px 50px rgba(80, 46, 18, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 36%),
    linear-gradient(180deg, var(--bg) 0%, #f5ecdf 55%, var(--bg-deep) 100%);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.bg-orb {
  position: fixed;
  inset: auto;
  border-radius: 999px;
  filter: blur(30px);
  opacity: 0.4;
  pointer-events: none;
}

.bg-orb-a {
  top: 56px;
  right: -40px;
  width: 180px;
  height: 180px;
  background: rgba(240, 207, 119, 0.6);
}

.bg-orb-b {
  left: -30px;
  bottom: 120px;
  width: 160px;
  height: 160px;
  background: rgba(90, 168, 132, 0.18);
}

.app-shell {
  position: relative;
  width: min(100%, 460px);
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 18px calc(env(safe-area-inset-bottom) + 98px);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: "Songti SC", "STSong", serif;
  font-size: 30px;
  font-weight: 700;
}

h2 {
  font-size: 20px;
}

.month-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ghost-btn,
.month-pill {
  border: 1px solid var(--line);
  background: rgba(255, 252, 247, 0.7);
  border-radius: 999px;
  color: var(--ink);
}

.ghost-btn {
  width: 38px;
  height: 38px;
  cursor: pointer;
}

.text-chip-btn {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.86);
  color: var(--ink);
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(80, 46, 18, 0.06);
}

.text-chip-btn.subtle {
  background: rgba(255, 255, 255, 0.6);
}

.text-chip-btn.danger {
  color: #a34034;
  background: rgba(211, 87, 69, 0.08);
  border-color: rgba(211, 87, 69, 0.18);
}

.month-pill {
  min-width: 112px;
  height: 38px;
  padding: 0 16px;
}

.content {
  display: grid;
  gap: 16px;
}

.status-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.status-badge {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-size: 13px;
  box-shadow: 0 10px 20px rgba(80, 46, 18, 0.06);
}

.hero-card,
.panel {
  background: var(--surface);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 22px;
  background: linear-gradient(135deg, #f6d887 0%, #f2cf74 58%, #f1d78a 100%);
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hero-amount {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: "Songti SC", "STSong", serif;
  color: #36240c;
}

.hero-amount span {
  font-size: 18px;
}

.hero-amount strong {
  font-size: 44px;
  line-height: 1;
}

.hero-caption {
  color: rgba(54, 36, 12, 0.66);
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.hero-grid div {
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 249, 236, 0.4);
}

.hero-grid span,
.budget-meta span {
  display: block;
  font-size: 13px;
  color: var(--muted);
}

.hero-grid strong,
.budget-meta strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.panel {
  padding: 18px;
}

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

.quick-form,
.budget-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.quick-form input,
.budget-form input {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.quick-form input:focus,
.budget-form input:focus {
  outline: 2px solid rgba(216, 154, 29, 0.28);
  border-color: rgba(216, 154, 29, 0.36);
}

.primary-btn {
  min-height: 52px;
  padding: 0 18px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, #1e9d72 0%, #167e5c 100%);
  color: white;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(20, 147, 107, 0.2);
}

.example-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.example-chip {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
  cursor: pointer;
}

.composer-hint,
.entries-meta {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

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

.budget-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.progress-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: rgba(217, 196, 170, 0.38);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #d89a1d 0%, #e4ba50 100%);
  transition: width 220ms ease;
}

.budget-caption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.breakdown-list {
  display: grid;
  gap: 14px;
}

.category-overview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.category-card {
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.category-card.income {
  background: rgba(47, 158, 97, 0.08);
}

.category-card.expense {
  background: rgba(211, 87, 69, 0.06);
}

.category-card strong,
.category-card span {
  display: block;
}

.category-card strong {
  margin-top: 8px;
  font-size: 20px;
}

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

.category-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.category-chip {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  cursor: pointer;
}

.category-chip.active {
  border-color: rgba(216, 154, 29, 0.4);
  background: rgba(240, 207, 119, 0.3);
  color: #6b4307;
}

.breakdown-item {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.6);
  cursor: pointer;
}

.breakdown-item.active {
  border-color: rgba(75, 186, 138, 0.34);
  background: rgba(75, 186, 138, 0.08);
}

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

.breakdown-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.breakdown-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(217, 196, 170, 0.26);
  overflow: hidden;
}

.breakdown-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4bba8a 0%, #7eceaa 100%);
}

.entry-groups {
  display: grid;
  gap: 16px;
}

.category-spotlight {
  margin-bottom: 12px;
}

.category-spotlight-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(255, 247, 226, 0.96) 0%, rgba(255, 255, 255, 0.84) 100%);
  border: 1px solid rgba(240, 207, 119, 0.35);
}

.category-spotlight-card strong,
.category-spotlight-card span {
  display: block;
}

.category-spotlight-card strong {
  font-size: 18px;
}

.category-spotlight-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.category-spotlight-card button {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(47, 35, 24, 0.08);
  color: var(--ink);
  cursor: pointer;
}

.entry-group {
  display: grid;
  gap: 12px;
}

.entry-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.entry-group-date {
  font-weight: 700;
}

.entry-group-total {
  font-size: 14px;
  color: var(--muted);
}

.entry-list {
  display: grid;
  gap: 10px;
}

.entry-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.entry-card:active {
  transform: scale(0.99);
  box-shadow: 0 8px 18px rgba(80, 46, 18, 0.08);
}

.entry-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: rgba(240, 207, 119, 0.24);
  font-size: 22px;
}

.entry-main {
  min-width: 0;
}

.entry-main strong {
  display: block;
  font-size: 16px;
}

.entry-main p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-side {
  text-align: right;
}

.entry-side strong {
  display: block;
  font-size: 18px;
}

.entry-side button {
  margin-top: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.amount-expense {
  color: var(--expense);
}

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

.empty-state {
  padding: 24px 18px;
  border-radius: 20px;
  border: 1px dashed var(--line);
  color: var(--muted);
  text-align: center;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  transform: translateX(-50%);
  width: min(calc(100% - 24px), 430px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: end;
  padding: 12px 12px 10px;
  border-radius: 28px;
  background: rgba(255, 251, 245, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 24px 50px rgba(80, 46, 18, 0.12);
  backdrop-filter: blur(14px);
}

.nav-link,
.nav-add {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.nav-link {
  padding: 8px 0;
}

.nav-add {
  width: 58px;
  height: 58px;
  margin: -28px auto 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #f2c24b 0%, #dca01d 100%);
  color: white;
  font-size: 34px;
  line-height: 1;
  box-shadow: 0 16px 24px rgba(216, 154, 29, 0.3);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 94px);
  transform: translateX(-50%) translateY(12px);
  min-width: 160px;
  max-width: calc(100% - 40px);
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(47, 35, 24, 0.9);
  color: white;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(47, 35, 24, 0.22);
  backdrop-filter: blur(10px);
  z-index: 30;
}

.edit-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 460px);
  max-height: min(82vh, 760px);
  overflow: auto;
  padding: 12px 18px calc(env(safe-area-inset-bottom) + 22px);
  border-radius: 28px 28px 0 0;
  background: rgba(255, 251, 245, 0.96);
  box-shadow: 0 -18px 50px rgba(47, 35, 24, 0.14);
  z-index: 31;
}

.hidden {
  display: none !important;
}

.sheet-handle {
  width: 52px;
  height: 5px;
  border-radius: 999px;
  margin: 4px auto 16px;
  background: rgba(143, 120, 99, 0.3);
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.sheet-form {
  display: grid;
  gap: 16px;
}

.type-toggle {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 6px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.75);
}

.type-pill {
  min-height: 42px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.type-pill.active {
  background: rgba(240, 207, 119, 0.28);
  color: #6b4307;
  font-weight: 600;
}

.sheet-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.sheet-field {
  display: grid;
  gap: 8px;
}

.sheet-field span,
.sheet-block-head span {
  color: var(--muted);
  font-size: 13px;
}

.sheet-field input {
  min-height: 48px;
  padding: 0 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
}

.sheet-block {
  display: grid;
  gap: 10px;
}

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

.sheet-block-head strong {
  font-size: 14px;
}

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

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

.picker-chip {
  min-height: 46px;
  padding: 8px 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  cursor: pointer;
}

.picker-chip.active {
  border-color: rgba(216, 154, 29, 0.42);
  background: rgba(240, 207, 119, 0.28);
  box-shadow: inset 0 0 0 1px rgba(216, 154, 29, 0.06);
}

.sheet-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}

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

@media (max-width: 420px) {
  .app-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  .topbar {
    flex-direction: column;
  }

  .month-switcher {
    width: 100%;
    justify-content: space-between;
  }

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

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

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

  .sheet-field-grid,
  .picker-grid,
  .account-grid {
    grid-template-columns: 1fr;
  }

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