:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f9;
  --text: #17203a;
  --muted: #5b6684;
  --border: #dde3ef;
  --primary: #1f4fd6;
  --primary-soft: #e4ebff;
  --ok: #138a4b;
  --ok-soft: #dcf5e7;
  --warn: #b26a00;
  --warn-soft: #fff1d6;
  --info: #6a3fd1;
  --info-soft: #eee6ff;
  --danger: #c0352b;
  --danger-soft: #fde4e1;
  --neutral-soft: #e9ecf2;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --surface: #171e2e;
    --surface-2: #1f2840;
    --text: #e8ecf6;
    --muted: #9aa5c2;
    --border: #2a3450;
    --primary: #7d9cff;
    --primary-soft: #222f58;
    --ok: #4fd08d;
    --ok-soft: #153626;
    --warn: #f2b54f;
    --warn-soft: #3a2c12;
    --info: #b79bff;
    --info-soft: #2b2250;
    --danger: #ff8077;
    --danger-soft: #45201d;
    --neutral-soft: #262f45;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem max(16px, calc((100% - 1160px) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.05rem; }
[hidden] { display: none !important; }
.topnav { display: flex; gap: .25rem; align-items: center; }
.topnav #instalar { margin-left: .25rem; white-space: nowrap; }
.aviso-offline, .aviso-ios { padding: .55rem 16px; font-size: .86rem; text-align: center; border-bottom: 1px solid var(--border); }
.aviso-offline { background: var(--warn-soft); color: var(--text); }
.aviso-ios { background: var(--info-soft); color: var(--text); }
.aviso-ios .btn { margin-left: .4rem; }
.aviso-passos { text-align: left; }
.aviso-passos p, .aviso-passos ul { max-width: 640px; margin: .3rem auto; }
.aviso-passos ul { padding-left: 1.2rem; }
.aviso-passos li { margin: .2rem 0; }
/* Lista de concursos das páginas para o Google (/concursos/). */
.seo-lista { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .5rem; }
.seo-lista li { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .7rem .9rem; }
.seo-lista a { font-weight: 700; text-decoration: none; }
.seo-lista small { display: block; color: var(--muted); margin-top: .15rem; }
.aviso-passos .obs { color: var(--muted); font-size: .82rem; }
.aviso-passos .detectado { background: var(--warn-soft); border-radius: 8px; padding: .45rem .6rem; }
.aviso-passos .btn { display: block; margin: .5rem auto .2rem; }
.topnav a { padding: .45rem .8rem; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .92rem; }
.topnav a.active, .topnav a:hover { background: var(--primary-soft); color: var(--primary); }
.topnav a { white-space: nowrap; }
/* Celular: marca numa linha e menu na outra, para o botão "Instalar app" não ficar cortado. */
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; row-gap: .4rem; padding-top: .5rem; padding-bottom: .5rem; }
  .topnav { width: 100%; }
  .topnav a { padding: .4rem .7rem; }
  .topnav #instalar { margin-left: auto; }
}

main { flex: 1; width: 100%; max-width: 1160px; margin: 0 auto; padding: 1.25rem 16px 2rem; outline: none; }
.footer { color: var(--muted); font-size: .82rem; text-align: center; padding: 1rem 16px 2rem; border-top: 1px solid var(--border); }
.footer p { max-width: 760px; margin: 0 auto; }

