/* =========================================================================
   Ads Assistente: visual do painel
   Base (cores, tipografia), estrutura (menu lateral + cabeçalho), componentes
   e, depois, o que é de cada tela. Claro e escuro seguem o sistema.
   ========================================================================= */
:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f3f4f7;
  --surface-3: #eceef2;
  --border: #e6e8ec;
  --border-strong: #d3d7de;
  --grid: #eceef1;
  --text: #121826;
  --text-2: #4a5263;
  --text-3: #7a8192;
  --accent: #3d5bd9;
  --accent-hover: #3450c4;
  --accent-ink: #ffffff;
  --accent-soft: #eef1fd;
  --accent-text: #2f49b8;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #12a150;
  --warning: #f2a516;
  --serious: #ec835a;
  --critical: #d63e3e;
  --neutral: #8c919c;
  --good-text: #0b7a3b;
  --bad-text: #b42f2f;
  --warn-bg: #fff8e6; --warn-border: #f6dd9c; --warn-text: #7a5300;
  --err-bg: #fdf1f1; --err-border: #f3c4c4; --err-text: #8f2323;
  --info-bg: #eef1fd; --info-border: #cdd6f8; --info-text: #253d9e;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar: 248px;
  --sticky-top: 92px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0d0f13;
    --surface: #15181e;
    --surface-2: #1b1f26;
    --surface-3: #232831;
    --border: #262b34;
    --border-strong: #353b47;
    --grid: #242932;
    --text: #eceef3;
    --text-2: #a9b0be;
    --text-3: #7f8797;
    --accent: #6c86f5;
    --accent-hover: #7d94f7;
    --accent-ink: #0d0f13;
    --accent-soft: rgba(108, 134, 245, .14);
    --accent-text: #9db0fa;
    --series-1: #3987e5;
    --series-2: #d95926;
    --good-text: #4cc77a;
    --bad-text: #f08080;
    --warn-bg: rgba(242, 165, 22, .1); --warn-border: rgba(242, 165, 22, .3); --warn-text: #f3c56b;
    --err-bg: rgba(214, 62, 62, .12); --err-border: rgba(214, 62, 62, .35); --err-text: #f39b9b;
    --info-bg: rgba(108, 134, 245, .12); --info-border: rgba(108, 134, 245, .3); --info-text: #b3c2fb;
    --shadow-sm: none;
    --shadow: none;
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.4rem; font-weight: 650; }
h2 { font-size: 1.02rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 600; }
p { margin: .4rem 0; }
.muted { color: var(--text-2); }
.small { font-size: .84rem; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
svg { flex: none; }

/* ---------- Estrutura: menu lateral ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 40;
  display: flex; flex-direction: column; gap: 1rem;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 1rem .75rem; overflow-y: auto;
}
.sb-brand { display: flex; align-items: center; gap: .55rem; padding: .25rem .4rem; font-weight: 700; font-size: 1rem; letter-spacing: -.01em; }
.sb-mark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #7a5af0); color: #fff; font-size: .9rem; font-weight: 800;
}
.sb-name { flex: 1; min-width: 0; }
.sb-account { display: grid; gap: .3rem; padding: 0 .4rem; }
.sb-label, .nav-title { font-size: .7rem; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); }
.sb-account select { width: 100%; font-weight: 600; }

nav.tabs { display: grid; gap: 1.1rem; flex: 1; align-content: start; }
.nav-group { display: grid; gap: 2px; }
.nav-title { padding: 0 .6rem .3rem; }
nav.tabs a {
  display: flex; align-items: center; gap: .65rem; padding: .45rem .6rem; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-weight: 500;
}
nav.tabs a svg, .sb-foot svg, .menu-btn svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
nav.tabs a:hover { background: var(--surface-2); color: var(--text); }
nav.tabs a.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.sb-foot { border-top: 1px solid var(--border); padding-top: .75rem; }
.sb-foot button { width: 100%; justify-content: flex-start; color: var(--text-2); }

/* ---------- Estrutura: cabeçalho da página ---------- */
.main-col { margin-left: var(--sidebar); min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem;
  padding: .9rem 32px; min-height: 72px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.menu-btn { display: none; }
.page-head { flex: 1; min-width: 180px; }
.crumb { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); }
.page-head h1 { margin: 0; }
.controls { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.period { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.page-sub { max-width: 1240px; padding: 1rem 32px 0; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1rem; align-items: baseline; }
.page-desc { margin: 0; color: var(--text-2); max-width: 760px; }
.sync-info { font-size: .78rem; color: var(--text-3); }
main { max-width: 1240px; padding: 1.25rem 32px 3rem; }
section.tab > * + * { margin-top: 1.25rem; }
.sb-backdrop { display: none; }

@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sb-backdrop { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(10, 12, 16, .4); }
  .main-col { margin-left: 0; }
  .menu-btn { display: inline-flex; padding: .4rem; }
  .topbar { padding: .7rem 16px; min-height: 60px; }
  .page-sub { padding: .85rem 16px 0; }
  main { padding: 1rem 16px 2.5rem; }
  .controls { width: 100%; }
}

/* ---------- Componentes ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow);
}
.panel-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem;
  margin: 0 0 1rem; padding-bottom: .85rem; border-bottom: 1px solid var(--border);
}
.panel-head h2, .panel-head h3 { margin: 0; }
.panel > h2:first-child, .panel > h3:first-child { margin-bottom: .75rem; }
details.panel > summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: baseline; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::before { content: "›"; display: inline-block; transition: transform .15s; color: var(--text-3); font-weight: 700; width: .8rem; }
details.panel[open] > summary::before { transform: rotate(90deg); }
details > summary { cursor: pointer; }

button, .btn, select, input, textarea { font: inherit; color: inherit; }
button, .btn {
  display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: .42rem .85rem; border-radius: var(--radius-sm); cursor: pointer; text-decoration: none;
  min-height: 36px; font-weight: 500; box-shadow: var(--shadow-sm);
  transition: background .12s, border-color .12s, color .12s;
}
button:hover, .btn:hover { background: var(--surface-2); }
button.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600;
}
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { color: var(--bad-text); }
button.danger:hover { background: var(--err-bg); border-color: var(--err-border); }
button.link, button.ghost { border-color: transparent; background: none; box-shadow: none; }
button.link { color: var(--accent-text); padding: .2rem .35rem; min-height: auto; }
button.link:hover { background: var(--accent-soft); }
button.link.danger { color: var(--bad-text); }
button.link.danger:hover { background: var(--err-bg); border-color: transparent; }
button.ghost:hover { background: var(--surface-2); }
button:disabled { opacity: .5; cursor: default; }
select, input, textarea {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--radius-sm);
  padding: .42rem .65rem; min-height: 36px; max-width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { width: 100%; min-height: 80px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=file] { border: none; padding: 0; min-height: auto; box-shadow: none; }
input[type=color] { padding: .15rem; }

.segmented { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-3); border-radius: 10px; }
.segmented button {
  border: none; background: transparent; box-shadow: none; border-radius: 7px;
  min-height: 30px; padding: .25rem .75rem; color: var(--text-2); font-weight: 500;
}
.segmented button:hover { background: color-mix(in srgb, var(--surface) 60%, transparent); color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }
.range-form { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.range-form.hidden { display: none; }
.range-form label { display: flex; gap: .3rem; align-items: center; font-size: .84rem; color: var(--text-2); }
.range-form input { min-height: 32px; padding: .2rem .45rem; }

.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .08rem .5rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); font-size: .74rem; font-weight: 600; white-space: nowrap; color: var(--text-2);
}
.badge-accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); letter-spacing: .04em; }
.status { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; font-weight: 600; white-space: nowrap; }
.status .ic {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  font-size: .7rem; color: #fff; font-weight: 700; line-height: 1;
}
.st-vencedor .ic { background: var(--good); }
.st-ok .ic { background: var(--neutral); }
.st-atencao .ic { background: var(--warning); color: #3a2a00; }
.st-critico .ic { background: var(--critical); }
.st-parado .ic { background: transparent; border: 1.5px solid var(--neutral); color: var(--neutral); }
.st-info .ic { background: var(--neutral); }

.notice {
  border: 1px solid var(--warn-border); background: var(--warn-bg); color: var(--warn-text);
  padding: .65rem .85rem; border-radius: var(--radius-sm); font-size: .88rem;
}
.notice a { color: inherit; font-weight: 600; }
.notice.error { border-color: var(--err-border); background: var(--err-bg); color: var(--err-text); }
.notice.info { border-color: var(--info-border); background: var(--info-bg); color: var(--info-text); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: var(--text); color: var(--bg); padding: .65rem 1rem; border-radius: 10px; max-width: calc(100% - 32px);
  box-shadow: var(--shadow-lg); font-size: .88rem;
}
.toast.error { background: var(--critical); color: #fff; }

.empty { text-align: center; color: var(--text-3); padding: 2.25rem 1rem; }
.panel.empty { border-style: dashed; box-shadow: none; background: transparent; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Subseções: fieldset vira um bloco com título pequeno em caixa alta. */
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1rem .4rem; margin: 0 0 1rem; background: var(--surface); min-width: 0; }
legend {
  font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3);
  padding: 0 .4rem; margin-left: -.4rem;
}
.field { display: grid; gap: .3rem; margin-bottom: .85rem; }
.field label { font-size: .84rem; font-weight: 550; color: var(--text); }
.field .hint { font-size: .78rem; color: var(--text-3); }
.field input, .field select { width: 100%; }
.row-2 { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .row-2 { grid-template-columns: 1fr 1fr; } }
.row-3 { display: grid; gap: 0 1rem; grid-template-columns: 1fr 1fr; max-width: 440px; }
label.check { display: inline-flex; align-items: center; gap: .45rem; min-height: 36px; cursor: pointer; }
label.check input, .write-toggle input, .step-check input { width: 18px; height: 18px; min-height: 0; padding: 0; flex: none; accent-color: var(--accent); }

