/* ViralSales Forms dashboard. One stylesheet, no framework, system fonts. */
:root {
  --bg: #f5f6f8; --panel: #ffffff; --ink: #141922; --muted: #5b6474; --faint: #8a93a2; --line: #e2e5ea; --line2: #eef0f3;
  --accent: #2f47e0; --accent-ink: #ffffff; --accent-soft: #eef1ff; --ok: #12805c; --ok-soft: #e8f6f0; --warn: #9a5b00;
  --warn-soft: #fff5e5; --err: #b42318; --err-soft: #fdeceb; --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: 13px; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── shell ── */
.shell { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.side { background: #0f1424; color: #d7dcea; padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #5b73ff, #2f47e0); display: grid; place-items: center; font-weight: 800; font-size: 15px; color: #fff; }
.brand b { font-size: 16px; letter-spacing: -.01em; }
.brand small { display: block; font-size: 11px; color: #9aa4bf; font-weight: 500; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #c9d0e3; text-decoration: none; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a[aria-current=page] { background: rgba(91,115,255,.22); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.side-foot { margin-top: auto; font-size: 12px; color: #9aa4bf; padding: 10px; border-top: 1px solid rgba(255,255,255,.08); }
.side-foot button { background: none; border: 0; color: #c9d0e3; padding: 0; cursor: pointer; text-decoration: underline; font-size: 12px; }
.main { min-width: 0; padding: 26px clamp(16px, 3vw, 36px) 60px; }
.topbar { display: none; }

/* ── common ── */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 18px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #c7ccd6; background: #fafbfc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; filter: none; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid rgba(47,71,224,.35); outline-offset: 1px; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: 6px; width: 30px; height: 30px; display: inline-grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--line2); color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line2); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.live { background: var(--ok-soft); color: var(--ok); }
.pill.draft { background: var(--warn-soft); color: var(--warn); }
.pill.archived { background: var(--line2); color: var(--faint); }
.pill.pending { background: var(--accent-soft); color: var(--accent); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; background: var(--line2); color: var(--muted); }
.tag.quiz { background: #eef1ff; color: #3446c9; }
.tag.form { background: #effaf4; color: #12704f; }

/* ── fields ── */
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin: 0 0 5px; }
.field > span em { font-style: normal; font-weight: 400; color: var(--faint); }
.field .hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=url], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid #d3d8e0; border-radius: 8px; background: #fff; font-size: 14px; }
textarea { min-height: 76px; resize: vertical; line-height: 1.45; }
textarea.code { font-family: var(--mono); font-size: 12.5px; min-height: 260px; white-space: pre; tab-size: 2; }
input[type=number] { max-width: 110px; }
input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid #d3d8e0; border-radius: 8px; background: #fff; }
.check { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 10px; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 0 12px; }
fieldset { border: 0; padding: 0; margin: 0; }
.section { border-top: 1px solid var(--line2); padding-top: 16px; margin-top: 18px; }
.section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.section > h3 { margin-bottom: 4px; }
.section > p.muted { margin: 0 0 12px; font-size: 13px; }

/* ── list page ── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin: 0 0 18px; }
.kpi { padding: 14px 16px; }
.kpi b { display: block; font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.kpi span { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); }
.chip[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: #fff; }
.filters input[type=search] { max-width: 260px; min-height: 34px; }
.filters select { max-width: 220px; min-height: 34px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfc; }
table.data td { padding: 12px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr.click { cursor: pointer; }
table.data tbody tr.click:hover td { background: #fafbff; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.title-cell b { display: block; font-weight: 650; }
.title-cell small { color: var(--faint); font-family: var(--mono); font-size: 12px; }
.empty { padding: 42px 20px; text-align: center; color: var(--muted); }
.empty h2 { color: var(--ink); margin-bottom: 6px; }
.table-wrap { overflow-x: auto; }

/* ── editor ── */
.ed-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: -6px 0 14px; }
.ed-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ed-title h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.ed-save { font-size: 12px; color: var(--faint); min-width: 74px; }
.checks { margin: 0 0 14px; border-radius: var(--radius); padding: 10px 14px; font-size: 14px; }
.checks.ok { background: var(--ok-soft); color: var(--ok); }
.checks.bad { background: var(--err-soft); color: var(--err); }
.checks.warn { background: var(--warn-soft); color: var(--warn); }
.checks summary { cursor: pointer; font-weight: 650; }
.checks ul { margin: 8px 0 2px; padding-left: 18px; }
.checks li { margin: 3px 0; }
.checks li button { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; text-align: left; }
.checks code { font-family: var(--mono); font-size: 12px; opacity: .85; }
.ed { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr); gap: 18px; align-items: start; }
.tabs { display: flex; flex-wrap: wrap; gap: 0 2px; border-bottom: 1px solid var(--line); padding: 0 8px; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 11px 8px 10px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected=true] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs button .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--err); margin-left: 5px; vertical-align: middle; }
.tab-body { padding: 18px; }
.item { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin: 0 0 12px; background: #fcfcfd; }
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 10px; }
.item-head b { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.item-tools { display: flex; gap: 2px; }
.opt-row { display: grid; grid-template-columns: minmax(0, 1fr) 104px 62px 30px; gap: 8px; align-items: center; margin: 0 0 6px; }
.opt-row input { min-height: 34px; }
.opt-head { display: grid; grid-template-columns: minmax(0, 1fr) 104px 62px 30px; gap: 8px; font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; margin: 4px 0; }
.field-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 120px; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.chips label { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 13px; cursor: pointer; background: #fff; }
.chips label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chips input { margin: 0; }
.when-q { font-size: 13px; margin: 8px 0 0; color: var(--muted); }
.badge-default { font-size: 11px; font-weight: 700; color: var(--ok); background: var(--ok-soft); border-radius: 5px; padding: 1px 7px; }
.add { width: 100%; border: 1px dashed #c4cad4; background: transparent; border-radius: 10px; padding: 10px; color: var(--muted); font-weight: 600; cursor: pointer; }
.add:hover { border-color: var(--accent); color: var(--accent); }

/* preview */
.pv { position: sticky; top: 16px; }
.pv-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pv-bar select { width: auto; min-height: 32px; padding: 4px 8px; font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 5px 10px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed=true] { background: var(--ink); color: #fff; }
.pv-page { padding: 22px; min-height: 420px; max-height: calc(100vh - 170px); overflow: auto; border-radius: 0 0 var(--radius) var(--radius); transition: background .15s; }
.pv-page.bg-white { background: #ffffff; }
.pv-page.bg-grey { background: #eef0f4; }
.pv-page.bg-dark { background: #111622; }
.pv-page.bg-photo { background: linear-gradient(135deg, #6a85ff 0%, #b06ab3 55%, #ffb36b 100%); }
.pv-frame { margin: 0 auto; transition: max-width .2s; }
.pv-frame.phone { max-width: 390px; }
.pv-host { font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 17px; color: #333; }
.pv-host .fake { font-size: 15px; color: #5b6474; margin: 0 0 16px; line-height: 1.6; }
.pv-page.bg-dark .pv-host .fake { color: #9aa4bf; }

/* design pickers */
.gal { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.sty { border: 2px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; text-align: left; padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.sty:hover { border-color: #b9c1ff; }
.sty[aria-pressed=true] { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,71,224,.18); }
.sty-shot { height: 210px; overflow: hidden; position: relative; background: #f1f3f6; padding: 10px; pointer-events: none; }
.sty-shot > div { width: 200%; transform: scale(.5); transform-origin: top left; }
.gal.small { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.gal.small .sty-shot { height: 150px; padding: 8px; }
.gal.small .sty-shot > div { width: 250%; transform: scale(.4); }
.gal.small .sty-cap { padding: 8px 10px 10px; }
.gal.small .sty-cap b { font-size: 13px; }
.gal.small .sty-cap span { font-size: 11.5px; }
.sty-cap { padding: 10px 12px 12px; border-top: 1px solid var(--line2); }
.sty-cap b { display: block; font-size: 14px; }
.sty-cap span { font-size: 12px; color: var(--muted); line-height: 1.4; display: block; margin-top: 2px; }
.pals { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.pal { border: 2px solid var(--line); border-radius: 10px; padding: 0; background: #fff; cursor: pointer; overflow: hidden; text-align: left; }
.pal[aria-pressed=true] { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,71,224,.18); }
.pal-sw { height: 46px; display: flex; align-items: flex-end; gap: 6px; padding: 8px; }
.pal-sw i { display: block; width: 26px; height: 14px; border-radius: 4px; }
.pal-sw em { font-style: normal; font-weight: 700; font-size: 15px; margin-left: auto; }
.pal span { display: block; font-size: 12px; font-weight: 600; padding: 6px 8px; border-top: 1px solid var(--line2); }
.pal.site .pal-sw { background: repeating-linear-gradient(45deg, #f3f4f6 0 8px, #e7e9ee 8px 16px); color: var(--muted); font-size: 12px; align-items: center; }
.css-ref { font-size: 12px; color: var(--muted); }
.css-ref code { font-family: var(--mono); background: var(--line2); padding: 1px 5px; border-radius: 4px; color: var(--ink); }

/* embed */
.snip { margin: 0 0 14px; }
.snip-head { display: flex; justify-content: space-between; align-items: center; margin: 0 0 5px; }
.snip-head b { font-size: 13px; }
.snip pre { margin: 0; padding: 10px 12px; background: #0f1424; color: #dfe5f5; border-radius: 8px; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-all; }
.snip p { margin: 5px 0 0; font-size: 12px; color: var(--muted); }

/* history */
.hist { list-style: none; padding: 0; margin: 0; }
.hist li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line2); font-size: 14px; }

/* leads */
.lead-detail td { background: #fafbfc; }
.answers { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.answers li { font-size: 13px; }
.answers b { font-weight: 600; }

/* modal, toast */
.modal-bg { position: fixed; inset: 0; background: rgba(15,20,36,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: min(640px, 100%); max-height: calc(100vh - 32px); overflow: auto; }
.modal-head { padding: 18px 20px 0; }
.modal-body { padding: 16px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line2); display: flex; justify-content: flex-end; gap: 8px; }
.kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 16px; }
.kind { border: 2px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; background: #fff; text-align: left; }
.kind[aria-pressed=true] { border-color: var(--accent); background: var(--accent-soft); }
.kind b { display: block; }
.kind span { font-size: 13px; color: var(--muted); }
.tpls { display: grid; gap: 8px; margin: 0 0 16px; }
.tpl { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.tpl:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.tpl input { margin-top: 4px; }
.tpl b { display: block; font-size: 14px; }
.tpl span { font-size: 13px; color: var(--muted); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #0f1424; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: calc(100vw - 32px); }
.toast.err { background: var(--err); }

/* sign-in */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 20% -10%, #dfe5ff 0%, transparent 60%), var(--bg); }
.signin .panel { width: min(420px, 100%); padding: 28px; }
.signin h1 { margin: 14px 0 6px; }
.signin p { color: var(--muted); margin: 0 0 18px; }
.signin .btn { width: 100%; min-height: 42px; margin-top: 4px; }
.signin .msg { margin: 14px 0 0; font-size: 14px; }

/* gallery page */
.gal-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 0 0 16px; }
.mini-pals { display: flex; gap: 6px; flex-wrap: wrap; }
.mini-pals button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.mini-pals button[aria-pressed=true] { box-shadow: 0 0 0 2px var(--ink); }
.mini-pals button.site { background: repeating-linear-gradient(45deg, #f3f4f6 0 4px, #d9dce3 4px 8px); }

/* phone and narrow screens */
.mobile-switch { display: none; }
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; }
  .side.open { display: flex; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #0f1424; color: #fff; position: sticky; top: 0; z-index: 30; }
  .topbar button { background: none; border: 0; color: #fff; cursor: pointer; padding: 4px; }
  .topbar svg { width: 22px; height: 22px; }
  .main { padding: 16px 16px 60px; }
  .ed { grid-template-columns: 1fr; }
  .mobile-switch { display: inline-flex; margin: 0 0 12px; }
  .ed[data-show=edit] .pv { display: none; }
  .ed[data-show=preview] .ed-form { display: none; }
  .pv { position: static; }
  .pv-page { max-height: none; padding: 14px; }
  .ed-title h1 { max-width: 70vw; font-size: 19px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .opt-row, .opt-head { grid-template-columns: minmax(0, 1fr) 96px 58px 30px; }
  .field-row { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
@media (max-width: 520px) {
  .kinds { grid-template-columns: 1fr; }
  table.data th.hide-xs, table.data td.hide-xs { display: none; }
}
