/* =========================================================
   翼享会员 Demo — shared foundation
   ========================================================= */
:root {
  --ink: #17221d;
  --ink-2: #3f4a44;
  --ink-3: #68726c;
  --muted: #858e88;
  --line: #e3e6df;
  --line-strong: #d3d8cf;
  --paper: #f4f5f1;
  --paper-2: #eceee8;
  --surface: #ffffff;
  --surface-2: #fafbf8;
  --brand: #14503f;
  --brand-2: #1b6651;
  --brand-3: #2f7a62;
  --brand-ink: #0d352a;
  --brand-soft: #e9f1ed;
  --brand-wash: #f2f7f4;
  --gold: #a97c3f;
  --gold-2: #c49a5c;
  --gold-soft: #f6efe2;
  --gold-line: #ddc49a;
  --danger: #b4453c;
  --danger-soft: #fbeeec;
  --warn: #9a641d;
  --warn-soft: #faf2e2;
  --success: #2c6b4e;
  --success-soft: #ebf3ee;
  --info: #38627e;
  --info-soft: #ebf2f7;
  --shadow-1: 0 1px 2px rgba(23, 34, 29, 0.03), 0 2px 7px rgba(23, 34, 29, 0.04);
  --shadow-2: 0 10px 30px rgba(23, 34, 29, 0.12);
  --shadow-3: 0 20px 60px rgba(13, 30, 23, 0.24);
  --r-s: 5px;
  --r-m: 9px;
  --r-l: 14px;
  --r-xl: 20px;
  --font: "PingFang SC", "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --num: "Bahnschrift", "DIN Alternate", "SF Pro Display", var(--font);
  --app-width: 430px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul, ol { margin: 0; padding: 0; }
h1, h2, h3, h4, p { margin: 0; }

.icon { flex: none; display: inline-block; vertical-align: -3px; }

.num, .tnum { font-family: var(--num); font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }

.muted { color: var(--muted); }
.sub { color: var(--ink-3); }
.strong { font-weight: 600; }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.center { display: flex; align-items: center; justify-content: center; }
.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;
}

