/* ────────────────────────────────────────────────────────────
   MaisonBay — Mastercard-inspired design system
   Tokens & rationale: see design/mastercard/DESIGN.md
   ──────────────────────────────────────────────────────────── */

:root {
  /* Surface */
  --canvas: #F3F0EE;
  --lifted: #FCFBFA;
  --white: #FFFFFF;
  --bone: #F4F4F4;
  --dust: #D1CDC7;
  --whisper: #E8E2DA;     /* ghost-watermark cream-on-cream */

  /* Ink & text */
  --ink: #141413;
  --charcoal: #262627;
  --slate: #696969;
  --granite: #555555;

  /* Accent (use sparingly) */
  --signal: #CF4500;
  --signal-light: #F37338;
  --clay: #9A3A0A;
  --link-blue: #3860BE;

  /* Radii — Apple-style: moderate, not stadium-round */
  --r-button: 12px;
  --r-pill: 999px;
  --r-hero: 18px;

  /* Shadow ladder */
  --shadow-1: 0 4px 24px rgba(0,0,0,.04);
  --shadow-2: 0 24px 48px rgba(0,0,0,.08);

  /* Type */
  --font: "Sofia Sans", system-ui, "Segoe UI", Roboto, Arial, sans-serif;

  /* Spacing scale (8px base) */
  --sp-1: 8px;
  --sp-2: 16px;
  --sp-3: 24px;
  --sp-4: 32px;
  --sp-5: 48px;
  --sp-6: 64px;
  --sp-7: 96px;
  --sp-8: 128px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 450;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* ─────────── Typography ─────────── */
.display-lg, h1.display-lg { font-size: clamp(40px, 6vw, 64px); font-weight: 500; line-height: 1; letter-spacing: -0.02em; margin: 0; }
.display-md, h1.display-md { font-size: clamp(28px, 4vw, 36px); font-weight: 500; line-height: 1.1; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 24px; font-weight: 500; letter-spacing: -0.02em; margin: 0; }
h3 { font-size: 20px; font-weight: 500; letter-spacing: -0.02em; margin: 0; }
.muted { color: var(--slate); }
.micro { font-size: 13px; line-height: 1.5; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--slate);
}
.eyebrow-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--signal-light);
  display: inline-block;
}

/* ─────────── Layout ─────────── */
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(80px, 10vh, 120px) clamp(24px, 4vw, 100px) var(--sp-7);
}
.body-centered .page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--sp-5) clamp(16px, 4vw, 48px);
}

.hero { margin-bottom: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-2); }
.hero-actions { margin-top: var(--sp-2); display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.hero-split { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-5); align-items: center; }
.hero-portrait { display: flex; align-items: center; justify-content: center; }
.hero-meta { display: flex; gap: var(--sp-2); align-items: center; margin: var(--sp-1) 0; flex-wrap: wrap; }

.section { margin-top: var(--sp-6); }
.section-narrow { max-width: 640px; }
.section-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--sp-3);
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--sp-3);
  margin-top: var(--sp-5);
}

/* ─────────── Navigation pill ─────────── */
.nav-pill {
  position: sticky; top: 24px;
  z-index: 50;
  margin: 24px auto 0;
  max-width: 1180px;
  background: var(--white);
  border-radius: 16px;
  box-shadow: var(--shadow-1);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 12px 28px;
  width: calc(100% - 48px);
}
.nav-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 500; font-size: 16px; letter-spacing: -0.03em;
}
.nav-logo-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--ink);
  position: relative;
}
.nav-logo-dot::after {
  content: ""; position: absolute; left: 8px; top: 0;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--signal-light);
  mix-blend-mode: multiply;
}
.nav-links { display: flex; gap: var(--sp-4); flex: 1; justify-content: center; }
.nav-links a { font-weight: 500; font-size: 16px; letter-spacing: -0.03em; }
.nav-links a.is-active { color: var(--signal); }
.nav-end { margin-left: auto; }

