:root {
  color-scheme: light;
  --paper: #f7f8f5;
  --surface: #ffffff;
  --ink: #1f2925;
  --muted: #6c7771;
  --line: #dfe5df;
  --soft: #edf1ec;
  --vermilion: #b84d32;
  --vermilion-dark: #8f3826;
  --tea: #dce7d3;
  --tea-dark: #55725a;
  --gold: #d5a944;
  --danger: #ad3737;
  --shadow: 0 14px 34px rgba(32, 51, 42, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 11px;
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(184, 77, 50, 0.04) 0, rgba(184, 77, 50, 0.04) 4px, transparent 4px) 18px 0 / 100% 100% no-repeat,
    var(--paper);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(184, 77, 50, 0.3);
  outline-offset: 2px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfcfa;
  color: var(--ink);
  padding: 14px 15px;
  min-height: 52px;
}

input::placeholder,
textarea::placeholder {
  color: #9aa39e;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

.app-shell {
  width: min(100%, 600px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 18px calc(48px + env(safe-area-inset-bottom));
}

.page {
  display: grid;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 13px 13px 5px 13px;
  background: var(--vermilion);
  color: #fffaf4;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 22px;
  font-weight: 800;
  box-shadow: 5px 5px 0 rgba(213, 169, 68, 0.28);
}

.brand-copy {
  min-width: 0;
}

.eyebrow,
.section-label,
.field-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.15em;
  line-height: 1.4;
  text-transform: uppercase;
}

.brand-title {
  margin: 2px 0 0;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: clamp(20px, 5.2vw, 26px);
  letter-spacing: -0.05em;
  line-height: 1.05;
}

.brand-title span {
  color: var(--vermilion);
}

.topbar-spacer {
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-button,
.text-button {
  color: var(--muted);
  background: transparent;
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 10px;
  font-weight: 750;
}

.icon-button:hover,
.text-button:hover {
  background: var(--soft);
  color: var(--ink);
}

.back-button {
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--ink);
  color: #f9fbf7;
  padding: 24px 24px 26px;
  box-shadow: var(--shadow);
}

.hero::after {
  position: absolute;
  right: -26px;
  bottom: -44px;
  width: 164px;
  height: 164px;
  border: 1px solid rgba(213, 169, 68, 0.55);
  border-radius: 50%;
  content: "";
  box-shadow: 0 0 0 16px rgba(213, 169, 68, 0.07), 0 0 0 32px rgba(213, 169, 68, 0.05);
}

.hero-kicker {
  position: relative;
  z-index: 1;
  margin: 0 0 12px;
  color: #f0c968;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.12em;
}

.hero h2 {
  position: relative;
  z-index: 1;
  max-width: 420px;
  margin: 0;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: clamp(28px, 7vw, 42px);
  letter-spacing: -0.06em;
  line-height: 1.1;
}

.hero p:last-child {
  position: relative;
  z-index: 1;
  max-width: 360px;
  margin: 14px 0 0;
  color: #c9d2cb;
  font-size: 14px;
  line-height: 1.7;
}

.card {
  border: 1px solid rgba(184, 77, 50, 0.08);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
}

.search-card {
  border-left: 5px solid var(--vermilion);
}

.card-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-heading h2,
.section-heading h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.04em;
}

.card-heading p,
.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

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

.search-form input {
  min-width: 0;
  font-size: 18px;
  letter-spacing: 0.05em;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-weight: 850;
  transition: transform 120ms ease, background-color 120ms ease, color 120ms ease;
}

.button:active {
  transform: translateY(1px);
}

.button.primary {
  background: var(--vermilion);
  color: #fffaf4;
  box-shadow: 0 7px 14px rgba(184, 77, 50, 0.2);
}

.button.primary:hover {
  background: var(--vermilion-dark);
}

.button.secondary {
  background: var(--tea);
  color: #314737;
}

.button.secondary:hover {
  background: #cfddc5;
}

.button.ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

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

.button.small {
  min-height: 40px;
  padding: 8px 12px;
  font-size: 13px;
}

.feedback {
  display: grid;
  gap: 10px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.feedback.is-error {
  color: var(--danger);
}

.feedback.is-success {
  color: var(--tea-dark);
}

.backup-reminder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid #e7c873;
  border-radius: var(--radius-md);
  background: #fff9e9;
  padding: 12px 14px;
  color: #6c5420;
}

.backup-reminder-copy {
  display: grid;
  gap: 3px;
  line-height: 1.45;
}

.backup-reminder-copy strong {
  color: #59420f;
  font-size: 14px;
}

.backup-reminder-copy span {
  font-size: 12px;
}

.backup-safety-note,
.backup-meta {
  margin: 0;
}

.tool-card {
  display: grid;
  gap: 14px;
  background: linear-gradient(135deg, #fff 0%, #f2f6ef 100%);
}

.settings-card {
  display: grid;
  gap: 14px;
  border-left: 5px solid var(--tea-dark);
}

.settings-card h2,
.settings-safety-card h2 {
  margin: -4px 0 0;
  font-size: 22px;
  letter-spacing: -0.04em;
}

.settings-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--soft);
  padding: 13px 14px;
  color: var(--muted);
  font-size: 13px;
}

.settings-preview strong {
  color: var(--ink);
  font-size: 16px;
}

.settings-safety-card {
  display: grid;
  gap: 12px;
}

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

.tool-grid .button {
  min-height: 46px;
  padding-inline: 8px;
  font-size: 13px;
}

