/* Layout: stacked numbered steps in one column; data table is the widest element. */
:root {
  --series-1: #2a78d6; --series-2: #eb6834; --surface: #FFFFFF;
  --bg: #F3F7F9; --surface: #FFFFFF; --ink: #10222F; --soft: #4F6575; --line: #D6E1E8;
  --accent: #0B5FA5; --accent-ink: #FFFFFF; --mint: #1E9E5A; --warn-bg: #FFF4E5; --warn: #9A5B00;
  --err-bg: #FDECEC; --err: #A3261F; --focus: #3A8DDE;
  --f-ui: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D161D; --surface: #14212B; --ink: #E4EDF3; --soft: #9AB0C0; --line: #26394A;
    --accent: #4BA3EE; --accent-ink: #06121C; --mint: #3CC07A; --warn-bg: #3A2A10; --warn: #F2B860;
    --err-bg: #3A1716; --err: #F59A93; --focus: #7BBCF5; color-scheme: dark;
    --series-1: #3987e5; --series-2: #d95926; --surface: #14212B;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--f-ui); }
a { color: var(--accent); }
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-inner { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left, 0px)); }
.logo { height: 40px; width: auto; }
.brand { display: flex; flex-direction: column; line-height: 1.2; }
.brand strong { font-size: 17px; }
.brand span { font-size: 12px; color: var(--soft); letter-spacing: .04em; text-transform: uppercase; }
.who { margin-left: auto; font-size: 13px; color: var(--soft); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px max(16px, env(safe-area-inset-left, 0px)) 48px;
  display: flex; flex-direction: column; gap: 20px; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; min-width: 0; }
.step-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.step-head h2 { margin: 0; font-size: 18px; }
.num { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.summary { margin-left: auto; font-size: 14px; color: var(--soft); font-variant-numeric: tabular-nums; }
.summary b { color: var(--ink); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab { border: 0; background: none; padding: 8px 14px; font: 600 14px var(--f-ui); color: var(--soft);
  border-bottom: 2px solid transparent; cursor: pointer; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
  border: 2px dashed var(--line); border-radius: 10px; padding: 32px 16px; cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-title { font-weight: 600; }
.drop-sub, .hint, .muted { color: var(--soft); font-size: 13px; }
.hint { margin: 10px 0 0; }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--soft); min-width: 0; border: 0; padding: 0; margin: 0; }
.field legend { padding: 0; margin-bottom: 6px; }
input[type=text], input[type=number], input[type=email], input[type=password], select, textarea {
  font: 14px var(--f-ui); color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 9px; width: 100%; }
textarea { font-family: var(--f-mono); font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-top: 12px; }
.opts { margin-top: 16px; }
.opts summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.crm-row { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.crm-row .field { width: 220px; }
#soqlField { margin-bottom: 12px; }

.pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.pill.ok { background: color-mix(in srgb, var(--mint) 15%, transparent); color: var(--mint); }
.pill.off { background: var(--warn-bg); color: var(--warn); }

.btn { font: 600 14px var(--f-ui); border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 7px; padding: 9px 16px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.alert { border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; font-size: 13.5px; background: var(--err-bg); color: var(--err); }
.alert ul { margin: 6px 0 0; padding-left: 18px; max-height: 160px; overflow: auto; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--soft);
  font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--bg); white-space: nowrap; }
td { padding: 0; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
td .cell { display: block; padding: 7px 10px; min-width: 70px; outline: none; white-space: nowrap; }
td .cell:focus { background: color-mix(in srgb, var(--accent) 10%, transparent); }
td .cell.code { font-family: var(--f-mono); font-size: 12.5px; }
td.serial { padding: 7px 10px; color: var(--soft); }
.r, td.r .cell { text-align: right; }
tr.sel td { background: color-mix(in srgb, var(--accent) 7%, transparent); }
tr.bad .cell { color: var(--err); }
tr.empty td { padding: 22px; text-align: center; color: var(--soft); }
.del { border: 0; background: none; color: var(--soft); cursor: pointer; padding: 6px 10px; font-size: 16px; }
.del:hover { color: var(--err); }

.designs { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.design { border: 2px solid var(--line); border-radius: 10px; padding: 10px; background: var(--surface); cursor: pointer;
  text-align: left; font: inherit; color: inherit; display: flex; flex-direction: column; gap: 6px; }
.design img { width: 100%; border-radius: 4px; aspect-ratio: 8.5/3.5; object-fit: cover; background: var(--bg); }
.design strong { font-size: 14px; }
.design span { font-size: 12.5px; color: var(--soft); }
.design[aria-pressed=true] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.preview { margin-top: 16px; }
.preview-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
#previewImg { width: 100%; max-width: 900px; border-radius: 6px; border: 1px solid var(--line); display: block; aspect-ratio: 8.5/3.5; background: var(--bg); }

.gen-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; align-items: start; }
.check, .radio { display: flex; gap: 8px; align-items: flex-start; color: var(--ink); font-size: 14px; margin-bottom: 6px; }
.check input, .radio input { margin-top: 4px; }
.gen-actions { display: flex; align-items: center; gap: 14px; margin-top: 18px; flex-wrap: wrap; }
.result { margin-top: 16px; border-radius: 8px; padding: 14px 16px; background: color-mix(in srgb, var(--mint) 12%, transparent);
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.result b { font-variant-numeric: tabular-nums; }
.sub { font-size: 14px; margin: 24px 0 8px; }
.runs td { padding: 7px 10px; white-space: nowrap; }
.foot { font-size: 12.5px; color: var(--soft); text-align: center; margin: 0; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left, 0px)); }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 0; font-size: 20px; }
.login-card p { margin: 0; }
.login-logo { height: 56px; width: auto; align-self: flex-start; }
.login-error { color: var(--err); background: var(--err-bg); border-radius: 6px; padding: 8px 10px; font-size: 13.5px; }

