
:root {
  --bg: #f1f1f1;
  --surface: #fff;
  --text: #303030;
  --text-dim: #616161;
  --border: #e3e3e3;
  --brand: #303030;
  --brand-text: #fff;
  --ok-bg: #cdfee1;
  --ok-text: #0c5132;
  --warn-bg: #ffd6a4;
  --warn-text: #5e4200;
  --crit-bg: #fee9e8;
  --crit-text: #8e1f0b;
  --radius: 12px;
  --shadow: 0 1px 0 rgba(0,0,0,.05), 0 1px 3px rgba(0,0,0,.05);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 800px; margin: 0 auto; padding: 20px 16px 64px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.02em; font-weight: 700; }
/* Card headings have to outrank the field labels below them, or the whole
   settings panel reads as one undifferentiated column of text. */
h2 {
  font-size: 17px; font-weight: 700; letter-spacing: -.01em;
  margin: 0 0 4px; color: var(--text);
}
h2 + p { margin-bottom: 16px; }
p { margin: 0 0 12px; color: var(--text-dim); }
p.tight { margin-bottom: 0; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok-text); }
.badge.warn { background: var(--warn-bg); color: var(--warn-text); }
.badge.crit { background: var(--crit-bg); color: var(--crit-text); }
button {
  font: inherit; font-weight: 600; cursor: pointer;
  border-radius: 8px; padding: 8px 16px;
  border: 1px solid var(--brand); background: var(--brand); color: var(--brand-text);
}
button:hover { opacity: .88; }
button:disabled { opacity: .5; cursor: default; }
button.plain { background: var(--surface); color: var(--text); border-color: #b5b5b5; }
button.danger { background: var(--surface); color: var(--crit-text); border-color: #e0b3b2; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.stat { background: #fafafa; border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.stat .n { font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.stat .l { font-size: 12px; color: var(--text-dim); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 4px; border-bottom: 1px solid var(--border); }
th { font-size: 12px; color: var(--text-dim); font-weight: 600; }
td.num, th.num { text-align: right; }
tr:last-child td { border-bottom: 0; }
label { display: block; font-weight: 500; margin: 0 0 4px; }
.field { margin-bottom: 14px; }
input[type=text], input[type=number], textarea, select {
  width: 100%; font: inherit; color: var(--text);
  padding: 8px 10px; border: 1px solid #8a8a8a; border-radius: 8px; background: var(--surface);
}
input:focus, textarea:focus, select:focus { outline: 2px solid #005bd3; outline-offset: -1px; }
.hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.swatch { display: flex; align-items: center; gap: 8px; }
.swatch input[type=color] { width: 40px; height: 36px; padding: 2px; border: 1px solid #8a8a8a; border-radius: 8px; background: var(--surface); }
.steps { counter-reset: s; }
.step { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.step:last-child { border-bottom: 0; }
.step .dot {
  flex: 0 0 24px; height: 24px; border-radius: 50%;
  background: #e3e3e3; color: var(--text-dim);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}
.step.done .dot { background: var(--ok-bg); color: var(--ok-text); }
.step .body { flex: 1; min-width: 0; }
.step .body strong { display: block; margin-bottom: 2px; }
.bar { height: 6px; border-radius: 3px; background: #e3e3e3; overflow: hidden; }
.bar > i { display: block; height: 100%; background: #303030; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: #303030; color: #fff; padding: 10px 16px; border-radius: 8px;
  font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,.2); z-index: 50;
}
.skeleton { color: var(--text-dim); padding: 40px 0; text-align: center; }

/* Settings editor ---------------------------------------------------------- */
.wrap.wide { max-width: 1180px; }
.editor .grp { border-top: 1px solid var(--border); padding: 4px 0; }
.editor .grp summary {
  cursor: pointer; padding: 13px 2px; list-style: none;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 15px; font-weight: 650; letter-spacing: -.01em; color: var(--text);
}
.editor .grp[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 12px; }
/* Field labels sit deliberately below the group heading in weight and size. */
.editor label { font-size: 13px; font-weight: 500; color: var(--text-dim); }
.editor label.chk { font-size: 13px; color: var(--text); }
.editor .grp summary::after { content: '+'; color: var(--text-dim); font-weight: 400; }
.editor .grp[open] summary::after { content: '−'; }
.editor .grp summary::-webkit-details-marker { display: none; }
.editor .field.off { display: none; }
.editor .field { margin-bottom: 12px; }
label.chk { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 0; cursor: pointer; }
label.chk input { width: auto; }
.rangerow { display: flex; align-items: center; gap: 10px; }
.rangerow input[type=range] { flex: 1; }
.rangerow output {
  min-width: 58px; text-align: right; font-variant-numeric: tabular-nums;
  font-size: 12px; color: var(--text-dim);
}
button.sm { padding: 4px 10px; font-size: 12px; }
button.sm.on { background: var(--brand); color: var(--brand-text); border-color: var(--brand); }

/* Statistics --------------------------------------------------------------- */
.stats-page { max-width: 1180px; }
.funnel { display: grid; grid-template-columns: 130px 1fr 56px 52px; align-items: center; gap: 10px; margin-bottom: 8px; }
.funnel span { font-size: 13px; color: var(--text-dim); }
.funnel b { text-align: right; font-variant-numeric: tabular-nums; }
.funnel em { text-align: right; font-style: normal; font-size: 12px; color: var(--text-dim); }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.theme-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: #fafafa; }
.theme-card.lead { border-color: #0c5132; background: var(--ok-bg); }
.theme-card strong { display: block; font-size: 13px; line-height: 1.3; }
.theme-card .rate { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 10px; }
.kv { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; padding: 3px 0; }
.kv span { color: var(--text-dim); }
.kv b { font-variant-numeric: tabular-nums; }

/* Image picker ------------------------------------------------------------- */
.imgpick { display: flex; align-items: center; gap: 8px; }
.thumb {
  width: 44px; height: 44px; flex: 0 0 auto; border-radius: 8px;
  border: 1px solid var(--border); background: #fafafa center/cover no-repeat;
}
.modal {
  position: fixed; inset: 0; z-index: 100; padding: 24px;
  background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center;
}
.sheet {
  background: var(--surface); border-radius: var(--radius); padding: 16px;
  width: min(760px, 100%); max-height: 80vh; overflow: auto;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.tile {
  aspect-ratio: 1; padding: 0; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: #fafafa center/cover no-repeat;
}
.tile:hover { outline: 2px solid #005bd3; }

/* Live preview ------------------------------------------------------------- */
.preview-wrap { position: sticky; top: 16px; }
.preview-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
/* The preview iframe is given a REAL viewport width and then scaled down.
   Sizing it to the column instead would put it below the 750px breakpoint, so
   a merchant choosing "Desktop" would be shown the mobile layout — confidently
   and wrongly. */
.pv-stage {
  position: relative; overflow: hidden; display: block;
  border: 1px solid var(--border); border-radius: 8px; background: #f6f6f6;
}
.pv-stage.desktop { height: 266px; }
.pv-stage.mobile { height: 520px; }
#preview { border: 0; display: block; transform-origin: top left; }
.pv-stage.desktop #preview { width: 1100px; height: 740px; transform: scale(.36); }
.pv-stage.mobile #preview { width: 390px; height: 722px; transform: scale(.72); margin-left: 50%; }
.pv-stage.mobile #preview { margin-left: calc(50% - 140px); }

/* Two columns once there is room; the preview leads because it is what the
   merchant is actually looking at while they drag a slider. */
@media (min-width: 1000px) {
  .wrap.wide .editor,
  .wrap.wide .preview-wrap { width: auto; }
  .wrap.wide { display: grid; grid-template-columns: 1fr 420px; gap: 0 20px; align-items: start; }
  .wrap.wide > .head { grid-column: 1 / -1; }
  .wrap.wide > .preview-wrap { grid-column: 2; grid-row: 2 / 99; }
}
.err { background: var(--crit-bg); color: var(--crit-text); padding: 12px; border-radius: 8px; }
