:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-soft: #eef2ff;
  --green: #16a34a;
  --red: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 8px 24px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Top nav ---- */
.nav {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand {
  font-weight: 800;
  font-size: 18px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand:hover { text-decoration: none; }
.brand .dot {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--brand), #818cf8);
  display: inline-grid; place-items: center; color: #fff; font-size: 14px;
}
.nav-links { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.nav-links a { color: var(--muted); font-weight: 500; font-size: 14px; }
.nav-links a.active, .nav-links a:hover { color: var(--ink); text-decoration: none; }

/* ---- Layout ---- */
.container { max-width: 1080px; margin: 0 auto; padding: 28px 20px 60px; }
.narrow { max-width: 480px; }
.page-title { font-size: 24px; font-weight: 800; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 24px; }

/* ---- Cards ---- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.grid { display: grid; gap: 16px; }
@media (min-width: 720px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* ---- Forms ---- */
label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: #334155; }
input, textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 18px; border-radius: 10px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
  background: var(--brand); color: #fff; transition: background .15s;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: #f8fafc; }
.btn.danger { background: #fff; color: var(--red); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.sm { padding: 7px 12px; font-size: 13px; }

.msg { padding: 10px 14px; border-radius: 10px; font-size: 14px; margin: 14px 0; display: none; }
.msg.show { display: block; }
.msg.err { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; }
.msg.ok { background: #f0fdf4; color: var(--green); border: 1px solid #bbf7d0; }

/* ---- Misc ---- */
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.spread { justify-content: space-between; }
.tag {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px;
  border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark);
}
.stat-num { font-size: 30px; font-weight: 800; }
.stat-label { color: var(--muted); font-size: 13px; }

/* ---- QR list ---- */
.qr-item {
  display: flex; align-items: center; gap: 16px; padding: 16px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; transition: border-color .15s;
}
.qr-item:hover { border-color: #cbd5e1; }
.qr-item h3 { margin: 0 0 2px; font-size: 16px; }
.qr-item .url { font-size: 13px; color: var(--muted); word-break: break-all; }
.qr-thumb { width: 56px; height: 56px; border-radius: 10px; border: 1px solid var(--line); flex: 0 0 auto; }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }

/* ---- Hero (home) ---- */
.hero { text-align: center; padding: 56px 20px 20px; }
.hero h1 { font-size: 40px; font-weight: 800; margin: 0 0 14px; line-height: 1.15; }
.hero h1 .grad { background: linear-gradient(135deg, var(--brand), #818cf8); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { font-size: 18px; color: var(--muted); max-width: 560px; margin: 0 auto 26px; }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.qr-preview { display: grid; place-items: center; gap: 14px; }
.qr-preview img, .qr-preview canvas { border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 8px; }

/* ---- Form builder ---- */
.field-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px;
  background: #fafbff;
}
.field-card .field-head { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.field-card .grow { flex: 1; min-width: 160px; }
.field-card label { margin-top: 0; }
select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--ink);
}
select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.chk { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: 14px; }
.chk input { width: auto; }
.field-opts { margin-top: 10px; }
.field-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }

/* table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 13px; background: #f8fafc; }
td.wrap, th.wrap { white-space: normal; }

/* public fill page */
.fill-wrap { max-width: 520px; margin: 0 auto; padding: 24px 16px 60px; }
.fill-logo { display: block; margin: 0 auto 10px; width: 64px; height: 64px; border-radius: 14px; object-fit: contain; }
body.fill { min-height: 100vh; }

/* =====================================================================
   Form themes — applied to the public fill page via body[data-theme].
   Each theme re-skins via CSS variables + a few element overrides.
   ===================================================================== */

/* 商务 · 会议 / 报名 */
body.fill[data-theme="business"] {
  --bg: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  --brand: #2563eb; --brand-dark: #1d4ed8; --brand-soft: #dbeafe;
  --radius: 8px;
  font-family: "Segoe UI", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
}
body.fill[data-theme="business"] .nav { background: #0f172a; border-bottom-color: #1e293b; }
body.fill[data-theme="business"] .brand { color: #f8fafc; }

/* 优雅 · 婚礼 / 时装 / 艺术 */
body.fill[data-theme="elegant"] {
  --bg: #faf6f0; --card: #fffdfa; --ink: #3a352f; --muted: #8a8178; --line: #e7ddcf;
  --brand: #b08968; --brand-dark: #997556; --brand-soft: #f3e9df;
  --radius: 4px;
  font-family: Georgia, "Times New Roman", "Songti SC", "STSong", serif;
}
body.fill[data-theme="elegant"] .page-title { font-weight: 600; letter-spacing: .5px; }
body.fill[data-theme="elegant"] .btn { letter-spacing: 2px; }

/* 活力 · 派对 / 活动 / 促销 */
body.fill[data-theme="vibrant"] {
  --bg: linear-gradient(135deg, #f093fb 0%, #f5576c 50%, #ff9a44 100%);
  --card: #ffffff; --brand: #f5576c; --brand-dark: #e0405a; --brand-soft: #ffe3e8;
  --radius: 18px;
}
body.fill[data-theme="vibrant"] .btn {
  background: linear-gradient(135deg, #f5576c, #ff9a44);
}
body.fill[data-theme="vibrant"] .btn:hover { filter: brightness(.95); background: linear-gradient(135deg, #f5576c, #ff9a44); }
body.fill[data-theme="vibrant"] .card { box-shadow: 0 12px 40px rgba(245, 87, 108, .25); }

/* 自然 · 教育 / 户外 / 公益 */
body.fill[data-theme="nature"] {
  --bg: linear-gradient(180deg, #f0fdf4 0%, #dcfce7 100%);
  --brand: #16a34a; --brand-dark: #15803d; --brand-soft: #dcfce7;
  --radius: 16px;
}

/* 暗夜 · 科技 / 游戏 */
body.fill[data-theme="dark"] {
  --bg: #0b1020; --card: #161d2e; --ink: #e6ebf5; --muted: #93a0bd; --line: #2a3450;
  --brand: #6366f1; --brand-dark: #4f46e5; --brand-soft: #1e2540;
  --input-bg: #0f1626; --radius: 12px;
}
body.fill[data-theme="dark"] .nav { background: #0b1020; border-bottom-color: #2a3450; }
body.fill[data-theme="dark"] .brand { color: #e6ebf5; }
body.fill[data-theme="dark"] label { color: #c2cce0; }

/* theme-aware inputs (base default stays white) */
input, textarea, select { background: var(--input-bg, #fff); }

/* ---- Theme picker (builder) ---- */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.theme-opt {
  border: 2px solid var(--line); border-radius: 12px; padding: 10px; cursor: pointer;
  background: #fff; transition: border-color .15s, transform .1s; text-align: left;
}
.theme-opt:hover { transform: translateY(-1px); }
.theme-opt.sel { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.theme-opt .sw { height: 38px; border-radius: 8px; margin-bottom: 8px; border: 1px solid rgba(0,0,0,.06); }
.theme-opt .nm { font-weight: 700; font-size: 14px; }
.theme-opt .sc { color: var(--muted); font-size: 12px; }
.sw-classic  { background: linear-gradient(135deg, #4f46e5, #818cf8); }
.sw-business { background: linear-gradient(135deg, #0f172a, #2563eb); }
.sw-elegant  { background: linear-gradient(135deg, #b08968, #faf6f0); }
.sw-vibrant  { background: linear-gradient(135deg, #f093fb, #f5576c, #ff9a44); }
.sw-nature   { background: linear-gradient(135deg, #16a34a, #86efac); }
.sw-dark     { background: linear-gradient(135deg, #0b1020, #6366f1); }
