:root {
  --bg: #fff9f2;
  --surface: #ffffff;
  --surface-soft: #fff3e8;
  --ink: #33263b;
  --muted: #806f82;
  --line: #eadfe7;
  --coral: #ff795f;
  --coral-dark: #e85e48;
  --coral-soft: #ffe4dc;
  --purple: #8d64b8;
  --purple-dark: #68418e;
  --purple-soft: #eee3fa;
  --yellow: #f5bd48;
  --yellow-soft: #fff0c7;
  --mint: #70bfa9;
  --mint-soft: #dff5ed;
  --income: #3fa67f;
  --income-dark: #257b5d;
  --income-soft: #dff6ec;
  --danger: #cf4a52;
  --danger-soft: #fee4e5;
  --shadow: 0 18px 50px rgba(78, 51, 73, 0.1);
  --shadow-small: 0 8px 24px rgba(78, 51, 73, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  font-family:
    "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(255, 190, 72, 0.13), transparent 26rem),
    radial-gradient(circle at 96% 8%, rgba(141, 100, 184, 0.11), transparent 26rem),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

button,
select,
input[type="date"],
input[type="month"],
label[for],
.settings-button {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(141, 100, 184, 0.27);
  outline-offset: 2px;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

.is-hidden {
  display: none !important;
}

.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;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--coral-dark);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.card {
  border: 1px solid rgba(234, 223, 231, 0.82);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.93);
  box-shadow: var(--shadow-small);
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 46px;
  padding: 0 18px;
  border-radius: 14px;
  border: 0;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--coral), #f36b85);
  box-shadow: 0 9px 20px rgba(255, 121, 95, 0.25);
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(255, 121, 95, 0.31);
}

.primary-button.income-button {
  background: linear-gradient(135deg, var(--income), #64b998);
  box-shadow: 0 9px 20px rgba(63, 166, 127, 0.24);
}

.primary-button.income-button:hover {
  box-shadow: 0 12px 26px rgba(63, 166, 127, 0.3);
}

.primary-button:active,
.secondary-button:active,
.danger-button:active {
  transform: translateY(1px);
}

.secondary-button {
  color: var(--purple-dark);
  border: 1px solid var(--line);
  background: #fff;
}

.secondary-button:hover {
  background: var(--purple-soft);
}

.danger-button {
  color: #fff;
  background: var(--danger);
}

.large-button {
  width: 100%;
  min-height: 54px;
  border-radius: 17px;
  font-size: 1rem;
}

.compact-button {
  min-height: 42px;
  padding-inline: 15px;
  white-space: nowrap;
}

.icon-button,
.text-button {
  border: 0;
  cursor: pointer;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 1.5rem;
}

.icon-button:hover {
  background: var(--surface-soft);
}

.icon-button.soft {
  width: 40px;
  height: 40px;
  color: var(--purple-dark);
  background: var(--purple-soft);
  font-size: 1.75rem;
}

.text-button {
  padding: 6px 8px;
  color: var(--purple-dark);
  background: transparent;
  font-weight: 800;
}

.unlock-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 22px;
}

.unlock-card {
  width: min(100%, 430px);
  padding: 26px;
  text-align: center;
  border: 1px solid rgba(234, 223, 231, 0.9);
  border-radius: 34px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.unlock-art-wrap {
  width: 174px;
  height: 174px;
  margin: -8px auto 18px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--yellow-soft);
  box-shadow: 0 12px 30px rgba(141, 100, 184, 0.16);
}

.unlock-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.08);
}

.unlock-card h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 8vw, 2.65rem);
  letter-spacing: -0.06em;
}

.unlock-copy {
  max-width: 300px;
  margin: 0 auto 24px;
  color: var(--muted);
  line-height: 1.65;
}

.unlock-form {
  display: grid;
  gap: 14px;
  text-align: left;
}

.local-note {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  width: 100%;
  padding-right: 66px !important;
}

.reveal-button {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  font-size: 0.82rem;
}

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

