:root {
  --bg: #050605;
  --side: #0d0f0e;
  --card: #141716;
  --card2: #1a1e1c;
  --line: #262b28;
  --text: #f2f5f3;
  --muted: #8b948f;
  --green: #5fe314;
  --green-d: #3fa80a;
  --green-bg: rgba(95, 227, 20, .12);
  --red: #ff4d4f;
  --amber: #f5b014;
  --blue: #3b82f6;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: Inter, system-ui, sans-serif; font-size: 14px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 13px; color: var(--text); }
input, select, textarea {
  background: #0a0c0b; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
textarea { resize: vertical; min-height: 70px; }
label { display: block; font-size: 12px; font-weight: 600; margin: 12px 0 6px; color: #cfd6d2; }

.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: #0a0c0b; padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: #3a413d; }
.btn.primary { background: var(--green); border-color: var(--green); color: #061200; }
.btn.primary:hover { background: #6ff52a; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost-danger { color: var(--red); border-color: rgba(255,77,79,.35); background: rgba(255,77,79,.08); }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 210px 190px 1fr; height: 100vh; }
.layout.collapsed { grid-template-columns: 64px 190px 1fr; }
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 22px; letter-spacing: -.5px; padding: 2px 8px 18px; }
.logo .mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #8dff4a, #2fa800); display: grid; place-items: center; color: #041000; font-weight: 900; font-size: 17px; }
.logo b { color: var(--green); }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 10px; border-radius: 10px; cursor: pointer; color: #dfe5e1; font-weight: 500; margin-bottom: 3px; white-space: nowrap; overflow: hidden; }
.nav-item:hover { background: #151917; }
.nav-item.active { background: #18201a; color: #fff; font-weight: 700; box-shadow: inset 0 0 0 1px #24301f; }
.nav-item svg { width: 18px; height: 18px; flex: none; color: var(--green); }
.side .spacer { flex: 1; }
.collapsed .side .nav-item span, .collapsed .logo span { display: none; }
.sub { background: #090b0a; border-right: 1px solid var(--line); padding: 54px 10px 10px; }
.sub-item { display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 10px; cursor: pointer; color: #d6ddd9; font-size: 13px; margin-bottom: 3px; }
.sub-item:hover { background: #131715; }
.sub-item.active { background: #17200f; color: #fff; font-weight: 700; box-shadow: inset 0 0 0 1px #2f4a17; }
.sub-item svg { width: 15px; height: 15px; color: var(--green); }
.tag-new { font-size: 9px; font-weight: 800; color: var(--green); border: 1px solid #2f4a17; background: #102008; padding: 2px 5px; border-radius: 5px; margin-left: auto; }

.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar { height: 54px; display: flex; align-items: center; gap: 14px; padding: 0 22px; border-bottom: 1px solid var(--line); background: #070908; }
.topbar h1 { font-size: 15px; margin: 0; font-weight: 700; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--red); font-size: 10px; font-weight: 800; letter-spacing: .5px; cursor: pointer; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 0 rgba(255,77,79,.7); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(255,77,79,0); } 100% { box-shadow: 0 0 0 0 rgba(255,77,79,0); } }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #e9ecea; color: #111; display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.content { flex: 1; overflow: auto; padding: 22px; }
.footer { padding: 10px 22px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); }

/* ---------- componentes ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 16px; }
.card h3 { margin: 0 0 14px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }
.seg { display: inline-flex; background: #0a0c0b; border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--green); color: #061200; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.kpi .t { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; display: flex; justify-content: space-between; }
.kpi .v { font-size: 24px; font-weight: 800; margin-top: 8px; }
.delta { font-size: 11px; font-weight: 700; color: var(--green); }
.delta.neg { color: var(--red); }
.tabs { display: flex; background: #0a0c0b; border: 1px solid var(--line); border-radius: 11px; padding: 4px; margin: 16px 0; }
.tabs button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 8px; font-weight: 700; color: var(--muted); cursor: pointer; }
.tabs button.on { background: #1c211e; color: #fff; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 10px; border-bottom: 1px solid var(--line); }
td { padding: 12px 10px; border-bottom: 1px solid #1d211f; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.small { font-size: 11px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 800; padding: 3px 8px; border-radius: 6px; text-transform: uppercase; letter-spacing: .3px; }
.pill.green { color: var(--green); background: var(--green-bg); }
.pill.amber { color: var(--amber); background: rgba(245,176,20,.12); }
.pill.red { color: var(--red); background: rgba(255,77,79,.12); }
.pill.gray { color: #aab3ae; background: #222724; }
.pill.blue { color: #6aa5ff; background: rgba(59,130,246,.14); }
.src { font-size: 10px; padding: 2px 6px; border-radius: 5px; background: #1d3fbf; color: #fff; font-weight: 700; }
.src.instagram { background: linear-gradient(90deg, #c13584, #f56040); }
.empty { text-align: center; color: var(--muted); padding: 50px 10px; }
.empty b { display: block; color: #fff; font-size: 16px; margin-bottom: 6px; }
.money { color: var(--green); font-weight: 800; }
.row { display: flex; gap: 12px; align-items: center; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chk { width: 16px; height: 16px; accent-color: var(--green); }

/* gráfico */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .b i { display: block; width: 100%; max-width: 22px; background: var(--green); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .b span { font-size: 9px; color: var(--muted); }

/* lista de disparos */
.disp { display: grid; grid-template-columns: 34px 210px 1fr 130px 270px; gap: 14px; align-items: center; background: #101311; border: 1px solid var(--line); border-left: 4px solid var(--amber); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.disp.done { border-left-color: var(--green); }
.disp.paused { border-left-color: #6b7570; }
.disp.review { border-left-color: var(--blue); }
.progress { height: 4px; background: #222; border-radius: 3px; overflow: hidden; margin: 6px 0 4px; max-width: 200px; }
.progress i { display: block; height: 100%; background: var(--green); }
.valuebox { background: #0d1a07; border: 1px solid #2f4a17; border-radius: 9px; padding: 6px 10px; text-align: center; }

/* modal / toast */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal h3 { margin: 0 0 6px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
#toast { position: fixed; bottom: 22px; right: 22px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
#toast div { background: #1a1f1c; border: 1px solid var(--line); border-left: 4px solid var(--green); padding: 11px 15px; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
#toast div.err { border-left-color: var(--red); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 50% 30%, #0e1a08, #000 60%); }
.login { width: 100%; max-width: 400px; background: #121513; border: 1px solid var(--line); border-radius: 16px; padding: 30px 26px; }
.login .logo { justify-content: center; font-size: 28px; }
.login h2 { margin: 6px 0 14px; }

/* modo ao vivo */
.livebox { position: fixed; inset: 0; background: radial-gradient(circle at 50% 40%, #0b2a12, #000 70%); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; z-index: 40; }
.livebox .big { font-size: 74px; font-weight: 900; color: var(--green); letter-spacing: -2px; text-shadow: 0 0 40px rgba(95,227,20,.35); }
.livebox .feed { margin-top: 26px; width: min(520px, 90vw); }
.livebox .feed div { background: rgba(255,255,255,.04); border: 1px solid #1f2a22; border-radius: 12px; padding: 12px 16px; margin-bottom: 8px; display: flex; justify-content: space-between; animation: pop .5s; }
@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.flash { animation: flash 1s; }
@keyframes flash { 0% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* chat */
.msgs { display: flex; flex-direction: column; gap: 6px; background: #0b0f0c; border-radius: 12px; padding: 12px; max-height: 60vh; overflow: auto; }
.msgs div { max-width: 80%; padding: 8px 11px; border-radius: 10px; background: #1d2420; white-space: pre-wrap; word-break: break-word; font-size: 13px; }
.msgs div.me { align-self: flex-end; background: #144d1b; }

/* ---------- editor de fluxo ---------- */
.editor-wrap { position: relative; height: calc(100vh - 54px - 44px); display: flex; flex-direction: column; }
.editor-top { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #0a0c0b; flex-wrap: wrap; }
.editor-top input.fname { max-width: 340px; font-weight: 700; }
#drawflow { flex: 1; position: relative; background: #0b0d0c; background-image: radial-gradient(#1f2421 1px, transparent 1px); background-size: 18px 18px; }
.zoombar { position: absolute; left: 14px; bottom: 14px; display: flex; flex-direction: column; background: #fff; border-radius: 8px; overflow: hidden; z-index: 5; }
.zoombar button { border: 0; background: #fff; color: #111; width: 30px; height: 30px; cursor: pointer; font-size: 16px; font-weight: 700; }
.palette { position: absolute; top: 56px; right: 14px; width: 560px; max-width: calc(100% - 28px); background: #101311; border: 1px solid var(--line); border-radius: 14px; padding: 14px; z-index: 20; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.palette .cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.palette h5 { margin: 6px 0 8px; font-size: 10px; color: var(--muted); letter-spacing: .6px; }
.palette .it { display: flex; gap: 8px; align-items: center; padding: 7px 6px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.palette .it:hover { background: #1a1f1c; }
.palette .it i { font-style: normal; width: 18px; text-align: center; }

.drawflow .drawflow-node { background: #141716 !important; border: 1.5px solid #2e3530 !important; border-radius: 12px !important; color: var(--text) !important; width: 270px !important; padding: 0 !important; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.drawflow .drawflow-node.selected { border-color: var(--green) !important; box-shadow: 0 0 0 3px var(--green-bg); }
.drawflow .drawflow-node .input, .drawflow .drawflow-node .output { width: 14px !important; height: 14px !important; background: #0b0d0c !important; border: 2px solid var(--green) !important; }
.drawflow .connection .main-path { stroke: #6b746f !important; stroke-width: 2.5px !important; }
.drawflow .connection .main-path:hover, .drawflow .connection .main-path.selected { stroke: var(--green) !important; }
.drawflow-delete { background: var(--red) !important; border: 0 !important; }
.nd { padding: 12px; font-size: 12px; }
.nd .hd { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.nd .hd b { font-size: 13px; }
.nd .hd .ic { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; font-size: 13px; }
.nd .hd small { display: block; color: var(--muted); font-size: 10px; font-weight: 500; }
.nd label { font-size: 11px; margin: 8px 0 4px; }
.nd input, .nd select, .nd textarea { font-size: 12px; padding: 7px 9px; border-radius: 7px; }
.nd textarea { min-height: 60px; }
.nd .vars { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.nd .vars span { font-size: 10px; color: #9fd97a; background: #0f1d0a; border: 1px solid #23381a; border-radius: 5px; padding: 2px 5px; cursor: pointer; }
.nd .outs { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.nd .outs span { font-size: 10px; color: var(--muted); }
.nd .help { color: var(--muted); font-size: 11px; line-height: 1.4; }
.nd .file { display: flex; gap: 6px; }
.nd .file label.up { margin: 0; flex: none; background: #fff; color: #111; border-radius: 7px; padding: 7px 9px; cursor: pointer; font-weight: 700; }
.funnel { position: absolute; top: -22px; left: 0; font-size: 10px; font-weight: 800; color: #061200; background: var(--green); padding: 2px 7px; border-radius: 6px; }

@media (max-width: 900px) {
  .layout, .layout.collapsed { grid-template-columns: 58px 1fr; }
  .layout .sub { display: none; }
  .side .nav-item span, .logo span { display: none; }
  .two { grid-template-columns: 1fr; }
  .disp { grid-template-columns: 1fr; }
  .mobile-sub { display: flex !important; }
}
.mobile-sub { display: none; gap: 6px; overflow-x: auto; margin-bottom: 14px; }
