/* =====================================================================================
   Lipy Forms — painel de gestão. Mesma paleta e tipografia do Lipy Games ("Crocante Pop"),
   em versão de ferramenta: menos textura, mais leitura. Tokens no topo; trocar pela marca é rápido.
   ===================================================================================== */
:root {
  --roxo-900: #22083b;
  --roxo-700: #4b1677;
  --roxo-600: #6b2fa0;
  --roxo-100: #efe4fb;
  --amarelo: #ffd23f;
  --laranja: #ff7a00;
  --creme: #fff8ea;
  --azul: #2d6cdf;
  --verde: #2f9e44;
  --vermelho: #d63a3d;

  --ink: var(--roxo-900);
  --ink-2: #4d3966;
  --muted: #7d6a92;
  --line: #eadfca;
  --card: #fffdf8;
  --bg: var(--creme);
  --track: #f1e7d4;

  --stroke: 2px solid var(--ink);
  --pop: 0 4px 0 var(--ink);
  --radius: 16px;
  --display: 'Lilita One', 'Baloo 2', system-ui, sans-serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font: 600 15px/1.5 var(--body); }
h1, h2, h3 { font-family: var(--display); font-weight: 400; line-height: 1.1; margin: 0 0 .35em; letter-spacing: .2px; text-wrap: balance; }
h1 { font-size: clamp(26px, 4vw, 34px); }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
p { margin: 0 0 .8em; }
a { color: var(--roxo-600); font-weight: 800; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--azul); outline-offset: 2px; border-radius: 6px; }

