:root {
  --bg: #131418;
  --surface: #1c1e25;
  --surface2: #232630;
  --border: #2c2f3a;
  --ink: #eef0f5;
  --muted: #9aa1ae;
  --accent: #acf7c1;
  --accent-2: #7fe8a6;
  --accent-ink: #0e1512;
  --accent-soft: rgba(172, 247, 193, .14);
  --green: #2bb673;
  --amber: #e0a72f;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
textarea { resize: vertical; min-height: 64px; }
label.fld { display: block; margin-bottom: 12px; }
label.fld > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; letter-spacing: .02em; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface2);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 15px;
  font-weight: 600;
  transition: filter .12s ease, transform .1s ease;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: #ff7a7a; border-color: #59333a; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Topbar ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 22px;
  background: rgba(19, 20, 24, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.logo { font-weight: 800; font-size: 17px; letter-spacing: -.02em; }
.logo .dot { color: var(--accent); }
.tabs { display: flex; gap: 4px; }
.tab {
  background: transparent; border: 0; color: var(--muted);
  padding: 8px 14px; border-radius: 999px; font-weight: 600;
}
.tab.active { background: var(--accent-soft); color: var(--accent); }
.topbar .spacer { flex: 1; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 26px 22px 80px; }

h1.page { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 4px; }
p.sub { color: var(--muted); margin: 0 0 22px; }

/* ── Login ── */
.login-box {
  max-width: 360px; margin: 12vh auto 0; padding: 30px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
}
.login-box h1 { font-size: 20px; margin: 0 0 4px; }
.login-box p { color: var(--muted); margin: 0 0 18px; font-size: 14px; }

/* ── Lista de fluxos ── */
.flow-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.flow-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
  transition: border-color .15s ease;
}
.flow-card:hover { border-color: #3d414f; }
.flow-card .name { font-weight: 700; font-size: 16px; }
.flow-card .url { font-size: 13px; color: var(--muted); word-break: break-all; }
.flow-card .foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; letter-spacing: .03em;
  padding: 4px 10px; border-radius: 999px;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.criando { color: var(--amber); background: rgba(224, 167, 47, .12); }
.badge.publicado { color: var(--green); background: rgba(43, 182, 115, .12); }
.badge.desativado { color: var(--muted); background: rgba(154, 161, 174, .12); }

/* ── Editor ── */
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 22px; align-items: start; }
@media (max-width: 980px) { .editor-grid { grid-template-columns: 1fr; } .phone-sticky { position: static !important; } }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.card h2 { font-size: 15px; margin: 0 0 14px; letter-spacing: .01em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

.avatar-line { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.avatar-preview { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; background: var(--surface2); border: 1px solid var(--border); }

.status-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pub-url { font-size: 13px; color: var(--muted); word-break: break-all; }
.pub-url a { color: var(--green); }

/* Etapas */
.step-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 14px; overflow: hidden;
}
.step-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.step-head .t { font-weight: 700; }
.step-head .spacer { flex: 1; }
.phase-pill { font-size: 12px; border-radius: 999px; padding: 4px 10px; width: auto; }
.step-body { padding: 14px 16px; }

.block-row, .opt-row {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
}
.block-row .head, .opt-row .head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.block-row .head .type { font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: .05em; text-transform: uppercase; }
.block-row .head .spacer, .opt-row .head .spacer { flex: 1; }
.mini {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 7px; padding: 3px 8px; font-size: 12px;
}
.mini:hover { color: var(--ink); }
.mini.x:hover { color: #ff7a7a; border-color: #59333a; }

.addbar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.sec-label { font-size: 12.5px; color: var(--muted); margin: 14px 0 8px; letter-spacing: .04em; text-transform: uppercase; }

.opt-grid { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(0,1fr); gap: 8px; }
@media (max-width: 640px) { .opt-grid { grid-template-columns: 1fr; } }

/* Barra de salvar fixa */
.savebar {
  position: sticky; bottom: 0; z-index: 15;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0 4px; margin-top: 10px;
  background: linear-gradient(transparent, var(--bg) 30%);
}
.save-state { font-size: 13px; color: var(--muted); }
.save-state.dirty { color: var(--amber); }
.save-state.ok { color: var(--green); }

/* ── Preview de celular (assinatura do painel) ── */
.phone-sticky { position: sticky; top: 78px; }
.phone {
  border: 1px solid var(--border);
  border-radius: 30px;
  background: #fff7f6;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
}
.phone-top {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: #fff; border-bottom: 1px solid #f0e6e6;
  color: #222;
}
.phone-top img, .phone-top .ph-av {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #eee;
  display: grid; place-items: center; font-weight: 700; color: #a99;
}
.phone-top .ph-name { font-weight: 700; font-size: 14px; }
.phone-top .ph-on { font-size: 11.5px; color: #2bb673; }
.phone-screen { height: 560px; overflow-y: auto; padding: 14px 12px 20px; }
.preview-tools { display: flex; gap: 8px; margin-top: 10px; }

/* dentro do preview reaproveitamos as classes do chat público em escala menor */
.phone-screen {
  font-size: 14.5px; color: #1c1f24;
  --pv-accent-text: color-mix(in srgb, var(--pv-accent, #acf7c1) 55%, black);
}
.phone-screen .row { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 8px; }
.phone-screen .row.user { justify-content: flex-end; }
.phone-screen .avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: #e6e0dd; flex: 0 0 30px; }
.phone-screen .avatar.ghost { visibility: hidden; }
.phone-screen .bubble { background: #eef4fb; border-radius: 16px; border-bottom-left-radius: 5px; padding: 10px 13px; max-width: 84%; overflow-wrap: break-word; }
.phone-screen .row.user .bubble { background: #23272f; color: #fff; border-bottom-left-radius: 16px; border-bottom-right-radius: 5px; }
.phone-screen .bubble.rich { background: #fff; border: 1px solid #eee3e3; width: 84%; }
.phone-screen .rich-title { font-size: 17px; font-weight: 800; margin: 2px 0 6px; }
.phone-screen .rich-title .hl { color: var(--pv-accent-text); }
.phone-screen .bubble.rich img.media { width: 100%; border-radius: 10px; display: block; margin: 8px 0 2px; }
.phone-screen .caption { font-size: 11.5px; color: #8a8a8a; }
.phone-screen .video-wrap { position: relative; width: 100%; aspect-ratio: 16/9; border-radius: 10px; overflow: hidden; background: #000; margin: 8px 0 2px; }
.phone-screen .video-wrap iframe, .phone-screen .video-wrap video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.phone-screen a.textlink { color: var(--pv-accent-text); font-weight: 600; }
.phone-screen .cta-btn {
  display: block; margin: 8px 0 2px; padding: 11px 14px; border-radius: 999px; border: 0;
  background: linear-gradient(90deg, var(--pv-accent, #acf7c1), #7fe8a6);
  color: #0e1512; font-weight: 700; text-align: center; text-decoration: none; font-size: 14px;
}
.phone-screen .opts { display: flex; flex-direction: column; gap: 8px; margin: 22px 0 4px; }
.phone-screen .opt {
  border: 0; background: #23272f; color: #fff; text-align: left;
  padding: 12px 15px; border-radius: 13px; font-size: 13px;
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-weight: 500;
}
.phone-screen .typing .bubble { display: inline-flex; gap: 4px; padding: 12px 13px; }
.phone-screen .dot { width: 6px; height: 6px; border-radius: 50%; background: #9aa6b5; animation: blink 1.2s infinite ease-in-out; }
.phone-screen .dot:nth-child(2) { animation-delay: .18s; }
.phone-screen .dot:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

/* ── Métricas ── */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 18px; }
.chip {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); border-radius: 999px; padding: 7px 14px; font-weight: 600; font-size: 13.5px;
}
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px;
}
.stat .n { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.stat .l { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) 220px 86px; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); }
.bar-row:last-child { border-bottom: 0; }
.bar-row .lbl { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .lbl .ph { font-size: 11px; color: var(--muted); }
.bar-track { height: 12px; background: var(--surface2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #7fe8a6); border-radius: 999px; }
.bar-fill.green { background: linear-gradient(90deg, #1f9e63, #4fd598); }
.bar-num { font-size: 13px; text-align: right; white-space: nowrap; }
.drop { color: #ff8a8a; font-size: 11.5px; }
@media (max-width: 700px) { .bar-row { grid-template-columns: minmax(0,1fr) 100px 80px; } }

.daily { display: flex; align-items: flex-end; gap: 5px; height: 110px; margin-top: 8px; }
.daily .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.daily .colbar { width: 100%; max-width: 34px; background: linear-gradient(180deg, #7fe8a6, var(--accent)); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.daily .cl { font-size: 10px; color: var(--muted); white-space: nowrap; }

.mrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.mrow:last-child { border-bottom: 0; }

.empty {
  border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 34px; text-align: center; color: var(--muted);
}

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--surface2); border: 1px solid var(--border); color: var(--ink);
  padding: 11px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 100;
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { border-color: #6a3038; color: #ffb0b0; }

.back { color: var(--muted); text-decoration: none; font-size: 13.5px; display: inline-flex; gap: 6px; margin-bottom: 10px; }
.back:hover { color: var(--ink); }

.hint { font-size: 12.5px; color: var(--muted); margin-top: -6px; margin-bottom: 12px; }

input[type="color"] { padding: 3px; height: 40px; width: 60px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