.app-header {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 76px;
  padding: 10px max(18px, calc((100vw - 1120px) / 2));
  border-bottom: 1px solid rgba(234, 223, 231, 0.78);
  background: rgba(255, 249, 242, 0.9);
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-avatar {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border: 3px solid #fff;
  border-radius: 17px;
  box-shadow: 0 7px 16px rgba(103, 62, 100, 0.15);
}

.brand-lockup h1 {
  margin: 0;
  font-size: 1.13rem;
  letter-spacing: -0.03em;
}

.brand-kicker {
  margin: 0 0 2px;
  color: var(--purple);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.operator-picker {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 42px;
  padding: 0 7px 0 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.operator-picker select {
  max-width: 76px;
  height: 100%;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 800;
}

.app-main {
  width: min(100%, 1120px);
  min-height: calc(100vh - 76px);
  margin: 0 auto;
  padding: 26px 22px 126px;
}

.app-view {
  display: none;
  animation: view-in 220ms ease-out;
}

.app-view.is-active {
  display: block;
}

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

.welcome-row,
.view-title-row,
.section-heading,
.sheet-heading,
.modal-header,
.chart-heading,
.filter-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.welcome-row {
  margin-bottom: 18px;
}

.welcome-row h2,
.view-title-row h2 {
  margin: 0;
  font-size: clamp(1.65rem, 4vw, 2.2rem);
  letter-spacing: -0.045em;
}

.mood-sticker {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 18px;
  background: var(--yellow-soft);
  box-shadow: var(--shadow-small);
  font-size: 1.7rem;
  transform: rotate(5deg);
}

.month-switcher {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: max-content;
  min-width: 250px;
  margin-bottom: 22px;
  padding: 8px 10px;
}

.month-input {
  width: 140px;
  height: 40px;
  padding: 0 8px;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 900;
  text-align: center;
}

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

.summary-card {
  position: relative;
  min-height: 148px;
  padding: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-small);
}

.summary-card::after {
  position: absolute;
  right: -24px;
  bottom: -38px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.32);
  content: "";
}

.summary-card.coral {
  background: linear-gradient(145deg, #ffe2d8, #ffd1c8);
}

.summary-card.purple {
  background: linear-gradient(145deg, #eee2fb, #dfcdf3);
}

.summary-card.yellow {
  background: linear-gradient(145deg, #fff2c9, #ffe39b);
}

.summary-card.mint {
  background: linear-gradient(145deg, #dff5ed, #c8ebdf);
}

.summary-card.sky {
  background: linear-gradient(145deg, #e5f2ff, #cfe6f8);
}

.summary-icon {
  display: grid;
  width: 38px;
  height: 38px;
  margin-bottom: 14px;
  place-items: center;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.62);
}

.summary-card p {
  margin-bottom: 5px;
  color: rgba(51, 38, 59, 0.7);
  font-size: 0.78rem;
  font-weight: 800;
}

.summary-card strong {
  position: relative;
  z-index: 1;
  display: block;
  margin-bottom: 4px;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  letter-spacing: -0.04em;
}

.summary-card small {
  position: relative;
  z-index: 1;
  color: rgba(51, 38, 59, 0.6);
}

.section-heading {
  margin: 36px 0 14px;
}

.section-heading h3 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
}

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

.chart-card {
  min-width: 0;
  padding: 20px;
  border: 1px solid rgba(234, 223, 231, 0.86);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-small);
}

.chart-heading {
  align-items: flex-start;
  margin-bottom: 12px;
}

.chart-heading h4 {
  margin-bottom: 4px;
  font-size: 1rem;
}

.chart-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.chart-badge {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 900;
}

.chart-badge.coral {
  color: var(--coral-dark);
  background: var(--coral-soft);
}

.chart-badge.purple {
  color: var(--purple-dark);
  background: var(--purple-soft);
}

.chart-badge.yellow {
  color: #8c6410;
  background: var(--yellow-soft);
}

.chart-badge.mint {
  color: #367d6b;
  background: var(--mint-soft);
}

.canvas-wrap {
  position: relative;
  width: 100%;
  height: 220px;
}

.canvas-wrap.compact-canvas {
  height: 168px;
}

.canvas-wrap canvas {
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px;
  color: var(--muted);
  border-radius: 18px;
  background: var(--surface-soft);
  font-size: 0.85rem;
  text-align: center;
}

.chart-insight {
  margin: 10px 0 0;
  padding: 11px 13px;
  color: var(--muted);
  border-radius: 13px;
  background: var(--surface-soft);
  font-size: 0.78rem;
  line-height: 1.5;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 13px;
  min-height: 24px;
  margin-top: 10px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
}

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

.view-title-row {
  margin-bottom: 18px;
}

.filter-card {
  margin-bottom: 18px;
  padding: 17px;
}

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

.invoice-filter-grid {
  grid-template-columns: 1fr 1fr 2fr;
}

.compact-field,
.field {
  display: grid;
  gap: 7px;
  min-width: 0;
  border: 0;
}

.field {
  margin: 0;
  padding: 0;
}

.compact-field span,
.field > span,
.field legend {
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 800;
}

.compact-field input,
.compact-field select {
  width: 100%;
  height: 43px;
  min-width: 0;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface-soft);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink);
  background: #fff;
  transition:
    border 150ms ease,
    box-shadow 150ms ease;
}

.field textarea {
  min-height: 94px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 4px rgba(141, 100, 184, 0.1);
}

.field small {
  color: var(--muted);
  line-height: 1.45;
}

.wide-filter {
  grid-column: span 1;
}

.filter-footer {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.filter-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.active-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 9px 12px;
  color: var(--purple-dark);
  border-radius: 12px;
  background: var(--purple-soft);
  font-size: 0.8rem;
  font-weight: 800;
}

.invoice-segment {
  display: inline-flex;
  gap: 5px;
  margin-bottom: 14px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
}

.segment-button {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.segment-button.is-active {
  color: #fff;
  background: var(--purple);
  box-shadow: 0 7px 16px rgba(141, 100, 184, 0.24);
}

.record-list {
  display: grid;
  gap: 12px;
}

.record-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border: 1px solid rgba(234, 223, 231, 0.88);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-small);
  transition:
    transform 150ms ease,
    box-shadow 150ms ease;
}