/* Cards & layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; }
.stack > * + * { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.two-col { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 860px) { .two-col { grid-template-columns: minmax(0, 1fr); } }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

/* Hero / stats */
.hero { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: end; margin-bottom: 1rem; }
.hero p { margin: 0; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.stat:hover { border-color: var(--primary); }
.stat b { display: block; font-size: 1.6rem; }
.stat span { color: var(--muted); font-size: .85rem; }

/* Filters */
.filters { display: grid; gap: .6rem; grid-template-columns: 2fr repeat(3, 1fr); margin-bottom: .6rem; }
.filters-2 { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 1rem; align-items: center; }
.cargos { list-style: none; margin: 0; padding: 0; display: grid; }
.cargos li { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; padding: .35rem 0; border-bottom: 1px dashed var(--border); font-size: .86rem; }
.cargos li:last-child { border-bottom: none; }
.cargos li b { font-weight: 600; }
.cargos li small { display: block; color: var(--muted); font-size: .74rem; }
.cargos .sal { font-weight: 700; color: var(--ok); text-align: right; font-size: .84rem; max-width: 50%; white-space: normal; }
.cargos li.mais { color: var(--muted); font-size: .8rem; }
.cargos li small.form { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: .1rem; }

/* Formação exigida na tabela de cargos */
tr.has-sub td { border-bottom: none; padding-bottom: .2rem; }
tr.sub td { padding-top: 0; font-size: .82rem; color: var(--muted); }
tr.sub .rot { font-weight: 600; color: var(--text); }

/* Edital embutido */
.edital-pdf { display: block; width: 100%; height: 78vh; min-height: 420px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2, transparent); margin-bottom: .8rem; }
.edital-pdf p { padding: 1rem; }
.edital-abas { margin-bottom: .8rem; }
.edital-abas .btn.on { border-color: var(--primary); color: var(--primary); font-weight: 600; }
@media (max-width: 860px) {
  .filters, .filters-2 { grid-template-columns: 1fr 1fr; }
  .filters .search { grid-column: 1 / -1; }
}
label.field { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; color: var(--muted); font-weight: 600; }
input, select, button, textarea { font: inherit; color: inherit; }
input[type=text], input[type=search], input[type=date], input[type=number], select {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font-size: .95rem;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .8rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: .88rem; font-weight: 600; white-space: nowrap; }
.chip[aria-pressed=true] { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .6rem 1rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; font-weight: 600; cursor: pointer; font-size: .92rem; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0f1420; } }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary:hover { color: #0f1420; } }
.btn.ghost { background: transparent; }
.btn.sm { padding: .35rem .7rem; font-size: .84rem; }
.iconbtn { border: none; background: transparent; cursor: pointer; font-size: 1.25rem; line-height: 1; padding: .2rem; color: var(--muted); }
.iconbtn.on { color: #e6a700; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--neutral-soft); color: var(--muted); white-space: nowrap; }
.badge.aberto { background: var(--ok-soft); color: var(--ok); }
.badge.edital_publicado { background: var(--primary-soft); color: var(--primary); }
.badge.autorizado { background: var(--info-soft); color: var(--info); }
.badge.previsto { background: var(--warn-soft); color: var(--warn); }
.badge.encerrado { background: var(--neutral-soft); color: var(--muted); }
.badge.exemplo { background: var(--danger-soft); color: var(--danger); }
.badge.outline { background: transparent; border: 1px solid var(--border); color: var(--muted); font-weight: 600; }

/* Concurso card */
.ccard { position: relative; display: flex; flex-direction: column; gap: .6rem; text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
.ccard:hover, .ccard:focus-within { border-color: var(--primary); transform: translateY(-1px); }
/* Link "esticado": o título cobre o card inteiro; o botão de favorito fica por cima (são irmãos, não aninhados). */
.ccard-link { color: inherit; text-decoration: none; }
.ccard-link::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.ccard-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
@supports selector(:has(a)) {
  .ccard-link:focus-visible { outline: none; }
  .ccard:has(.ccard-link:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
}
.ccard .iconbtn { position: relative; z-index: 1; }
.ccard .head { display: flex; justify-content: space-between; gap: .5rem; align-items: start; }
.ccard .org { font-size: .82rem; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .02em; }
.ccard h3 { font-size: 1.05rem; margin: .1rem 0 0; }
.ccard .meta { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem .8rem; font-size: .84rem; }
.ccard .meta div span { color: var(--muted); display: block; font-size: .74rem; }
.countdown { font-size: .86rem; font-weight: 600; padding: .5rem .7rem; border-radius: 10px; background: var(--surface-2); }
.countdown.urgente { background: var(--danger-soft); color: var(--danger); }
.countdown.ok { background: var(--ok-soft); color: var(--ok); }

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }

/* Detail */
.back { display: inline-block; margin-bottom: .8rem; text-decoration: none; font-weight: 600; font-size: .9rem; }
.detail-head { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: start; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin-top: 1rem; }
@media (max-width: 700px) { .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fact { background: var(--surface-2); border-radius: 10px; padding: .6rem .8rem; }
.fact span { display: block; font-size: .75rem; color: var(--muted); font-weight: 600; }
.fact b { font-size: 1rem; }

.timeline { list-style: none; padding: 0; margin: .5rem 0 0; }
.timeline li { position: relative; padding: 0 0 .9rem 1.4rem; border-left: 2px solid var(--border); margin-left: .4rem; }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: .25rem; width: 12px; height: 12px; border-radius: 50%; background: var(--border); }
.timeline li.done::before { background: var(--ok); }
.timeline li.now::before { background: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.timeline b { display: block; font-size: .92rem; }
.timeline span { font-size: .84rem; color: var(--muted); }

.bars { display: flex; flex-direction: column; gap: .55rem; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 1.2fr) 2fr auto; gap: .6rem; align-items: center; font-size: .86rem; }
.bar-track { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--primary); }
.bar-row .val { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 92px; text-align: right; }
.trend-up { color: var(--ok); font-weight: 700; }
.trend-down { color: var(--danger); font-weight: 700; }

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.table-wrap { overflow-x: auto; }

ul.tips { margin: .4rem 0 0; padding-left: 1.1rem; }
ul.tips li { margin-bottom: .35rem; font-size: .9rem; }
.callout { border-left: 4px solid var(--warn); background: var(--warn-soft); padding: .7rem .9rem; border-radius: 8px; font-size: .88rem; }
.callout.info { border-color: var(--primary); background: var(--primary-soft); }

/* Plano */
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.level-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .5rem .9rem; margin-top: .6rem; }
.level { display: grid; grid-template-columns: 1fr auto; gap: .2rem .6rem; align-items: center; background: var(--surface-2); padding: .55rem .75rem; border-radius: 10px; font-size: .86rem; }
.level input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--primary); }
.level output { font-weight: 700; color: var(--primary); font-size: .78rem; }

