:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #1D4ED8;
  --brand-soft: #dbeafe;
  --souvi-blue: #1D4ED8;
  --souvi-sun: #F5C518;
  --danger: #b91c1c;
  --draft: #a16207;
  --draft-bg: #fef9c3;
  --pub: #15803d;
  --pub-bg: #dcfce7;
  --off: #b91c1c;
  --off-bg: #fee2e2;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.04);
  --radius: 12px;
  font-family: "PingFang SC", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
button, .btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); border-radius: 8px; padding: 8px 14px; font: inherit; cursor: pointer;
}
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }
.btn-danger { color: var(--danger); border-color: #fecaca; background: #fff; }
.btn-ghost { background: transparent; }
.app { max-width: 1180px; margin: 20px auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 18px; font-weight: 650; }
.brand-mark { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; }
.brand-mark i { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg,#1D4ED8,#1E3A8A); display:inline-block; }
.brand-mark .brand-logo {
  width: 28px; height: 28px; border-radius: 8px; background: #1D4ED8; padding: 3px; box-sizing: border-box; display: block;
}
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 22px; border-bottom: 1px solid var(--line); background: #fafbfc; }
.search { flex: 1; min-width: 200px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; background: #fff; color: var(--muted); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 12px; color: var(--muted); background: #fff; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 500; background: #f8fafc; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.draft { color: var(--draft); background: var(--draft-bg); }
.status.pub { color: var(--pub); background: var(--pub-bg); }
.status.off { color: var(--off); background: var(--off-bg); }
.ops { display: flex; gap: 12px; white-space: nowrap; }
.ops a { font-size: 13px; font-weight: 500; }
.ops .muted { color: #94a3b8; }
.hint { padding: 12px 22px; font-size: 12px; color: var(--muted); background: #f8fafc; }
.grid2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; padding: 20px 22px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: #fff; }
.card h2 { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: #f1f5f9; padding: 8px 10px; border-radius: 8px; flex: 1; }
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.label { width: 72px; color: var(--muted); font-size: 12px; }
.qr { width: 148px; height: 148px; border-radius: 12px; background:
  linear-gradient(45deg,#cbd5e1 25%,transparent 25%) -8px 0/16px 16px,
  linear-gradient(-45deg,#cbd5e1 25%,transparent 25%) -8px 0/16px 16px,
  linear-gradient(45deg,transparent 75%,#cbd5e1 75%) 0 0/16px 16px,
  linear-gradient(-45deg,transparent 75%,#cbd5e1 75%) 0 0/16px 16px, #e2e8f0;
  display: flex; align-items: center; justify-content: center; color: var(--ink); font-weight: 700; font-size: 12px; border: 1px solid var(--line);
}
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: #f8fafc; border-radius: 10px; padding: 12px; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 22px 20px; }
.crumb { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.meta { color: var(--muted); font-size: 13px; margin-top: 6px; }
.layout3 { display: grid; grid-template-columns: 240px 1fr 300px; min-height: 620px; }
@media (max-width: 960px) { .layout3 { grid-template-columns: 1fr; } }
.col { border-right: 1px solid var(--line); padding: 14px; background: #fff; }
.col:last-child { border-right: 0; background: #f8fafc; }
.col h2 { font-size: 12px; color: var(--muted); margin-bottom: 10px; font-weight: 600; }
.mod { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; background: #fff; }
.mod.active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.handle { color: #94a3b8; cursor: grab; }
.preview { border: 1px solid var(--line); border-radius: 12px; min-height: 520px; background: linear-gradient(180deg,#0b1220,#111827); color: #e2e8f0; padding: 18px; }
.ph { height: 10px; background: rgba(255,255,255,.12); border-radius: 6px; margin: 8px 0; }
.media { height: 110px; border: 1px dashed rgba(148,163,184,.45); border-radius: 10px; display:flex;align-items:center;justify-content:center;color:#94a3b8;font-size:12px;margin-top:10px; }
.field { margin-bottom: 12px; }
.field label { display:block; font-size:12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font: inherit; background: #fff;
}
.field textarea { min-height: 88px; resize: vertical; }
.banner { background: #ecfdf5; color: #065f46; border-bottom: 1px solid #a7f3d0; padding: 8px 16px; font-size: 12px; text-align: center; }

/* status-qr: alerts / job pills / progress */
.btn-sm { padding: 6px 10px; font-size: 12px; }
.alert { margin: 0 22px 12px; padding: 12px 14px; border-radius: 10px; border: 1px solid; font-size: 13px; }
.alert strong { display: block; margin-bottom: 4px; }
.alert.warn { background: #fffbeb; border-color: #fcd34d; color: #78350f; }
.alert.err { background: #fef2f2; border-color: #fecaca; color: #7f1d1d; }
.alert.info { background: #eff6ff; border-color: #bfdbfe; color: #1e3a8a; }
.alert.ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.job { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: #fafbfc; }
.job .title { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-weight: 600; font-size: 13px; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.pill.queue { background: #e0e7ff; color: #3730a3; }
.pill.run { background: #ffedd5; color: #c2410c; }
.pill.fail { background: #fee2e2; color: #b91c1c; }
.pill.done { background: #dcfce7; color: #166534; }
.pill.warn { background: #fffbeb; color: #b45309; }
.pill.off { background: #f1f5f9; color: #64748b; }
.pill.on { background: #ecfdf5; color: #15803d; }
.bar { height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin: 8px 0; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #0f766e, #14b8a6); }
.qr-img { width: 148px; height: 148px; border-radius: 12px; border: 1px solid var(--line); background: #fff; display: block; }


/* list-batch: filters + checkboxes + bulk bar + modal */
body { padding-bottom: 88px; }
.filters { align-items: center; }
.filter-form { display: flex; gap: 10px; flex: 1; flex-wrap: wrap; align-items: center; }
.filter-form select,
.filter-form input[type=date] {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; background: #fff;
}
.date-range { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.check { width: 18px; height: 18px; accent-color: var(--brand); vertical-align: middle; }
.bulk {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: none; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #0f172a; color: #fff; padding: 12px 16px; border-radius: 14px;
  box-shadow: 0 12px 40px rgba(15,23,42,.35); z-index: 30; max-width: calc(100% - 24px);
}
.bulk.show { display: flex; }
.bulk .btn { border-color: rgba(255,255,255,.2); }
.bulk .btn-ghost { background: transparent; color: #fff; }
.bulk .btn-danger { background: #ef4444; border-color: #ef4444; color: #fff; }
.modal-bg {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45);
  z-index: 40; align-items: center; justify-content: center; padding: 16px;
}
.modal-bg.show { display: flex; }
.modal {
  background: #fff; border-radius: 14px; max-width: 420px; width: 100%;
  padding: 18px; box-shadow: var(--shadow);
}
.modal h3 { margin-bottom: 8px; font-size: 16px; }
.modal p { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

/* Wave Portal: public /portal + admin toggle */
.portal-page { background: var(--bg); }
.portal-page .portal { max-width: 1100px; margin: 0 auto; padding: 0 16px 40px; }
.portal-page .hero {
  margin: 16px 0 20px; padding: 28px 24px; border-radius: 18px; color: #e8eef7;
  background:
    radial-gradient(ellipse 70% 80% at 10% 0%, rgba(29,78,216,.35), transparent 55%),
    radial-gradient(ellipse 50% 60% at 90% 20%, rgba(245,197,24,.18), transparent 50%),
    linear-gradient(160deg, #0b1220, #0f172a 60%, #111827);
}
.portal-page .hero .hero-brand {
  margin-bottom: 14px;
  display: inline-flex; align-items: center;
  background: rgba(255,255,255,.92); border-radius: 12px; padding: 8px 12px;
}
.portal-page .hero .hero-brand img { display: block; height: 40px; width: auto; }
.portal-page .hero .eyebrow { font-size: 12px; color: #93c5fd; margin-bottom: 8px; }
.portal-page .hero h1 { font-size: clamp(1.4rem, 3vw, 1.9rem); font-weight: 700; margin-bottom: 8px; }
.portal-page .hero p { color: #94a3b8; max-width: 36em; font-size: 14px; }
.portal-page .portal-toolbar { padding: 0; border: 0; background: transparent; margin-bottom: 16px; }
.portal-page .grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding: 0;
}
@media (max-width: 900px) { .portal-page .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .portal-page .grid { grid-template-columns: 1fr; } }
.portal-page .portal-card {
  display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; box-shadow: 0 6px 20px rgba(15,23,42,.04);
  transition: transform .15s, box-shadow .15s; color: inherit; text-decoration: none;
}
.portal-page .portal-card:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(15,23,42,.08); }
.portal-page .cover {
  aspect-ratio: 16/10;
  background:
    linear-gradient(160deg, rgba(20,184,166,.35), transparent 55%),
    linear-gradient(20deg, #1e293b, #0f172a);
  display: flex; align-items: flex-end; padding: 12px; color: #e2e8f0; font-size: 12px; position: relative;
}
.portal-page .cover .tag {
  position: absolute; top: 10px; left: 10px; background: rgba(15,23,42,.55);
  backdrop-filter: blur(6px); padding: 3px 8px; border-radius: 999px; font-size: 11px; color: #e2e8f0;
}
.portal-page .cover .play {
  position: absolute; right: 10px; bottom: 10px; width: 28px; height: 28px; border-radius: 50%;
  background: rgba(20,184,166,.9); color: #042f2e; display: flex; align-items: center;
  justify-content: center; font-size: 12px;
}
.portal-page .cover .ph-cover { opacity: .7; }
.portal-page .body { padding: 12px 14px 14px; }
.portal-page .body h3 { font-size: 15px; font-weight: 650; margin-bottom: 4px; color: var(--ink); }
.portal-page .body .meta { font-size: 12px; color: var(--muted); }
.portal-page .empty {
  padding: 40px; text-align: center; color: var(--muted); border: 1px dashed var(--line);
  border-radius: 14px; background: #fff; grid-column: 1 / -1;
}
.portal-page .chip { cursor: pointer; }
.toggle {
  width: 40px; height: 22px; border-radius: 999px; background: #cbd5e1; position: relative;
  display: inline-block; border: 0; padding: 0; cursor: pointer; vertical-align: middle;
  appearance: none; flex-shrink: 0;
}
.toggle.on { background: var(--brand); }
.toggle i {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: left .15s; pointer-events: none;
}
.toggle.on i { left: 20px; }
.toggle[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
button.toggle { font: inherit; color: inherit; }


/* Wave S1: sales exclusive links + stats */
.qr-sm { width: 56px; height: 56px; border-radius: 8px; border: 1px solid var(--line); background: #fff; display: block; object-fit: contain; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 720px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-box { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.stat-box .n { font-size: 22px; font-weight: 700; }
.stat-box .l { font-size: 12px; color: var(--muted); margin-top: 2px; }
.sales-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sales-table th, .sales-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.sales-table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.mono-url { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; }
.note-foot { font-size: 12px; color: var(--muted); margin-top: 10px; }
.dev-row { display: flex; gap: 24px; flex-wrap: wrap; }
.dev-row > div { flex: 1; min-width: 140px; }

/* Wave S3: version history + rollback */
.pill.cur { background: var(--brand-soft); color: #1e40af; }
.ver-table tr.ver-current { background: #eff6ff; }
.ver-table .btn:disabled { opacity: .45; cursor: not-allowed; }
.modal .alert.warn {
  padding: 10px 12px; border-radius: 8px; background: #fffbeb; color: #b45309; font-size: 12px;
}
.modal code { font-size: 12px; background: #f1f5f9; padding: 2px 6px; border-radius: 4px; }


/* Wave S4 AI summary */
.pill.ai { background: #ede9fe; color: #6d28d9; }
.sum-status { padding: 10px 12px; border-radius: 10px; font-size: 12px; margin-bottom: 12px; border: 1px solid var(--line); background: #f8fafc; line-height: 1.5; }
.sum-status.run { background: #fffbeb; border-color: #fcd34d; color: #b45309; }
.sum-status.err { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.sum-status.ok { background: #ecfdf5; border-color: #a7f3d0; color: #15803d; }
.summary-ta { width: 100%; min-height: 120px; border: 1px solid var(--line); border-radius: 10px; padding: 12px; font: inherit; resize: vertical; box-sizing: border-box; }
