:root {
  --navy: #0e2a3d;
  --navy-2: #163a52;
  --teal: #0d7377;
  --teal-d: #095c5f;
  --teal-soft: #e6f3f3;
  --paper: #f3f6f8;
  --surface: #ffffff;
  --ink: #14202b;
  --muted: #5a6b7a;
  --line: #d5dee6;
  --ok: #1f7a4d;
  --warn: #9a6b16;
  --danger: #9b2c2c;
  --shadow: 0 10px 28px rgba(14, 42, 61, 0.07);
  --radius: 12px;
  --font-ui: "Manrope", "Segoe UI", system-ui, sans-serif;
  --font-text: "Literata", Georgia, "Times New Roman", serif;
}

html, body { height: 100%; }
body.app-body {
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(13, 115, 119, 0.10), transparent 55%),
    radial-gradient(700px 380px at -5% 0%, rgba(14, 42, 61, 0.08), transparent 50%),
    var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
}

.brand-sans, .sidebar, .btn, .form-control, .form-select, .nav-link, table, .badge, .topbar {
  font-family: var(--font-ui);
}

.sidebar {
  width: 268px;
  background: linear-gradient(185deg, var(--navy) 0%, #0a1f2e 100%);
  min-height: 100vh;
  color: #e8eef4;
  position: sticky;
  top: 0;
  flex-shrink: 0;
}
.sidebar a {
  color: #d5e2ec;
  text-decoration: none;
  display: flex;
  gap: .65rem;
  align-items: center;
  padding: .5rem .9rem;
  border-radius: 10px;
  transition: background .15s ease, color .15s ease;
}
.sidebar a:hover, .sidebar a.active {
  background: rgba(255,255,255,.09);
  color: #fff;
}
.escola-contexto {
  background: rgba(255,255,255,.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,.18);
  font-size: .8rem;
}
.escola-contexto option { color: #1c2430; }
.sidebar .section-label {
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #8aa4b8;
  margin: 1.1rem .9rem .35rem;
}

.topbar {
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-weight: 700; letter-spacing: -0.02em; }

.card-soft {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
}
.stat .n {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.stat .label,
.stat .text-muted.small {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

.btn-teal {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
  font-weight: 600;
}
.btn-teal:hover { background: var(--teal-d); border-color: var(--teal-d); color: #fff; }

.table thead th {
  font-size: .72rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom-color: var(--line);
}

.login-wrap {
  min-height: 100vh;
  background:
    radial-gradient(1000px 480px at 12% -8%, #1a4a63, transparent 55%),
    linear-gradient(160deg, #0e2a3d, #0a1f2e 60%, #0d3739);
}
.login-card { max-width: 420px; }
.logo-dot {
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--teal); color: #fff;
  display: grid; place-items: center; font-weight: 800;
}
.school-logo {
  width: 36px; height: 36px; object-fit: contain;
  background: #fff; border-radius: 8px;
}

.feedback-box {
  background: #f7fbfb;
  border-left: 4px solid var(--teal);
  padding: 1rem 1.2rem;
  border-radius: 0 12px 12px 0;
  line-height: 1.55;
}

.tex-content { font-family: var(--font-text); }
.tex-content .katex { font-size: 1.05em; }
.tex-resumo { max-height: 3.4em; overflow: hidden; }
.tex-preview {
  min-height: 4.5rem;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: .75rem 1rem;
}
.tex-preview .katex-display { margin: .4rem 0; }

.sidebar-mobile { background: #0a1f2e; }
.sidebar-mobile a,
.offcanvas .sidebar-mobile a {
  color: #d5e2ec;
  text-decoration: none;
  display: flex;
  gap: .6rem;
  align-items: center;
  padding: .45rem .85rem;
  border-radius: 8px;
}
.sidebar-mobile a:hover, .sidebar-mobile a.active {
  background: rgba(255,255,255,.08);
  color: #fff;
}
.sidebar-mobile .section-label {
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #8aa4b8;
  margin: 1rem .85rem .35rem;
}

/* Pipeline / fluxo da prova */
.pipeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .65rem;
  margin-bottom: 1.25rem;
}
.pipeline-step,
a.pipeline-step {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .85rem .9rem;
  position: relative;
  min-height: 92px;
  color: var(--ink);
  text-decoration: none !important;
  box-shadow: var(--shadow);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
a.pipeline-step:hover,
a.pipeline-step:focus {
  color: var(--ink);
  text-decoration: none !important;
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(13, 115, 119, 0.12);
  transform: translateY(-1px);
}
.pipeline-step.is-done { border-color: #9ad0b8; background: #f3faf6; }
.pipeline-step.is-now {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(13, 115, 119, 0.15);
}
.pipeline-step .num {
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .08em;
  color: var(--muted);
  text-transform: uppercase;
}
.pipeline-step .title {
  font-weight: 700;
  margin-top: .15rem;
  color: var(--navy);
}
.pipeline-step .hint { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.pipeline-step a {
  text-decoration: none !important;
  color: inherit;
  display: block;
  height: 100%;
}

.hub-grid {
  display: grid;
  grid-template-columns: 1.4fr .9fr;
  gap: 1rem;
}
@media (max-width: 992px) {
  .pipeline { grid-template-columns: 1fr 1fr; }
  .hub-grid { grid-template-columns: 1fr; }
}

.prova-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: .55rem;
  height: 100%;
}
.prova-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}
.prova-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  font-size: .8rem;
  color: var(--muted);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: #eef3f6;
  color: var(--navy);
  font-size: .72rem;
  font-weight: 600;
}
.chip.ok { background: #e5f6ec; color: var(--ok); }
.chip.warn { background: #fff4d6; color: var(--warn); }
.chip.teal { background: var(--teal-soft); color: var(--teal-d); }

.banco-topo.sticky-filtros {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(243, 246, 248, 0.94);
  backdrop-filter: blur(8px);
  padding: .35rem 0 .75rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: .85rem !important;
}
.banco-grade {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: .85rem;
}
.banco-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .95rem;
  display: flex;
  flex-direction: column;
  gap: .65rem;
  min-height: 100%;
  transition: transform .15s ease, box-shadow .15s ease;
}
.banco-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.banco-card-meta { display: flex; flex-wrap: wrap; gap: .35rem; }
.banco-card-body { display: flex; gap: .65rem; align-items: flex-start; flex: 1; }
.banco-resumo {
  font-family: var(--font-text);
  font-size: .95rem;
  line-height: 1.4;
  color: #243140;
}
.banco-card-actions { display: flex; flex-wrap: wrap; gap: .4rem; }

.picker-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
.picker-bar {
  position: sticky;
  bottom: .75rem;
  z-index: 15;
  background: rgba(14, 42, 61, 0.95);
  color: #fff;
  border-radius: 14px;
  padding: .75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  box-shadow: 0 12px 30px rgba(14, 42, 61, 0.25);
}
.picker-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: .75rem;
  align-items: start;
  padding: .85rem 0;
  border-bottom: 1px solid var(--line);
}
.picker-row:last-child { border-bottom: 0; }

.dropzone {
  border: 2px dashed #a9becd;
  border-radius: 16px;
  background: #f8fbfc;
  padding: 2rem 1.25rem;
  text-align: center;
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.dropzone.is-drag {
  border-color: var(--teal);
  background: var(--teal-soft);
}
.dropzone input[type=file] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.dropzone-wrap { position: relative; }

.status-dot {
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  display: inline-block;
  margin-right: .35rem;
}
.status-dot.pendente, .status-dot.processando { background: #c9842a; }
.status-dot.ok, .status-dot.concluido { background: var(--ok); }
.status-dot.revisao_manual, .status-dot.erro { background: var(--danger); }

.gabarito-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.2rem, 1fr));
  gap: .75rem;
}
.gabarito-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: .7rem .4rem .55rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.gabarito-num {
  font-size: .7rem;
  letter-spacing: .06em;
  color: var(--muted);
  text-transform: uppercase;
}
.gabarito-letra {
  font-size: 2.15rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--teal);
}
.gabarito-letra.discursiva {
  color: var(--warn);
  font-size: 1.6rem;
}
.gabarito-hint { font-size: .65rem; color: #8aa4b8; }

.q-figura {
  display: block;
  max-width: 100%;
  max-height: 220px;
  width: auto;
  height: auto;
  border-radius: 8px;
  object-fit: contain;
  background: #eef3f6;
}
.q-figura-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  background: #eef3f6;
  flex-shrink: 0;
}
.q-figura-lg { max-height: 420px; width: 100%; background: #fff; }
.questao-ver { max-width: 920px; }
.questao-ver-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--paper);
  padding: .4rem 0 .85rem;
}
.questao-enunciado {
  font-family: var(--font-text);
  font-size: 1.12rem;
  line-height: 1.65;
  white-space: pre-wrap;
}
.q-galeria {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 1rem;
}
.q-galeria-item {
  margin: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: .75rem;
}
.q-galeria-btn {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: #eef3f6;
  border-radius: 12px;
  cursor: zoom-in;
  overflow: hidden;
}
.q-galeria-btn img {
  display: block;
  width: 100%;
  max-height: 520px;
  height: auto;
  object-fit: contain;
  background: #eef3f6;
}
.q-galeria-item figcaption {
  font-size: .85rem;
  color: var(--muted);
  margin-top: .5rem;
  text-align: center;
}
.q-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1080;
  background: rgba(12, 24, 36, .92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 3.5rem 4rem;
}
.q-lightbox img {
  max-width: min(96vw, 1200px);
  max-height: calc(100vh - 7rem);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
  background: #111;
}
.q-lightbox-fechar,
.q-lightbox-nav {
  position: absolute;
  border: 0;
  background: rgba(255,255,255,.12);
  color: #fff;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  font-size: 1.8rem;
  line-height: 1;
}
.q-lightbox-fechar { top: 1rem; right: 1rem; }
.q-lightbox-prev { left: .8rem; }
.q-lightbox-next { right: .8rem; }
.q-lightbox-legenda {
  position: absolute;
  bottom: 1rem;
  left: 0;
  right: 0;
  text-align: center;
  color: #e8eef4;
  margin: 0;
}
body.q-lightbox-open { overflow: hidden; }
.q-alt {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .7rem .9rem;
  background: #fff;
}
.q-alt-ok {
  border-color: #9ad0b8;
  background: #f1faf5;
}

@media (display-mode: standalone) {
  .topbar { padding-top: calc(.75rem + env(safe-area-inset-top)); }
}

@media (prefers-reduced-motion: reduce) {
  .banco-card, .sidebar a { transition: none; }
}
