:root {
  --bg: #f4f6fb;
  --bg-accent: radial-gradient(circle at top, rgba(59, 130, 246, 0.12), transparent 30%), linear-gradient(180deg, #f9fbff 0%, #f2f5fa 100%);
  --surface: rgba(255, 255, 255, 0.9);
  --surface-strong: rgba(255, 255, 255, 0.98);
  --surface-muted: #eef3fb;
  --surface-soft: #f6f8fc;
  --surface-elevated: rgba(15, 23, 42, 0.86);
  --text: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --text-on-dark: #f8fafc;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, 0.1);
  --income: #059669;
  --income-soft: rgba(5, 150, 105, 0.12);
  --expense: #dc2626;
  --expense-soft: rgba(220, 38, 38, 0.1);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.12);
  --border: rgba(148, 163, 184, 0.2);
  --border-strong: rgba(100, 116, 139, 0.28);
  --shadow-xs: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 10px 28px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 18px 44px rgba(15, 23, 42, 0.1);
  --radius-xs: 10px;
  --radius-sm: 14px;
  --radius: 18px;
  --radius-lg: 24px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --shell-width: 760px;
  --header-height: 44px;
  --bottom-nav-height: 84px;
  --safe-bottom: max(24px, env(safe-area-inset-bottom));
  --safe-top: max(20px, env(safe-area-inset-top));
  --transition: 180ms ease;
  --font-sans: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Monaco, monospace;
  color-scheme: light;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body,
#__next {
  min-height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-accent);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button,
input,
select,
textarea {
  border: 0;
}

button {
  background: none;
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.18);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + var(--space-3));
}

.app-shell--standalone {
  padding-bottom: 0;
}

.app-shell__container {
  width: min(100% - 28px, var(--shell-width));
  margin: 0 auto;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding-top: var(--safe-top);
  backdrop-filter: blur(20px);
  background: rgba(249, 251, 255, 0.9);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}

.app-header::after {
  content: none;
}

.app-header--compact {
  background: rgba(249, 251, 255, 0.86);
}

.app-header__inner {
  position: relative;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
}

.app-header--compact .app-header__inner {
  min-height: 32px !important;
  height: 32px !important;
  gap: 4px !important;
  padding: 0 !important;
}

.app-header__main,
.app-header__spacer {
  min-width: 0;
  flex: 1;
}

.app-header__main {
  display: flex;
  align-items: center;
  flex: 1;
  height: 100%;
}

.app-header--actions-only .app-header__main {
  display: none;
}

.app-header__text {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.app-header__text h1 {
  font-size: 1.02rem;
  line-height: 1.15;
  letter-spacing: -0.03em;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header--compact .app-header__text h1 {
  font-size: 0.98rem;
}

.app-header__text p {
  color: var(--text-secondary);
  font-size: 0.76rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header--compact .app-header__text p {
  font-size: 0.74rem;
}

.app-header__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
  margin-left: auto;
  flex-shrink: 0;
}

.app-header--compact .app-header__actions {
  gap: 6px;
}

.app-content {
  padding: 10px 0 0;
}

.app-content__inner {
  display: grid;
  gap: 14px;
  align-content: start;
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: var(--radius);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.05);
  backdrop-filter: blur(18px);
}

.section-card,
.category-section,
.settings-section,
.category-tip,
.dashboard-hero,
.auth-card,
.confirm-card {
  overflow: hidden;
}

.section-card,
.category-section,
.settings-section,
.dashboard-hero,
.auth-card {
  padding: 16px;
}

.section-card--search {
  display: grid;
  gap: 14px;
}

.section-card--search-panel {
  padding: 12px;
  gap: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(247, 249, 253, 0.9));
}

.section-heading,
.section-header,
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.section-header {
  align-items: center;
}

.section-heading--compact,
.section-header {
  margin-bottom: 14px;
}

