:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafafb;
  --border: #e4e6eb;
  --border-strong: #d3d6dc;
  --text: #14161a;
  --text-2: #5b6270;
  --text-3: #8b929e;
  --primary: #3b4cca;
  --primary-hover: #2f3eb0;
  --primary-soft: #eef0fc;
  --green: #12805c;
  --green-soft: #e7f6ef;
  --amber: #96601a;
  --amber-soft: #fdf3e2;
  --red: #b4232b;
  --red-soft: #fdecec;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }

/* ---------- layout ---------- */
.header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1120px; margin: 0 auto; padding: 0 24px;
  height: 58px; display: flex; align-items: center; gap: 28px;
}
.logo { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 15px; color: var(--text); }
.logo-mark {
  width: 26px; height: 26px; border-radius: 7px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  padding: 7px 11px; border-radius: 7px; color: var(--text-2); font-size: 13.5px; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.header-right { display: flex; align-items: center; gap: 10px; }

.container { max-width: 1120px; margin: 0 auto; padding: 32px 24px 72px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 22px; }
.page-head p { color: var(--text-2); margin-top: 5px; font-size: 13.5px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-products {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(310px, 380px));
  justify-content: start;
}

/* ---------- surface ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }
.card-head {
  padding: 15px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-head h3 { font-size: 14.5px; }
.card-body { padding: 20px; }
.muted { color: var(--text-2); }
.tiny { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: .15s; white-space: nowrap; font-family: inherit;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--red); border-color: #f0c9cb; background: #fff; }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 6px; }
.btn-lg { height: 40px; padding: 0 20px; font-size: 14px; }
.btn-block { width: 100%; }

/* ---------- form ---------- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--border-strong);
  border-radius: 8px; background: #fff; color: var(--text); font-size: 13.5px;
  font-family: inherit; transition: .15s;
}
.textarea { height: auto; padding: 9px 11px; resize: vertical; min-height: 76px; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59, 76, 202, .12);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.form-error {
  background: var(--red-soft); color: var(--red); border-radius: 8px;
  padding: 9px 12px; font-size: 13px; margin-bottom: 14px;
}

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-weight: 500; color: var(--text-3); font-size: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
  background: var(--surface-2);
}
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfcfd; }

/* ---------- badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 21px; padding: 0 7px;
  border-radius: 5px; font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-gray { background: #f1f2f4; color: var(--text-2); }
.badge-blue { background: var(--primary-soft); color: var(--primary); }

/* ---------- product card ---------- */
.product-card { display: flex; flex-direction: column; }
.product-top { padding: 20px 20px 0; display: flex; gap: 13px; }
.product-icon {
  width: 42px; height: 42px; border-radius: 11px; background: var(--primary-soft);
  color: var(--primary); display: grid; place-items: center; font-size: 19px; flex: none;
}
.product-name { font-size: 15px; font-weight: 600; }
.product-desc { padding: 12px 20px 0; color: var(--text-2); font-size: 13px; min-height: 40px; }
.plans { padding: 16px 20px 20px; margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.plan {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; transition: .15s; background: var(--surface);
}
.plan:hover { border-color: var(--primary); background: var(--primary-soft); }
.plan-info { min-width: 0; }
.plan-name { font-weight: 550; font-size: 13.5px; }
.plan-meta { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.plan-price { font-size: 15px; font-weight: 650; color: var(--text); letter-spacing: -.02em; }
.plan-price small { font-size: 11px; font-weight: 500; color: var(--text-3); margin-left: 2px; }

/* ---------- stat ---------- */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px; }
.stat-label { font-size: 12px; color: var(--text-3); }
.stat-value { font-size: 21px; font-weight: 650; letter-spacing: -.02em; margin-top: 3px; }
.stat-value small { font-size: 12px; font-weight: 500; color: var(--text-3); }

/* ---------- code ---------- */
.code-box {
  display: flex; align-items: center; gap: 10px; background: var(--surface-2);
  border: 1px dashed var(--border-strong); border-radius: 9px; padding: 9px 12px;
}
.code-text { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; font-weight: 600; letter-spacing: .06em; }

pre.code {
  background: #12141a; color: #e6e8ee; border-radius: 10px; padding: 15px 17px;
  overflow-x: auto; font-size: 12.5px; line-height: 1.65;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
pre.code .c { color: #7d8698; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; }
.tab {
  padding: 9px 13px; font-size: 13.5px; font-weight: 500; color: var(--text-2);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  background: none; border-top: 0; border-left: 0; border-right: 0; font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- modal ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 20, 30, .42); z-index: 90;
  display: grid; place-items: center; padding: 24px; animation: fade .14s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto; animation: pop .16s ease;
}
@keyframes pop { from { transform: translateY(6px) scale(.99); opacity: .6 } to { transform: none; opacity: 1 } }
.modal.modal-lg { max-width: 640px; }
.modal-head { padding: 17px 20px 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 16px 20px; }
.modal-foot { padding: 0 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }
.icon-btn {
  width: 28px; height: 28px; border-radius: 6px; border: 0; background: transparent;
  color: var(--text-3); cursor: pointer; font-size: 17px; line-height: 1; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- toast ---------- */
.toasts { position: fixed; top: 68px; right: 16px; z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1b1e26; color: #fff; padding: 10px 15px; border-radius: 9px; font-size: 13px;
  box-shadow: var(--shadow-lg); animation: slide .18s ease; max-width: 340px;
}
.toast.err { background: #a5232b; }
@keyframes slide { from { transform: translateX(14px); opacity: 0 } to { transform: none; opacity: 1 } }

/* ---------- misc ---------- */
.empty { padding: 52px 20px; text-align: center; color: var(--text-3); font-size: 13.5px; }
.empty-icon { font-size: 26px; opacity: .45; margin-bottom: 8px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.notice-bar {
  background: var(--primary-soft); border: 1px solid #dfe3fb; color: #2c3690;
  border-radius: 9px; padding: 10px 14px; font-size: 13px; margin-bottom: 20px;
}
.qr-wrap { display: grid; place-items: center; padding: 10px; }
.qr-wrap img { width: 240px; height: 240px; border-radius: 8px; border: 1px solid var(--border); }
.auth-wrap { max-width: 380px; margin: 7vh auto 0; }
.spinner {
  width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg) } }
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: 0; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .nav { display: none; }
  .header-inner { justify-content: space-between; }
}
@media (max-width: 560px) {
  .container { padding: 22px 16px 56px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .header-inner { padding: 0 16px; }
}