/* ---------- Visão geral ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.kpi .label { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.kpi .value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: .25rem 0 .15rem; letter-spacing: -.02em; }
.kpi .delta { font-size: .78rem; color: var(--text-3); }
.delta .up-good, .delta .down-good { color: var(--good-text); font-weight: 600; }
.delta .up-bad, .delta .down-bad { color: var(--bad-text); font-weight: 600; }
.delta .flat { color: var(--text-2); font-weight: 600; }

.charts { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 860px) { .charts { grid-template-columns: 1fr 1fr; } }
.chart-box { position: relative; }
.chart-box svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-box .axis text { fill: var(--text-3); font-size: 11px; }
.chart-box .grid line { stroke: var(--grid); stroke-width: 1; }
.chart-box .baseline { stroke: var(--border-strong); stroke-width: 1; }
.chart-box .bar { transition: opacity .1s; pointer-events: none; }
.chart-box .hit { fill: transparent; cursor: default; }
.chart-box .hit:hover + .bar, .chart-box .bar.hover { opacity: .75; }
.chart-tip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .45rem .65rem; font-size: .8rem; box-shadow: var(--shadow-lg);
  white-space: nowrap; z-index: 5; transform: translate(-50%, -100%);
}
.chart-tip .k { color: var(--text-2); }
.chart-tip .swatch { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: .3rem; }
details.table-view { margin-top: .6rem; font-size: .84rem; }
details.table-view summary { color: var(--text-2); }

.alerts { display: grid; gap: .6rem; }
.alert { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem .95rem; background: var(--surface); }
.alert .head { display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; }
.alert .title { font-weight: 600; }
.alert .item { color: var(--text-3); font-size: .84rem; }
.alert p { margin: .35rem 0 0; }
.alert .action { font-size: .88rem; color: var(--text-2); background: var(--surface-2); border-radius: 6px; padding: .45rem .6rem; margin-top: .5rem; }
.alert .action strong { color: var(--text); }
.status-summary { display: flex; flex-wrap: wrap; gap: .5rem 1rem; }

/* ---------- Anúncios ---------- */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
th, td { padding: .6rem .75rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
th {
  background: var(--surface-2); font-weight: 650; white-space: nowrap; position: sticky; top: 0;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3);
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent-text); }
th .arrow { font-size: .7rem; color: var(--text-3); }
tbody tr.row { cursor: pointer; }
tbody tr.row:hover { background: var(--surface-2); }
td.name { min-width: 220px; font-weight: 500; }
td.name .sub { color: var(--text-3); font-size: .78rem; font-weight: 400; }
tr.detail td { background: var(--bg); }
.detail-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 860px) { .detail-grid { grid-template-columns: 1.2fr 1fr; } }
.creative { display: flex; gap: .75rem; }
.creative img, .creative .thumb { width: 72px; height: 72px; border-radius: var(--radius-sm); object-fit: cover; flex: none; background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); font-size: .7rem; }
.creative .body { white-space: pre-wrap; }