.section-heading h2,
.section-header h2,
.section-header h3,
.modal-header h2 {
  font-size: 1.02rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.sub {
  color: var(--text-tertiary);
  font-size: 0.9rem;
  line-height: 1.45;
}

.btn {
  width: 100%;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 15px;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition);
  border: 1px solid transparent;
  box-shadow: none;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled,
.icon-button:disabled,
.type-btn:disabled,
.category-btn:disabled,
.icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.btn-inline {
  width: auto;
  min-width: fit-content;
}

.btn-small {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 0.84rem;
  border-radius: 11px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4d84f7);
  color: #fff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.14);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  border-color: rgba(148, 163, 184, 0.16);
}

.btn-secondary:hover:not(:disabled) {
  border-color: rgba(37, 99, 235, 0.22);
  background: rgba(255, 255, 255, 0.94);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: rgba(148, 163, 184, 0.18);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: rgba(148, 163, 184, 0.08);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, var(--expense));
  color: #fff;
  box-shadow: 0 10px 22px rgba(220, 38, 38, 0.14);
}

.button-content {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-secondary);
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.icon-button:hover:not(:disabled) {
  transform: translateY(-1px);
  color: var(--text);
  border-color: rgba(191, 219, 254, 1);
  background: #ffffff;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}

.icon-button--ghost {
  background: transparent;
  box-shadow: none;
}

.month-switcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(226, 232, 240, 0.95);
}

.header-center-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 4px;
  padding: 0;
  box-sizing: border-box;
}

.header-center-container > * {
  display: flex;
  align-items: center;
}

.header-left-actions,
.header-right-actions {
  display: flex;
  align-items: center;
  min-width: 32px;
}

.header-spacer {
  min-width: 40px;
}

.month-switcher-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: 1;
}

.month-switcher-container .icon-button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.month-switcher-container .month-switcher__label {
  font-size: 1rem;
  font-weight: 700;
  min-width: 90px;
  text-align: center;
}

.modal-title-container {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.modal-title {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.03em;
}

.app-header--compact .modal-title {
  font-size: 0.98rem;
}

.month-switcher--header {
  min-width: 0;
  padding: 3px;
  gap: 3px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  justify-content: center;
}

.app-header--compact .month-switcher--header {
  padding: 3px;
  border-radius: 14px;
}

.month-switcher--header .icon-button {
  width: 32px;
  height: 32px;
  border-radius: 10px;
}

.month-switcher--header .month-switcher__label {
  min-width: 118px;
  padding: 0 8px;
  font-size: 0.84rem;
}

.month-switcher__label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  min-width: 92px;
  text-align: center;
  white-space: nowrap;
}

.stats-grid {
  display: grid;
  gap: 12px;
}

.stats-grid--hero {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stats-grid--split {
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  align-items: start;
}

.dashboard-hero {
  display: grid;
  gap: 14px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.95), rgba(246, 249, 253, 0.92));
}

.stat-card,
.search-stat {
  position: relative;
  border-radius: 16px;
}

.stat-card {
  display: grid;
  gap: 6px;
  padding: 14px 13px;
  text-align: left;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition), background var(--transition);
}

.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-xs);
}

.stat-card.active {
  border-color: rgba(37, 99, 235, 0.3);
  background: rgba(240, 246, 255, 0.96);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.08);
}

.stat-card--balance {
  background: rgba(255, 255, 255, 0.82);
}

.label {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-tertiary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.value,
.record-amount,
.bill-amount,
.category-amount,
.day-expense,
.search-stat .value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.value {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.value.income,
.record-amount.income,
.bill-amount.income,
.search-stat .value.income {
  color: var(--income);
}

.value.expense,
.record-amount.expense,
.bill-amount.expense,
.search-stat .value.expense {
  color: var(--expense);
}

.records-list,
.bills-list,
.category-breakdown {
  display: grid;
  gap: 12px;
}

.records-list--flush {
  gap: 16px;
}

.date-group {
  display: grid;
  gap: 8px;
}

.date-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
}

.day-expense {
  color: var(--text-tertiary);
  font-size: 0.78rem;
}

.record-item,
.bill-item,
.category-item,
.settings-item,
.category-tag {
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: none;
}

.bill-item,
.settings-item {
  position: relative;
}

.bill-item::after,
.settings-item::after {
  content: '';
  position: absolute;
  inset: auto 14px 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(148, 163, 184, 0), rgba(148, 163, 184, 0.22), rgba(148, 163, 184, 0));
  opacity: 0;
  transition: opacity var(--transition);
}

