/* Simulador de Projetos — CSS sem build. Grade de 4px, uma cor de destaque, neutros de verdade. */
:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #16191d;
    --text-2: #4a525c;
    --text-3: #5f6873;          /* apagado: 5,6:1 sobre branco */
    --line: rgba(22, 25, 29, .09);
    --border: #8a929c;          /* borda de controle: 3,3:1 sobre branco */
    --accent: #1d4ed8;
    --accent-ink: #ffffff;
    --accent-soft: #e8eefc;
    --good: #15803d;
    --good-soft: #e7f5ec;
    --warn: #a15c07;
    --warn-soft: #fdf3e3;
    --bad: #b42318;
    --bad-soft: #fdecea;
    --radius: 12px;
    --radius-sm: 8px;
    --ease: cubic-bezier(.2, 0, 0, 1);
    font-size: 16px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 400 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 8px; font-weight: 600; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 12px; }
a { color: var(--accent); }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }

/* Estrutura */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 12px 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar .brand { font-weight: 600; font-size: .95rem; }
.topbar .meta { color: var(--text-3); font-size: .875rem; text-align: right; }
.page { max-width: 880px; margin: 0 auto; padding: 20px 16px 64px; }
.page.wide { max-width: 1200px; }
.stack > * + * { margin-top: 16px; }
.section + .section { margin-top: 32px; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
}
.card.flat { padding: 16px; }
.eyebrow { font-size: .8125rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; font-weight: 500; }
.muted { color: var(--text-2); }
.small { font-size: .875rem; }

