/* ==========================================================================
   Diagramador de Livros — design system
   ========================================================================== */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --border: #e3e6ef;
  --text: #1a1d29;
  --text-soft: #5b6172;
  --text-faint: #8b92a6;
  --brand: #4f46e5;
  --brand-hover: #4338ca;
  --brand-soft: #eef0fe;
  --ok: #0a7d33;
  --ok-soft: #e7f6ec;
  --err: #c0392b;
  --err-soft: #fdecea;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .04), 0 8px 24px rgba(20, 24, 40, .06);
  --shadow-sm: 0 1px 2px rgba(20, 24, 40, .06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #171a23;
    --surface-2: #1e222e;
    --border: #2a2f3d;
    --text: #eceef4;
    --text-soft: #a2a9bd;
    --text-faint: #6d7488;
    --brand: #7c78f0;
    --brand-hover: #918efb;
    --brand-soft: #21243a;
    --ok: #4ade80;
    --ok-soft: #16281c;
    --err: #f87171;
    --err-soft: #2a1717;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .35);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- layout ---- */
.wrap { max-width: 760px; margin: 0 auto; padding: 0 20px; }

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: 62px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 16px; color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), #8b5cf6);
  display: grid; place-items: center; color: #fff; font-size: 16px;
  box-shadow: var(--shadow-sm);
}
.nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nav .who { color: var(--text-faint); font-size: 13px; margin-right: 4px; }

.main { padding: 40px 0 64px; }