.record-item,
.bill-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 16px;
  cursor: pointer;
  text-align: left;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition), background var(--transition);
}

.record-item {
  flex-wrap: nowrap;
}

.record-item:hover,
.bill-item:hover {
  transform: translateY(-1px);
  border-color: rgba(37, 99, 235, 0.14);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
}

.bill-item:hover::after,
.settings-item:hover::after {
  opacity: 1;
}

.record-item--static {
  cursor: default;
}

.record-item--static:hover {
  transform: none;
}

.record-left,
.bill-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.record-icon,
.bill-icon,
.auth-logo__mark,
.empty-state__icon,
.confirm-card__icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.record-icon,
.bill-icon {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(237, 244, 255, 0.98), rgba(247, 250, 255, 0.92));
  font-size: 1.2rem;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.1);
}

.record-info,
.bill-info,
.settings-info,
.confirm-card__body {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.record-info {
  flex: 1;
}

.record-category,
.bill-category,
.settings-title,
.cat-name {
  font-weight: 700;
  color: var(--text);
}

.record-note,
.bill-day,
.bill-note,
.settings-desc,
.results-count,
.category-percent,
.about-info .sub,
.search-input-wrap__hint {
  color: var(--text-tertiary);
  font-size: 0.88rem;
  line-height: 1.42;
}

.record-amount,
.bill-amount,
.category-amount {
  font-size: 0.98rem;
  font-weight: 700;
  white-space: nowrap;
}

.record-amount {
  flex-shrink: 0;
  align-self: center;
}

.loading-state,
.empty-state {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 8px;
  min-height: 148px;
  color: var(--text-secondary);
}

.empty-state--card {
  padding: 24px 16px;
}

.empty-state--inline {
  min-height: 220px;
  border-radius: 16px;
  background: rgba(246, 248, 252, 0.92);
  border: 1px dashed var(--border-strong);
}

.empty-state__icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: rgba(240, 245, 255, 0.92);
  color: var(--primary);
}

.fab {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 12px);
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--primary), #4f8dfc);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 18px 34px rgba(37, 99, 235, 0.24);
  z-index: 45;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}

.fab:hover {
  transform: translateY(-2px) scale(1.01);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 18px 14px max(14px, env(safe-area-inset-bottom));
  background: rgba(15, 23, 42, 0.44);
  backdrop-filter: blur(12px);
  z-index: 80;
}

.modal-overlay--fullscreen {
  align-items: stretch;
  padding: 0;
  background: rgba(15, 23, 42, 0.32);
}

.modal-overlay--center {
  align-items: center;
}

.modal,
.confirm-card {
  width: min(100%, 560px);
  background: var(--surface-strong);
  border: 1px solid rgba(255, 255, 255, 0.62);
  box-shadow: var(--shadow-md);
}

.modal {
  border-radius: 24px 24px 20px 20px;
  padding: 18px;
  max-height: min(88vh, 920px);
  overflow-y: auto;
}

.modal--fullscreen {
  width: 100%;
  max-width: none;
  min-height: 100dvh;
  max-height: 100dvh;
  border-radius: 0;
  border: 0;
  padding: calc(var(--safe-top) + 8px) 16px calc(var(--safe-bottom) + 20px);
  background: linear-gradient(180deg, rgba(249, 251, 255, 0.99), rgba(244, 246, 251, 0.98));
}

.modal--fullscreen .modal-header {
  position: sticky;
  top: calc(var(--safe-top) * -1 - 8px);
  margin: calc(var(--safe-top) * -1 - 8px) -16px 14px;
  padding: calc(var(--safe-top) + 8px) 16px 12px;
  background: linear-gradient(180deg, rgba(249, 251, 255, 0.98), rgba(249, 251, 255, 0.92));
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  backdrop-filter: blur(18px);
  z-index: 2;
}

