/* Design tokens: 天马ACC purple light UI, spaced after the live reference
   site th188.top (its "vault" theme: airy gaps, 1180px shell, soft shadows). */
:root {
  --bg: #f6f6fb;
  --bg-warm: #edecf6;
  --surface: #ffffff;
  --surface-2: #eef0f8;
  --text: #1c1b2e;
  --muted: #565574;
  --faint: #8584a0;
  --primary: #6d45f7;
  --primary-dark: #5b34e6;
  --primary-soft: #efe9ff;
  --success: #0c8584;
  --success-soft: #d6f3f2;
  --warning: #b6770a;
  --warning-soft: #fdf0d7;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --cyan: #0d9488;
  --cyan-soft: #dcf5f1;
  --info-soft: #efe9ff;
  --border: #e6e5f1;
  --border-strong: #d2d1e4;
  --hover: #f4f5f9;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --shadow-sm: 0 2px 8px -3px rgba(33, 26, 23, .14);
  --shadow: 0 2px 10px -4px rgba(28, 27, 46, .10), 0 14px 30px -22px rgba(28, 27, 46, .22);
  --shadow-lg: 0 26px 50px -24px rgba(33, 26, 23, .32);
  --gap-block: 24px;
  --container: 1180px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; color: var(--primary-dark); }

/* Off-screen helper for the clipboard fallback (strict CSP forbids inline styles). */
.sr-copy {
  position: fixed;
  left: -9999px;
  top: 0;
  opacity: 0;
}

/* SVG sprite icon base (mirrors the prototype's .ic). */
.ic {
  width: 1.15em;
  height: 1.15em;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-block;
  vertical-align: -.18em;
  flex: 0 0 auto;
}
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cfd3dd; border-radius: 8px; }