/* ---------- Brand ---------- */
.brand-seal {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 5px;
  background: var(--brand); color: #f1e6cf;
  font-weight: 700; font-family: "Songti SC", "STSong", var(--font);
  letter-spacing: 0; flex: none;
}
.brand-seal-light {
  background: transparent; border: 1px solid var(--gold-line);
  color: #e5cfa4;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--r-m);
  background: transparent; color: var(--ink);
  font-weight: 600; font-size: 14px; line-height: 1;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .12s ease, opacity .16s ease;
  white-space: nowrap; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: .48; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { border-color: var(--brand-3); color: var(--brand); }
.btn-ghost { color: var(--ink-2); padding: 0 10px; }
.btn-ghost:hover { background: var(--paper-2); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-ghost { color: var(--danger); border-color: #eccbc6; background: #fff; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 12px; border-radius: 6px; gap: 5px; }
.btn-xs { min-height: 26px; padding: 0 9px; font-size: 11px; border-radius: 5px; gap: 4px; }
.btn-lg { min-height: 50px; font-size: 15px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-link { min-height: auto; padding: 2px 0; border: 0; background: transparent; font-size: 12px; color: var(--brand); font-weight: 600; }
.btn-link:hover { color: var(--brand-3); }

.icon-btn {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink-2);
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }
.icon-btn-sm { width: 28px; height: 28px; border-radius: 6px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field-label {
  font-size: 12px; font-weight: 600; color: var(--ink-2);
  display: flex; align-items: center; gap: 5px;
}
.field-label em { font-style: normal; color: var(--danger); }
.field-help { font-size: 11px; color: var(--muted); line-height: 1.5; }
.field-error { font-size: 11px; color: var(--danger); display: flex; align-items: center; gap: 4px; }
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 8px;
  background: #fff; color: var(--ink); outline: none;
  min-height: 42px; padding: 9px 12px; font-size: 14px;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.input::placeholder, .textarea::placeholder { color: #a7ada8; }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--brand-3);
  box-shadow: 0 0 0 3px rgba(27, 102, 81, 0.10);
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: #d79a93; box-shadow: 0 0 0 3px rgba(180, 69, 60, 0.08);
}
.input.is-error { border-color: #d79a93; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
.select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2368726c' stroke-width='1.7'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.input-wrap .input { padding-left: 37px; }
.input-wrap .suffix { position: absolute; right: 12px; color: var(--muted); font-size: 12px; }
.search-field { position: relative; }
.search-field .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-field .input { padding-left: 37px; background: #fff; }
.form-grid { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.checkbox, .radio {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
  font-size: 12.5px; color: var(--ink-2);
}
.checkbox input, .radio input {
  appearance: none; width: 17px; height: 17px; margin: 0; flex: none;
  border: 1px solid var(--line-strong); background: #fff; border-radius: 4px;
  position: relative; cursor: pointer; transition: border-color .15s, background .15s;
}
.checkbox input:checked, .radio input:checked { background: var(--brand); border-color: var(--brand); }
.checkbox input:checked::after {
  content: ""; position: absolute; left: 5px; top: 1px; width: 4px; height: 8px;
  border-right: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(40deg);
}
.radio input { border-radius: 50%; }
.radio input:checked::after {
  content: ""; position: absolute; inset: 4px; border-radius: 50%; background: #fff;
}
.switch {
  width: 42px; height: 24px; border-radius: 12px; background: #d9ddd6; border: 0;
  position: relative; flex: none; transition: background .18s ease;
}
.switch::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px;
  background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.15);
  transition: transform .18s ease;
}
.switch[aria-checked="true"] { background: var(--brand-3); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

/* ---------- Segmented / Tabs / Chips ---------- */
.segmented {
  display: inline-flex; padding: 3px; background: var(--paper-2);
  border-radius: 8px; gap: 2px;
}
.segmented button {
  border: 0; background: transparent; border-radius: 6px; color: var(--ink-3);
  min-height: 30px; padding: 0 12px; font-size: 12px; font-weight: 500;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.segmented button.is-active {
  background: #fff; color: var(--ink); font-weight: 600;
  box-shadow: 0 1px 3px rgba(23,34,29,.07);
}
.segmented button:disabled { opacity: .45; cursor: not-allowed; }

.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 0; background: transparent; padding: 11px 0 10px; position: relative;
  color: var(--ink-3); font-size: 13px; font-weight: 500; white-space: nowrap;
}
.tabs button.is-active { color: var(--ink); font-weight: 600; }
.tabs button.is-active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--brand); border-radius: 2px 2px 0 0;
}
.tabs .count { margin-left: 4px; color: var(--muted); font-size: 11px; font-family: var(--num); }

.chip {
  display: inline-flex; align-items: center; gap: 5px; min-height: 26px;
  padding: 0 9px; border: 1px solid var(--line); border-radius: 5px;
  background: #fff; color: var(--ink-2); font-size: 11.5px; font-weight: 500;
}
.chip.is-active { border-color: var(--brand); background: var(--brand-wash); color: var(--brand); }
.chip-btn { cursor: pointer; }
.chip-btn:hover { border-color: var(--brand-3); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px;
  border-radius: 4px; font-size: 11px; font-weight: 600; line-height: 1.5;
  white-space: nowrap;
}
.badge-green { color: var(--success); background: var(--success-soft); }
.badge-gray { color: var(--ink-3); background: #f0f2ed; }
.badge-gold { color: var(--gold); background: var(--gold-soft); }
.badge-red { color: var(--danger); background: var(--danger-soft); }
.badge-warn { color: var(--warn); background: var(--warn-soft); }
.badge-blue { color: var(--info); background: var(--info-soft); }
.badge-dark { color: #fff; background: var(--brand); }

/* ---------- Avatars ---------- */
.avatar {
  width: 36px; height: 36px; border-radius: 9px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; letter-spacing: .02em;
  background: #e8eee9; color: #335445;
}
.avatar-sm { width: 28px; height: 28px; border-radius: 7px; font-size: 11px; }
.avatar-lg { width: 56px; height: 56px; border-radius: 14px; font-size: 18px; }
.tone-jade { background: #e4efe8; color: #2a5d47; }
.tone-sand { background: #f2ede3; color: #775f36; }
.tone-clay { background: #f2e8e4; color: #7c5145; }
.tone-slate { background: #e8ebef; color: #47586b; }
.tone-moss { background: #e8ede2; color: #53613e; }
.tone-rose { background: #f2e9e9; color: #77504f; }
.tone-bronze { background: #f0e9dd; color: #755a31; }
.tone-ink { background: #e5e9e6; color: #35453d; }

/* ---------- Cards / rows ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-l); box-shadow: var(--shadow-1);
}
.card-pad { padding: 16px; }
.divider { height: 1px; background: var(--line); }
.hr-soft { height: 1px; background: #eef0eb; }

.list-row {
  display: flex; align-items: center; gap: 12px; padding: 13px 0;
  border-bottom: 1px solid #eef0eb;
}
.list-row:last-child { border-bottom: 0; }

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; min-height: 150px; padding: 26px 16px; text-align: center; color: var(--muted);
}
.empty .empty-icon {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--paper-2); color: var(--muted);
}
.empty .empty-title { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.empty .empty-desc { font-size: 12px; line-height: 1.6; max-width: 260px; }

.notice {
  display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px;
  border: 1px solid var(--gold-line); background: #fbf7ef; border-radius: 7px;
  font-size: 11.5px; color: #6f5a34; line-height: 1.6;
}
.notice .icon { color: var(--gold); margin-top: 1px; }
.notice-green { border-color: #cfe0d5; background: var(--brand-wash); color: #376352; }
.notice-green .icon { color: var(--brand-3); }
.notice-red { border-color: #efd2cd; background: var(--danger-soft); color: #8c3a32; }
.notice-red .icon { color: var(--danger); }

/* ---------- Modal / Sheet / Toast ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(12, 22, 17, .46);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; animation: fadeIn .18s ease both;
}
.modal-overlay.is-sheet { align-items: flex-end; padding: 0; }
.modal {
  width: min(480px, 100%); max-height: min(80vh, 720px); background: #fff;
  border-radius: 14px; box-shadow: var(--shadow-3);
  display: flex; flex-direction: column; overflow: hidden;
  animation: modalIn .2s cubic-bezier(.2,.8,.2,1) both;
}
.modal.is-wide { width: min(720px, 100%); }
.modal.is-sheet {
  width: min(var(--app-width), 100%); border-radius: 16px 16px 0 0;
  max-height: 88vh; animation: sheetIn .22s cubic-bezier(.2,.8,.2,1) both;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px 12px; flex: none;
}
.modal-head h3 { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.modal-head .sub { font-size: 11.5px; margin-top: 2px; }
.modal-body { padding: 4px 18px 18px; overflow: auto; overscroll-behavior: contain; }
.modal-foot {
  display: flex; gap: 10px; justify-content: flex-end; padding: 12px 18px 16px;
  border-top: 1px solid var(--line); background: #fff; flex: none;
}
.modal-foot .btn { min-width: 82px; }
.modal.is-sheet .modal-foot { padding-bottom: 18px; }
.modal.is-sheet .modal-foot .btn-primary { flex: 1; }
.sheet-handle {
  width: 34px; height: 4px; border-radius: 2px; background: #d9ddd6;
  margin: 8px auto 0; flex: none;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }

.toast-root { position: fixed; inset: 0; pointer-events: none; z-index: 320; }
.toast {
  position: fixed; left: 50%; top: 22px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; max-width: min(360px, calc(100vw - 32px));
  padding: 10px 14px; border-radius: 8px; background: rgba(20, 35, 28, .93);
  color: #fff; font-size: 12.5px; line-height: 1.45; box-shadow: 0 8px 26px rgba(0,0,0,.18);
  animation: toastIn .2s ease both; backdrop-filter: blur(8px);
}
.toast .icon { color: #cfe3d8; }
.toast.is-error { background: rgba(106, 40, 34, .95); }
.toast.is-error .icon { color: #f3c9c3; }
.toast.is-info { background: rgba(36, 52, 45, .93); }
.toast.is-leaving { animation: toastOut .18s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toastOut { to { opacity: 0; transform: translate(-50%, -8px); } }

/* ---------- Tables ---------- */
.table-wrap {
  overflow: auto; border: 1px solid var(--line); border-radius: var(--r-m);
  background: #fff; scrollbar-width: thin;
}
.table { width: 100%; border-collapse: collapse; min-width: 680px; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 600; color: var(--ink-3);
  padding: 10px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
.table td {
  padding: 12px 14px; border-bottom: 1px solid #eff1ec; font-size: 12.5px;
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: #fbfcf9; }
.table tbody tr.is-clickable { cursor: pointer; }
.table .cell-main { font-weight: 600; color: var(--ink); }
.table .cell-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.table .cell-num { font-family: var(--num); font-variant-numeric: tabular-nums; }
.table .cell-strong { font-weight: 600; }
.table .actions { white-space: nowrap; }
.table .tick { position: sticky; left: 0; background: #fff; z-index: 2; }

.pagination {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 2px 0; font-size: 12px; color: var(--muted);
}
.pagination .pages { display: flex; gap: 3px; }
.pagination button {
  min-width: 28px; height: 28px; border: 1px solid var(--line); background: #fff;
  border-radius: 5px; font-size: 11.5px; color: var(--ink-2);
}
.pagination button.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination button:disabled { opacity: .4; }

/* ---------- QR ---------- */
.qr-frame {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 14px; background: #fff; border: 1px solid var(--line);
  border-radius: 10px;
}
.qr-frame svg { display: block; width: 100%; height: auto; }
.qr-caption { font-size: 10px; color: var(--muted); letter-spacing: .18em; text-transform: uppercase; }

/* ---------- Progress / meters ---------- */
.progress {
  height: 5px; border-radius: 3px; background: #e9ece6; overflow: hidden;
}
.progress > span {
  display: block; height: 100%; border-radius: 3px; background: var(--brand-3);
  transition: width .3s ease;
}
.progress.is-gold > span { background: var(--gold); }
.meter {
  display: flex; align-items: center; gap: 10px;
}
.meter .track { flex: 1; height: 6px; background: #eef0eb; border-radius: 4px; overflow: hidden; }
.meter .track span { display: block; height: 100%; background: var(--brand); border-radius: 4px; }

/* ---------- Stat / utility ---------- */
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 8px 12px; font-size: 12px; }
.kv .k { color: var(--muted); }
.kv .v { color: var(--ink-2); }
.stat-label { font-size: 11px; color: var(--ink-3); letter-spacing: .02em; }
.stat-value { font-family: var(--num); font-weight: 600; letter-spacing: -.01em; }
.eyebrow {
  font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold);
  font-weight: 600;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand-3); flex: none; }
.dot-gold { background: var(--gold); }
.dot-red { background: var(--danger); }
.dot-gray { background: #b6bdb7; }

.price { font-family: var(--num); font-weight: 600; letter-spacing: -.01em; }
.strike { text-decoration: line-through; color: var(--muted); font-weight: 400; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Chart scaffolding ---------- */
.chart-box { position: relative; width: 100%; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-tooltip {
  position: absolute; pointer-events: none; z-index: 3;
  background: rgba(20, 34, 28, .94); color: #fff; border-radius: 6px;
  padding: 6px 9px; font-size: 11px; line-height: 1.5; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px)); opacity: 0; transition: opacity .12s ease;
}
.chart-tooltip.is-on { opacity: 1; }
.chart-tooltip strong { font-family: var(--num); font-size: 13px; }
.chart-legend { display: flex; align-items: center; gap: 14px; font-size: 11px; color: var(--ink-3); }
.chart-legend .key { display: inline-block; width: 14px; height: 2px; background: var(--brand); margin-right: 5px; vertical-align: middle; }
.chart-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.chart-table th, .chart-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.chart-table th:first-child, .chart-table td:first-child { text-align: left; }
.chart-table th { color: var(--muted); font-weight: 500; }

/* ---------- Misc ---------- */
.skeleton { background: linear-gradient(90deg, #eef0eb 25%, #f6f7f3 37%, #eef0eb 63%); background-size: 400% 100%; animation: shimmer 1.2s ease infinite; border-radius: 5px; }
@keyframes shimmer { to { background-position: -400% 0; } }
.safe-bottom { padding-bottom: env(safe-area-inset-bottom, 0); }
.hide { display: none !important; }
.no-scroll { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
