:root {
  --ink: #11243b;
  --ink-soft: #40556f;
  --muted: #64748b;
  --line: #dbe3ee;
  --panel: #ffffff;
  --canvas: #f3f6fb;
  --brand: #176e62;
  --brand-dark: #0f554c;
  --brand-soft: #e5f5f1;
  --accent: #c2410c;
  --danger: #a4262c;
  --shadow: 0 10px 30px rgba(17, 36, 59, .08);
  --radius: 14px;
  --blue: #194f8a;
  --red: #923442;
  --green: #216047;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.55 "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 8% 0%, #e9f4f1 0, transparent 32rem), var(--canvas);
  min-height: 100vh;
}
[hidden] { display: none !important; }
a { color: var(--brand-dark); }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .55rem; letter-spacing: -.01em; }
h1 { font-size: clamp(1.55rem, 2.6vw, 2.25rem); }
h2 { font-size: clamp(1.25rem, 1.9vw, 1.65rem); }
h3 { font-size: 1.05rem; }
p { margin: .45rem 0; }
small, .muted { color: var(--muted); }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.eyebrow { text-transform: uppercase; letter-spacing: .11em; font-size: .72rem; font-weight: 700; color: var(--brand); margin-bottom: .35rem; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .85rem clamp(1rem, 3vw, 2.2rem);
  background: rgba(17, 36, 59, .96);
  color: #fff;
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,.09);
}
.brand { color: #fff; text-decoration: none; font-size: 1.42rem; font-weight: 650; letter-spacing: -.02em; }
.brand b { color: #56d9bb; }
.brand .version { font-size: .66rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #b9c8d8; margin-left: .4rem; }
.header-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.header-actions .button, .header-actions button { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.22); color: #fff; }
.button, button, select, input, textarea { font: inherit; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  cursor: pointer; border: 1px solid #c8d4e2; border-radius: 9px;
  padding: .62rem .9rem; background: #fff; color: var(--ink); text-decoration: none;
  font-weight: 600; line-height: 1.1;
  transition: background .16s ease, border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}
button:hover, .button:hover { border-color: #9fb1c7; box-shadow: 0 3px 10px rgba(17,36,59,.09); }
button:active, .button:active { transform: translateY(1px); }
button:disabled, .button[aria-disabled="true"] { opacity: .5; cursor: not-allowed; box-shadow: none; }
button.primary, .button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover, .button.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
button.ghost { background: transparent; }
button.small, .button.small { padding: .45rem .65rem; font-size: .82rem; }
button.danger { color: var(--danger); border-color: #e7b7ba; background: #fff7f7; }
button.danger:hover { background: #ffecee; }
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .24rem .6rem; border-radius: 999px; font-size: .74rem; font-weight: 700;
  background: var(--brand-soft); color: var(--brand-dark); border: 1px solid #bfe4db;
}
.badge.warn { background: #fff4e5; color: #9a4b00; border-color: #f4d3a8; }
.badge.off { background: #eef1f6; color: var(--muted); border-color: #d9e0ea; }

/* Layout */
main { width: 100%; }
.auth-shell {
  width: min(1160px, calc(100% - 2rem));
  margin: clamp(1.4rem, 5vw, 4rem) auto;
  display: grid; grid-template-columns: 1.15fr .85fr; gap: clamp(1rem, 3vw, 2.4rem);
  align-items: center;
}
.hero { padding: .5rem; }
.hero h1 { max-width: 15ch; }
.hero > p { color: var(--ink-soft); font-size: 1.02rem; max-width: 60ch; }
.feature-list { margin: 1.1rem 0; padding: 0; list-style: none; display: grid; gap: .5rem; }
.feature-list li { position: relative; padding-left: 1.45rem; color: var(--ink-soft); }
.feature-list li::before { content: "✓"; position: absolute; left: 0; color: var(--brand); font-weight: 800; }
.auth-card { width: 100%; box-shadow: var(--shadow); }
.legal { font-size: .77rem; color: var(--muted); line-height: 1.45; }
.workspace-shell {
  width: min(1320px, calc(100% - 2rem));
  margin: 1.2rem auto 3rem;
  display: grid; grid-template-columns: 215px minmax(0, 1fr); gap: 1.2rem;
  align-items: start;
}
.workspace-shell > * { min-width: 0; }
.sidebar { position: sticky; top: 4.6rem; min-width: 0; }
#nav { display: grid; gap: .25rem; min-width: 0; }
#nav button {
  width: 100%; justify-content: flex-start; background: transparent; border-color: transparent;
  color: var(--ink-soft); padding: .58rem .7rem; font-size: .88rem;
}
#nav button:hover { background: #eaf0f8; color: var(--ink); box-shadow: none; }
.sidebar-note { margin-top: 1rem; padding: .8rem; border: 1px dashed #cbd7e6; border-radius: 10px; font-size: .76rem; color: var(--muted); }
.content { min-width: 0; }
#notice { margin-bottom: .7rem; }
#notice:not(:empty) {
  padding: .7rem .9rem; border: 1px solid #f1d6a7; background: #fff8ec;
  color: #7c4a00; border-radius: 10px; font-size: .9rem;
}
#authoralSetting { margin: 0 0 .7rem; font-size: .84rem; color: var(--muted); }
#authoralSetting label { display: inline-flex; align-items: center; gap: .5rem; padding: .3rem .65rem; background: #fff; border: 1px solid var(--line); border-radius: 999px; }
section, .card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
section { padding: clamp(1rem, 2.4vw, 1.6rem); margin: 0 0 1rem; }
.card { padding: 1.1rem; margin: .8rem 0; }
.card > :first-child { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.row { display: flex; gap: .55rem; align-items: center; flex-wrap: wrap; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .7rem; }
.spacer { flex: 1; }
.stack { display: grid; gap: .55rem; }

/* Forms */
label { display: block; margin: .65rem 0; font-size: .88rem; font-weight: 600; color: var(--ink-soft); }
label > input, label > select, label > textarea { display: block; width: 100%; margin-top: .28rem; }
fieldset { border: 1px solid var(--line); border-radius: 11px; padding: .7rem .9rem; margin: .8rem 0; }
legend { font-size: .8rem; font-weight: 700; color: var(--ink-soft); padding: 0 .35rem; }
input, select, textarea {
  border: 1px solid #c7d3e2; border-radius: 9px; padding: .58rem .68rem;
  background: #fff; color: var(--ink); max-width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(23, 110, 98, .26); outline-offset: 1px; border-color: var(--brand);
}
textarea { width: 100%; min-height: 84px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--brand); }
label:has(> input[type="checkbox"]) { font-weight: 500; }
.filter-options { display: flex; gap: .35rem .95rem; flex-wrap: wrap; margin: .35rem 0; }
.filter-options label { margin: 0; font-weight: 500; display: inline-flex; align-items: center; gap: .35rem; }
#manualItems { display: grid; max-height: 19rem; overflow: auto; border: 1px solid var(--line); border-radius: 9px; padding: .5rem; }
.manual-row { display: flex; gap: .55rem; align-items: baseline; margin: .2rem 0; }
.manual-row input { flex: none; }
#individualPoints { display: grid; gap: .35rem; max-height: 22rem; overflow: auto; }
#individualPoints label { display: grid; grid-template-columns: minmax(0, 1fr) 7rem; align-items: center; gap: .6rem; margin: 0; font-weight: 500; }
#individualPoints input { width: 100%; }

/* Content blocks */
.item, article.question, .record, .student-row, .class-row, .plan-row, .material-row {
  border-bottom: 1px solid #e7ecf3; padding: .75rem 0;
}
.item:last-child, article.question:last-child { border-bottom: 0; }
.item h3, .item h4 { margin-bottom: .15rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem; }
.card h2 { font-size: 1.05rem; }
.bank-item, .question { line-height: 1.6; }
.question { border-bottom: 1px solid #cbd5e1; padding: .9rem 0; margin: .9rem 0; }
.question:last-child { border-bottom: 0; }
.question p { margin: .45rem 0; }
details > summary { cursor: pointer; font-weight: 650; color: var(--ink); padding: .3rem 0; }
details > summary:hover { color: var(--brand-dark); }
.explanation { background: #f0f7f5; padding: .7rem .9rem; margin-top: .6rem; border-left: 3px solid var(--brand); border-radius: 0 8px 8px 0; }
.explanation p { margin: .35rem 0; }
.visual { margin: .7rem 0; max-width: 520px; }
.visual svg { width: 100%; height: auto; }
.visual figcaption { font-size: .73rem; color: var(--muted); }
.visual table { border-collapse: collapse; width: 100%; }
.visual td, .visual th { border: 1px solid #94a3b8; padding: .45rem; text-align: center; }
.paper img, .visual img { display: block; max-width: 100%; max-height: 65mm; object-fit: contain; }
table.data { border-collapse: collapse; width: 100%; font-size: .86rem; overflow-wrap: anywhere; }
table.data th, table.data td { border-bottom: 1px solid var(--line); padding: .45rem .4rem; text-align: left; vertical-align: top; }
table.data th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.bar { height: .45rem; border-radius: 999px; background: #e6ecf4; overflow: hidden; min-width: 4rem; }
.bar > i { display: block; height: 100%; background: var(--brand); }
.stat { display: flex; flex-direction: column; gap: .1rem; padding: .65rem .75rem; background: #f7fafc; border: 1px solid var(--line); border-radius: 10px; }
.stat b { font-size: 1.25rem; }
.stat span { font-size: .74rem; color: var(--muted); }
.answer-line { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .18em; }
.notice-box { padding: .75rem .9rem; border-radius: 10px; background: #fff8ec; border: 1px solid #f1d6a7; color: #7c4a00; }
.notice-box.error { background: #fff3f3; border-color: #efc2c5; color: #8d2026; }
.hidden { display: none !important; }
.option { white-space: pre-wrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Academic paper */
.paper { background: #fff; padding: 1.1rem 0; }
.paper .code { font-size: .7rem; text-align: right; color: var(--muted); border-top: 4px solid var(--caderno, var(--ink)); padding-top: .35rem; letter-spacing: .03em; }
.paper h2 { margin: .35rem 0; }
.paper .option { margin: .2rem 0; }

/* Auth/reset */
.auth-card form { margin-top: .7rem; }
.auth-card .actions { justify-content: space-between; }
#licenseStatus, #claimStatus { font-size: .85rem; }
.status-good { color: var(--brand-dark); font-weight: 700; }
.status-bad { color: var(--danger); font-weight: 700; }

/* Responsive */
@media (max-width: 860px) {
  .auth-shell { grid-template-columns: 1fr; margin-top: 1.2rem; }
  .hero h1 { max-width: none; }
  .workspace-shell { grid-template-columns: 1fr; gap: .7rem; }
  .sidebar { position: static; }
  #nav { display: flex; overflow-x: auto; gap: .3rem; padding-bottom: .3rem; scrollbar-width: thin; }
  #nav button { width: auto; flex: 0 0 auto; white-space: nowrap; }
  .sidebar-note { display: none; }
  .grid { grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); }
  .grid.two { grid-template-columns: 1fr; }
  .header-actions .button, .header-actions button { padding: .42rem .58rem; font-size: .8rem; }
  .brand { font-size: 1.2rem; }
  #individualPoints label { grid-template-columns: 1fr; gap: .2rem; }
}
@media (max-width: 480px) {
  .workspace-shell { width: calc(100% - 1rem); }
  .auth-shell { width: calc(100% - 1rem); }
  section { padding: .85rem; }
  .card { padding: .85rem; }
  .header-actions .button[href="admin.html"] { display: none; }
  .paper { padding: .4rem 0; }
}

/* Print: somente o caderno/gabarito */
@media print {
  body { background: #fff; color: #000; font-size: 11.5pt; }
  .site-header, #authPanel, .sidebar, #notice, #authoralSetting, #toolbar, #home, #admin,
  #bank, #diagnostic, #simulator, #planning, #library, #classes, #license, #saved,
  #controls, #output > .no-print { display: none !important; }
  .workspace-shell { display: block; width: auto; margin: 0; }
  .content { padding: 0; margin: 0; }
  #output { border: 0; border-radius: 0; padding: 0; margin: 0; }
  #output[hidden] { display: none !important; }
  .paper { break-after: page; padding: 0; }
  .paper:last-child { break-after: auto; }
  .paper .code { border-top-width: 3px; }
  .question { break-inside: avoid; padding: .35rem 0; margin: .35rem 0; line-height: 1.38; }
  .question p { margin: .25rem 0; }
  .explanation { background: #fff; padding: .3rem .55rem; margin-top: .3rem; }
  .explanation p { margin: .2rem 0; }
  .visual { max-width: 430px; margin: .35rem 0; }
  .paper h2 { margin-bottom: .35rem; }
  a { color: #000; text-decoration: none; }
  @page { size: A4; margin: 14mm; }
}