/* ---------- Contas ---------- */
.accounts-layout { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .accounts-layout { grid-template-columns: 250px 1fr; align-items: start; } .accounts-layout > :first-child { position: sticky; top: var(--sticky-top); } }
.account-list { display: grid; gap: 2px; }
.account-list button { justify-content: flex-start; text-align: left; width: 100%; border-color: transparent; box-shadow: none; background: none; color: var(--text-2); }
.account-list button:hover { background: var(--surface-2); color: var(--text); }
.account-list button.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.secret-row { display: flex; gap: .4rem; }
.secret-row input { flex: 1; min-width: 0; }
.list-editor { display: grid; gap: .5rem; }
.list-editor .entry { display: grid; gap: .4rem; grid-template-columns: 1fr; border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-sm); padding: .55rem; }
@media (min-width: 640px) { .list-editor .entry { grid-template-columns: 1fr 1fr 1fr auto; align-items: center; } }
.form-actions {
  display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between; position: sticky; bottom: 0; z-index: 5;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px);
  padding: .75rem 0; margin-top: .5rem; border-top: 1px solid var(--border);
}

/* ---------- IA: chat, sugestões, concorrentes ---------- */
.chat-panel { display: grid; gap: .85rem; }
.chat-list { display: flex; flex-direction: column; gap: .7rem; max-height: 62vh; min-height: 220px; overflow-y: auto; padding: .25rem .1rem; }
.msg { max-width: 85%; border-radius: 14px; padding: .65rem .85rem; border: 1px solid var(--border); overflow-wrap: anywhere; }
.msg-user { align-self: flex-end; background: var(--accent-soft); border-color: transparent; border-bottom-right-radius: 4px; }
.msg-ai { align-self: flex-start; background: var(--surface-2); border-color: transparent; border-bottom-left-radius: 4px; }
.msg-body p { margin: 0 0 .5rem; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body ul, .msg-body ol, .analysis ul, .analysis ol { margin: .2rem 0 .5rem; padding-left: 1.3rem; }
.msg-body .md-h, .analysis .md-h { font-weight: 700; margin-top: .6rem; }
.msg-meta { font-size: .74rem; color: var(--text-3); margin-top: .3rem; }
.msg-images { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .4rem; }
.msg-images img { width: 96px; height: 96px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; }
.perf-dot { width: .5rem; height: .5rem; border-radius: 50%; flex: none; }
.perf-forte { background: var(--good); } .perf-bom { background: var(--series-1); } .perf-medio { background: var(--neutral); }
.perf-teste { background: var(--warning); } .perf-fraco { background: var(--critical); }
.note-badges { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .3rem; }
.comp-toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.page-picker { border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius); padding: .75rem; margin-bottom: .9rem; display: grid; gap: .55rem; }
.page-search { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.page-search input { flex: 1 1 260px; min-width: 0; }
.page-results { display: grid; gap: .4rem; }
.page-option { display: flex; gap: .65rem; align-items: center; padding: .35rem .4rem; border-radius: var(--radius-sm); }
.page-option:hover { background: var(--surface); }
.page-option img, .page-noimg { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none; background: var(--surface-3); }
.page-info { flex: 1; min-width: 0; }
.note-video { display: block; width: 100%; max-width: 320px; max-height: 480px; border-radius: var(--radius-sm); background: #000; margin-bottom: .4rem; }
.chat-form { display: grid; gap: .55rem; }
.chat-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.chat-actions .primary, .chat-actions [type=submit]:last-child { margin-left: auto; }
.file-btn { cursor: pointer; display: inline-flex; align-items: center; }
.thumbs { display: flex; flex-wrap: wrap; gap: .4rem; }
.thumbs:empty { display: none; }
.thumb-pick { position: relative; }
.thumb-pick img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); display: block; }
.thumb-pick button { position: absolute; top: -8px; right: -8px; min-height: 0; width: 22px; height: 22px; padding: 0; border-radius: 50%; line-height: 1; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; margin-top: .75rem; }
.chips button { font-size: .84rem; border-radius: 999px; }
.sug-grid { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.sug-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; display: grid; gap: .6rem; align-content: start; background: var(--surface-2); }
.sug-card h3 { margin: 0; }
.sug-label { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); display: flex; justify-content: space-between; align-items: center; }
.sug-label button { text-transform: none; letter-spacing: 0; }
.sug-text { white-space: pre-wrap; font-size: .92rem; }
.sug-list { margin: .2rem 0 0; padding-left: 1.1rem; font-size: .9rem; }
.sug-list li { display: list-item; }
.bad { color: var(--bad-text); font-weight: 600; }
.notes { display: grid; gap: .6rem; margin-bottom: .75rem; }
.note { border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-sm); padding: .6rem .75rem; }
.note-text { white-space: pre-wrap; margin-bottom: .3rem; }
.note-form { display: grid; gap: .55rem; }
.analysis { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: .85rem; }
.analysis p { margin: 0 0 .5rem; }