.section {
  display: grid;
  gap: 13px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

.section-heading > div {
  display: grid;
  gap: 4px;
}

.activity-list,
.history-list {
  display: grid;
  gap: 10px;
}

.activity-item,
.history-item {
  position: relative;
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 15px 16px 15px 19px;
}

.activity-item::before,
.history-item::before {
  position: absolute;
  top: 15px;
  bottom: 15px;
  left: 0;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: var(--gold);
  content: "";
}

.activity-top,
.history-top,
.activity-bottom,
.history-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.activity-phone,
.history-type {
  font-weight: 850;
}

.activity-time,
.history-time,
.history-note {
  color: var(--muted);
  font-size: 12px;
}

.activity-value,
.history-balance {
  color: var(--vermilion);
  font-size: 16px;
  font-weight: 900;
  white-space: nowrap;
}

.empty-state {
  border: 1px dashed #cbd5cc;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  padding: 19px;
  font-size: 14px;
  line-height: 1.6;
}

.member-card {
  display: grid;
  gap: 12px;
}

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

.member-phone {
  overflow: hidden;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-phone-label {
  margin-bottom: 5px;
}

.balance-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--ink);
  color: #f8fbf7;
  padding: 24px;
  box-shadow: var(--shadow);
}

.balance-card::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 7px;
  background: var(--vermilion);
  content: "";
}

.balance-label {
  color: #c9d2cb;
  font-size: 13px;
  font-weight: 760;
}

.balance-amount {
  margin: 8px 0 15px;
  color: #fffaf4;
  font-family: "Avenir Next", "PingFang SC", system-ui, sans-serif;
  font-size: clamp(34px, 10vw, 56px);
  font-weight: 900;
  letter-spacing: -0.06em;
  line-height: 1;
  white-space: nowrap;
}

.balance-amount small {
  color: #f0c968;
  font-size: 0.42em;
  letter-spacing: 0;
}

.balance-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  color: #bdc9c0;
  font-size: 12px;
}

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

.action-button {
  display: grid;
  min-height: 96px;
  justify-items: start;
  align-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  padding: 16px;
  text-align: left;
  box-shadow: 0 8px 20px rgba(32, 51, 42, 0.05);
}

.action-button:hover {
  border-color: var(--vermilion);
}

.action-button.recharge-button {
  background: #fbfcf9;
}

.action-button.recharge-button strong {
  color: var(--tea-dark);
}

.action-button strong {
  color: var(--vermilion);
  font-size: 18px;
}

.action-button span {
  color: var(--muted);
  font-size: 12px;
}

.history-item {
  gap: 11px;
}

.history-type {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-type::before {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--vermilion);
  content: "";
}

.history-item.is-use .history-type::before {
  background: var(--tea-dark);
}

.history-item.is-recharge .history-type::before {
  background: var(--gold);
}

.history-lines {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.history-lines strong {
  color: var(--ink);
  font-weight: 800;
}

.danger-zone {
  display: flex;
  justify-content: flex-end;
  padding-top: 5px;
}

.modal-root {
  position: fixed;
  z-index: 20;
  inset: 0;
  pointer-events: none;
}

.modal-root.is-open {
  pointer-events: auto;
}

.modal-backdrop {
  display: grid;
  align-items: end;
  min-height: 100%;
  background: rgba(20, 28, 24, 0.46);
  padding: 16px;
}

.modal {
  width: min(100%, 560px);
  max-height: min(86vh, 720px);
  overflow: auto;
  margin: 0 auto;
  border-radius: 24px 24px 15px 15px;
  background: var(--surface);
  padding: 22px;
  box-shadow: 0 -10px 46px rgba(16, 24, 20, 0.22);
}

.modal-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 17px;
}

.modal-header h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.04em;
}

.modal-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.modal-close {
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--soft);
  color: var(--ink);
  width: 38px;
  height: 38px;
  font-size: 20px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field-label {
  letter-spacing: 0.08em;
}

.field-hint,
.notice {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.amount-input {
  font-size: 21px;
  font-weight: 850;
}

.suggestion-box,
.confirm-summary,
.restore-summary {
  display: grid;
  gap: 8px;
  border-radius: var(--radius-md);
  background: var(--soft);
  padding: 14px;
}

.suggestion-row,
.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.suggestion-row strong,
.summary-row strong {
  color: var(--ink);
  font-size: 16px;
}

.summary-row.is-emphasis strong {
  color: var(--vermilion);
  font-size: 20px;
}

.modal-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 5px;
}

.modal-actions.single {
  grid-template-columns: 1fr;
}

.warning {
  border-radius: var(--radius-sm);
  background: #fff2ef;
  color: var(--danger);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
}

.toast-region {
  position: fixed;
  z-index: 30;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 16px;
  display: grid;
  justify-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: min(100%, 480px);
  border-radius: 999px;
  background: var(--ink);
  color: #fffaf4;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 750;
  box-shadow: 0 10px 25px rgba(20, 28, 24, 0.18);
}

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

.loading {
  display: grid;
  min-height: 70vh;
  place-items: center;
  color: var(--muted);
}

@media (min-width: 680px) {
  .app-shell {
    padding-top: 34px;
  }

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

  .modal {
    border-radius: 24px;
  }
}

@media (max-width: 390px) {
  .app-shell {
    padding-inline: 14px;
  }

  .card,
  .balance-card,
  .hero {
    padding-inline: 17px;
  }

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

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

  .member-phone {
    font-size: 20px;
  }

  .balance-amount {
    font-size: 34px;
  }
}

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