/* ─────────── Buttons ─────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 500; font-size: 16px; letter-spacing: -0.02em;
  border: 1.5px solid var(--ink); cursor: pointer;
  border-radius: var(--r-button);
  padding: 8px 24px;
  transition: transform .12s ease, opacity .12s ease;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--ink); color: var(--canvas); }
.btn-secondary { background: var(--white); color: var(--ink); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--lifted); }
.btn-ghost.danger { color: var(--signal); }

.btn-sm { padding: 4px 16px; font-size: 14px; }
.btn-block { width: 100%; }

/* ─────────── Stat tiles ─────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-2);
}
.stat-tile {
  background: var(--lifted);
  border-radius: var(--r-hero);
  padding: var(--sp-3);
  display: flex; flex-direction: column; gap: var(--sp-1);
}
.stat-value { font-size: 36px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.1; }
.stat-hint { color: var(--slate); font-size: 14px; }

/* ─────────── User list rows (pill cards) ─────────── */
.user-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.user-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--sp-3);
  background: var(--white);
  border-radius: 16px;
  padding: 14px 28px;
  box-shadow: var(--shadow-1);
  position: relative;
  color: var(--ink);
}
.user-row:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-2); }
.user-row-wide { border-radius: 16px; padding: 20px 32px; }
.user-row-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.user-row-name { font-size: 20px; font-weight: 500; letter-spacing: -0.02em; }
.user-row-name a { color: inherit; }
.user-row-meta { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; font-size: 14px; }
.user-row-actions { display: flex; gap: var(--sp-1); align-items: center; flex-wrap: wrap; }
.satellite-cta {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--canvas); color: var(--ink);
  display: grid; place-items: center;
  font-size: 18px; font-weight: 500;
  box-shadow: var(--shadow-1);
}

/* ─────────── Avatar (circle portrait) ─────────── */
.avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--signal-light);
  color: var(--white);
  display: grid; place-items: center;
  font-weight: 700; font-size: 28px;
  flex-shrink: 0;
}

/* ─────────── Badges ─────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 4px 12px; border-radius: var(--r-pill);
  font-size: 13px; font-weight: 500; letter-spacing: -0.01em;
  background: var(--bone); color: var(--ink);
}
.badge-active { background: #E6F0E6; color: #2C5F2D; }
.badge-banned { background: #FDE4D8; color: var(--signal); }
.badge-expired { background: #ECE6DD; color: var(--charcoal); }
/* 最近活跃：绿点 + 文字，与状态徽章区分开（状态是账号态，这个是使用态） */
.badge-online { background: #E6F0E6; color: #2C5F2D; }
.badge-online::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: #2C5F2D;
  vertical-align: middle;
}

/* ─────────── Progress bar ─────────── */
.progress {
  width: 100%; height: 6px; border-radius: var(--r-pill);
  background: var(--dust); overflow: hidden;
}
.progress-lg { height: 12px; margin-top: var(--sp-2); }
.progress > span {
  display: block; height: 100%;
  background: var(--ink);
  border-radius: var(--r-pill);
  transition: width .4s ease;
}

/* ─────────── Cards ─────────── */
.card {
  background: var(--lifted);
  border-radius: var(--r-hero);
  padding: var(--sp-3);
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.kv { display: flex; flex-direction: column; gap: 8px; }
.kv-airy { gap: 12px; }
.kv-row { display: flex; justify-content: space-between; gap: var(--sp-2); }
.kv-row span { color: var(--slate); }

/* ─────────── Forms ─────────── */
.form-stack { display: flex; flex-direction: column; gap: var(--sp-2); }
.form-card { background: var(--lifted); border-radius: var(--r-hero); padding: var(--sp-4); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 14px; font-weight: 500; color: var(--charcoal); }
.field-hint { font-size: 13px; color: var(--slate); }
.field-input {
  font: inherit; font-weight: 450;
  background: var(--white); color: var(--ink);
  border: 1px solid rgba(20,20,19,0.18);
  border-radius: 14px;
  padding: 12px 16px;
  outline: none;
}
.field-input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(20,20,19,0.08); }
.form-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-1); }
.form-actions-centered { justify-content: center; }