h1, h2, h3, h4 { margin: 0 0 12px; line-height: 1.3; letter-spacing: -.015em; }
h1 { font-size: 22px; font-weight: 800; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
h4 { font-size: 14px; font-weight: 700; }
p { margin: 0 0 10px; }

code {
  background: #f3f4f6;
  border-radius: 4px;
  padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.container { max-width: var(--container); margin: 0 auto; padding: 0 24px; }
@media (max-width: 640px) { .container { padding: 0 16px; } }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1 1 auto; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }

/* Top bar (site) */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 70px;
}
.brand { font-size: 19px; font-weight: 800; letter-spacing: -.02em; color: var(--text); white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand b { color: var(--primary); font-weight: 800; }
.nav { display: flex; align-items: center; gap: 2px; margin-left: 6px; }
.nav a {
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 15px;
  color: var(--muted);
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav-user { display: flex; align-items: center; gap: 9px; margin-left: auto; }
/* Top-bar actions use pill shapes like the reference (个人中心 / 登录 / 注册). */
.topact .btn { border-radius: 999px; border-width: 1px; }

/* Icon button + pill (shared by site top bar) */
.ti {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; color: var(--muted);
  position: relative; cursor: pointer; border: 0;
  background: var(--surface-2); font: inherit;
  transition: background .15s, color .15s;
}
.ti:hover { background: var(--primary-soft); color: var(--primary); }
.ti .ic { width: 18px; height: 18px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 38px; padding: 0 14px; border-radius: 19px;
  border: 1.5px solid var(--border); background: var(--surface);
  font-weight: 700; color: var(--text); cursor: pointer; white-space: nowrap;
}
.pill:hover { border-color: #cfd3dd; }
.pill .amt { color: var(--primary); font-variant-numeric: tabular-nums; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 22px;
  margin: var(--gap-block) 0;
  transition: border-color .15s, box-shadow .15s;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.card-head h2, .card-head h3 { margin: 0; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 16px;
}
.stat .label { color: var(--faint); font-size: 12px; margin-bottom: 4px; }
.stat .value { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--faint); font-size: 12px; margin-top: 4px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 7px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s, filter .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--hover); border-color: var(--border-strong); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(28, 27, 46, .10);
}
.btn-primary:hover { background: var(--primary); border-color: var(--primary); color: #fff; filter: brightness(1.06); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; filter: brightness(1.05); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.btn-sm { min-height: 30px; padding: 3px 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field > label { font-size: 13px; font-weight: 700; color: var(--muted); }
.input, .select, .textarea {
  width: 100%;
  min-height: 42px;
  padding: 8px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fbfbfd;
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(109, 69, 247, .12);
}
.input:disabled, .select:disabled { background: #f3f4f6; color: var(--faint); }
.textarea { min-height: 120px; resize: vertical; }
.hint { color: var(--faint); font-size: 12px; }
.error-text { color: var(--danger); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.form-inline { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 11px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { color: var(--faint); font-weight: 700; font-size: 12px; background: #fafbff; white-space: nowrap; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #fafbff; }
/* An in-place edit keeps the scroll position, so the touched row flashes once
   to stay findable in a long list (admin products page). */
.table tbody tr.row-flash { animation: row-flash 1.4s ease-out; }
@keyframes row-flash { from { background: var(--primary-soft); } to { background: transparent; } }
.table td.amount, .table th.amount { text-align: right; font-variant-numeric: tabular-nums; }
.table td.actions { white-space: nowrap; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: #f1f2f6;
  color: var(--muted);
  white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: #dc2626; }
.badge-info { background: var(--cyan-soft); color: var(--cyan); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }

/* Alerts */
.alert {
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fafbff;
  margin-bottom: 14px;
  font-size: 13px;
}
.alert-error { background: var(--danger-soft); border-color: #f5c2c2; color: #b42318; }
.alert-success { background: var(--success-soft); border-color: #bbf0cc; color: #15803d; }
.alert-warning { background: var(--warning-soft); border-color: #fbdba7; color: #b45309; }
.alert-info { background: var(--primary-soft); border-color: #ddd6f7; color: var(--primary-dark); }

/* Empty / loading */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 46px 16px; text-align: center; color: var(--faint);
}
.empty .ic { width: 46px; height: 46px; color: #cbd0db; stroke-width: 1.6; }
.loading { padding: 32px 16px; text-align: center; color: var(--faint); }
.spinner {
  width: 18px; height: 18px; display: inline-block; vertical-align: -3px;
  border: 2px solid var(--border-strong); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 16px; }
.pagination .page-info { color: var(--faint); font-size: 12px; margin-right: 6px; }
.pagination button {
  min-width: 32px; min-height: 32px; padding: 2px 8px;
  border: 1.5px solid var(--border); background: #fff; border-radius: 9px;
  color: var(--text); cursor: pointer; font: inherit; font-size: 12px; font-weight: 600;
}
.pagination button:hover { border-color: var(--primary); color: var(--primary); }
.pagination button[aria-current="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination button:disabled { opacity: .45; cursor: not-allowed; }
/* Rows-per-page picker sits inside the pagination row, so it cannot inherit the
   full-width 42px form control box. */
.pagination .page-size { width: auto; min-height: 32px; padding: 2px 8px; font-size: 12px; font-weight: 600; border-radius: 9px; margin-right: 6px; }

/* A table cell that opens an editor: reads as text, behaves as a button. */
.cell-edit {
  border: 0; background: transparent; padding: 2px 5px; margin: -2px -5px;
  font: inherit; color: inherit; cursor: pointer; border-radius: 7px;
  border-bottom: 1px dashed var(--border-strong);
}
.cell-edit:hover { color: var(--primary); border-bottom-color: var(--primary); background: var(--primary-soft); }
.cell-edit:disabled { opacity: .5; cursor: default; }

/* Tabs */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; border-bottom: 0; margin-bottom: 16px; padding-bottom: 2px; }
.tabs button {
  padding: 8px 16px; border: 0; border-bottom: 0; border-radius: 9px;
  background: #f1f2f6; color: var(--muted); font: inherit; font-weight: 700; font-size: 13px; cursor: pointer;
  transition: background .15s, color .15s;
}
.tabs button:hover { background: var(--hover); color: var(--text); }
.tabs button.active { background: var(--primary); color: #fff; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 24, 40, .45);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100;
}
.modal {
  width: 100%; max-width: 440px; background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 24px;
}
.modal h3 { margin-bottom: 10px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Toast */
.toast-stack { position: fixed; top: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  min-width: 220px; max-width: 360px; padding: 11px 16px; border-radius: 11px;
  background: #1f2430; color: #fff; box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 600;
}
.toast.success { background: #15803d; }
.toast.error { background: #dc2626; }

/* Auth pages */
.auth-wrap {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 32px 16px; gap: 0;
  background:
    radial-gradient(900px 420px at 15% -10%, rgba(109, 69, 247, .12), transparent 60%),
    radial-gradient(700px 360px at 90% 10%, rgba(109, 69, 247, .07), transparent 55%),
    var(--bg);
}
.auth-brand { font-size: 19px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 16px; color: var(--text); }
.auth-brand:hover { color: var(--text); }
.auth-brand b { color: var(--primary); font-weight: 800; }
.auth-card {
  width: 100%; max-width: 430px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 30px;
}
.auth-card h1 { font-size: 22px; font-weight: 900; text-align: center; margin-bottom: 6px; }
.auth-card > .muted, .auth-card > p.small { text-align: center; color: var(--faint); font-size: 13px; margin-top: 0; }
.auth-links { margin-top: 18px; display: flex; justify-content: space-between; gap: 10px; font-size: 13px; flex-wrap: wrap; }
.auth-footer { margin-top: 18px; color: var(--faint); font-size: 12px; text-align: center; }

/* Icon-prefixed input wrapper (auth forms) */
.fld { margin-bottom: 16px; }
.fld:last-of-type { margin-bottom: 0; }
.fld > label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 7px; }
.fld .inp {
  position: relative; display: flex; align-items: center;
  min-height: 46px; border: 1.5px solid var(--border); border-radius: 11px;
  padding: 0 14px; background: #fbfbfd; transition: border-color .15s, background .15s, box-shadow .15s;
}
.fld .inp:focus-within { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(109, 69, 247, .12); }
.fld .inp > .ic { color: var(--faint); margin-right: 9px; }
.fld .inp input {
  flex: 1; border: none; outline: none; background: transparent;
  font: inherit; font-size: 14px; color: var(--text); min-width: 0; padding: 8px 0;
}
.fld .inp input::placeholder { color: var(--faint); }
.fld .eye {
  color: var(--faint); cursor: pointer; margin-left: 6px; padding: 4px;
  border: 0; background: none; display: grid; place-items: center; border-radius: 6px;
  transition: color .12s;
}
.fld .eye:hover { color: var(--primary); }
.auth-card form { margin-top: 22px; }
.auth-card form > .btn-block { margin-top: 8px; }

/* Misc */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 9px 16px; font-size: 13px; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; word-break: break-all; font-weight: 600; }
.hero { padding: 26px 0 6px; }
.hero h1 { margin: 0 0 6px; font-size: 24px; font-weight: 900; }
.hero p { margin: 0; color: var(--faint); }
.footer { padding: 24px 16px; color: var(--muted); font-size: 12px; }
.sep { height: 1px; background: var(--border); margin: 16px 0; }
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: #f1f2f6; color: var(--muted); font-size: 11px; font-weight: 600;
}
.copy-row { display: flex; align-items: center; gap: 8px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--primary); font-weight: 700; }
.back-link:hover { color: var(--primary-dark); text-decoration: underline; }

@media (max-width: 640px) {
  body { font-size: 14px; }
  .container { padding: 0 14px; }
  .input, .select { min-height: 44px; }
  .btn { min-height: 42px; }
  .btn-sm { min-height: 32px; }
  .card { padding: 16px; }
  .kv { grid-template-columns: 110px 1fr; }
  .table th, .table td { padding: 9px 10px; }
  .hero { padding: 18px 0 4px; }
  .hero h1 { font-size: 22px; }
}