.modal--fullscreen form {
  display: grid;
  gap: 2px;
  width: 100%;
}

.confirm-card {
  border-radius: 22px;
  padding: 20px;
  display: grid;
  gap: 16px;
}

.confirm-card__icon {
  width: 46px;
  height: 46px;
  border-radius: 15px;
}

.confirm-card__icon--danger {
  background: var(--expense-soft);
  color: var(--expense);
}

.confirm-card__icon--info {
  background: var(--primary-soft);
  color: var(--primary);
}

.confirm-card__body h2 {
  font-size: 1.04rem;
  margin-bottom: 4px;
}

.confirm-card__body p {
  color: var(--text-secondary);
  line-height: 1.5;
}

.confirm-card__actions,
.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-actions {
  margin-top: 18px;
  justify-content: flex-end;
}

.modal-actions .btn {
  flex: 0 0 auto;
  min-width: 112px;
}

.confirm-card__actions .btn {
  flex: 0 1 auto;
  min-width: 100px;
  min-height: 40px;
}

.error-msg {
  margin-bottom: 12px;
  padding: 11px 13px;
  border-radius: 13px;
  border: 1px solid rgba(220, 38, 38, 0.14);
  background: #fef2f2;
  color: var(--expense);
  font-size: 0.9rem;
}

.form-group {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  width: 100%;
}

.form-group--inline {
  gap: 0;
}

.form-group label {
  font-size: 0.86rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea,
.search-input-wrap input {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border-radius: 13px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.02);
}

.form-group textarea {
  min-height: 104px;
  resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.search-input-wrap input:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.34);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
}

.type-switch,
.period-tabs,
.category-type-tabs,
.auth-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  border-radius: 16px;
  background: rgba(246, 248, 252, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.14);
}

.period-tabs {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 14px;
}

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

.type-btn,
.period-tabs button,
.category-type-tabs button,
.auth-switch button {
  min-height: 40px;
  padding: 9px 12px;
  border-radius: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.type-btn.active,
.period-tabs button.active,
.category-type-tabs button.active,
.auth-switch .is-active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.type-btn.active.income {
  color: var(--income);
  background: rgba(5, 150, 105, 0.08);
}

.type-btn.active.expense {
  color: var(--expense);
  background: rgba(220, 38, 38, 0.08);
}

.amount-input {
  text-align: center;
  font-size: clamp(1.5rem, 4vw, 1.9rem) !important;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.category-grid,
.icon-grid {
  display: grid;
  gap: 9px;
}

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

.category-grid .category-btn {
  min-width: 0;
}

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

.icon-grid .icon-btn {
  min-height: 48px;
  font-size: 1.2rem;
}

.category-btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 68px;
  padding: 10px 8px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(255, 255, 255, 0.86);
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition), background var(--transition), color var(--transition);
}

.category-btn {
  flex-direction: column;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.category-btn .icon {
  font-size: 1.2rem;
}

.icon-btn {
  min-height: 56px;
  font-size: 1.3rem;
}

.category-btn:hover:not(:disabled),
.icon-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-xs);
}

.category-btn.active,
.icon-btn.active {
  border-color: rgba(37, 99, 235, 0.28);
  background: var(--primary-soft);
  color: var(--primary);
}

.datetime-picker {
  display: flex;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}

.datetime-picker input {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
}

.search-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.search-form--refresh {
  padding: 4px;
  border-radius: 16px;
  background: rgba(246, 248, 252, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.search-form--refresh .search-input-wrap {
  flex: 1;
}

.search-form--refresh .search-input-wrap input {
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(148, 163, 184, 0.12);
}

.search-form--refresh .btn {
  min-width: 92px;
  padding-inline: 18px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
}

.search-input-wrap input {
  padding-left: 42px;
}

.search-input-wrap__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
}

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

.section-card--search .results-count {
  padding: 0 2px;
  font-weight: 600;
}

.category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.category-list--chips {
  gap: 10px;
}

.category-tag {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 7px 10px;
  border-radius: 14px;
}

.category-section--refresh .section-header .btn-inline {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 12px;
}

.cat-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: rgba(246, 248, 252, 0.96);
}

