:root {
  --bg: #f3f6fb;
  --card: #ffffff;
  --ink: #1b2a41;
  --muted: #5d6b82;
  --line: #dde4ef;
  --brand: #0b5fa5;
  --brand-dark: #08457a;
  --mag: #0b7a4b;
  --mag-bg: #e2f5ec;
  --adm: #b25e00;
  --adm-bg: #fdf0dc;
  --yes: #0b7a4b;
  --no: #8a94a6;
  --new: #0b7a4b;
  --chg: #b25e00;
  --del: #b3261e;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

.topbar { background: linear-gradient(120deg, var(--brand-dark), var(--brand)); color: #fff; padding: 22px 0 18px; }
.topbar-inner { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.eyebrow { margin: 0 0 4px; font-size: .8rem; opacity: .85; letter-spacing: .02em; }
h1 { margin: 0; font-size: 1.7rem; }
.source { margin: 0; font-size: .82rem; opacity: .9; text-align: right; }

.tabs { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 10px 16px; border-radius: 10px 10px 0 0; font-size: .95rem; cursor: pointer; font-weight: 600;
}
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.tab:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, .dropzone:focus-visible { outline: 3px solid #7db7ec; outline-offset: 1px; }

main { padding-top: 14px; padding-bottom: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 2px rgba(20, 40, 80, .05); }
.view[hidden] { display: none; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.1; color: var(--brand-dark); }
.stat span { font-size: .8rem; color: var(--muted); }
.stat.new b { color: var(--new); } .stat.chg b { color: var(--chg); } .stat.del b { color: var(--del); }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.field.grow { flex: 1 1 320px; }
.field.actions { flex-direction: row; gap: 8px; }
label { font-size: .78rem; font-weight: 600; color: var(--muted); }
input[type="search"], select {
  font: inherit; padding: 10px 12px; border: 1px solid #c4cfe0; border-radius: 9px; background: #fff; color: var(--ink); width: 100%;
}
.searchbox { position: relative; }
.searchbox input { padding-right: 38px; font-size: 1.05rem; }
.icon-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: #e9eef6; border-radius: 50%; width: 26px; height: 26px; cursor: pointer; color: var(--muted); }
.btn {
  font: inherit; font-weight: 600; font-size: .9rem; padding: 10px 14px; border-radius: 9px; border: 1px solid var(--brand);
  background: var(--brand); color: #fff; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); }
.btn.ghost { background: #fff; color: var(--brand); }
.btn.ghost:hover { background: #eef5fc; }

.result-count { margin: 12px 2px 8px; color: var(--muted); font-size: .9rem; }

/* table */
.table-wrap { padding: 0; overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
thead th {
  position: sticky; top: 0; background: #eaf1fa; text-align: left; padding: 11px 12px; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .03em; color: #33466a; cursor: pointer; user-select: none; border-bottom: 1px solid var(--line);
}
thead th.num { width: 110px; }
thead th.center, td.center { text-align: center; }
.arrow { font-size: .7rem; opacity: .7; }
tbody td { padding: 9px 12px; border-bottom: 1px solid #edf1f7; vertical-align: top; }
tbody tr:hover { background: #f6faff; }
td.code { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--brand-dark); white-space: nowrap; }
td.code button { all: unset; cursor: pointer; border-bottom: 1px dashed var(--brand); }
td.code button:focus-visible { outline: 2px solid #7db7ec; }
mark { background: #ffe58a; padding: 0 1px; border-radius: 2px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.pill.MAGISTERIO { background: var(--mag-bg); color: var(--mag); }
.pill.ADMINISTRATIVO { background: var(--adm-bg); color: var(--adm); }
.yn { font-weight: 700; } .yn.SIM { color: var(--yes); } .yn.NAO { color: var(--no); }
.empty { padding: 28px; text-align: center; color: var(--muted); margin: 0; }

.pager { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
.pager button { font: inherit; padding: 7px 12px; border: 1px solid #c4cfe0; background: #fff; border-radius: 8px; cursor: pointer; }
.pager button:disabled { opacity: .45; cursor: default; }
.pager span { color: var(--muted); font-size: .9rem; }

/* compare */
.compare-intro h2 { margin-top: 0; }
.compare-intro ul { padding-left: 18px; }
.compare-intro li { margin: 6px 0; }
.badge { display: inline-block; font-size: .7rem; font-weight: 800; padding: 2px 8px; border-radius: 6px; color: #fff; }
.badge.new { background: var(--new); } .badge.chg { background: var(--chg); } .badge.del { background: var(--del); }
.dropzone { border: 2px dashed #9db6d6; border-radius: var(--radius); padding: 26px 16px; text-align: center; cursor: pointer; background: #f7faff; margin-top: 12px; transition: .15s; }
.dropzone:hover, .dropzone.drag { background: #e8f2fe; border-color: var(--brand); }
.dz-title { margin: 0; font-weight: 700; color: var(--brand-dark); font-size: 1.05rem; }
.dz-sub { margin: 6px 0 0; color: var(--muted); font-size: .88rem; word-break: break-all; }
.progress { height: 8px; background: #e3eaf4; border-radius: 999px; margin-top: 12px; overflow: hidden; }
.bar { height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.cmp-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.cmp-section { margin-bottom: 16px; }
.cmp-section h3 { margin: 0 0 8px; display: flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.cmp-section .table-wrap { max-height: 480px; overflow: auto; }
.diff-old { text-decoration: line-through; color: var(--del); }
.diff-new { color: var(--new); font-weight: 600; }
.diff-line { display: block; font-size: .86rem; }
.ok-box { background: var(--mag-bg); color: #0a5c38; border: 1px solid #b7e3cc; padding: 14px; border-radius: var(--radius); font-weight: 600; margin-bottom: 14px; }
.err-box { background: #fdecea; color: #8c1d18; border: 1px solid #f3b9b4; padding: 14px; border-radius: var(--radius); margin-top: 12px; }
.note { margin-top: 10px; background: #fffbea; border-color: #f0e2a0; }
.note p { margin: 6px 0 0; }

.footer { color: var(--muted); font-size: .82rem; padding-bottom: 28px; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #1b2a41; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; }
.toast.show { opacity: 1; }

/* mobile: tabela vira cartões */
@media (max-width: 720px) {
  h1 { font-size: 1.35rem; }
  .source { text-align: left; }
  .field { min-width: 100%; }
  .field.actions .btn { flex: 1; }
  .tab { flex: 1; padding: 10px 8px; font-size: .85rem; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr { padding: 10px 12px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
  tbody td { border: 0; padding: 2px 0; }
  tbody td.code { grid-column: 1 / -1; font-size: 1.15rem; }
  tbody td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: .72rem; font-weight: 600; display: block; }
  tbody td.act { grid-column: 1 / -1; font-weight: 600; }
  td.center { text-align: left; }
  tbody td[data-l="Atividade"]::before, tbody td[data-l="Código"]::before { display: none; }
}