/* mode switch + payments */
.modes { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-left: 18px; }
.mode { border: 0; background: var(--surface); color: var(--soft); font: 600 13px var(--f-ui); padding: 7px 12px; cursor: pointer; }
.mode.active { background: var(--accent); color: var(--accent-ink); }
.signout { border: 0; background: none; color: var(--accent); font: 600 13px var(--f-ui); cursor: pointer; padding: 4px; }
.only-pay, .only-cashed { display: none !important; }
body.pay .only-pay { display: revert !important; }
body.pay .only-promo, body.cashed .only-promo { display: none !important; }
body.cashed .step:not(.only-cashed) { display: none !important; }
body.cashed .only-cashed { display: revert !important; }
.banner { border-radius: 8px; padding: 10px 14px; font-size: 13.5px; background: var(--warn-bg); color: var(--warn); margin-bottom: 12px; }
.banner ul { margin: 6px 0 0; padding-left: 18px; }
.banner.ready { background: color-mix(in srgb, var(--mint) 12%, transparent); color: var(--ink); }
.status { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.status.pending { background: var(--warn-bg); color: var(--warn); }
.status.approved { background: color-mix(in srgb, var(--mint) 15%, transparent); color: var(--mint); }
.status.cancelled, .status.void { background: var(--err-bg); color: var(--err); }
.act { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 6px; font: 600 12.5px var(--f-ui);
  padding: 4px 10px; cursor: pointer; margin-right: 4px; }
.act.go { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.act:disabled { opacity: .45; cursor: not-allowed; }
@media (max-width: 640px) { .modes { margin-left: 0; } .top-inner { flex-wrap: wrap; } }
.runs td:first-child { white-space: normal; min-width: 240px; }
.runs td:last-child { white-space: nowrap; }

/* accounts + settings */
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.linkbtn { background: none; border: 0; color: var(--accent); font: 600 13.5px var(--f-ui); cursor: pointer; padding: 2px; align-self: flex-start; }
.login-ok { color: var(--ink); background: color-mix(in srgb, var(--mint) 14%, transparent); border-radius: 6px; padding: 8px 10px; font-size: 13.5px; margin: 0; }
.login-card { max-width: 400px; }
.steps { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--soft); display: flex; flex-direction: column; gap: 4px; }
.qr { background: #fff; border-radius: 8px; padding: 8px; align-self: center; width: 200px; max-width: 100%; }
.qr svg { width: 100%; height: auto; display: block; }
.secret, .mono { font-family: var(--f-mono); font-size: 13px; letter-spacing: .04em; word-break: break-all; }
.secret { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; display: block; }
.codes { font-family: var(--f-mono); font-size: 15px; line-height: 1.7; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 14px; margin: 0; columns: 2; }
.kv { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 18px; }
.kv div { display: flex; flex-direction: column; font-size: 14px; }
.kv span { font-size: 12px; color: var(--soft); text-transform: uppercase; letter-spacing: .05em; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 16px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.card-plain { border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.card-plain h3 { margin: 0; font-size: 15px; }
.save-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 14px; }
.save-row .field { width: 200px; }
.inline { font: 13.5px var(--f-ui); color: var(--ink); background: transparent; border: 1px solid transparent; border-radius: 5px; padding: 4px 6px; max-width: 220px; }
.inline:hover, .inline:focus { border-color: var(--line); background: var(--bg); }
.backlink { color: var(--accent); font-weight: 600; font-size: 13px; text-decoration: none; }
.backlink:first-of-type { margin-left: 18px; }
.wrap > .tabs { margin-bottom: 0; }
.tabpane.step { border-top-left-radius: 0; }
.preview img { width: 100%; max-width: 900px; height: auto; display: block; border-radius: 6px; border: 1px solid var(--line); }

/* redeem */
.wrap.narrow { max-width: 720px; }
input.big { font-size: 20px; padding: 10px 12px; letter-spacing: .06em; }
.verdict { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  border-radius: 10px; padding: 14px 16px; font-size: 17px; font-weight: 700; margin-bottom: 16px; }
.verdict b { font-size: 26px; font-variant-numeric: tabular-nums; }
.verdict.ok { background: color-mix(in srgb, var(--mint) 16%, transparent); color: var(--ink); border: 2px solid var(--mint); }
.verdict.bad { background: var(--err-bg); color: var(--err); border: 2px solid var(--err); }
.cert-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 24px; }
.cert-kv div { min-width: 0; }
.cert-kv b { overflow-wrap: anywhere; }
.grid2.tight { margin-top: 0; }
.admin-tools { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.history { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--soft); display: flex; flex-direction: column; gap: 4px; }
p.alert { margin: 0; }

/* analytics */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile span { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--soft); }
.tile b { font-size: 24px; font-variant-numeric: tabular-nums; }
.tile em { font-style: normal; font-size: 12.5px; color: var(--soft); }
.tile.warn { border-color: var(--warn); box-shadow: inset 4px 0 0 var(--warn); }
.tile.bad { border-color: var(--err); box-shadow: inset 4px 0 0 var(--err); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-top: 16px; }
.chart-card { margin: 0; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.chart-card figcaption { font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.chart-box { position: relative; height: 260px; }

/* ---------- app shell: left menu, top bar with profile ---------- */
:root { --side-w: 236px; --side-bg: #0E2236; --side-ink: #C9D7E3; --side-hi: #FFFFFF; --side-act: rgba(255,255,255,.12); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --side-bg: #0A141C; --side-ink: #9AB0C0; --side-act: rgba(255,255,255,.08); } }
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side-bg); color: var(--side-ink); position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 14px 10px; gap: 14px; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 12px; border-bottom: 1px solid rgba(255,255,255,.08); min-width: 0; }
.biz-logo { max-height: 36px; max-width: 64px; width: auto; border-radius: 4px; background: #fff; padding: 2px; }
.biz-mark { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  color: #fff; background: #0B5FA5; flex: none; }
.biz-name { color: var(--side-hi); font-weight: 700; font-size: 14.5px; line-height: 1.25; overflow-wrap: anywhere; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link, .pm-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 7px; text-decoration: none;
  font-size: 14px; font-weight: 500; }
.side-link { color: var(--side-ink); }
.side-link svg, .pm-link svg { width: 18px; height: 18px; fill: currentColor; flex: none; opacity: .9; }
.side-link:hover { background: var(--side-act); color: var(--side-hi); }
.side-link.active { background: var(--side-act); color: var(--side-hi); box-shadow: inset 3px 0 0 color-mix(in srgb, var(--accent) 60%, white); }
.app-main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px 20px; }
.top-title { font-weight: 700; font-size: 16px; }
.biz-switch { font: 600 14px var(--f-ui); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; max-width: 260px; }
.profile { position: relative; }
.profile-btn { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 4px 10px 4px 4px; cursor: pointer; font: 600 14px var(--f-ui); }
.profile-btn:hover { border-color: var(--accent); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 12.5px; font-weight: 700; }
.chev { width: 18px; height: 18px; fill: var(--soft); }
.profile-menu { position: absolute; right: 0; top: calc(100% + 6px); width: 270px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.16); padding: 6px; z-index: 30; max-height: calc(100vh - 80px); overflow-y: auto; }
.pm-head { display: flex; flex-direction: column; gap: 2px; padding: 10px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; font-size: 13px; }
.pm-head span { color: var(--soft); overflow-wrap: anywhere; }
.pm-role { font-size: 12px; }
.pm-link { color: var(--ink); width: 100%; border: 0; background: none; cursor: pointer; text-align: left; font-family: var(--f-ui); }
.pm-link:hover { background: var(--bg); }
.pm-link.active { color: var(--accent); }
.pm-out { border-top: 1px solid var(--line); border-radius: 0 0 7px 7px; margin-top: 6px; }
.app .wrap { max-width: 1180px; width: 100%; margin: 0; padding: 22px max(16px, env(safe-area-inset-right, 0px)) 48px 22px; }
.app .wrap.narrow { max-width: 760px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }                      /* on phones the profile menu is the navigation */
  .profile-name { display: none; }
  .app .wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); }
}
.logo-box { min-height: 90px; border: 1px dashed var(--line); border-radius: 8px; display: grid; place-items: center; padding: 10px; background: #fff; }
.logo-box img { max-height: 90px; max-width: 100%; }

/* design editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 22px; align-items: start; }
.sticky-prev { position: sticky; top: 76px; margin-top: 0; }
@media (max-width: 1100px) { .editor { grid-template-columns: minmax(0, 1fr); } .sticky-prev { position: static; order: -1; } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; }
.chip span { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13.5px; color: var(--ink); cursor: pointer; }
.chip input:checked + span { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); font-weight: 600; }
.chip input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.colors { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.colors label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--soft); }
.colors input[type=color], input[type=color] { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); padding: 3px; cursor: pointer; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.design .row { margin-top: 4px; }
#list .design { cursor: default; }
.pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--soft); border: 1px solid var(--line); vertical-align: middle; }
.login-mark { width: 52px; height: 52px; font-size: 18px; border-radius: 12px; }