.cat-delete {
  width: 26px;
  height: 26px;
  margin-left: 2px;
}

.category-tip {
  padding: 14px 16px;
  color: var(--text-secondary);
  text-align: center;
}

.bills-list {
  gap: 10px;
}

.bill-item.inactive {
  opacity: 0.72;
}

.bill-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.bill-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bill-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 0.75rem;
  font-weight: 700;
}

.status-chip--success {
  background: var(--income-soft);
  color: var(--income);
}

.settings-section {
  display: grid;
  gap: 8px;
}

.settings-section--refresh {
  padding: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(247, 249, 252, 0.82));
  border-color: rgba(148, 163, 184, 0.12);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
}

.settings-section--refresh .section-heading {
  margin-bottom: 0;
  padding: 4px 4px 2px;
}

.settings-section--refresh .section-heading h2 {
  font-size: 0.98rem;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 15px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(148, 163, 184, 0.12);
}

.settings-item--stacked {
  align-items: flex-end;
}

.settings-item--stacked .settings-info {
  width: 100%;
}

.settings-item .btn-inline {
  flex-shrink: 0;
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 12px;
}

.settings-title {
  font-size: 0.95rem;
}

.settings-desc {
  font-size: 0.84rem;
  line-height: 1.5;
}

.about-info {
  display: grid;
  gap: 6px;
  padding: 6px 6px 2px;
  color: var(--text-secondary);
}

/* Simplified Settings */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.settings-link {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px;
  background: var(--surface-raised);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 16px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-primary);
  transition: transform var(--transition), box-shadow var(--transition);
  text-align: left;
}

.settings-link:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.settings-link:active:not(:disabled) {
  transform: translateY(0);
}

.settings-link:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.settings-link .chevron {
  margin-left: auto;
  color: var(--text-tertiary);
}

.settings-link--danger {
  color: var(--expense);
}

.settings-footer {
  text-align: center;
  padding: 20px;
  color: var(--text-tertiary);
  font-size: 0.85rem;
}

.about-info p:first-child {
  color: var(--text);
  font-weight: 700;
}

.auth-layout {
  min-height: calc(100vh - var(--header-height) - var(--safe-top));
}

.auth-page {
  min-height: calc(100vh - var(--header-height) - var(--safe-top));
  display: grid;
  place-items: center;
  padding: 20px 0 36px;
}

.auth-card {
  width: min(100%, 420px);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(247, 249, 253, 0.95));
}

.auth-card--refresh {
  padding: 20px;
  border-radius: 28px;
  border-color: rgba(255, 255, 255, 0.72);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.07);
}

.auth-logo {
  display: grid;
  justify-items: center;
  gap: 9px;
  text-align: center;
  margin-bottom: 20px;
}

.auth-logo--refresh {
  margin-bottom: 16px;
}

.auth-logo__mark {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #60a5fa);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.2);
}

.auth-logo h1 {
  font-size: 1.58rem;
  letter-spacing: -0.04em;
}

.auth-logo p {
  color: var(--text-secondary);
  max-width: 28ch;
  line-height: 1.5;
  font-size: 0.92rem;
}

.auth-form {
  display: grid;
  gap: 4px;
}

.auth-form .btn-primary {
  margin-top: 4px;
}

.chart-container {
  position: relative;
  min-height: 248px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(250, 251, 253, 0.92), rgba(255, 255, 255, 0.98));
  border: 1px solid rgba(148, 163, 184, 0.12);
  padding: 14px;
}

.period-tabs,
.category-type-tabs {
  margin-bottom: 14px;
}