.record-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 11px 30px rgba(78, 51, 73, 0.11);
}

.record-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 16px;
  background: var(--surface-soft);
  font-size: 1.25rem;
}

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

.record-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.record-title-row h3 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 0.97rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-amount {
  flex: 0 0 auto;
  font-size: 1.05rem;
  font-weight: 900;
}

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

.record-meta,
.record-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.record-note {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--purple-dark);
  background: var(--purple-soft);
  font-size: 0.67rem;
  font-weight: 800;
}

.tag.coral {
  color: var(--coral-dark);
  background: var(--coral-soft);
}

.tag.yellow {
  color: #805b0f;
  background: var(--yellow-soft);
}

.tag.mint {
  color: #367d6b;
  background: var(--mint-soft);
}

.tag.gray {
  color: #796d79;
  background: #f0ebef;
}

.record-actions {
  display: flex;
  gap: 4px;
}

.record-action {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.record-action:hover {
  color: var(--purple-dark);
  background: var(--purple-soft);
}

.record-action.delete:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.empty-state {
  padding: 46px 24px;
  text-align: center;
}

.empty-emoji {
  margin-bottom: 14px;
  font-size: 2.8rem;
}

.empty-state h3 {
  margin-bottom: 7px;
}

.empty-state p {
  max-width: 430px;
  margin: 0 auto 20px;
  color: var(--muted);
  line-height: 1.65;
}

.bottom-nav {
  position: fixed;
  z-index: 35;
  right: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(5, 72px);
  align-items: center;
  justify-content: center;
  width: max-content;
  min-height: 70px;
  padding: 7px;
  border: 1px solid rgba(234, 223, 231, 0.92);
  border-radius: 25px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 46px rgba(69, 44, 66, 0.18);
  transform: translateX(50%);
  backdrop-filter: blur(18px);
}

.nav-button {
  display: grid;
  gap: 2px;
  place-items: center;
  min-height: 56px;
  padding: 3px 8px;
  border: 0;
  border-radius: 17px;
  color: var(--muted);
  background: transparent;
  font-size: 0.68rem;
  font-weight: 800;
  cursor: pointer;
}

.nav-button.is-active {
  color: var(--purple-dark);
  background: var(--purple-soft);
}

.nav-icon {
  font-size: 1.24rem;
  font-weight: 900;
}

.quick-add-button {
  position: fixed;
  z-index: 40;
  right: 50%;
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 82px);
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  padding: 0;
  border: 4px solid var(--bg);
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, var(--coral), #f26d86);
  box-shadow: 0 12px 25px rgba(255, 121, 95, 0.38);
  transform: translateX(50%);
  cursor: pointer;
}

