:root {
  --bg: #f5f6f8; --card: #ffffff; --text: #16181d; --muted: #6b7280; --line: #e4e7ec;
  --accent: #0f9d58; --accent-2: #e8f6ee; --warn: #b45309; --warn-bg: #fef3c7;
  --danger: #c0352b; --up: #0f9d58; --down: #c0352b; --chip: #eef0f3;
  --meta: #1d4ed8; --google: #b45309; --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --card: #171a21; --text: #e7e9ee; --muted: #9aa1ad; --line: #272b35;
    --accent: #34c27a; --accent-2: #133524; --warn: #f5b454; --warn-bg: #3a2c12;
    --danger: #f0776c; --up: #34c27a; --down: #f0776c; --chip: #222631;
    --meta: #7aa2ff; --google: #f5b454; --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; }
a { color: inherit; }
a:hover { color: var(--accent); }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
h2 small, .muted, small.muted { color: var(--muted); font-weight: 400; }
h2 small { font-size: 12px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 54px;
  background: var(--card); border-bottom: 1px solid var(--line); }
.logo { font-weight: 700; text-decoration: none; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-2); display: inline-block; }
.top nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.top nav a { text-decoration: none; padding: 7px 11px; border-radius: 8px; color: var(--muted); white-space: nowrap; }
.top nav a.on, .top nav a:hover { background: var(--chip); color: var(--text); }
.sair { color: var(--muted); text-decoration: none; font-size: 13px; }
.pill { background: var(--accent); color: #fff; font-size: 11px; border-radius: 10px; padding: 0 6px; font-weight: 600; }
.pill.live { background: var(--warn); }

main { max-width: 1280px; margin: 0 auto; padding: 22px 20px 60px; }
.titulo { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.titulo .sub, p.sub { margin: 4px 0 0; color: var(--muted); }
.acoes { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.acoes form { margin: 0; }

.btn { display: inline-block; border: 0; border-radius: 8px; padding: 8px 14px; background: var(--accent); color: #fff; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.07); color: #fff; }
.btn.sec { background: var(--chip); color: var(--text); }
.btn.mini { padding: 4px 9px; font-size: 12px; }
.btn.perigo { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.btn[disabled] { opacity: .5; cursor: default; }

.flash { background: var(--accent-2); border: 1px solid var(--accent); padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }
.vazio { color: var(--muted); padding: 18px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; }
.vazio.grande { padding: 30px; margin-bottom: 18px; background: var(--card); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.kpi span { color: var(--muted); font-size: 12px; display: block; }
.kpi b { font-size: 26px; letter-spacing: -.02em; }
.kpi small { margin-left: 6px; font-weight: 600; }
.kpi.destaque { border-color: var(--accent); background: linear-gradient(180deg, var(--accent-2), var(--card)); }

.painel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); min-width: 0; }
.duas { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.duas > .painel { margin-bottom: 16px; }
.mais { margin-left: auto; font-size: 12px; color: var(--accent); text-decoration: none; font-weight: 500; }

.grafico { position: relative; }
.chart { width: 100%; display: block; }
.gmax { position: absolute; right: 0; top: -22px; font-size: 11px; color: var(--muted); }
.geixo { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }
.chart rect { fill: var(--accent); opacity: .85; }
.chart rect:hover { opacity: 1; }
.chart text { fill: var(--muted); font-size: 11px; }

.tabela { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td a { text-decoration: none; }
.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.up { color: var(--up); font-weight: 600; }
.down { color: var(--down); font-weight: 600; }
.acoes-linha form { display: flex; gap: 6px; justify-content: flex-end; margin: 0; }

.badge { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--chip); color: var(--muted); font-weight: 600; vertical-align: 1px; white-space: nowrap; }
.b-monitorada { background: var(--accent-2); color: var(--accent); }
.b-descoberta, .b-nova { background: var(--warn-bg); color: var(--warn); }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--chip); color: var(--muted); text-decoration: none; white-space: nowrap; }
.tag.marca { background: var(--accent-2); color: var(--accent); font-weight: 600; }
.tag.novo { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.tag.fonte-meta { color: var(--meta); }
.tag.fonte-google { color: var(--google); }

.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; gap: 8px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.lista li:last-child { border-bottom: 0; }
.lista a { text-decoration: none; }
.lista .dir { margin-left: auto; font-size: 12px; color: var(--muted); }

.grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.ad { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.ad .midia { display: block; aspect-ratio: 4 / 3; background: var(--chip); overflow: hidden; }
.ad .midia img { width: 100%; height: 100%; object-fit: cover; display: block; }
.semimg { height: 100%; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; text-transform: lowercase; }
.ad .corpo { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.ad .tags { display: flex; gap: 5px; flex-wrap: wrap; }
.ad .quem { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad .quem small { color: var(--muted); font-weight: 400; }
.ad .quando { color: var(--muted); font-size: 12px; }
.ad .txt { margin: 2px 0; font-size: 13px; overflow-wrap: anywhere; }
.ad .reg { font-size: 11px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 5px; }
.ad .links { margin-top: auto; display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.ad .links span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad .links a { color: var(--accent); text-decoration: none; white-space: nowrap; }

.abas { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.abas a { text-decoration: none; padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.abas a.on { color: var(--text); border-color: var(--accent); font-weight: 600; }
.abas small { background: var(--chip); border-radius: 8px; padding: 0 6px; margin-left: 3px; }

.filtros { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filtros input:not([type=checkbox]), .filtros select { flex: 0 1 auto; }
.filtros input[name=q] { flex: 1 1 260px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; max-width: 100%; }
textarea { width: 100%; resize: vertical; }
.chk { display: flex; gap: 5px; align-items: center; color: var(--muted); white-space: nowrap; }

.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
.form label small { color: var(--muted); font-weight: 400; }
.form input, .form select { width: 100%; }
.form-del { margin-top: 12px; }
.nova-marca { position: relative; }
.nova-marca summary { list-style: none; }
.nova-marca summary::-webkit-details-marker { display: none; }
.nova-marca[open] .form { position: absolute; right: 0; top: 42px; width: 300px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; z-index: 4; box-shadow: 0 8px 30px rgba(0,0,0,.15); }

.ajustes { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 16px; }
.ajustes label.painel { display: flex; flex-direction: column; gap: 6px; }
.paginas { display: flex; gap: 12px; justify-content: center; align-items: center; margin-top: 18px; }

.fontes { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; margin-bottom: 16px; }
.fonte { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.fonte form { margin: 0; }
.st { font-weight: 600; }
.st-ok { color: var(--up); } .st-parcial { color: var(--warn); } .st-erro { color: var(--down); } .st-rodando, .live { color: var(--warn); }
.codigo, .log { background: var(--chip); padding: 10px 12px; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 6px 0; }
.log { max-height: 320px; overflow-y: auto; min-width: 280px; }
details summary { cursor: pointer; color: var(--accent); }

body.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.caixa { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.caixa h1 { display: flex; gap: 10px; align-items: center; }
.caixa label { display: flex; flex-direction: column; gap: 5px; }
.caixa button { border: 0; border-radius: 8px; padding: 10px; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.erro { color: var(--danger); }

/* ---- Painel publicado (só leitura): esconde tudo que altera dados ---- */
body.leitura form[action^="/acao"], body.leitura a[href="/enviar"], body.leitura .nova-marca, body.leitura .form-del { display: none !important; }
.sync { font-size: 12px; color: var(--muted); margin: -8px 0 14px; }

/* ---- Escalados / análise ---- */
.aviso { background: var(--warn-bg); border: 1px solid var(--warn); color: var(--text); padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }
.aviso.erro-box { background: transparent; border-color: var(--danger); }
.escala { display: inline-block; min-width: 30px; text-align: center; font-weight: 700; font-size: 12px; padding: 2px 7px; border-radius: 8px; background: var(--chip); color: var(--muted); }
.escala.e-alta { background: var(--danger); color: #fff; }
.escala.e-media { background: var(--warn); color: #fff; }
.ad .midia { position: relative; }
.ad .sobre { position: absolute; top: 8px; left: 8px; }
.ad .dur { position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,.65); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 6px; }
.tag.st-ok { color: var(--up); font-weight: 600; } .tag.st-meio { color: var(--meta); } .tag.st-erro { color: var(--down); }
.tag.fonte-kwai { color: #f97316; } .tag.fonte-tiktok, .tag.fonte-manual { color: var(--text); }
.motivos { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.motivos span { font-size: 11px; background: var(--chip); color: var(--muted); padding: 1px 6px; border-radius: 6px; }
.motivos.grande { margin: 12px 0; }
.motivos.grande span { font-size: 12px; padding: 3px 8px; }
.analise { display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: 18px; align-items: start; }
.lado-video { position: sticky; top: 70px; }
.lado-video video, .lado-video .poster { width: 100%; max-height: 70vh; background: #000; border-radius: 12px; display: block; object-fit: contain; }
.ficha { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 12px 0; font-size: 13px; }
.ficha dt { color: var(--muted); } .ficha dd { margin: 0; }
.pre { white-space: pre-wrap; margin: 0; font-size: 13px; }
.destaque-ia { border-color: var(--accent); }
.motivos-ia { padding-left: 20px; margin: 8px 0 0; } .motivos-ia li { margin-bottom: 8px; }
.conf { font-size: 11px; padding: 0 6px; border-radius: 6px; background: var(--chip); }
.conf.c-alta { background: var(--accent-2); color: var(--accent); } .conf.c-baixa { color: var(--muted); }
.linha-tempo { list-style: none; padding: 0; margin: 0; }
.linha-tempo li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.linha-tempo .t, .transcricao .t { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); margin-right: 8px; }
.simples { padding-left: 18px; margin: 0 0 8px; } .simples li { margin-bottom: 5px; }
.quadros { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.quadros figure { margin: 0; } .quadros img { width: 100%; border-radius: 8px; display: block; background: var(--chip); }
.quadros figcaption { font-size: 11px; color: var(--muted); text-align: center; }
.transcricao p { margin: 0 0 8px; }
.duas.mini { gap: 10px; }
.painel p { margin: 0 0 8px; }

@media (max-width: 860px) {
  .analise { grid-template-columns: 1fr; }
  .lado-video { position: static; }
  .duas { grid-template-columns: 1fr; }
  .top { padding: 0 12px; gap: 10px; }
  .logo { font-size: 0; gap: 0; }
  main { padding: 16px 16px 50px; }
  .kpi b { font-size: 22px; }
}

.top .pill.live { background: var(--warn); color: #fff; }