/* ─────────── Alerts ─────────── */
.alert { padding: 12px 16px; border-radius: 14px; font-size: 14px; }
.alert-error { background: rgba(207,69,0,0.08); color: var(--signal); border: 1px solid rgba(207,69,0,0.2); }

/* ─────────── Login shell ─────────── */
.login-shell { position: relative; max-width: 480px; width: 100%; }
.login-watermark, .user-watermark {
  position: absolute; inset: -80px -120px auto auto;
  font-size: clamp(96px, 14vw, 160px);
  font-weight: 500; letter-spacing: -0.02em;
  color: var(--whisper);
  pointer-events: none;
  user-select: none;
  z-index: 0;
  white-space: nowrap;
}
.login-card {
  position: relative; z-index: 1;
  background: var(--white);
  border-radius: var(--r-hero);
  padding: var(--sp-5);
  box-shadow: var(--shadow-2);
  display: flex; flex-direction: column; gap: var(--sp-2);
}

/* ─────────── User-facing card ─────────── */
.user-shell { position: relative; max-width: 460px; width: 100%; }
.user-watermark { inset: -100px auto auto -60px; color: var(--whisper); }
.user-card, .state-card {
  position: relative; z-index: 1;
  background: var(--white);
  border-radius: var(--r-hero);
  padding: var(--sp-5);
  box-shadow: var(--shadow-2);
  display: flex; flex-direction: column; gap: var(--sp-2);
  text-align: center;
  align-items: center;
}
.qr-portrait {
  width: clamp(220px, 60vw, 280px);
  height: clamp(220px, 60vw, 280px);
  border-radius: 50%;
  background: var(--canvas);
  display: grid; place-items: center;
  margin: var(--sp-2) auto;
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.qr-img { width: 78%; height: 78%; display: block; }
.raw-uri { margin-top: var(--sp-2); width: 100%; text-align: left; }
.raw-uri summary { cursor: pointer; color: var(--slate); font-size: 14px; }
.raw-uri pre {
  margin-top: 8px;
  background: var(--bone);
  padding: 12px;
  border-radius: 14px;
  font-size: 12px;
  white-space: pre-wrap; word-break: break-all;
}

/* ─────────── Audit list ─────────── */
.audit-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.audit-list li {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: var(--sp-2);
  padding: 10px 14px;
  border-radius: 18px;
  background: var(--lifted);
  font-size: 13px;
}
.audit-when { color: var(--slate); }
.audit-actor { color: var(--charcoal); font-weight: 500; }
.audit-action { color: var(--ink); font-weight: 500; }
.audit-target { color: var(--slate); }
.audit-list .empty { background: transparent; }

/* ─────────── Misc ─────────── */
.empty { color: var(--slate); padding: var(--sp-3); text-align: center; }
.chart-wrap { background: var(--lifted); border-radius: var(--r-hero); padding: var(--sp-3); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; margin-right: 6px; }
.dot.ok { background: #2C5F2D; }
.dot.bad { background: var(--signal); }

/* ─────────── Responsive ─────────── */
@media (max-width: 768px) {
  .page { padding-top: clamp(96px, 14vh, 140px); }
  .nav-pill { padding: 10px 18px; }
  .nav-links { gap: var(--sp-3); }
  .hero-split { grid-template-columns: 1fr; text-align: left; }
  .user-row { grid-template-columns: auto 1fr; padding: 14px 18px; border-radius: 14px; }
  .user-row-actions { grid-column: 1 / -1; }
  .satellite-cta { display: none; }
}

/* Number inputs: remove up/down spinners so values are typed directly. */
.field-input[type="number"]::-webkit-outer-spin-button,
.field-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.field-input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Portal tabs */
.tab-bar {
  display: inline-flex;
  gap: 4px;
  background: rgba(0, 0, 0, .05);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 24px;
}
.tab-btn {
  border: none;
  background: transparent;
  padding: 8px 22px;
  border-radius: 8px;
  font: inherit;
  font-weight: 500;
  color: #6b6b6b;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tab-btn:hover { color: #141413; }
.tab-btn.is-active {
  background: #fff;
  color: #141413;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

/* Log table */
.log-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.log-table thead th {
  text-align: left;
  padding: 14px 20px;
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #8a8a86;
  border-bottom: 1px solid rgba(0, 0, 0, .08);
  background: rgba(0, 0, 0, .015);
}
.log-table tbody td { padding: 13px 20px; border-bottom: 1px solid rgba(0, 0, 0, .05); vertical-align: middle; }
.log-table tbody tr:last-child td { border-bottom: none; }
.log-table tbody tr:hover { background: rgba(0, 0, 0, .015); }

/* Portal: nav tabs (styled like nav links) + centered layout */
.nav-links .nav-tab {
  background: none;
  border: none;
  font: inherit;
  font-weight: 500;
  font-size: 16px;
  letter-spacing: -0.03em;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
}
.nav-links .nav-tab:hover { color: var(--signal); }
.nav-links .nav-tab.is-active { color: var(--signal); }

.hero-centered { align-items: center; text-align: center; }
.section-centered { margin-left: auto; margin-right: auto; }

/* ─────────── Admin dark theme ───────────
   Inverts the palette for admin pages only (portal/login stay light) so you
   can always tell at a glance which side you're on. Achieved by remapping the
   design tokens; token-based components flip automatically. */
html:has(> body.admin-theme) { background: #17181A; }
body.admin-theme {
  --canvas:  #17181A;
  --lifted:  #232427;
  --white:   #232427;
  --bone:    #232427;
  --dust:    #3A3B3F;
  --whisper: #202124;
  --ink:     #F4F2EF;
  --charcoal:#E6E4E0;
  --slate:   #9B9B97;
  --granite: #B9B9B5;
  background: var(--canvas);
  min-height: 100vh;
}
/* Dark-theme touch-ups for spots with hardcoded light-on-light values */
body.admin-theme .field-input { border-color: rgba(255,255,255,0.16); }
body.admin-theme .field-input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(255,255,255,0.10); }
body.admin-theme .nav-pill { box-shadow: 0 4px 24px rgba(0,0,0,0.35); }
body.admin-theme .card,
body.admin-theme .form-card,
body.admin-theme .stat-tile,
body.admin-theme .login-card { box-shadow: 0 8px 32px rgba(0,0,0,0.30); }
body.admin-theme .log-table thead th { border-bottom-color: rgba(255,255,255,0.10); background: rgba(255,255,255,0.02); }
body.admin-theme .log-table tbody td { border-bottom-color: rgba(255,255,255,0.07); }
body.admin-theme .log-table tbody tr:hover { background: rgba(255,255,255,0.03); }

/* 教程页步骤列表 */
.guide-steps { margin: 0; padding-left: 1.3em; text-align: left; }
.guide-steps li { margin: 0.5em 0; line-height: 1.6; }
.guide-steps strong { font-weight: 600; }

/* 成功提示 —— 之前只有 error/warn 两种 */
.alert-ok { background: #E6F0E6; color: #2C5F2D; }
/* 警示（不是错误）—— 用于「这些码只显示一次」这类不可逆提醒 */
.field-inline { flex-direction: row; align-items: center; gap: 8px; }
.badge-warn { background: #FBF3DF; color: #7A5A12; }
.alert-warn { background: #FBF3DF; color: #7A5A12; border: 1px solid rgba(122,90,18,0.2); }