.quick-add-button span {
  font-size: 2rem;
  font-weight: 300;
  transform: translateY(-1px);
}

.sheet-backdrop,
.modal-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  align-items: end;
  padding: 18px;
  background: rgba(42, 29, 43, 0.42);
  backdrop-filter: blur(5px);
  animation: fade-in 160ms ease-out;
}

.modal-backdrop {
  z-index: 90;
  align-items: center;
  justify-items: center;
}

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

.action-sheet {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 12px 20px 24px;
  border-radius: 30px;
  background: #fff;
  box-shadow: var(--shadow);
  animation: sheet-up 200ms ease-out;
}

@keyframes sheet-up {
  from {
    transform: translateY(18px);
  }
}

.sheet-handle {
  width: 42px;
  height: 5px;
  margin: 2px auto 18px;
  border-radius: 999px;
  background: var(--line);
}

.sheet-heading {
  margin-bottom: 16px;
}

.sheet-heading h2 {
  margin: 0;
  font-size: 1.4rem;
}

.quick-actions,
.settings-list {
  display: grid;
  gap: 10px;
}

.quick-action,
.settings-button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 13px;
  align-items: center;
  min-height: 74px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--ink);
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.quick-action:hover,
.settings-button:hover {
  border-color: rgba(141, 100, 184, 0.34);
  background: var(--surface-soft);
}

.quick-action-icon,
.settings-icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 15px;
  font-size: 1.3rem;
}

.quick-action.expense .quick-action-icon {
  background: var(--yellow-soft);
}

.quick-action.invoice .quick-action-icon {
  background: var(--purple-soft);
}

.quick-action.income .quick-action-icon {
  background: var(--income-soft);
}

.quick-action strong,
.quick-action small,
.settings-button strong,
.settings-button small {
  display: block;
}

.quick-action small,
.settings-button small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
}

.form-modal,
.small-modal {
  width: min(100%, 680px);
  max-height: min(92vh, 860px);
  overflow: auto;
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: modal-in 190ms ease-out;
  overscroll-behavior: contain;
}

.wide-modal {
  width: min(100%, 760px);
}

.small-modal {
  width: min(100%, 440px);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: scale(0.985) translateY(8px);
  }
}

.modal-header {
  position: sticky;
  z-index: 2;
  top: 0;
  min-height: 72px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.27rem;
  text-align: center;
}

.modal-header .eyebrow {
  margin-bottom: 2px;
  text-align: center;
}

.modal-header-spacer {
  width: 44px;
}

.record-form {
  display: grid;
  gap: 18px;
  padding: 20px;
}

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

.span-two {
  grid-column: span 2;
}