.section-card .chart-container {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.chart-container--large {
  min-height: 304px;
}

.chart-container--small {
  min-height: 264px;
}

.chart-container--stats {
  background: linear-gradient(180deg, rgba(248, 250, 253, 0.92), rgba(255, 255, 255, 0.98));
  border-color: rgba(148, 163, 184, 0.1);
}

.chart-container--stats-donut {
  padding: 18px;
}

.section-card--stats {
  padding: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.93), rgba(247, 249, 252, 0.9));
}

.stats-grid--stats {
  gap: 12px;
}

.category-breakdown {
  align-content: start;
}

.category-breakdown--stats {
  gap: 10px;
}

.category-item {
  display: grid;
  grid-template-columns: minmax(72px, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 18px;
}

.category-item--stats {
  display: grid;
  grid-template-rows: auto auto;
  gap: 8px;
  padding: 12px 14px;
}

.category-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.category-item--stats .category-amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.98rem;
  font-weight: 700;
}

.stats-category-item {
  display: grid;
  grid-template-rows: auto auto;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(246, 248, 252, 0.8);
}

.stats-category-item--clickable {
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: left;
  transition: background 0.2s ease;
}

.stats-category-item--clickable:hover {
  background: rgba(37, 99, 235, 0.1);
}

.stats-category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stats-category-name {
  font-weight: 600;
  color: var(--text);
}

.stats-category-amount {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text);
}

.stats-category-bar-wrap {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.stats-category-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
}

/* 统计页面总额显示 */
.stats-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--card-bg);
  border-radius: 8px;
  margin-bottom: 12px;
}

.stats-total-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.stats-total-amount {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

/* 分类选择chips */
.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.category-chip {
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.category-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.category-chip.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* 已选分类标签 */
.selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 4px 12px;
  border-radius: 16px;
  background: var(--primary);
  color: white;
  font-size: 13px;
}

.selected-chip-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.3);
  color: white;
  cursor: pointer;
  padding: 0;
}

.selected-chip-remove:hover {
  background: rgba(255, 255, 255, 0.5);
}

.category-item .category-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-info {
  display: grid;
  gap: 3px;
}

.category-name {
  font-weight: 700;
}

.category-bar-wrap {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.category-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
}

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 14px);
  transform: translateX(-50%);
  width: min(calc(100% - 28px), 480px);
  display: grid;
  gap: 8px;
  z-index: 90;
}

.toast {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 13px;
  border-radius: 15px;
  background: var(--surface-elevated);
  color: var(--text-on-dark);
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(18px);
}

.toast__icon,
.toast__close {
  color: inherit;
}

.toast__message {
  line-height: 1.42;
}

.toast__close.icon-button {
  width: 30px;
  height: 30px;
  border-radius: 10px;
}

.toast--success {
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.96), rgba(6, 182, 212, 0.9));
}

.toast--error {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.96), rgba(244, 63, 94, 0.92));
}

.toast--info {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.94), rgba(51, 65, 85, 0.94));
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 35;
  padding: 0 0 var(--safe-bottom);
  background: linear-gradient(180deg, rgba(244, 246, 251, 0), rgba(244, 246, 251, 0.92) 24%, rgba(244, 246, 251, 0.98) 100%);
}

.bottom-nav__inner {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 10px 10px 11px;
  border-radius: 22px 22px 0 0;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.66);
  box-shadow: 0 -12px 30px rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(24px);
}

.bottom-nav__item {
  min-height: 54px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  padding: 7px 4px;
  border-radius: 16px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}

.bottom-nav__item span {
  font-size: 0.74rem;
  font-weight: 700;
}

.bottom-nav__item.is-active {
  background: var(--primary-soft);
  color: var(--primary);
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
}

.checkbox-label input {
  width: 18px;
  height: 18px;
}

.is-spinning {
  animation: spin 0.9s linear infinite;
}

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