/* ---- cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.card + .card { margin-top: 20px; }

h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 6px; }
h2 { font-size: 16px; font-weight: 650; margin: 0 0 14px; }
.subtitle { color: var(--text-soft); margin: 0 0 24px; }
.muted { color: var(--text-faint); font-size: 13px; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--brand); color: #fff; border: 0;
  border-radius: var(--radius-sm); padding: 12px 20px;
  font-family: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background .15s ease, transform .05s ease, opacity .15s ease;
}
.btn:hover { background: var(--brand-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--text-soft); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.success { background: var(--ok); }

/* ---- forms ---- */
.field { margin-bottom: 14px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
input[type=email], input[type=password], input[type=text] {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* ---- login ---- */
.login-shell { min-height: 100%; display: grid; place-items: center; padding: 48px 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-head { text-align: center; margin-bottom: 24px; }
.login-head .logo {
  width: 48px; height: 48px; border-radius: 12px; margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--brand), #8b5cf6);
  display: grid; place-items: center; color: #fff; font-size: 24px;
  box-shadow: var(--shadow);
}

/* ---- upload dropzone ---- */
.drop {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 40px 24px; text-align: center; background: var(--surface-2);
  transition: border-color .15s, background .15s; cursor: pointer;
}
.drop:hover, .drop.drag { border-color: var(--brand); background: var(--brand-soft); }
.drop .icon { font-size: 34px; line-height: 1; margin-bottom: 12px; }
.drop .hint { color: var(--text-faint); font-size: 13px; margin-top: 4px; }
.drop .filename { font-weight: 600; color: var(--brand); margin-top: 8px; word-break: break-all; }
#arq { display: none; }

.actions { margin-top: 20px; display: flex; gap: 10px; }
.opt-check { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; font-size: 14px; color: var(--text-soft); cursor: pointer; }
.opt-check input { width: 16px; height: 16px; flex: none; }

/* escolha de cor do miolo (Preto e branco / Colorido) */
.opt-cor { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 16px 0 0; flex-wrap: wrap; }
.opt-cor-txt { display: flex; flex-direction: column; gap: 2px; font-size: 14px; color: var(--text-soft); }
.opt-cor-hint { font-size: 12px; color: var(--text-faint); }
.seg-btn.pb.ativo { background: var(--text-faint); color: #fff; }
.seg-btn.cor.ativo { background: var(--brand); color: #fff; }

/* card de aprendizado (feedback) — bem visível */
.feedback-card { border: 2px solid var(--brand); background: var(--brand-soft); }
.feedback-card h2 { color: var(--brand); }
.fb-texto { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-family: inherit; font-size: 15px; resize: vertical; margin-bottom: 10px; box-sizing: border-box; }
.fb-texto:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.fb-img { border: 2px dashed var(--brand); border-radius: var(--radius-sm); padding: 14px; text-align: center; color: var(--text-soft); font-size: 14px; background: var(--surface); }
.fb-link { color: var(--brand); font-weight: 600; cursor: pointer; text-decoration: underline; }
.fb-preview { margin-top: 10px; }
.fb-preview img { max-width: 100%; max-height: 260px; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; }

/* formulário inline (criar usuário) */
.form-inline { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-inline .field { margin: 0; flex: 1; min-width: 180px; }
.form-inline .btn { flex: none; }
table form { display: inline; margin: 0; }

/* editar o livro (antes de diagramar) */
.livro-edit { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.livro-edit .field { margin: 0; }
@media (max-width: 640px) { .livro-edit { grid-template-columns: 1fr; } }
#editar-livro textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-family: inherit; font-size: 14px; resize: vertical; box-sizing: border-box; }
.ed-sinopse { width: 100%; min-height: 90px; max-height: 260px; overflow-y: auto; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-family: inherit; font-size: 14px; line-height: 1.5; box-sizing: border-box; }
.ed-sinopse:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.ed-sinopse:empty:before { content: attr(data-ph); color: var(--text-soft); }
.ed-sinopse mark.troca { background: #fde68a; color: #7c5e00; cursor: pointer; padding: 0 2px; border-radius: 3px; }
.ed-sinopse .trocado { background: #bbf7d0; color: #065f46; padding: 0 2px; border-radius: 3px; }
.troca-aviso { margin-top: 6px; font-size: 13px; color: var(--text-soft); }

/* editor de texto (Editar texto -> Gerar PDF final) */
.edt-lbl { display: block; font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
.edt-titulo { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-family: inherit; font-size: 15px; font-weight: 600; box-sizing: border-box; margin-bottom: 12px; }
.edt-h { margin: 0 0 10px; font-size: 16px; }
textarea.edt-par { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-family: inherit; font-size: 14px; line-height: 1.55; resize: vertical; box-sizing: border-box; margin-bottom: 8px; overflow: hidden; min-height: 44px; }
textarea.edt-par:focus, .edt-titulo:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
/* remoção de conteúdo esquecido (seção / parágrafo) */
.edt-sec-topo { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.edt-sec-rot { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.edt-rm-sec { flex-shrink: 0; font: inherit; font-size: 12px; padding: 4px 9px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: #c0392b; cursor: pointer; }
.edt-rm-sec:hover { background: #fdecea; border-color: #e6b0aa; }
.edt-par-row { display: flex; align-items: flex-start; gap: 6px; margin-bottom: 8px; }
.edt-par-row textarea.edt-par { flex: 1; margin-bottom: 0; }
.edt-rm-par { flex-shrink: 0; font-size: 14px; line-height: 1; padding: 8px 9px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; color: #c0392b; }
.edt-rm-par:hover { background: #fdecea; }
.edt-removida > *:not(.edt-sec-topo), .edt-par-row.edt-removida textarea { opacity: .4; text-decoration: line-through; pointer-events: none; }
.edt-sec.edt-removida { border-color: #e6b0aa; background: rgba(192, 57, 43, .04); }
.edt-par-row.edt-removida textarea { background: rgba(192, 57, 43, .05); }
.troca-aviso mark { background: #fde68a; color: #7c5e00; padding: 0 3px; border-radius: 3px; }
.extra-add { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.extra-add input { flex: 1; min-width: 140px; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-family: inherit; font-size: 14px; }
.extra-add select { padding: 9px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-family: inherit; }
.lista-extra { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.extra-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 14px; }
.x-extra { border: 0; background: transparent; color: var(--err); cursor: pointer; font-size: 15px; }

/* troca de senha inline (usuários) */
.form-senha { display: inline-flex; gap: 6px; margin-right: 6px; }
.form-senha input { padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 13px; width: 130px; }

/* painel (dashboard) */
.cards-metric { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 640px) { .cards-metric { grid-template-columns: repeat(2, 1fr); } }
.metric { text-align: center; padding: 18px 12px; }
.metric-num { font-size: 26px; font-weight: 800; color: var(--brand); }
.metric-lbl { font-size: 13px; color: var(--text-soft); margin-top: 2px; }
.barras { display: flex; flex-direction: column; gap: 8px; }
.barra-linha { display: grid; grid-template-columns: 180px 1fr 40px; align-items: center; gap: 10px; font-size: 13px; }
@media (max-width: 640px) { .barra-linha { grid-template-columns: 110px 1fr 34px; } }
.barra-rot { color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra-track { background: var(--surface-2); border-radius: 6px; height: 18px; overflow: hidden; }
.barra-fill { display: block; height: 100%; background: var(--brand); border-radius: 6px; min-width: 2px; }
.barra-fill.alt { background: #10b981; }
.barra-fill.err { background: #ef8a5b; }
.barra-num { text-align: right; font-weight: 700; }

/* treinamento */
.cards-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.cards-2 > .card { margin-top: 0; }
@media (max-width: 720px) { .cards-2 { grid-template-columns: 1fr; } .cards-2 > .card + .card { margin-top: 12px; } }
.ta { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-family: inherit; font-size: 14px; resize: vertical; box-sizing: border-box; }
.ta:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.regras { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.regra-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 14px; }
.regra-item form { margin: 0; }
.x-regra { border: 0; background: transparent; color: var(--err); cursor: pointer; font-size: 14px; }
.fb-list { display: flex; flex-direction: column; gap: 10px; }
.fb-reg { padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.fb-reg-licao { font-weight: 600; }
.fb-reg-orig { font-style: italic; margin-top: 2px; }
.fb-reg-meta { font-size: 12px; margin-top: 4px; }

/* ---- status / alerts ---- */
.status { margin-top: 20px; }
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-radius: var(--radius-sm); font-size: 14px;
}
.alert.ok  { background: var(--ok-soft); color: var(--ok); }
.alert.err { background: var(--err-soft); color: var(--err); }
.alert.info { background: var(--brand-soft); color: var(--brand); }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  display: inline-block; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); font-weight: 600; font-size: 13px;
}
.empty { text-align: center; color: var(--text-faint); padding: 32px 12px; }

.back { display: inline-block; margin-bottom: 16px; color: var(--text-soft); font-size: 14px; }

/* ==========================================================================
   Diagramação: layout 2 colunas, progresso, revisão, relatório
   ========================================================================== */
.btn.sm { padding: 7px 12px; font-size: 13px; }

/* corrige [hidden] sendo sobreposto por display:flex/grid */
[hidden] { display: none !important; }

/* largura total para a tela de diagramação */
.wrap.wrap-wide { max-width: 1360px; }

/* topo do trabalho: título/subtítulo · usuário · tempo total */
.job-topo { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.jt-titulo { font-size: 18px; font-weight: 700; }
.jt-sub { color: var(--text-soft); font-style: italic; margin-top: 2px; }
.jt-meta { text-align: right; display: flex; flex-direction: column; gap: 3px; flex: none; }
.jt-user { color: var(--text-faint); font-size: 13px; }
.jt-tempo { font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; font-size: 15px; }

/* layout adaptativo: 1 coluna (revisão usa tudo) -> 2 colunas com PDF grande */
.diag { display: grid; grid-template-columns: 1fr; gap: 22px; align-items: start; }
.diag.com-pdf { grid-template-columns: minmax(0, 1fr) minmax(460px, 46%); }
.painel { min-width: 0; }
.sidebar { display: none; }
.diag.com-pdf .sidebar { display: block; }

/* revisão: FLUXO NATURAL — a página inteira rola. Sem altura fixa nem scroll interno,
   pra a caixa de erros NUNCA cortar em zoom do navegador, escala do Windows (125%/150%)
   ou telas baixas. (Bug antigo: 'height: calc(100vh - 118px)' — se o cabeçalho passava
   de 118px, o fim da lista e o botão 'Gerar' saíam da tela e não dava pra rolar até eles.) */
.tela-rev { display: flex; flex-direction: column; gap: 14px; }
.rev-cabecalho h1 { margin-bottom: 10px; }
.rev-lista { display: flex; flex-direction: column; gap: 12px; }
.rev-lista .card { margin: 0; }
.rev-rodape { display: flex; align-items: flex-end; gap: 16px; }
.rev-rodape .rodape-isbn { flex: 1; margin: 0; }
.rev-rodape .field { margin: 0; }
.rev-rodape .btn { flex: none; white-space: nowrap; }

/* controle Corrigir / Manter */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; flex: none; }
.seg-btn { border: 0; background: var(--surface); color: var(--text-soft); padding: 7px 13px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .12s; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.corrigir.ativo { background: var(--ok); color: #fff; }
.seg-btn.manter.ativo { background: var(--text-faint); color: #fff; }
.seg-btn:not(.ativo):hover { background: var(--surface-2); }

/* barra lateral com o PDF */
.sidebar { position: sticky; top: 20px; }
.sidebar-vazio {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 40px 16px; text-align: center; background: var(--surface-2);
}
.sidebar-vazio .icon { font-size: 34px; margin-bottom: 8px; }
.sidebar-pdf {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.sidebar-topo {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px;
}
.sidebar-pdf iframe { width: 100%; height: 86vh; border: 0; display: block; background: #fff; }
.sidebar-topo > div { display: flex; gap: 6px; }

/* passos de progresso */
.passos { list-style: none; margin: 8px 0 0; padding: 0; }
.passo {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--border); font-size: 15px; color: var(--text-soft);
}
.passo:last-child { border-bottom: 0; }
.passo.ok { color: var(--text); }
.passo.run { color: var(--brand); font-weight: 600; }
.passo.err { color: var(--err); }
.p-ok { color: var(--ok); font-weight: 700; }
.p-pend { color: var(--text-faint); }
.p-err { color: var(--err); font-weight: 700; }

/* revisão: ações e contador */
.rev-acoes { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* card de proposta */
.proposta { padding: 16px 18px; }
.prop-topo { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}
.badge.pt { background: var(--brand-soft); color: var(--brand); }
.badge.rep { background: #fff3e0; color: #b45309; }
.badge.est { background: #ede9fe; color: #6d28d9; }
@media (prefers-color-scheme: dark) {
  .badge.rep { background: #2e2410; color: #f0b357; }
  .badge.est { background: #241f3a; color: #b9a4ff; }
}
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 6px; margin-left: 4px;
  background: var(--surface-2); color: var(--text-faint); font-size: 12px;
}

/* trechos antes/depois e diff */
.trecho {
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px;
  line-height: 1.6; background: var(--surface-2); margin-top: 6px; white-space: pre-wrap;
}
.trecho.del { background: var(--err-soft); color: var(--text); }
.trecho.add { background: var(--ok-soft); color: var(--text); }
.trecho.diff ins { background: rgba(10,125,51,.18); text-decoration: none; border-radius: 3px; padding: 0 2px; }
.trecho.diff del { background: rgba(192,57,43,.18); border-radius: 3px; padding: 0 2px; }
/* trecho repetido destacado dentro do bloco */
mark.rep-span { background: #fde68a; color: #111; border-radius: 3px; padding: 0 2px; }
@media (prefers-color-scheme: dark) { mark.rep-span { background: #6b5d1a; color: #fff; } }
.badge.rep.parecida { background: var(--brand-soft); color: var(--brand); }
/* seleção fina de erros: cada troca é um chip clicável */
.chg { cursor: pointer; border-radius: 4px; padding: 1px 3px; border: 1px solid transparent; white-space: normal; }
.chg.sel { background: rgba(10,125,51,.12); border-color: rgba(10,125,51,.40); }
.chg:not(.sel) { background: rgba(192,57,43,.10); border-color: rgba(192,57,43,.35); }
.chg.sel del { opacity: .55; }
.chg:not(.sel) ins { opacity: .45; text-decoration: line-through; }
.chg:not(.sel) del { text-decoration: none; }      /* mantendo o original: mostra normal */
.chg:hover { filter: brightness(.97); }
p.mini { font-size: 12px; margin-top: 6px; }
/* listas com filtro por data + paginação + scroll (biblioteca, histórico) */
.lista-ctrl { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin: 4px 0 14px; }
.lista-ctrl .campo { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-soft); }
.lista-ctrl input { padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 14px; }
.lista-ctrl input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.lista-ctrl .lista-q { min-width: 220px; }
.lista-scroll { max-height: 66vh; overflow: auto; }
.lista-pag { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.lista-pag .muted { font-size: 13px; }

/* --- filtro por período (chips) — Histórico e Biblioteca --- */
.filtro-bar { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; margin: 6px 0 12px; }
.filtro-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.lista .filtro-chips { margin-bottom: 10px; }
.chip {
  display: inline-flex; align-items: center; padding: 7px 15px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-soft);
  font: inherit; font-size: 13px; font-weight: 600; line-height: 1;
  cursor: pointer; user-select: none; text-decoration: none;
  transition: background .12s, color .12s, border-color .12s;
}
.chip:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.chip.ativo { background: var(--brand); border-color: var(--brand); color: #fff; }
.filtro-range { display: flex; gap: 8px 12px; align-items: flex-end; flex-wrap: wrap; }
.filtro-range .campo { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-soft); }
.filtro-range input { padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 14px; }
.filtro-range input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.filtro-info { font-size: 13px; color: var(--text-soft); margin: -2px 0 16px; }
.filtro-info strong { color: var(--text); }

/* tabela zebrada (mais legível no Histórico) */
.tab-zebra tbody tr:nth-child(even) { background: var(--surface-2); }
.tab-zebra tbody tr:hover { background: var(--brand-soft); }

/* toggle sim/não */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.slider {
  width: 42px; height: 24px; border-radius: 999px; background: var(--border);
  position: relative; transition: background .15s;
}
.slider::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: var(--shadow-sm);
}
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::after { transform: translateX(18px); }
.sim-nao { font-size: 13px; font-weight: 600; color: var(--text-soft); }

/* relatório */
.card.destaque { border-color: var(--brand); }
.nota {
  font-size: 14px; background: var(--brand-soft); color: var(--brand);
  padding: 2px 10px; border-radius: 999px; font-weight: 700; margin-left: 6px;
}
.probs { margin: 8px 0 0; padding-left: 0; list-style: none; }
.probs li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.probs li:last-child { border-bottom: 0; }
.sev { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; margin-right: 6px; }
.sev.critico { background: var(--err-soft); color: var(--err); }
.sev.aviso { background: #fff3e0; color: #b45309; }
.sev.leve { background: var(--surface-2); color: var(--text-faint); }
.rev-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.rev-item:last-child { border-bottom: 0; }

/* histórico conversacional (o diagramador falando) — só texto + tempo do lado */
.conversa { display: flex; flex-direction: column; gap: 0; }
.msg { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); animation: surge .2s ease; }
.msg:last-child { border-bottom: 0; }
@keyframes surge { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; } }
.msg-txt { color: var(--text); font-size: 14px; line-height: 1.5; }
.msg.vivo .msg-txt { color: var(--brand); font-weight: 500; }
.msg-t { flex: none; font-size: 12px; font-weight: 700; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* info do livro detectado na revisão */
.livro-info {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px; margin: 4px 0 14px;
}
.li-titulo { font-size: 18px; font-weight: 700; }
.li-sub { font-style: italic; color: var(--text-soft); margin-top: 2px; }
.li-autor { color: var(--text-faint); font-size: 14px; margin-top: 4px; }

/* ==========================================================================
   Biblioteca — grade de cartões de livro
   ========================================================================== */
.wrap-mid { max-width: 1080px; }

.bib-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 4px; }
.bib-count {
  flex: none; margin-top: 6px; padding: 5px 12px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 13px;
  white-space: nowrap;
}
.bib-search {
  width: 100%; padding: 12px 16px; margin: 8px 0 22px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
.bib-search:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.bib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 16px; }
.bib-card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 18px; transition: box-shadow .15s, transform .05s, border-color .15s;
}
.bib-card:hover { box-shadow: var(--shadow); border-color: #d3d7e6; transform: translateY(-1px); }
@media (prefers-color-scheme: dark) { .bib-card:hover { border-color: #363c4d; } }

.bib-card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.bib-capa {
  width: 42px; height: 42px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-size: 22px;
  background: linear-gradient(135deg, var(--brand-soft), var(--surface-2));
}
.nota-badge {
  flex: none; padding: 3px 10px; border-radius: 999px;
  font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums;
}
.nota-badge.boa   { background: var(--ok-soft);  color: var(--ok); }
.nota-badge.media { background: #fff3e0; color: #b45309; }
.nota-badge.baixa { background: var(--err-soft); color: var(--err); }
@media (prefers-color-scheme: dark) { .nota-badge.media { background: #2e2410; color: #f0b357; } }

.bib-titulo {
  font-size: 15px; font-weight: 650; line-height: 1.35; margin: 0 0 4px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.bib-autor { color: var(--text-soft); font-size: 13px; margin: 0 0 12px; }
.bib-meta {
  display: flex; flex-direction: column; gap: 3px; margin: auto 0 14px;
  color: var(--text-faint); font-size: 12px;
}
.bib-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bib-baixar { display: flex; flex-direction: column; gap: 8px; }
.bib-baixar .btn { margin-top: 0; }
.bib-formatos { display: flex; gap: 8px; }
.bib-formatos .btn { flex: 1; }

@media (max-width: 520px) { .bib-grid { grid-template-columns: 1fr 1fr; gap: 12px; } .bib-card { padding: 14px; } }

/* ---- responsive ---- */
@media (max-width: 980px) {
  .diag, .diag.com-pdf { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .diag.com-pdf .sidebar { display: block; }
  .sidebar-pdf iframe { height: 70vh; }
}
@media (max-width: 560px) {
  .card { padding: 20px; }
  h1 { font-size: 21px; }
  .nav .who { display: none; }
}