.amount-field {
  padding: 17px 18px;
  border-radius: 20px;
  background: linear-gradient(145deg, var(--coral-soft), #fff0ea);
}

.amount-field label {
  display: block;
  margin-bottom: 4px;
  color: var(--coral-dark);
  font-size: 0.76rem;
  font-weight: 900;
}

.amount-field > span {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.income-amount-field {
  background: linear-gradient(145deg, var(--income-soft), #effbf6);
}

.income-amount-field label,
.income-eyebrow {
  color: var(--income-dark) !important;
}

.amount-field b {
  font-size: 1.4rem;
}

.amount-field input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: clamp(2rem, 7vw, 2.8rem);
  font-weight: 900;
  letter-spacing: -0.05em;
}

.compact-amount {
  padding-block: 13px;
}

.compact-amount input {
  font-size: clamp(1.75rem, 6vw, 2.3rem);
}

.choice-row {
  display: grid;
  gap: 10px;
}

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

.choice-card {
  position: relative;
  cursor: pointer;
}

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

.choice-card span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  font-size: 0.86rem;
  font-weight: 800;
  transition:
    border 150ms ease,
    background 150ms ease,
    box-shadow 150ms ease;
}

.choice-card input:checked + span {
  color: var(--purple-dark);
  border-color: var(--purple);
  background: var(--purple-soft);
  box-shadow: 0 0 0 3px rgba(141, 100, 184, 0.1);
}

.choice-card.income-choice input:checked + span {
  color: var(--income-dark);
  border-color: var(--income);
  background: var(--income-soft);
  box-shadow: 0 0 0 3px rgba(63, 166, 127, 0.1);
}

.choice-card b {
  font-size: 1.1rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-error {
  min-height: 1.2em;
  margin: 0;
  color: var(--danger);
  font-size: 0.8rem;
  font-weight: 700;
}

.upload-field input {
  padding: 9px;
  background: var(--surface-soft);
}

.existing-attachments {
  display: grid;
  gap: 8px;
}

.attachment-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-soft);
}