/* ---------- WhatsApp ---------- */
.wa-layout { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .wa-layout { grid-template-columns: 1fr 1fr; align-items: start; } }
.wa-status { display: flex; align-items: center; gap: .45rem; margin-bottom: .6rem; flex-wrap: wrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--neutral); }
.dot-connected { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
.dot-qr, .dot-connecting { background: var(--warning); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 22%, transparent); }
.qr { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin: .5rem 0; }
.qr img { background: #fff; padding: 8px; border-radius: var(--radius-sm); max-width: 100%; height: auto; border: 1px solid var(--border); }
.qr ol { margin: 0; padding-left: 1.2rem; max-width: 320px; }
.group-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.group-list li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding: .45rem 0; }
.group-list li:last-child { border-bottom: none; }
.wa-preview { white-space: normal; background: var(--surface-2); border-radius: var(--radius); padding: .85rem 1rem; font-size: .9rem; line-height: 1.5; max-width: 560px; overflow-wrap: anywhere; border: 1px solid var(--border); }

/* ---------- Ajuda ---------- */
.help-layout { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .help-layout { grid-template-columns: 270px 1fr; align-items: start; } .help-nav { position: sticky; top: var(--sticky-top); } }
.help-nav { display: grid; gap: 2px; }
.help-nav a { display: flex; justify-content: space-between; gap: .5rem; padding: .45rem .6rem; border-radius: var(--radius-sm); text-decoration: none; color: var(--text-2); }
.help-nav a:hover { background: var(--surface-2); color: var(--text); }
.help-nav a.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.progress { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; margin-bottom: .75rem; }
.progress span { display: block; height: 100%; background: var(--good); transition: width .2s; }
.steps { list-style: none; margin: 1rem 0; padding: 0; display: grid; gap: .75rem; }
.step { display: grid; grid-template-columns: auto 1fr; gap: .85rem; border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem; background: var(--surface); }
.step.done { opacity: .65; }
.step.done h3 { text-decoration: line-through; }
.step-check { display: grid; justify-items: center; align-content: start; gap: .4rem; cursor: pointer; }
.step-n { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; font-size: .82rem; }
.step.done .step-n { background: var(--good); color: #fff; }
.step-body { min-width: 0; }
.step-body p, .step-body ul, .step-body ol { margin: .3rem 0 .5rem; }
.step-body ul, .step-body ol { padding-left: 1.2rem; }
.step-body .notice { margin-top: .5rem; }
.step-body pre, .wa-preview pre { background: var(--surface-3); padding: .5rem .7rem; border-radius: 6px; overflow-x: auto; font-size: .84rem; }
.step-body code { overflow-wrap: anywhere; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; color: var(--text); }

/* ---------- Edição na Meta e referências ---------- */
.edit-box { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: .85rem; display: grid; gap: .55rem; }
.edit-box h3 { margin: 0; }
.edit-form { display: grid; gap: .55rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem; }
.edit-form input[type=number] { width: 9rem; margin-left: .3rem; }
.write-toggle label { display: flex; gap: .5rem; align-items: flex-start; font-weight: 600; }
.write-toggle input { margin-top: .2rem; }
.refs { display: grid; gap: .5rem; }
.ref { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: center; border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-sm); padding: .45rem .55rem; }
.ref-frames { display: flex; gap: 2px; }
.ref-frames img { width: 40px; height: 56px; object-fit: cover; border-radius: 3px; display: block; }
.ref-info { display: grid; gap: .3rem; min-width: 0; }
.ref-info input { width: 100%; }
@media (max-width: 640px) { .ref { grid-template-columns: 1fr auto; } .ref-frames { grid-column: 1 / -1; } }
.ref-strip { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.ref-strip figure { margin: 0; width: 72px; }
.ref-strip img { width: 72px; height: 96px; object-fit: cover; border-radius: 6px; display: block; }
.ref-strip figcaption { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.create-form { display: grid; gap: .45rem; border-top: 1px solid var(--border); padding-top: .7rem; }
.create-form select, .create-form input:not([type=file]) { width: 100%; }

/* ---------- Vídeos ---------- */
@font-face { font-family: "Montserrat AA"; src: url("/fonts/Montserrat-ExtraBold.ttf") format("truetype"); font-weight: 800; font-display: swap; }
.drop {
  display: grid; gap: .5rem; place-items: center; text-align: center; border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius); padding: 1.75rem 1rem; cursor: pointer; background: var(--surface-2); transition: border-color .12s, background .12s;
}
.drop.over, .drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.drop .progress { width: min(360px, 100%); }
.video-grid { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.video-card { cursor: pointer; display: grid; gap: .35rem; align-content: start; transition: border-color .12s, box-shadow .12s; }
.video-card:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); }
.video-card img, .video-card .thumb { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius-sm); background: #000; display: grid; place-items: center; color: var(--text-3); }
.video-editor { display: grid; gap: 1.25rem; grid-template-columns: 1fr; margin-bottom: 1rem; }
@media (min-width: 980px) { .video-editor { grid-template-columns: minmax(280px, 400px) 1fr; align-items: start; } .v-left { position: sticky; top: var(--sticky-top); } }
.v-name { min-width: 0; flex: 1; font-weight: 600; }
.vstage-wrap { display: grid; gap: .45rem; justify-items: center; }
.vstage { --ratio: 1; position: relative; width: min(100%, calc(70vh * var(--ratio))); aspect-ratio: var(--ratio); background: #000; border-radius: var(--radius); overflow: hidden; }
.vstage video { position: absolute; inset: 0; width: 100%; height: 100%; }
.vcap, .vov { position: absolute; left: 7%; right: 7%; text-align: center; font-family: "Montserrat AA", var(--font); font-weight: 800; line-height: 1.25; pointer-events: none; color: #fff; overflow-wrap: anywhere; }
.vcap { bottom: 14%; text-shadow: 0 0 3px #000, 0 0 3px #000, 0 2px 4px #000; }
.vcap[data-pos="middle"] { bottom: auto; top: 50%; transform: translateY(-50%); }
.vcap[data-pos="top"] { bottom: auto; top: 10%; }
.vcap[data-color="amarelo"] { color: #ffe100; }
.vcap span, .vov span { padding: .04em .3em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.vcap.boxed { text-shadow: none; }
.vcap.boxed span { background: rgba(0, 0, 0, .55); }
.vov span { background: #2a78d6; }
.vov { top: 10%; }
.vov[data-pos="bottom"] { top: auto; bottom: 14%; }
.vov[data-pos="bottom"][data-stack="1"] { bottom: 26%; }
.vov[data-pos="top"][data-stack="1"] { top: 22%; }
.vlogo { position: absolute; height: auto; pointer-events: none; }
.vlogo[data-pos="top-right"] { top: 4%; right: 4%; }
.vlogo[data-pos="top-left"] { top: 4%; left: 4%; }
.vlogo[data-pos="bottom-right"] { bottom: 4%; right: 4%; }
.vlogo[data-pos="bottom-left"] { bottom: 4%; left: 4%; }
.cap-style { max-width: none; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); align-items: end; margin-top: .5rem; }
.cap-list { display: grid; gap: .3rem; max-height: 340px; overflow-y: auto; }
.cap-row { display: grid; grid-template-columns: 70px 70px 70px 1fr auto; gap: .3rem; align-items: center; padding: .15rem .25rem; border-radius: 6px; }
.cap-row.active { background: var(--accent-soft); }
.cap-row input { min-width: 0; width: 100%; }
@media (max-width: 640px) { .cap-row { grid-template-columns: 1fr 1fr auto; } .cap-row [data-cap="text"] { grid-column: 1 / -1; order: 5; } .cap-row [data-seek] { grid-column: 1 / -1; justify-self: start; } }
.vstage video { transition: transform .08s; }
.vcut { position: absolute; top: 8px; left: 8px; background: rgba(0, 0, 0, .7); color: #fff; font-size: .75rem; padding: .15rem .45rem; border-radius: 4px; pointer-events: none; }
.vcap b { font-weight: 800; display: inline-block; transform: scale(1.1); }
.auto-box { border-color: var(--info-border); background: var(--surface); box-shadow: inset 3px 0 0 var(--accent); }
.ref-fig { position: relative; margin: 0; width: 96px; }
.ref-fig img { width: 96px; height: 128px; object-fit: cover; border-radius: 6px; display: block; background: #000; }
.ref-fig button { position: absolute; top: -8px; right: -8px; min-height: 0; width: 22px; height: 22px; padding: 0; border-radius: 50%; }
.ref-add { height: 128px; width: 96px; justify-content: center; text-align: center; font-size: .8rem; border-style: dashed; }
.seg-list, .ov-list { display: grid; gap: .3rem; }
.seg-row { display: grid; grid-template-columns: 52px 76px 76px 50px auto; gap: .3rem; align-items: center; padding: .15rem .25rem; border-radius: 6px; }
.seg-row.active { background: var(--accent-soft); }
.seg-row input { min-width: 0; width: 100%; }
.seg-btns { display: inline-flex; gap: .2rem; justify-self: end; }
.seg-btns button { min-height: 0; padding: .15rem .45rem; }
.ov-row { display: grid; grid-template-columns: 1fr 110px 70px 70px auto; gap: .3rem; align-items: center; }
.ov-row input, .ov-row select { min-width: 0; width: 100%; }
@media (max-width: 640px) { .seg-row { grid-template-columns: 1fr 1fr 1fr; } .seg-btns { grid-column: 1 / -1; } .ov-row { grid-template-columns: 1fr 1fr; } .ov-row [data-ov="text"] { grid-column: 1 / -1; } }
.vctrl { display: flex; align-items: center; gap: .5rem; width: min(100%, calc(70vh * var(--ratio, .5625))); }
.vctrl button { min-height: 32px; padding: .2rem .7rem; }
.vctrl input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent); }
.vcliptag { position: absolute; top: 8px; right: 8px; background: rgba(0, 0, 0, .6); color: #fff; font-size: .72rem; padding: .1rem .4rem; border-radius: 4px; pointer-events: none; }
.vstage .vlogo, .vstage .vcap, .vstage .vov, .vstage .vcut, .vstage .vcliptag { z-index: 2; }
.clip-strip { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .4rem; }
.clip-fig img, .clip-fig .thumb { width: 96px; height: 72px; }
.clip-fig figcaption { white-space: normal; }
.seg-row.with-clip { grid-template-columns: 52px 62px 76px 76px 50px auto; }
.choice h2 { margin-bottom: .2rem; }
.choice-grid { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin: .85rem 0; }
.choice-grid button { display: grid; gap: .3rem; text-align: left; justify-items: start; justify-content: start; padding: 1rem 1.1rem; min-height: 0; border-radius: var(--radius); }
.choice-grid button:hover { border-color: var(--accent); background: var(--accent-soft); }
.batch-card { cursor: pointer; }
.batch-card:hover { border-color: var(--accent); }
.batch-thumbs { display: flex; gap: .4rem; overflow: hidden; }
.batch-thumbs img { width: 96px; height: 54px; object-fit: cover; border-radius: 6px; background: #000; }
@media (max-width: 640px) { .seg-row.with-clip { grid-template-columns: 1fr 1fr 1fr; } }
.v-final { display: grid; gap: .35rem; margin: .75rem 0; justify-items: start; }
.v-final video { max-width: min(100%, 360px); max-height: 60vh; border-radius: var(--radius-sm); background: #000; }

/* Vídeo animado por IA */
.motion-open {
  display: grid; gap: .3rem; text-align: left; justify-items: start; justify-content: start; width: 100%; margin-top: .85rem;
  padding: 1rem 1.1rem; min-height: 0; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent-soft), transparent 70%); border-color: var(--info-border);
}
.motion-open:hover { border-color: var(--accent); background: var(--accent-soft); }
.motion-form { margin-top: .85rem; padding: 1.1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.motion-form h3 { margin-top: 0; }
.motion-form .row-fields { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.motion-form textarea { width: 100%; }
.voice-fields { margin: .4rem 0 .6rem; padding: .85rem 1rem .2rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.voice-fields .row-fields { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.voice-fields .voice-play { align-content: end; }
.voice-fields textarea { width: 100%; }
.voice-fields [data-voice-error]:empty { display: none; }
.cost-note { margin: .6rem 0; padding: .5rem .75rem; border-radius: var(--radius-sm); background: var(--info-bg); border: 1px solid var(--info-border); color: var(--info-text); }

/* ---------- Instagram ---------- */
.ig-grid { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.ig-card { display: grid; gap: .35rem; align-content: start; position: relative; margin: 0; }
.ig-card.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ig-card img, .ig-card .thumb { width: 100%; aspect-ratio: 9 / 16; max-height: 260px; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-2); }
.ig-pick { display: flex; align-items: center; gap: .3rem; }
.ig-cap { overflow-wrap: anywhere; }
.ig-metrics { display: flex; flex-wrap: wrap; gap: .25rem .6rem; }
.good-text { color: var(--good-text); }
.ig-results { display: grid; gap: .85rem; }
.ig-result { display: grid; grid-template-columns: 96px 1fr; gap: .85rem; padding: .9rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.ig-result.win { border-color: var(--good); box-shadow: inset 3px 0 0 var(--good); }
.ig-result img, .ig-result .thumb { width: 96px; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.ig-result p { margin: .3rem 0; }
.ig-result ul { margin: .2rem 0 .3rem 1.1rem; padding: 0; }
.ig-adtext { margin: .45rem 0; padding: .5rem .75rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
@media (max-width: 560px) { .ig-result { grid-template-columns: 1fr; } .ig-result img { width: 120px; } }

/* ---------- Posts (imagem estática) ---------- */
.brand-form { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin-top: 1rem; }
.brand-form .brand-contact, .brand-form .field:nth-last-child(2), .brand-form > .chat-actions { grid-column: 1 / -1; }
.brand-form input[type=color] { height: 2.4rem; padding: .15rem; cursor: pointer; }
.brand-logo { height: 48px; max-width: 160px; object-fit: contain; background: repeating-conic-gradient(var(--surface-3) 0 25%, transparent 0 50%) 0 0 / 12px 12px; border-radius: 6px; }
.post-opts { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.post-photo-thumb { height: 48px; width: 64px; object-fit: cover; border-radius: 6px; }
.post-editor { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.post-preview { position: sticky; top: var(--sticky-top); display: grid; gap: .35rem; justify-items: center; }
.post-preview img { width: 100%; max-height: 70vh; object-fit: contain; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); }
.post-grid { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.post-card { display: grid; gap: .4rem; align-content: start; padding: .7rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); transition: box-shadow .12s, border-color .12s; }
.post-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.post-card img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: var(--radius-sm); background: var(--surface-2); display: block; }
@media (max-width: 760px) { .post-editor { grid-template-columns: 1fr; } .post-preview { position: static; } }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }
.login-box { width: 100%; max-width: 380px; padding: 1.75rem; box-shadow: var(--shadow-lg); }
.login-box h1 { display: flex; align-items: center; gap: .6rem; font-size: 1.25rem; margin-bottom: .25rem; }
.login-box form { display: grid; gap: .75rem; margin-top: 1rem; }
.login-box label { font-size: .84rem; font-weight: 550; }
.login-box input { width: 100%; }

@media (max-width: 640px) {
  .topbar { position: static; }
  .kpi .value { font-size: 1.25rem; }
  .panel { padding: 1rem; }
  .segmented { overflow-x: auto; max-width: 100%; }
}