.progress { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--ok); transition: width .3s; }

.phase-strip { display: flex; border-radius: 10px; overflow: hidden; margin: .6rem 0; font-size: .78rem; font-weight: 700; }
.phase-strip div { padding: .45rem .6rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ph-base { background: #3d6bf0; }
.ph-aprof { background: #7a52e0; }
.ph-final { background: #d9822b; }

.week { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: .75rem; overflow: hidden; }
.week > summary { list-style: none; cursor: pointer; padding: .8rem 1rem; display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; }
.week > summary::-webkit-details-marker { display: none; }
.week > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.week[open] > summary::before { transform: rotate(90deg); }
.week.current { border-color: var(--primary); }
.week .wbody { padding: 0 1rem 1rem; display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.day { background: var(--surface-2); border-radius: 10px; padding: .6rem .7rem; }
.day h4 { margin: 0 0 .4rem; font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.session { display: flex; gap: .5rem; align-items: start; padding: .35rem 0; font-size: .86rem; border-top: 1px dashed var(--border); }
.session:first-of-type { border-top: none; }
.session input { margin-top: .2rem; accent-color: var(--ok); width: 16px; height: 16px; flex: none; }
.session.done .s-txt { text-decoration: line-through; color: var(--muted); }
.s-txt b { display: block; }
.s-type { font-size: .72rem; font-weight: 700; padding: .05rem .4rem; border-radius: 6px; margin-right: .3rem; }
.t-teoria { background: var(--primary-soft); color: var(--primary); }
.t-questoes { background: var(--info-soft); color: var(--info); }
.t-revisao { background: var(--ok-soft); color: var(--ok); }
.t-simulado { background: var(--warn-soft); color: var(--warn); }

.plan-list .card { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }

@media print {
  .topbar, .footer, .no-print { display: none !important; }
  .week { break-inside: avoid; }
  .week > summary::before { display: none; }
  body { background: #fff; }
}
