:root {
  --bg: #f5f7fa; --painel: #ffffff; --painel-2: #eef2f7; --borda: #dde3ea;
  --texto: #0f1a2a; --texto-2: #475569; --suave: #64748b;
  --acento: #1d4ed8; --acento-2: #3b82f6; --acento-fundo: #e0eaff; --ciano: #0e7c86;
  --ok: #15803d; --ok-fundo: #dcfce7; --alerta: #b45309; --alerta-fundo: #fef3c7; --erro: #b91c1c; --erro-fundo: #fee2e2;
  --lateral: #070b15; --lateral-texto: #c1d4e3; --lateral-ativo: #7fd6db;
  --raio: 10px; --sombra: 0 1px 2px rgba(15, 26, 42, .06), 0 4px 16px rgba(15, 26, 42, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a101c; --painel: #111a2b; --painel-2: #172238; --borda: #24324a;
    --texto: #eef3f9; --texto-2: #b6c5d6; --suave: #8ea6bd;
    --acento: #7aa7ff; --acento-2: #3b82f6; --acento-fundo: #1a2c52; --ciano: #7fd6db;
    --ok: #4ade80; --ok-fundo: #12321f; --alerta: #fbbf24; --alerta-fundo: #3a2c0c; --erro: #f87171; --erro-fundo: #3b1717;
    --sombra: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a101c; --painel: #111a2b; --painel-2: #172238; --borda: #24324a;
  --texto: #eef3f9; --texto-2: #b6c5d6; --suave: #8ea6bd;
  --acento: #7aa7ff; --acento-2: #3b82f6; --acento-fundo: #1a2c52; --ciano: #7fd6db;
  --ok: #4ade80; --ok-fundo: #12321f; --alerta: #fbbf24; --alerta-fundo: #3a2c0c; --erro: #f87171; --erro-fundo: #3b1717;
  --sombra: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--texto); background: var(--bg);
  display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh;
}
a { color: var(--acento); }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
.sub { color: var(--texto-2); margin: 0 0 1.5rem; max-width: 70ch; }
.vazio { color: var(--suave); padding: 2rem 0; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.suave { color: var(--suave); }
.pequeno { font-size: .85rem; }

/* Lateral */
.lateral { background: var(--lateral); color: var(--lateral-texto); padding: 20px 14px; display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; height: 100vh; }
.marca { display: flex; gap: 10px; align-items: center; color: #f4f8fc; text-decoration: none; font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; padding: 0 6px; }
.marca b { color: var(--lateral-ativo); }
.marca small { display: block; font-weight: 500; letter-spacing: 0; color: #8ea6bd; font-size: .78rem; }
#menu { display: flex; flex-direction: column; gap: 2px; }
#menu a { color: var(--lateral-texto); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 500; }
#menu a:hover { background: rgba(255, 255, 255, .06); }
#menu a[aria-current="page"] { background: rgba(127, 214, 219, .12); color: var(--lateral-ativo); }
.lateral-rodape { margin-top: auto; display: grid; gap: 6px; font-size: .8rem; padding: 0 6px; }
.lateral-projeto { display: grid; gap: 6px; font-size: .8rem; padding: 0 6px; }
.lateral-rodape select, .lateral-projeto select { background: #111a2b; color: #eef3f9; border-color: #24324a; width: 100%; }
.lateral-projeto select { font-weight: 600; }
body.sem-projeto #menu, body.sem-projeto .lateral-rodape { display: none; }
.lateral-conta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .8rem; padding: 10px 6px 0; border-top: 1px solid #1b2638; }
.lateral-conta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lateral-conta button { background: transparent; color: var(--lateral-texto); border-color: #24324a; padding: 4px 10px; font-size: .8rem; }
.lateral-conta button:hover { background: rgba(255, 255, 255, .06); }

/* Tela de entrada */
body.tela-acesso { display: block; }
body.tela-acesso .lateral { display: none; }
.acesso { min-height: calc(100vh - 96px); display: grid; place-content: center; gap: 20px; width: min(400px, 100%); margin: 0 auto; }
.acesso-marca { display: flex; gap: 10px; align-items: center; justify-content: center; font-weight: 800; font-size: 1.5rem; }
.acesso-marca b { color: var(--ciano); }
.acesso form { width: min(400px, calc(100vw - 32px)); }
.acesso h1 { font-size: 1.3rem; }
.acesso button.primario { justify-content: center; }
.erro-acesso { color: var(--erro); font-size: .88rem; margin: 0; min-height: 1.3em; }

main { padding: 32px clamp(16px, 4vw, 48px) 64px; outline: none; min-width: 0; }

/* Componentes */
.cartao { background: var(--painel); border: 1px solid var(--borda); border-radius: var(--raio); padding: 20px; box-shadow: var(--sombra); }
.grade { display: grid; gap: 16px; }
.grade-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.grade-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); margin-bottom: 16px; }
.kpi { background: var(--painel); border: 1px solid var(--borda); border-radius: var(--raio); padding: 16px; }
.kpi span { color: var(--texto-2); font-size: .85rem; }
.kpi strong { display: block; font-size: 1.8rem; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 4px; }
.kpi small { color: var(--suave); font-size: .8rem; }

button, .botao {
  font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; border-radius: 8px; padding: 8px 14px;
  border: 1px solid var(--borda); background: var(--painel); color: var(--texto); text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .botao:hover { background: var(--painel-2); }
button.primario, .botao.primario { background: var(--acento-2); border-color: var(--acento-2); color: #fff; }
button.primario:hover, .botao.primario:hover { background: #1d4ed8; }
button:disabled { opacity: .55; cursor: not-allowed; }
button.link { border: 0; background: none; padding: 0; color: var(--acento); font-weight: 500; text-align: left; }
button.link:hover { text-decoration: underline; background: none; }
.acoes { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

input, select, textarea {
  font: inherit; color: var(--texto); background: var(--painel); border: 1px solid var(--borda); border-radius: 8px; padding: 7px 10px; min-width: 0;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--acento-2); outline-offset: 1px; }
textarea { width: 100%; resize: vertical; }
label.campo { display: grid; gap: 4px; font-size: .85rem; color: var(--texto-2); font-weight: 500; }
label.check { display: inline-flex; gap: 6px; align-items: center; font-size: .9rem; white-space: nowrap; }
.filtros { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.filtros input[type="search"] { flex: 1 1 240px; }

.selo { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--painel-2); color: var(--texto-2); white-space: nowrap; }
.selo.ok { background: var(--ok-fundo); color: var(--ok); }
.selo.alerta { background: var(--alerta-fundo); color: var(--alerta); }
.selo.acento { background: var(--acento-fundo); color: var(--acento); }
.selo.erro { background: var(--erro-fundo); color: var(--erro); }

/* Tabelas */
.tabela-caixa { overflow-x: auto; border: 1px solid var(--borda); border-radius: var(--raio); background: var(--painel); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--borda); text-align: left; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--suave); background: var(--painel-2); position: sticky; top: 0; white-space: nowrap; }
th button { all: unset; cursor: pointer; }
th button:focus-visible { outline: 2px solid var(--acento-2); }
th[aria-sort="ascending"] button::after { content: " ▲"; }
th[aria-sort="descending"] button::after { content: " ▼"; }
tbody tr:hover { background: var(--painel-2); }
td.titulo { min-width: 200px; max-width: 460px; }
td select { padding: 3px 6px; font-size: .85rem; }
.contagem { color: var(--suave); font-size: .85rem; margin: 8px 2px; }

/* Termos */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--acento-fundo); color: var(--acento); border-radius: 999px; padding: 3px 4px 3px 12px; font-size: .9rem; }
.chip button { border: 0; background: none; color: inherit; padding: 0 6px; font-size: 1rem; line-height: 1; }
.log { background: #070b15; color: #c1d4e3; font: .85rem/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; border-radius: 8px; padding: 12px 14px; min-height: 120px; max-height: 360px; overflow: auto; white-space: pre-wrap; margin: 0; }
.log .erro { color: #f87171; }
.log .ok { color: #4ade80; }

/* Listas de pendências */
.lista { list-style: none; padding: 0; margin: 0; }
.lista li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--borda); align-items: center; }
.lista li:last-child { border-bottom: 0; }

/* Gaveta de canal */
.gaveta { position: fixed; inset: 0; background: rgba(7, 11, 21, .45); display: flex; justify-content: flex-end; z-index: 10; }
.gaveta[hidden] { display: none; }
.gaveta-corpo { background: var(--bg); width: min(560px, 100%); height: 100%; overflow-y: auto; padding: 24px; box-shadow: -8px 0 32px rgba(0, 0, 0, .25); }
.gaveta-topo { display: flex; justify-content: space-between; gap: 12px; align-items: start; margin-bottom: 16px; }
dl.dados { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: .9rem; }
dl.dados dt { color: var(--suave); }
dl.dados dd { margin: 0; overflow-wrap: anywhere; }

/* Mensagem */
.previa { font-family: inherit; line-height: 1.6; white-space: pre-wrap; background: var(--painel-2); border-radius: 8px; padding: 16px; font-size: .92rem; margin: 0; overflow-wrap: anywhere; }
.pendente { background: var(--alerta-fundo); color: var(--alerta); border-radius: 3px; padding: 0 2px; }
.campos { display: grid; gap: 12px; align-content: start; }
.dica { background: var(--acento-fundo); color: var(--texto); border-radius: 8px; padding: 10px 14px; font-size: .88rem; margin: 0 0 16px; }

/* Documentos */


.aviso { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: #0f1a2a; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: .9rem; opacity: 0; transition: .2s; pointer-events: none; z-index: 20; }
.aviso.visivel { opacity: 1; transform: translateX(-50%); }
.aviso.erro { background: #b91c1c; }

@media (max-width: 860px) {
  body { grid-template-columns: minmax(0, 1fr); }
  .lateral { min-width: 0; position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; }
  #menu { flex-direction: row; overflow-x: auto; width: 100%; order: 3; }
  #menu a { white-space: nowrap; padding: 6px 10px; }
  .lateral-rodape, .lateral-projeto { grid-template-columns: auto minmax(0, 1fr); align-items: center; padding: 0; }
  .lateral-projeto { margin-left: auto; }
  .lateral-rodape { margin: 0; order: 4; width: 100%; }
  .lateral-conta { order: 5; width: 100%; padding-top: 8px; }
  main { padding: 20px 16px 48px; }
  .paginacao .acoes { flex-wrap: nowrap; gap: 4px; }
  .paginacao button { min-width: 30px; padding: 4px 8px; }
  .rotulo-por-pagina { display: none; }
}

/* Paginação */
.paginacao { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; margin: 8px 2px; }
.paginacao .contagem { margin: 0; }
.paginacao button { padding: 4px 10px; min-width: 34px; justify-content: center; }
.paginacao select { padding: 3px 6px; }

/* Botões só com ícone */
.icone { width: 18px; height: 18px; display: block; flex: none; }
.icones { display: flex; gap: 4px; align-items: center; flex-wrap: nowrap; }
.icone-botao { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border-radius: 8px;
  border: 1px solid var(--borda); background: var(--painel); color: var(--texto-2); cursor: pointer; text-decoration: none; flex: none; }
.icone-botao:hover { background: var(--acento-fundo); color: var(--acento); border-color: transparent; }
.icone-botao:disabled { opacity: .4; cursor: not-allowed; background: var(--painel); color: var(--texto-2); }
th.acoes-col, td.acoes-col { width: 1%; white-space: nowrap; }
tr.ignorado td { opacity: .55; }
tr.ignorado td.acoes-col { opacity: 1; }

/* Gaveta do vídeo */
.gaveta-corpo.larga { width: min(720px, 100%); }
.player { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #000; margin-bottom: 8px; }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.descricao { margin: 16px 0 0; }
.descricao summary { cursor: pointer; font-weight: 600; }
.descricao p { white-space: pre-wrap; font-size: .9rem; color: var(--texto-2); overflow-wrap: anywhere; }
.comentario-texto { white-space: pre-wrap; font-size: .9rem; overflow-wrap: anywhere; }
.citacao { margin: 0; padding: 6px 12px; border-left: 3px solid var(--acento-2); background: var(--painel-2); border-radius: 0 8px 8px 0; font-size: .88rem; white-space: pre-wrap; max-height: 120px; overflow: auto; }
/* Ações numa linha só, com a coluna presa à direita: fica visível mesmo quando a tabela rola para o lado. */
td.acoes-col .icones { gap: 3px; }
td.acoes-col .icone-botao { width: 28px; height: 28px; }
td.acoes-col .icone { width: 16px; height: 16px; }
th.acoes-col, td.acoes-col { position: sticky; right: 0; z-index: 1; box-shadow: -1px 0 0 var(--borda); }
td.acoes-col { background: var(--painel); }
tbody tr:hover td.acoes-col { background: var(--painel-2); }
th.acoes-col { z-index: 2; }
/* Em telas mais estreitas, curtidas e duração saem da tabela (continuam no painel Visualizar). */
@media (max-width: 1360px) { .col-curtidas { display: none; } }
@media (max-width: 1200px) { .col-duracao { display: none; } }

/* Caixa de marcação maior, para opções importantes. */
label.check-grande { display: flex; white-space: normal; align-items: center; gap: 10px; font-size: .95rem; padding: 10px 12px; border: 1px solid var(--borda); border-radius: 8px; background: var(--painel-2); cursor: pointer; }
.check-grande input[type="checkbox"] { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--acento-2); cursor: pointer; }