.attachment-row p {
  margin: 0;
  overflow: hidden;
  font-size: 0.78rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-row small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.attachment-row button {
  padding: 6px;
  border: 0;
  color: var(--danger);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.more-sheet {
  width: min(100%, 570px);
}

.settings-button {
  width: 100%;
  border: 0;
  background: var(--surface-soft);
}

.settings-icon.purple {
  background: var(--purple-soft);
}

.settings-icon.yellow {
  background: var(--yellow-soft);
}

.settings-icon.mint {
  background: var(--mint-soft);
}

.settings-icon.coral {
  background: var(--coral-soft);
}

.file-settings-button {
  position: relative;
  overflow: hidden;
}

.file-settings-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.local-warning {
  margin-top: 15px;
  padding: 13px 15px;
  color: #73551a;
  border-radius: 15px;
  background: var(--yellow-soft);
}

.local-warning strong {
  font-size: 0.82rem;
}

.local-warning p {
  margin: 4px 0 0;
  font-size: 0.74rem;
  line-height: 1.6;
}

.confirm-dialog {
  width: min(calc(100% - 36px), 390px);
  padding: 0;
  border: 0;
  border-radius: 25px;
  box-shadow: var(--shadow);
}

.confirm-dialog::backdrop {
  background: rgba(42, 29, 43, 0.45);
  backdrop-filter: blur(4px);
}

.confirm-dialog form {
  padding: 25px;
  text-align: center;
}

.confirm-icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 0 auto 13px;
  place-items: center;
  border-radius: 17px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 1.4rem;
  font-weight: 900;
}

.confirm-dialog h2 {
  margin-bottom: 8px;
  font-size: 1.3rem;
}

.confirm-dialog p {
  margin-bottom: 20px;
  color: var(--muted);
  line-height: 1.6;
}

.confirm-dialog .form-actions {
  justify-content: center;
}

.toast-region {
  position: fixed;
  z-index: 200;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  display: grid;
  gap: 8px;
  width: min(calc(100% - 36px), 420px);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 15px;
  color: #fff;
  border-radius: 15px;
  background: var(--ink);
  box-shadow: 0 12px 30px rgba(42, 29, 43, 0.25);
  font-size: 0.84rem;
  font-weight: 800;
  animation: toast-in 200ms ease-out;
}

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

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

@media (max-width: 880px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .wide-filter {
    grid-column: span 2;
  }

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

@media (max-width: 680px) {
  .app-header {
    height: 70px;
    padding-inline: 16px;
  }

  .brand-avatar {
    width: 43px;
    height: 43px;
    border-radius: 14px;
  }

  .brand-lockup h1 {
    font-size: 1rem;
  }

  .brand-kicker {
    display: none;
  }

  .operator-picker {
    height: 40px;
    padding-left: 8px;
  }

  .header-actions > .icon-button {
    display: none;
  }

  .app-main {
    padding: 20px 15px 120px;
  }

  .welcome-row {
    align-items: flex-start;
  }

  .welcome-row h2,
  .view-title-row h2 {
    font-size: 1.55rem;
  }

  .mood-sticker {
    width: 47px;
    height: 47px;
    border-radius: 15px;
    font-size: 1.45rem;
  }

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

  .summary-grid {
    gap: 10px;
  }

  .summary-card {
    min-height: 138px;
    padding: 15px;
    border-radius: 19px;
  }

  .summary-icon {
    width: 34px;
    height: 34px;
    margin-bottom: 11px;
  }

  .summary-card strong {
    font-size: 1.25rem;
  }

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

  .chart-card {
    padding: 17px;
    border-radius: 23px;
  }

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

  .filter-card {
    padding: 14px;
  }

  .record-card {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 14px;
  }

  .record-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    padding-top: 3px;
    border-top: 1px solid var(--line);
  }

  .record-action {
    width: auto;
    min-width: 76px;
    padding-inline: 12px;
  }

  .record-action::after {
    margin-left: 5px;
    font-size: 0.72rem;
  }

  .record-action.edit::after {
    content: "编辑";
  }

  .record-action.delete::after {
    content: "删除";
  }

  .bottom-nav {
    right: 10px;
    left: 10px;
    grid-template-columns: repeat(5, 1fr);
    width: auto;
    transform: none;
  }

  .quick-add-button {
    right: 50%;
  }

  .sheet-backdrop,
  .modal-backdrop {
    padding: 0;
  }

  .action-sheet,
  .form-modal,
  .small-modal {
    width: 100%;
    max-height: calc(100vh - max(10px, env(safe-area-inset-top)));
    border-radius: 28px 28px 0 0;
  }

  .modal-backdrop {
    align-items: end;
  }

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

  .span-two {
    grid-column: span 1;
  }

  .record-form {
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }

  .form-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin: 0 -20px -20px;
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
  }

  .form-actions button {
    flex: 1;
  }
}

@media (max-width: 390px) {
  .unlock-card {
    padding: 22px 18px;
  }

  .unlock-art-wrap {
    width: 150px;
    height: 150px;
  }

  .app-main {
    padding-inline: 12px;
  }

  .brand-lockup {
    gap: 8px;
  }

  .brand-avatar {
    width: 40px;
    height: 40px;
  }

  .operator-picker > span {
    display: none;
  }

  .summary-card {
    min-height: 132px;
    padding: 13px;
  }

  .summary-card p,
  .summary-card small {
    font-size: 0.7rem;
  }

  .summary-card strong {
    font-size: 1.08rem;
  }

  .filter-grid,
  .invoice-filter-grid {
    grid-template-columns: 1fr;
  }

  .wide-filter {
    grid-column: span 1;
  }

  .view-title-row {
    align-items: flex-end;
  }

  .compact-button {
    padding-inline: 12px;
    font-size: 0.78rem;
  }

  .invoice-segment {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .segment-button {
    padding-inline: 7px;
    font-size: 0.74rem;
  }

  .record-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
  }

  .two-options {
    grid-template-columns: 1fr;
  }

  .bottom-nav {
    min-height: 66px;
    padding: 5px;
    border-radius: 22px;
  }

  .nav-button {
    min-height: 54px;
    padding-inline: 4px;
  }

  .quick-add-button {
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 78px);
    width: 58px;
    height: 58px;
  }
}

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