:root {
  color-scheme: light;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  background: #f4f6fb;
  color: #172033;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-width: 320px; min-height: 100%; }
body { background: linear-gradient(180deg, #eef3ff 0, #f7f8fb 240px, #f7f8fb 100%); }
button, input, textarea { font: inherit; }
button, input, textarea { min-width: 0; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.page-shell { width: min(100%, 48rem); min-height: 100svh; margin: 0 auto; }
.center-view, .auth-view { min-height: 100svh; display: grid; place-items: center; padding: 24px 16px; }
.center-view { align-content: center; color: #657087; }
.auth-card { width: min(100%, 25rem); background: #fff; border: 1px solid #e1e6f0; border-radius: 24px; padding: 26px 22px; box-shadow: 0 18px 50px rgba(39, 63, 112, .10); }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 17px; background: #315fdb; color: white; font-size: 27px; font-weight: 800; }
.auth-card h1 { margin: 0; text-align: center; font-size: 25px; }
.auth-card .muted { text-align: center; margin-bottom: 24px; }

label { display: block; margin: 14px 0 7px; font-size: 14px; font-weight: 650; color: #344057; }
input, textarea { width: 100%; border: 1px solid #cfd6e4; border-radius: 12px; background: #fff; color: #172033; padding: 11px 13px; font-size: 16px; outline: none; }
input { min-height: 46px; }
textarea { resize: vertical; min-height: 84px; }
input:focus, textarea:focus { border-color: #315fdb; box-shadow: 0 0 0 3px rgba(49, 95, 219, .14); }
.field-hint, .muted { color: #6f788b; font-size: 14px; }
.field-hint { margin: 6px 0 0; }
.optional { color: #8b93a2; font-weight: 500; }
.form-error { padding: 10px 12px; border-radius: 10px; background: #fff0f0; color: #a52525; font-size: 14px; }

.primary-button, .secondary-button, .danger-button, .small-button, .icon-button, .text-button, .nav-button, .close-button { min-height: 44px; border: 0; border-radius: 12px; padding: 0 16px; font-weight: 700; }
.primary-button { width: 100%; margin-top: 18px; background: #315fdb; color: #fff; }
.primary-button:disabled, .danger-button:disabled { opacity: .56; }
.secondary-button, .small-button { background: #e9edf5; color: #344057; }
.danger-button { background: #c73535; color: #fff; }
.text-button { padding-inline: 10px; background: transparent; color: #315fdb; }

.app-view { min-height: 100svh; padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 18px 13px; }
.app-header h1 { margin: 2px 0 0; font-size: clamp(24px, 7vw, 30px); letter-spacing: -.03em; }
.eyebrow { margin: 0; color: #657087; font-size: 12px; font-weight: 800; letter-spacing: .12em; }
.notice { margin: 0 14px 12px; padding: 11px 13px; border-radius: 12px; background: #e8f6ed; color: #27633c; font-size: 14px; }
.content-panel { padding: 0 14px 18px; }
.entry-form { background: #fff; border: 1px solid #e0e5ef; border-radius: 20px; padding: 18px; box-shadow: 0 12px 32px rgba(39, 63, 112, .07); }
.date-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.money-field { display: flex; align-items: center; border: 1px solid #cfd6e4; border-radius: 12px; background: #fff; }
.money-field:focus-within { border-color: #315fdb; box-shadow: 0 0 0 3px rgba(49, 95, 219, .14); }
.money-field span { padding-left: 13px; color: #657087; font-weight: 800; }
.money-field input { border: 0; box-shadow: none; font-size: 22px; font-weight: 750; }
.money-field input:focus { box-shadow: none; }

.month-toolbar { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 8px; align-items: center; }
.month-toolbar input { text-align: center; font-weight: 750; }
.icon-button { padding: 0; background: #fff; border: 1px solid #dce2ed; color: #315fdb; font-size: 28px; }
.month-summary { display: flex; justify-content: space-between; align-items: baseline; padding: 18px 3px 9px; color: #667085; }
.month-summary strong { color: #172033; font-size: 22px; }
.entry-list { border: 1px solid #e0e5ef; border-radius: 18px; overflow: hidden; background: #fff; }
.entry-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 12px; padding: 15px; border-bottom: 1px solid #edf0f5; }
.entry-row:last-child { border-bottom: 0; }
.entry-main { min-width: 0; }
.entry-description { display: block; overflow-wrap: anywhere; font-weight: 750; }
.entry-meta, .entry-note { display: block; margin-top: 4px; color: #737d90; font-size: 13px; overflow-wrap: anywhere; }
.entry-amount { align-self: start; white-space: nowrap; font-weight: 800; font-variant-numeric: tabular-nums; }
.entry-actions { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 7px; }
.entry-action { min-height: 38px; border: 0; border-radius: 10px; padding: 0 12px; background: #edf1f8; color: #42506a; }
.entry-action.delete { color: #a52525; background: #fff0f0; }
.empty-state { padding: 54px 18px; text-align: center; color: #737d90; }
.empty-state h2 { color: #344057; font-size: 18px; }
.empty-icon { width: 48px; height: 48px; display: grid; place-items: center; margin: auto; border-radius: 50%; background: #e8f6ed; color: #2b7b48; font-weight: 800; }

.bottom-nav { position: fixed; z-index: 5; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%, 48rem); display: grid; grid-template-columns: 1fr 1fr; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid #dfe4ed; background: rgba(255, 255, 255, .96); backdrop-filter: blur(16px); }
.nav-button { display: grid; place-items: center; gap: 2px; min-height: 56px; background: transparent; color: #7c8494; font-size: 12px; }
.nav-button span:first-child { font-size: 20px; line-height: 20px; }
.nav-button.active { color: #315fdb; background: #edf2ff; }

dialog { width: min(calc(100% - 28px), 28rem); max-height: calc(100dvh - 32px); border: 0; border-radius: 22px; padding: 0; color: #172033; box-shadow: 0 24px 80px rgba(18, 29, 51, .28); }
dialog::backdrop { background: rgba(19, 28, 45, .48); backdrop-filter: blur(2px); }
.dialog-form, .confirm-dialog { padding: 20px; overflow: auto; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-heading h2, .confirm-dialog h2 { margin: 0; font-size: 21px; }
.close-button { padding: 0; width: 44px; background: #edf1f8; color: #4d586e; font-size: 24px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.dialog-actions .primary-button { margin: 0; }
.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 (min-width: 640px) {
  .app-view { background: rgba(255,255,255,.35); border-inline: 1px solid rgba(213,220,233,.8); }
  .content-panel { padding-inline: 22px; }
  .app-header { padding-inline: 26px; }
}

@media (prefers-reduced-motion: no-preference) {
  button { transition: transform .12s ease, background-color .16s ease; }
  button:active { transform: scale(.98); }
}