/* Formulários */
label { display: block; font-weight: 500; margin-bottom: 6px; }
.field + .field { margin-top: 16px; }
.hint { color: var(--text-3); font-size: .875rem; margin-top: 4px; }
input[type=text], input[type=number], input[type=date], input[type=password] {
    width: 100%; min-height: 48px; padding: 10px 12px;
    font: inherit; font-size: 1rem; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
input:focus-visible, button:focus-visible, a:focus-visible, .option:focus-within {
    outline: 3px solid var(--accent); outline-offset: 2px;
}
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { width: 20px; height: 20px; margin-top: 2px; }
.error { color: var(--bad); font-size: .875rem; margin-top: 6px; }
.code-input { text-transform: uppercase; letter-spacing: .2em; font-weight: 600; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; padding: 10px 20px; border-radius: var(--radius-sm);
    font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
    border: 1px solid transparent; transition: background-color .14s var(--ease);
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #1e40af; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: wait; }

/* Avisos */
.notice { border-radius: var(--radius-sm); padding: 12px 16px; background: var(--accent-soft); color: #1e3a8a; }
.notice.warn { background: var(--warn-soft); color: #7a4405; }
.notice.bad { background: var(--bad-soft); color: #8a1c12; }
.notice.good { background: var(--good-soft); color: #11612e; }

/* Indicadores */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.kpi {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: 12px; min-width: 0;
}
.kpi .label { font-size: .8125rem; color: var(--text-3); }
.kpi .value { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .sub { font-size: .8125rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.kpi.good { border-left: 4px solid var(--good); }
.kpi.warn { border-left: 4px solid var(--warn); }
.kpi.bad { border-left: 4px solid var(--bad); }
.kpi .delta { font-size: .8125rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.zero { color: var(--text-3); }

/* Opções da rodada */
.options { display: grid; gap: 8px; }
.option {
    display: flex; gap: 12px; align-items: flex-start;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 14px 16px; cursor: pointer; transition: border-color .14s var(--ease), background-color .14s var(--ease);
}
.option:hover { border-color: var(--accent); }
.option input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.option .letter { font-weight: 700; color: var(--accent); margin-right: 4px; }
.option .chips { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
/* Consequências possíveis antes da escolha: recolhidas dentro da opção; tocar no resumo não marca a opção. */
.option > span { min-width: 0; flex: 1; }
.conseq { display: block; margin-top: 8px; font-size: .875rem; color: var(--text-2); }
.conseq summary { display: inline-flex; align-items: center; min-height: 32px; cursor: pointer; color: var(--accent); font-weight: 500; }
.conseq ul { margin: 4px 0 0; padding-left: 18px; }
.conseq li { margin: 4px 0; }
.conseq li.personal, .conseq-all { color: var(--text); }
.conseq-all { background: var(--warn-soft); border-radius: var(--radius-sm); padding: 10px 14px; margin: 0 0 8px; font-size: .875rem; }
.conseq-all ul { margin: 4px 0 0; padding-left: 18px; }
/* Projeto herdado (entrada tardia): cartão recolhível e marca nas decisões que não foram do aluno. */
.inherited { border-left: 4px solid var(--warn); }
.inherited summary { cursor: pointer; }
.tag-inherited { display: inline-block; margin-left: 6px; font-size: .75rem; padding: 1px 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.chip { font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--text-2); font-variant-numeric: tabular-nums; }

/* Tabelas */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 500; color: var(--text-3); font-size: .8125rem; white-space: nowrap; background: var(--bg); position: sticky; top: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.pos { color: var(--good); }
td.neg { color: var(--bad); }

/* Listas de leitura */
.outlook { margin: 0; padding-left: 20px; }
.outlook li + li { margin-top: 6px; }
.choices { list-style: none; margin: 0; padding: 0; }
.choices li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 12px; }
.choices li:last-child { border-bottom: 0; }
.choices .r { color: var(--text-3); font-size: .875rem; width: 40px; flex: none; font-variant-numeric: tabular-nums; }
.choices .l { font-weight: 700; color: var(--accent); width: 16px; flex: none; }

/* Painel do professor */
.prof-grid { display: grid; gap: 16px; }
.prof-grid > * { min-width: 0; } /* sem isso, tabelas largas estouram a tela do celular */
@media (min-width: 960px) { .prof-grid { grid-template-columns: 1.1fr 1fr; align-items: start; } }
.big-code { font-size: 2.5rem; font-weight: 700; letter-spacing: .15em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-row { display: flex; flex-wrap: wrap; gap: 24px; }
.stat .n { font-size: 1.75rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .t { font-size: .8125rem; color: var(--text-3); }
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 24px 1fr 32px; gap: 8px; align-items: center; }
.bar .track { background: var(--bg); border-radius: 4px; height: 24px; overflow: hidden; border: 1px solid var(--line); }
.bar .fill { background: var(--accent); height: 100%; transition: width .2s var(--ease); }
.bar .k { font-weight: 700; color: var(--accent); }
.bar .c { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.bar-label { font-size: .8125rem; color: var(--text-2); margin: -4px 0 4px 32px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); margin-right: 6px; vertical-align: middle; }
.dot.on { background: var(--good); }
.tag { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.tag.ok { background: var(--good-soft); color: #11612e; }
.tag.wait { background: var(--warn-soft); color: #7a4405; }

/* Opinião do especialista */
.expert-summary { background: var(--bg); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 12px; }
.expert-list { list-style: none; margin: 0; padding: 0; }
.expert-item { padding: 12px 0; border-top: 1px solid var(--line); }
.expert-item p { margin: 6px 0 0; color: var(--text-2); }
.expert-item.is-chosen { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 12px; border-top-color: transparent; }
.expert-item.is-chosen p { color: var(--text); }
.expert-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.expert-head .letter { font-weight: 700; color: var(--accent); }
.expert-label { font-weight: 500; flex: 1 1 200px; }
.verdict { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.v-recomendada { background: var(--good-soft); color: #11612e; }
.v-defensavel { background: var(--accent-soft); color: #1e3a8a; }
.v-arriscada { background: var(--warn-soft); color: #7a4405; }
.v-nao_recomendada { background: var(--bad-soft); color: #8a1c12; }

/* Documentação */
.doc { max-width: 820px; margin: 0 auto; }
.doc-toc ol { margin: 8px 0 0; padding-left: 20px; columns: 2 240px; column-gap: 32px; }
.doc-toc li { margin: 4px 0; break-inside: avoid; }
.doc-section { margin-top: 40px; scroll-margin-top: 16px; }
.doc-section h1 { font-size: 1.5rem; padding-top: 24px; border-top: 1px solid var(--line); }
.doc-section h2 { font-size: 1.125rem; margin-top: 28px; }
.doc-section h3 { margin-top: 20px; }
.doc-section p, .doc-section li { max-width: 72ch; }
.doc-section ul, .doc-section ol { padding-left: 20px; }
.doc-section li + li { margin-top: 4px; }
.doc-section table { display: block; overflow-x: auto; margin: 12px 0 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.doc-section table th { position: static; }
.doc-section blockquote { margin: 16px 0; padding: 12px 16px; background: var(--accent-soft); border-radius: var(--radius-sm); color: #1e3a8a; }
.doc-section blockquote p { margin: 0; }
.doc-section pre { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 16px; overflow-x: auto; font-size: .8125rem; line-height: 1.5; }
.doc-top { font-size: .875rem; margin-top: 12px; }
.topbar a.top-link { font-size: .875rem; font-weight: 500; white-space: nowrap; }

/* Variantes: por que esta opção está diferente para o aluno */
.because { display: block; margin-top: 4px; font-size: .8125rem; color: var(--text-3); }
.expert-variant { margin: 10px 0 0 16px; padding-left: 12px; border-left: 3px solid var(--line); }
.expert-variant .expert-label { font-weight: 500; font-size: .875rem; }
.variants { list-style: none; margin: 2px 0 6px 28px; padding: 0; font-size: .8125rem; color: var(--text-2); }
.variants li { margin-top: 2px; }

/* Tratamento de riscos no checkpoint */
fieldset.risk { border: 0; padding: 0; margin: 16px 0 0; min-width: 0; }
fieldset.risk legend { padding: 0; margin-bottom: 4px; }
.option.off { opacity: .6; cursor: not-allowed; background: var(--bg); }
.option.off:hover { border-color: var(--border); }
.status { font-weight: 600; color: var(--text-2); }
.status.s-aberto, .status.s-perdida { color: var(--bad); }
.status.s-mitigado, .status.s-transferido, .status.s-aproveitada, .status.s-expirado { color: var(--good); }
.risk-dist { margin: 8px 0 0; padding-left: 18px; font-size: .875rem; }
.risk-dist li + li { margin-top: 4px; }

/* Recuperação do atraso no checkpoint */
.recover-grid { display: grid; gap: 12px; margin-top: 12px; }
.lever { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; background: var(--surface); }
.lever label { font-weight: 600; display: block; }
.lever .hint { margin: 4px 0 8px; }
.lever input[type=number] { width: 96px; font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.lever.off { opacity: .6; }
.recover-sum { margin-top: 12px; padding: 12px; border-radius: var(--radius-sm); background: var(--bg); font-variant-numeric: tabular-nums; }

/* Termos técnicos: o termo é um botão (funciona com toque); o balão abre abaixo dele */
.term { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: help;
    text-decoration: underline dotted var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; display: inline; text-align: inherit; }
.term:hover, .term[aria-expanded="true"] { color: var(--accent); }
.term-pop { position: absolute; z-index: 50; max-width: min(340px, calc(100vw - 24px)); background: var(--text); color: #fff;
    border-radius: var(--radius-sm); padding: 12px 14px; font-size: .875rem; line-height: 1.45; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.term-pop strong { display: block; margin-bottom: 4px; }
.term-pop p { margin: 0; }
.term-pop button { position: absolute; top: 4px; right: 4px; background: none; border: 0; color: #fff; font-size: 1.25rem; line-height: 1; padding: 4px 8px; cursor: pointer; }
.terms summary { cursor: pointer; font-weight: 500; }
.terms dl { margin: 12px 0 0; }
.terms dt { font-weight: 600; margin-top: 10px; }
.terms dt:first-child { margin-top: 0; }
.terms dd { margin: 2px 0 0; color: var(--text-2); }

@media print {
    .topbar, .doc-toc .btn, .doc-top, .term-pop { display: none; }
    .term { text-decoration: none; }
    body { background: #fff; }
    .page { padding: 0; max-width: none; }
    .doc-section { break-before: page; margin-top: 0; }
    .doc-section table { display: table; }
    a { color: inherit; text-decoration: none; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