/* ---------- topo ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px;
  padding: 10px max(16px, env(safe-area-inset-left, 0px)) 10px max(16px, env(safe-area-inset-right, 0px));
  background: var(--roxo-600) radial-gradient(circle, rgba(255, 255, 255, .13) 1.4px, transparent 2px) 0 0 / 14px 14px;
  color: #fff; border-bottom: 3px solid var(--ink);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand img { height: 34px; width: auto; }
.brand span { font-family: var(--display); font-size: 20px; letter-spacing: .3px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: #fff; text-decoration: none; font-weight: 800; padding: 6px 12px; border-radius: 999px; opacity: .88; }
.nav a:hover { opacity: 1; background: rgba(255, 255, 255, .12); }
.nav a.active { background: var(--amarelo); color: var(--ink); opacity: 1; }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.who .role { background: rgba(255, 255, 255, .16); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 800; }
.who a { color: #fff; }
.menu-btn { display: none; }

main { max-width: 1180px; margin: 0 auto; padding: 26px max(16px, env(safe-area-inset-right, 0px)) 60px max(16px, env(safe-area-inset-left, 0px)); }
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 20px; margin-bottom: 20px; }
.page-head p { margin: 0; color: var(--muted); max-width: 70ch; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.crumb a { font-weight: 700; }

/* ---------- blocos ---------- */
.card { background: var(--card); border: var(--stroke); border-radius: var(--radius); box-shadow: var(--pop); padding: 18px; min-width: 0; }
.card.flat { box-shadow: none; border: 1.5px solid var(--line); }
.card h3 + .sub { margin-top: -2px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: grid; gap: 18px; }
.grid.split { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none;
  border: var(--stroke); border-radius: 12px; padding: 9px 16px; background: var(--amarelo); color: var(--ink);
  font: 400 16px/1.1 var(--display); letter-spacing: .3px; box-shadow: 0 3px 0 var(--ink); transition: transform .08s;
}
.btn:active { transform: translateY(3px); box-shadow: none; }
.btn.secondary { background: var(--card); }
.btn.purple { background: var(--roxo-600); color: #fff; }
.btn.danger { background: #ffe1e1; }
.btn.small { font-size: 14px; padding: 6px 11px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--roxo-600); font-weight: 800; cursor: pointer; text-decoration: underline; }

label.field { display: grid; gap: 5px; font-weight: 800; font-size: 14px; }
.input, select.input, textarea.input {
  width: 100%; border: 2px solid #d9c9ad; border-radius: 12px; padding: 10px 12px; background: #fff; font-weight: 700;
}
.input:focus { border-color: var(--roxo-600); outline: none; box-shadow: 0 0 0 3px var(--roxo-100); }
.hint { font-weight: 600; font-size: 12.5px; color: var(--muted); }
.error { color: var(--vermelho); font-weight: 800; font-size: 14px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 900; background: var(--track); color: var(--ink-2); white-space: nowrap; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--verde); background: #e3f5e6; }
.pill.warn { color: #b35c00; background: #fff0d6; }
.pill.bad { color: var(--vermelho); background: #ffe5e5; }
.pill.info { color: var(--roxo-600); background: var(--roxo-100); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
code { font: 700 12.5px ui-monospace, 'SF Mono', Menlo, Consolas, monospace; background: var(--track); padding: 2px 6px; border-radius: 6px; }

/* ---------- indicadores e gráficos ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0; }
.kpi { background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 14px; }
.kpi dt { font-size: 12.5px; color: var(--muted); font-weight: 800; }
.kpi dd { margin: 2px 0 0; font: 400 30px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.kpi small { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.kpi.hl { background: var(--amarelo); border: var(--stroke); box-shadow: var(--pop); }
.kpi.hl dt, .kpi.hl small { color: var(--ink-2); }

.hbars { display: grid; gap: 9px; }
.hbar { display: grid; grid-template-columns: minmax(80px, 150px) minmax(0, 1fr) 104px; gap: 10px; align-items: center; font-size: 14px; }
.hbar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track { height: 12px; background: var(--track); border-radius: 999px; overflow: hidden; }
.track i { display: block; height: 100%; border-radius: 999px; background: var(--roxo-600); }
.hbar .v { text-align: right; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.cols { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); align-items: end; gap: 6px; height: 170px; border-bottom: 1.5px solid var(--line); }
.cols .col { display: flex; flex-direction: column; justify-content: end; align-items: center; height: 100%; gap: 3px; min-width: 0; }
.cols .col i { display: block; width: 100%; max-width: 46px; border-radius: 6px 6px 0 0; background: var(--roxo-600); min-height: 1px; }
.cols .col span { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cols-labels { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; font-size: 11.5px; color: var(--muted); text-align: center; margin-top: 4px; }
.cols.dense { gap: 2px; }
.cols.dense .col span { display: none; }
.cols-labels.dense { gap: 2px; font-size: 10px; }
.cols-labels.dense span:nth-child(odd) { visibility: hidden; }

.funnel { display: grid; gap: 6px; }
.funnel .step { display: grid; grid-template-columns: minmax(110px, 220px) minmax(0, 1fr) 120px; gap: 10px; align-items: center; font-size: 13.5px; }
.funnel .step .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.funnel .track { height: 18px; border-radius: 6px; }
.funnel .track i { border-radius: 6px; background: linear-gradient(90deg, var(--roxo-600), #9b5de5); }
.funnel .drop { color: var(--vermelho); font-size: 12px; font-weight: 800; }

/* ---------- temas ---------- */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 20px; }
.theme-card { display: grid; gap: 12px; }
.theme-card .frame { height: 430px; border-radius: 28px; padding: 7px; background: #1b1420; box-shadow: 0 14px 30px -18px rgba(34, 8, 59, .6); }
.theme-card header { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.theme-card header p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- biblioteca ---------- */
.drop { display: grid; gap: 4px; place-items: center; text-align: center; padding: 26px 16px; border: 2.5px dashed #c9b48f; border-radius: var(--radius); background: #fffdf8; cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--roxo-600); background: var(--roxo-100); }
.drop b { font: 400 19px var(--display); }
.flavor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; }
.flavor-tile { display: grid; gap: 4px; justify-items: center; text-align: center; font-size: 13px; min-width: 0; }
.flavor-tile code { font-size: 11px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.flavor-tile .pack { width: 92px; height: 112px; border-radius: 14px; display: grid; place-items: center; border: 2px solid rgba(34, 8, 59, .15); overflow: hidden; }
.flavor-tile .pack span { color: #fff; font-weight: 900; font-size: 12px; text-shadow: 0 1px 2px rgba(0, 0, 0, .45); }
.flavor-tile.ok .pack { background: #fff !important; }
.flavor-tile .pack img { width: 100%; height: 100%; object-fit: contain; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.media-card { display: grid; gap: 10px; align-content: start; padding: 12px; }
.media-card .thumb { aspect-ratio: 4 / 3; max-width: 100%; border-radius: 10px; display: grid; place-items: center; overflow: hidden;
  background: repeating-conic-gradient(#f1e7d4 0% 25%, #fffdf8 0% 50%) 0 0 / 16px 16px; }
.media-card .thumb img { width: 100%; height: 100%; object-fit: contain; }
.media-card .meta { display: grid; gap: 3px; min-width: 0; }
.media-card .meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- formulário: abas ---------- */
.form-head { margin-bottom: 10px; }
.tabs-bar { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs-bar a { padding: 9px 14px; text-decoration: none; color: var(--muted); font-weight: 800; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs-bar a.active { color: var(--ink); border-bottom-color: var(--roxo-600); }
.filters { margin-bottom: 16px; align-items: end; }
.filters .field { min-width: 140px; }
.texts { margin: 0; padding-left: 18px; display: grid; gap: 6px; max-height: 260px; overflow: auto; font-size: 14px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 700; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--roxo-600); }
.hint code { font-size: 11.5px; }

/* ---------- construtor ---------- */
.builder-bar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; padding: 10px 14px; margin-bottom: 14px; position: sticky; top: 64px; z-index: 5; }
.bb-status { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; min-width: 0; }
.bb-status .pill { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.builder { display: grid; grid-template-columns: minmax(250px, 300px) minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.b-list { padding: 12px; }
.b-list-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
#b-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 64vh; overflow: auto; }
.b-step { display: flex; align-items: stretch; gap: 4px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; }
.b-step.sel { border-color: var(--roxo-600); box-shadow: 0 0 0 3px var(--roxo-100); }
.b-step-main { flex: 1; min-width: 0; display: flex; gap: 8px; align-items: flex-start; text-align: left; background: none; border: 0; padding: 8px; cursor: pointer; }
.b-ico { width: 24px; height: 24px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--roxo-100); color: var(--roxo-600); font-size: 13px; }
.b-step-text { display: grid; min-width: 0; font-size: 13.5px; line-height: 1.3; }
.b-step-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-step-text .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-step-tools { display: flex; align-items: center; gap: 1px; padding-right: 4px; }
.b-step:not(.sel) > .b-step-tools { display: none; }
.b-editor .grid { align-items: start; }
.b-step-tools button { border: 0; background: none; cursor: pointer; color: var(--muted); font-weight: 900; padding: 4px 5px; border-radius: 6px; }
.b-step-tools button:hover:not(:disabled) { background: var(--track); color: var(--ink); }
.b-step-tools button:disabled { opacity: .25; cursor: default; }
.b-step-tools button.danger { color: var(--vermelho); font-size: 11px; }
.b-add { position: relative; margin-top: 10px; }
.b-menu { position: absolute; z-index: 20; left: 0; top: calc(100% + 6px); width: min(520px, 86vw); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; padding: 14px; max-height: 60vh; overflow: auto; }
.b-menu-group { display: grid; gap: 2px; align-content: start; }
.b-menu-group b { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 2px; }
.b-menu-item { text-align: left; background: none; border: 0; border-radius: 8px; padding: 6px 8px; cursor: pointer; font-weight: 700; }
.b-menu-item:hover:not(:disabled) { background: var(--roxo-100); }
.b-menu-item:disabled { color: var(--muted); cursor: not-allowed; }
.b-editor { display: grid; gap: 14px; padding: 16px; min-width: 0; }
.b-ed-head { display: flex; justify-content: space-between; align-items: center; }
.b-opts, .b-cond { border: 1.5px dashed var(--line); border-radius: 12px; padding: 10px 12px 12px; margin: 0; display: grid; gap: 8px; min-width: 0; }
.b-opts legend, .b-cond legend { font-weight: 900; font-size: 14px; padding: 0 4px; }
.b-cond .row { flex-wrap: wrap; }
.b-cond .input { width: auto; min-width: 0; flex: 1 1 140px; }
.opt-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.opt { display: grid; grid-template-columns: 40px minmax(0, 1fr) 52px 100px 56px; gap: 6px; align-items: center; }
.opt .input { padding: 7px 9px; }
.opt-color { width: 36px; height: 34px; border: 0; background: none; padding: 0; cursor: pointer; }
.opt-emoji { text-align: center; }
.opt-val { font-size: 11px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt-img { width: 40px; height: 48px; border: 1.5px dashed #c9b48f; border-radius: 8px; background: #fff; display: grid; place-items: center; cursor: pointer; overflow: hidden; padding: 0; font-size: 9px; color: var(--muted); }
.opt-img img { width: 100%; height: 100%; object-fit: contain; }
.opt-img.big { width: 140px; height: 110px; font-size: 12px; }
.b-preview { position: sticky; top: 132px; }
.b-preview .frame { height: 600px; }
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(34, 8, 59, .45); display: grid; place-items: center; padding: 16px; }
.modal-box { width: min(760px, 100%); max-height: 86vh; overflow: auto; display: grid; gap: 12px; }
.mm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.mm-item { display: grid; gap: 4px; padding: 6px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-size: 11.5px; text-align: center; min-width: 0; }
.mm-item:hover { border-color: var(--roxo-600); }
.mm-item img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.mm-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- configurações e links ---------- */
.theme-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.theme-opt { display: grid; gap: 6px; justify-items: center; cursor: pointer; font-size: 13px; }
.theme-opt input { position: absolute; opacity: 0; }
.theme-mini { display: block; width: 150px; height: 230px; overflow: hidden; border-radius: 18px; border: 3px solid transparent; pointer-events: none; }
.theme-mini .lf-chat { width: 300px; height: 460px; transform: scale(.5); transform-origin: 0 0; }
.theme-opt input:checked + .theme-mini { border-color: var(--roxo-600); box-shadow: 0 0 0 3px var(--roxo-100); }
.theme-opt input:focus-visible + .theme-mini { outline: 3px solid var(--azul); }
.qr-box { background: #fff; border-radius: 14px; padding: 14px; display: grid; place-items: center; border: 1.5px solid var(--line); }
.qr-box img { width: min(240px, 100%); height: auto; }
tr[data-link] { cursor: pointer; }
tr.sel td { background: var(--roxo-100); }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px));
  background: var(--roxo-600) radial-gradient(circle, rgba(255, 255, 255, .12) 1.5px, transparent 2.1px) 0 0 / 16px 16px; }
.auth .card { width: min(420px, 100%); display: grid; gap: 14px; }
.auth .mascot { width: 130px; margin: -80px auto 0; filter: drop-shadow(0 5px 0 rgba(34, 8, 59, .25)); }
.auth h1 { text-align: center; margin: 0; }

/* senha provisória */
.secret { display: flex; gap: 8px; align-items: center; background: var(--amarelo); border: var(--stroke); border-radius: 12px; padding: 10px 12px; }
.secret code { background: #fff; font-size: 15px; flex: 1; min-width: 0; overflow-wrap: anywhere; }

#toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 140%) rotate(-1deg); z-index: 50;
  background: var(--amarelo); color: var(--ink); border: var(--stroke); box-shadow: var(--pop); border-radius: 14px; padding: 10px 18px; font-weight: 900; transition: transform .25s ease; max-width: calc(100vw - 32px); }
#toast.show { transform: translate(-50%, 0) rotate(-1deg); }
#toast:empty { display: none; }

.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty img { width: 120px; display: block; margin: 0 auto 10px; }

@media (max-width: 1180px) {
  .builder { grid-template-columns: minmax(240px, 280px) minmax(0, 1fr); }
  .b-preview { grid-column: 1 / -1; position: static; max-width: 380px; }
}
@media (max-width: 860px) {
  .grid.c2, .grid.c3, .grid.split { grid-template-columns: minmax(0, 1fr); }
  .builder { grid-template-columns: minmax(0, 1fr); }
  .b-preview { position: static; }
  .builder-bar { position: static; }
  .opt { grid-template-columns: 40px minmax(0, 1fr) 48px auto; }
  .opt .opt-val { display: none; }
  .b-menu { grid-template-columns: minmax(0, 1fr); }
  .topbar { flex-wrap: wrap; gap: 10px; }
  .nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .who .name { display: none; }
  .hbar { grid-template-columns: minmax(70px, 110px) minmax(0, 1fr) 86px; }
  .funnel .step { grid-template-columns: minmax(90px, 130px) minmax(0, 1fr) 96px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