@media (max-width: 1024px) {
  .stats-grid--split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 32px;
    --bottom-nav-height: 82px;
  }

  .app-shell__container {
    width: min(100% - 24px, var(--shell-width));
  }

  .app-header__inner,
  .app-header--compact .app-header__inner {
    min-height: 32px;
    align-items: stretch;
    gap: 4px;
    padding: 0;
  }

  .app-header__text h1 {
    font-size: 1rem;
  }

  .app-header__actions {
    gap: 6px;
    max-width: none;
    flex-wrap: nowrap;
    justify-content: flex-end;
  }

  .month-switcher--header {
    min-width: 0;
    padding: 3px;
  }

  .month-switcher--header .month-switcher__label {
    min-width: 108px;
    font-size: 0.82rem;
  }

  .month-switcher--header .icon-button,
  .icon-button {
    width: 38px;
    height: 38px;
  }

  .section-card,
  .category-section,
  .settings-section,
  .dashboard-hero,
  .auth-card,
  .modal,
  .confirm-card {
    padding: 16px;
  }

  .section-card--stats,
  .section-card--search-panel {
    padding: 12px;
  }

  .modal--fullscreen {
    padding: calc(var(--safe-top) + 6px) 14px calc(var(--safe-bottom) + 18px);
  }

  .modal--fullscreen .modal-header {
    top: calc(var(--safe-top) * -1 - 6px);
    margin: calc(var(--safe-top) * -1 - 6px) -14px 12px;
    padding: calc(var(--safe-top) + 6px) 14px 10px;
  }

  .stats-grid--hero,
  .search-summary,
  .category-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .icon-grid .icon-btn {
    min-height: 44px;
    font-size: 1.1rem;
  }

  .search-form,
  .settings-item,
  .settings-item--stacked {
    flex-direction: column;
    align-items: stretch;
  }

  .search-form--refresh .btn {
    width: 100%;
  }

  .record-amount {
    align-self: center;
  }

  .bill-right,
  .settings-item--stacked {
    width: auto;
  }

  .bill-actions {
    width: auto;
    justify-content: flex-end;
  }

  .bill-actions .btn {
    flex: 0 0 auto;
  }

  .category-item {
    grid-template-columns: minmax(72px, auto) minmax(0, 1fr) auto;
  }

  .toast-stack {
    bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 10px);
  }
}

@media (max-width: 560px) {
  .app-header__inner {
    flex-direction: row;
    align-items: center;
  }

  .app-header__main,
  .app-header__text {
    min-width: 0;
    flex: 1;
  }

  .app-header__text {
    gap: 2px;
  }

  .app-header__actions {
    width: auto;
    flex: 1;
    justify-content: flex-end;
    gap: 6px;
  }

  .month-switcher,
  .month-switcher--header {
    flex: 1;
    justify-content: center;
  }

  .month-switcher--header .month-switcher__label {
    min-width: 96px;
    flex: 1;
  }

  .search-summary,
  .icon-grid,
  .auth-switch {
    grid-template-columns: 1fr;
  }

  .record-item,
  .bill-item,
  .settings-item,
  .category-item {
    padding: 13px;
  }

  .stats-grid--hero {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .period-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .record-left,
  .bill-left {
    gap: 10px;
  }

  .record-left,
  .record-item,
  .bill-item {
    min-width: 0;
  }

  .record-item,
  .bill-item {
    gap: 10px;
  }

  .record-icon,
  .bill-icon,
  .empty-state__icon {
    width: 40px;
    height: 40px;
    border-radius: 13px;
  }

  .datetime-picker {
    gap: 6px;
  }

  .modal-actions,
  .confirm-card__actions {
    flex-direction: column;
  }

  .auth-page {
    padding: 12px 0 24px;
  }

  .auth-card--refresh {
    padding: 18px 16px;
    border-radius: 24px;
  }

  .auth-logo {
    gap: 8px;
    margin-bottom: 16px;
  }

  .auth-logo h1 {
    font-size: 1.46rem;
  }

  .category-btn,
  .icon-btn {
    min-height: 54px;
  }

  .toast {
    grid-template-columns: auto 1fr;
  }

  .toast__close {
    grid-column: 2;
    justify-self: end;
  }

  .bottom-nav__inner {
    gap: 6px;
    padding: 10px;
  }

  .bottom-nav__item {
    min-height: 54px;
  }
}
