:root {
  --bg: #15161a;
  --panel: #1f2126;
  --panel-2: #262930;
  --field: #181a1f;
  --border: #33363e;
  --border-soft: #2a2d34;
  --text: #eceef2;
  --muted: #9a9ea8;
  --faint: #6c707a;
  --accent: #c6f36c;
  --accent-ink: #15161a;
  --accent-soft: rgba(198, 243, 108, .10);
  --danger: #ff6b6b;
  --warn: #ffc56b;
  --ok: #7be495;
  --radius: 14px;
  --radius-sm: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  min-height: 100vh;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

/* ---------- topo ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 24px;
  background: rgba(21, 22, 26, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-soft);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; letter-spacing: .2px; white-space: nowrap; }
.brand b { color: var(--accent); font-weight: 700; }
.brand.big { font-size: 22px; justify-content: center; margin-bottom: 8px; }
.logo {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 800;
}
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: none; cursor: pointer; white-space: nowrap;
  padding: 8px 14px; border-radius: 9px; color: var(--muted);
}
.tab:hover { color: var(--text); background: var(--panel); }
.tab.active { color: var(--text); background: var(--panel-2); }
.tab .badge { margin-left: 6px; }
.top-right { display: flex; align-items: center; gap: 10px; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 99px; font-size: 12.5px;
  border: 1px solid var(--border); color: var(--muted); white-space: nowrap;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.pill.on { color: var(--ok); border-color: rgba(123, 228, 149, .35); }
.pill.on::before { background: var(--ok); box-shadow: 0 0 0 3px rgba(123, 228, 149, .15); }
.pill.off { color: var(--danger); border-color: rgba(255, 107, 107, .35); }
.pill.off::before { background: var(--danger); }
.pill.paused { color: var(--warn); border-color: rgba(255, 197, 107, .35); }
.pill.paused::before { background: var(--warn); }

.badge {
  display: inline-block; min-width: 20px; padding: 1px 7px; border-radius: 99px;
  background: var(--accent); color: var(--accent-ink); font-size: 11.5px; font-weight: 700; text-align: center;
}
.badge.muted { background: var(--panel-2); color: var(--muted); }

/* ---------- layout ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 26px 24px 120px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 650; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.stack { display: grid; gap: 18px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.error-text { color: var(--danger); margin: 6px 0 0; }

/* ---------- cartoes ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 24px 28px;
}
.card-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 20px; }
.card-head .num {
  flex: none; width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center;
  border: 1px solid var(--border); color: var(--accent); font-weight: 700; font-size: 13px;
}
.card-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.card-head p { margin: 3px 0 0; color: var(--muted); }
.card-head .side { margin-left: auto; }

/* ---------- blocos selecionaveis ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.tiles.wide { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.tile {
  position: relative; text-align: center; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border-soft); border-radius: 12px;
  padding: 20px 12px 16px; min-height: 130px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  transition: border-color .15s, background .15s;
}
.tile:hover:not(.disabled) { border-color: var(--border); }
.tile.selected { border-color: var(--accent); background: var(--accent-soft); }
.tile.disabled { cursor: default; opacity: .45; }
.tile .t-title { font-weight: 650; }
.tile .t-sub { color: var(--muted); font-size: 12.5px; }
.tile .check {
  position: absolute; top: 10px; right: 10px; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--accent); display: grid; place-items: center;
}
.tile.selected .check { background: var(--accent); }
.tile.selected .check::after {
  content: ""; width: 5px; height: 9px; margin-top: -2px;
  border: solid var(--accent-ink); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.tile.disabled .check { display: none; }
.tiles.nets { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tiles.nets .tile { min-height: 124px; padding: 16px 8px 12px; }
.tiles.dests { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tile.option { text-align: left; align-items: center; justify-content: flex-start; flex-direction: row; gap: 14px; min-height: 0; padding: 18px 46px 18px 18px; }
.tile.option .t-icon { flex: none; font-size: 20px; line-height: 1.2; color: var(--accent); }
.tile.option .t-body { display: grid; gap: 2px; }
.tile.add { border-style: dashed; color: var(--muted); }
.tile.add .plus { font-size: 26px; line-height: 1; color: var(--accent); }

.net-icon {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 8px;
  background: #34373f; font-weight: 800; font-size: 18px; color: #fff;
}
.net-icon.instagram { background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fd5949 45%, #d6249f 60%, #285AEB 90%); }
.net-icon.youtube { background: #ff0033; }
.avatar {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 10px;
  background: linear-gradient(135deg, #3a3e48, #22252b); border: 1px solid var(--border);
  font-size: 22px; font-weight: 700; color: var(--accent);
}
.avatar.sm { width: 40px; height: 40px; font-size: 15px; margin: 0; flex: none; }

/* ---------- campos ---------- */
.fields { display: grid; grid-template-columns: 1fr 180px; gap: 16px; margin-top: 22px; }
.field { display: grid; gap: 8px; }
.field > span { color: var(--muted); }
.field .hint { color: var(--faint); font-size: 12.5px; }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; background: var(--field); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; outline: none; transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { min-height: 96px; resize: vertical; }
.with-suffix { display: flex; align-items: center; gap: 10px; }
.with-suffix input { width: 110px; }
.check-line { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.check-line input { width: 18px; height: 18px; accent-color: var(--accent); }

.segmented { display: inline-flex; background: var(--field); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.segmented button { border: 0; background: none; padding: 7px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.segmented button.on { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }

details.filters { border-top: 1px solid var(--border-soft); margin-top: 22px; padding-top: 16px; }
details.filters summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; color: var(--text); }
details.filters summary::-webkit-details-marker { display: none; }
details.filters summary::before { content: "▸"; color: var(--accent); transition: transform .15s; }
details.filters[open] summary::before { transform: rotate(90deg); }
details.filters .filter-body { display: grid; gap: 16px; margin-top: 16px; }

/* ---------- edicao: templates e filtros ---------- */
.avatar-img { object-fit: cover; padding: 0; }
.fgroup { margin-top: 16px; }
.fgroup-title { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .6px; margin-bottom: 10px; }
.filters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.ftile {
  cursor: pointer; border: 1px solid var(--border-soft); border-radius: 10px; overflow: hidden; background: var(--panel-2);
  display: flex; flex-direction: column; transition: border-color .15s;
}
.ftile:hover { border-color: var(--border); }
.ftile.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ftile img, .ftile .fdice { width: 100%; aspect-ratio: 9 / 13; object-fit: cover; display: block; background: #000; }
.ftile .fdice { display: grid; place-items: center; font-size: 34px; background: var(--field); }
.ftile span { font-size: 12px; padding: 6px 4px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ftile.selected span { color: var(--accent); }

/* ---------- botoes ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  padding: 10px 16px; border-radius: 10px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { border-color: #444852; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.full { width: 100%; }

/* ---------- barra fixa de salvar ---------- */
.savebar {
  position: sticky; bottom: 16px; z-index: 10; margin-top: 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: rgba(31, 33, 38, .96); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
.savebar .msg { color: var(--muted); }

/* ---------- estatisticas ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.stat { background: var(--panel); border: 1px solid var(--border-soft); border-radius: 12px; padding: 14px 16px; }
.stat .v { font-size: 26px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12.5px; }
.stat.hl .v { color: var(--accent); }

/* ---------- listas ---------- */
.list { display: grid; gap: 10px; }
.item {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--border-soft); border-radius: 12px; padding: 14px 16px;
}
.item.off { opacity: .55; }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item .meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.item .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip { font-size: 11.5px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.chip.accent { border-color: rgba(198, 243, 108, .4); color: var(--accent); }
.chip.danger { border-color: rgba(255, 107, 107, .4); color: var(--danger); }
.chip.warn { border-color: rgba(255, 197, 107, .4); color: var(--warn); }
.chip.ok { border-color: rgba(123, 228, 149, .4); color: var(--ok); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.err-line { color: var(--danger); font-size: 12.5px; margin-top: 4px; overflow-wrap: anywhere; }

.empty {
  text-align: center; padding: 48px 20px; color: var(--muted);
  border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }
.empty .btn { margin-top: 16px; }

/* ---------- clonagem: fluxo origem -> destino ---------- */
.source-item { align-items: flex-start; padding: 18px 18px 16px; }
.source-item .actions { align-self: center; }
.flow { display: flex; align-items: stretch; gap: 10px; flex-wrap: wrap; }
.flow-node {
  display: flex; flex-direction: column; gap: 3px; padding: 10px 16px 11px; border-radius: 12px;
  min-width: 190px; border: 1px solid transparent;
}
.flow-label { font-size: 11px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; opacity: .9; }
.flow-handle { font-size: 17px; font-weight: 800; letter-spacing: .1px; overflow-wrap: anywhere; }
.flow-net { font-size: 11.5px; opacity: .75; }
.flow-handles { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.flow-handle.warn { color: var(--warn); text-decoration: underline dotted; }

.flow-node.origin.instagram {
  background: linear-gradient(135deg, rgba(254, 218, 117, .30), rgba(250, 126, 30, .32) 30%, rgba(214, 41, 118, .38) 60%, rgba(150, 47, 191, .38));
  border-color: #e1306c; color: #ffe0ee; box-shadow: 0 0 22px rgba(225, 48, 108, .25);
}
.flow-node.origin.instagram .flow-handle { color: #fff; text-shadow: 0 0 16px rgba(255, 90, 160, .8); }
.flow-node.origin.youtube { background: rgba(255, 0, 51, .14); border-color: rgba(255, 0, 51, .55); color: #ffc2cc; }
.flow-node.origin.youtube .flow-handle { color: #ff5c78; }

.flow-node.dest {
  background: linear-gradient(135deg, rgba(198, 243, 108, .32), rgba(60, 220, 150, .26));
  border-color: var(--accent); color: #efffd6; box-shadow: 0 0 22px rgba(198, 243, 108, .22);
}
.flow-node.dest .flow-handle { color: #f4ffe0; text-shadow: 0 0 16px rgba(198, 243, 108, .85); }
.flow-node.dest.empty { background: rgba(255, 107, 107, .12); border-color: rgba(255, 107, 107, .5); }
.flow-node.dest.empty .flow-handle { color: var(--danger); text-shadow: none; }

.flow-arrow { display: flex; align-items: center; min-width: 54px; flex: 0 0 auto; position: relative; }
.flow-line {
  flex: 1; height: 4px; border-radius: 3px;
  background: linear-gradient(90deg, #ff4f9a, #ffb23d, var(--accent));
  background-size: 200% 100%; animation: flowmove 2.2s linear infinite;
}
.flow-head { color: var(--accent); font-size: 22px; margin-left: -4px; line-height: 1; }
.flow-arrow.paused .flow-line { animation: none; background: var(--border); }
.flow-arrow.paused .flow-head { color: var(--faint); }
@keyframes flowmove { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .flow-line { animation: none; } }
.source-chips { margin-top: 12px; gap: 6px; }
.item.off .flow-node { filter: saturate(.35); }

/* ---------- aprovacao ---------- */
.videos { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.vcard { background: var(--panel); border: 1px solid var(--border-soft); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.vcard video { width: 100%; aspect-ratio: 9 / 16; background: #000; display: block; object-fit: contain; }
.vcard .vbody { padding: 12px; display: grid; gap: 6px; flex: 1; }
.vcard .cap { color: var(--muted); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.vcard .vact { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 12px 12px; }

/* ---------- modal / toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: 100%; max-width: 420px; }
.modal h2 { margin: 0 0 6px; font-size: 18px; }
.modal .stack { gap: 14px; margin-top: 16px; }
.toast {
  position: fixed; left: 50%; bottom: 104px; transform: translateX(-50%) translateY(20px);
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 11px 16px;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 60; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(255, 107, 107, .5); color: #ffd0d0; }
.log { background: var(--field); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; font: 12px/1.5 Consolas, monospace; max-height: 340px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); }
.foot { text-align: center; color: var(--faint); font-size: 12px; padding: 0 16px 24px; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

/* ---------- capa (ajustes) ---------- */
.cover-block { display: flex; gap: 20px; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border-soft); flex-wrap: wrap; }
.cover-preview { width: 120px; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); background: var(--field); }
.cover-preview.empty { display: grid; place-items: center; color: var(--faint); font-size: 12.5px; }
.cover-body { flex: 1; min-width: 240px; display: grid; gap: 12px; align-content: start; }
.cover-body .field input { width: 110px; }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 16px; }

/* ---------- celular ---------- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .tabs { order: 3; flex-basis: 100%; }
  .top-right { margin-left: auto; }
  .container { padding: 18px 16px 110px; }
  .card { padding: 18px 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .fields { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .item { flex-wrap: wrap; }
  .item .actions { width: 100%; justify-content: flex-start; }
  .tiles, .tiles.nets, .tiles.dests { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .savebar { bottom: 8px; }
  .flow { flex-direction: column; }
  .flow-node { min-width: 0; }
  .flow-arrow { min-width: 0; height: 26px; justify-content: center; }
  .flow-line { display: none; }
  .flow-head { transform: rotate(90deg); margin: 0; }
}
