:root {
  --bg: #f5f8fc;
  --card: #ffffff;
  --text: #243247;
  --muted: #637083;
  --primary: #3f6fe5;
  --primary-dark: #2f58bd;
  --border: #dce4ef;
  --danger: #b42318;
  --ok: #237a4b;
  --shadow: 0 8px 30px rgba(28, 44, 70, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px max(20px, calc((100vw - 1200px)/2));
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.topbar a {
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
}

.topbar nav {
  display: flex;
  gap: 18px;
}

.brand { font-size: 1.25rem; }

.container {
  max-width: 1200px;
  margin: 28px auto;
  padding: 0 18px 60px;
}

.hero {
  text-align: center;
  margin: 50px auto 30px;
}

.hero h1 {
  font-size: clamp(2.2rem, 6vw, 4.2rem);
  margin-bottom: 8px;
}

.hero p {
  font-size: 1.25rem;
  color: var(--muted);
}

.card, .reading-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 24px;
}

.big-card {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.narrow {
  max-width: 500px;
  margin: 80px auto;
}

.center { text-align: center; }

label {
  display: block;
  font-weight: 700;
  margin: 18px 0 8px;
}

input, select, textarea {
  width: 100%;
  padding: 14px 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font: inherit;
  background: #fff;
  color: var(--text);
}

textarea { resize: vertical; }

.btn {
  display: inline-block;
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  background: #e8edf6;
  color: var(--text);
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover { background: var(--primary-dark); }

.btn.giant {
  display: block;
  width: 100%;
  padding: 20px;
  font-size: 1.3rem;
  margin-top: 28px;
}

.btn.small {
  padding: 7px 10px;
  font-size: .88rem;
}

.flash {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 14px;
  background: #eef3fb;
}

.flash.erro { color: var(--danger); }
.flash.ok { color: var(--ok); }

.training-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 20px;
}

.training-head h1 { margin-bottom: 4px; }
.training-head p { margin: 0; color: var(--muted); }

.timer {
  font-size: clamp(2.2rem, 7vw, 5rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  padding: 12px 24px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--border);
}

.timer.warning {
  color: var(--danger);
}

.countdown {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(20, 29, 45, .92);
  color: white;
  font-size: min(45vw, 16rem);
  font-weight: 900;
}

.hidden { display: none !important; }

.reading-card {
  min-height: 300px;
}

.reading-card #text {
  font-family: Arial, sans-serif;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.8;
  white-space: pre-wrap;
}

.reading-card.locked {
  opacity: .32;
  user-select: none;
  pointer-events: none;
}

.reading-card.active {
  opacity: 1;
  pointer-events: none;
  user-select: none;
}

.reading-card.select-last {
  opacity: 1;
}

.reading-card.select-last .word {
  cursor: pointer;
  border-radius: 6px;
  padding: 1px 2px;
}

.reading-card.select-last .word:hover {
  background: #e7efff;
}

.word.chosen {
  background: #cfe0ff !important;
  outline: 3px solid var(--primary);
}

.large { font-size: 1.25rem; }

.score {
  font-size: 6rem;
  font-weight: 900;
  margin: 10px 0 20px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
}

th {
  background: #f7f9fc;
}

.inline-form {
  display: flex;
  gap: 6px;
  align-items: center;
}

.error-input {
  width: 80px;
  padding: 7px 8px;
}

@media (max-width: 720px) {
  .admin-grid { grid-template-columns: 1fr; }
  .training-head { align-items: flex-start; flex-direction: column; }
  .timer { width: 100%; text-align: center; }
  .topbar { align-items: flex-start; gap: 10px; }
}

.mode-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; margin-top:8px; }
.mode-card { margin:0; padding:16px; border:2px solid var(--border); border-radius:14px; cursor:pointer; display:flex; gap:10px; align-items:flex-start; }
.mode-card input { width:auto; margin-top:4px; }
.mode-card span { display:grid; gap:4px; }
.mode-card small, .muted { color:var(--muted); }
.filter-grid { display:grid; grid-template-columns:1fr 1fr 1fr auto; gap:14px; align-items:end; }
.filter-actions { display:flex; gap:8px; align-items:center; }
.chart-wrap { height:340px; }
.badge { display:inline-block; border-radius:999px; padding:5px 9px; font-size:.82rem; font-weight:800; }
.badge.treino { background:#eaf7ef; color:#237a4b; }
.badge.avaliacao { background:#e8efff; color:#315cb5; }
.result-form { display:grid; grid-template-columns:72px minmax(180px,1fr) auto; gap:6px; align-items:center; min-width:330px; }
.observation-input { min-width:180px; padding:7px 8px; }
@media (max-width:850px) {
  .mode-grid, .filter-grid { grid-template-columns:1fr; }
  .result-form { grid-template-columns:70px 1fr; }
  .result-form .btn { grid-column:1 / -1; }
}


.local-chart {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  min-height: 330px;
  overflow-x: auto;
  padding: 28px 10px 8px;
  border-bottom: 1px solid var(--border);
}

.chart-column {
  flex: 0 0 68px;
  display: grid;
  grid-template-rows: 24px 220px auto auto;
  align-items: end;
  text-align: center;
}

.chart-value {
  font-weight: 900;
  font-size: .95rem;
  margin-bottom: 5px;
}

.chart-bar-wrap {
  height: 220px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.chart-bar {
  width: 36px;
  min-height: 8px;
  background: var(--primary);
  border-radius: 9px 9px 3px 3px;
}

.chart-label {
  margin-top: 8px;
  font-size: .78rem;
  font-weight: 700;
}

.chart-type {
  margin-top: 2px;
  font-size: .68rem;
  color: var(--muted);
}

@media (max-width: 720px) {
  .local-chart { gap: 8px; }
  .chart-column { flex-basis: 58px; }
  .chart-bar { width: 30px; }
}


.user-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef3fb;
  font-size: .9rem;
  font-weight: 700;
}

.login-title {
  text-align: center;
  margin-bottom: 20px;
}

.login-title h1 {
  margin: 6px 0 4px;
}

.login-title p {
  margin: 0;
  color: var(--muted);
}

.login-icon {
  font-size: 3rem;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.panel-heading h1 {
  margin-bottom: 4px;
}

.admin-highlight {
  border-width: 2px;
}

.teacher-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.teacher-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  background: #fbfcfe;
}

.teacher-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.check-list {
  display: grid;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  margin: 8px 0 14px;
  max-height: 190px;
  overflow-y: auto;
}

.check-list.compact {
  max-height: 150px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 5px;
  font-weight: 600;
}

.check-item input {
  width: auto;
}

.teacher-actions {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.teacher-actions form:first-child {
  display: flex;
  gap: 6px;
}

.inline-create {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 14px;
  align-items: end;
}

.align-end {
  align-self: end;
}

.scope-note {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #eef3fb;
  color: var(--muted);
}

.badge.inactive {
  background: #f2f2f2;
  color: #666;
}

.error-code {
  font-size: 5rem;
  font-weight: 900;
  line-height: 1;
  color: var(--primary);
}

@media (max-width: 850px) {
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-create {
    grid-template-columns: 1fr;
  }

  .teacher-actions form:first-child {
    display: grid;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar nav {
    flex-wrap: wrap;
  }
}


.class-code-input {
  text-transform: uppercase;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: .08em;
}

.public-help {
  text-align: center;
  color: var(--muted);
  margin-top: 16px;
}

.compact-hero {
  margin-top: 25px;
}

.secondary-actions {
  text-align: center;
  margin-top: 16px;
}

.class-code-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.class-code-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: #fbfcfe;
}

.class-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: .08em;
  margin-top: 5px;
  color: var(--primary);
}


.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-heading h2,
.section-heading p {
  margin-top: 0;
}

.report-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 12px;
}

.metric-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: #fbfcfe;
  display: grid;
  gap: 4px;
}

.metric-card span {
  font-size: .84rem;
  color: var(--muted);
}

.metric-card strong {
  font-size: 2rem;
}

.metric-card small {
  color: var(--muted);
}

.report-body {
  background: #fff;
}

.report-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px;
}

.report-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: 24px;
}

.report-header {
  display: flex;
  justify-content: space-between;
  gap: 25px;
  align-items: flex-end;
  padding-bottom: 20px;
  border-bottom: 2px solid #222;
}

.report-header h1 {
  margin-bottom: 3px;
}

.report-header p {
  margin: 0;
}

.report-student {
  text-align: right;
  display: grid;
}

.report-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 24px 0;
}

.report-stats > div {
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 13px;
  display: grid;
}

.report-stats span,
.report-stats small {
  color: #555;
}

.report-stats strong {
  font-size: 1.7rem;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.report-table th,
.report-table td {
  border: 1px solid #ccc;
  padding: 8px;
  vertical-align: top;
}

.report-footer {
  margin-top: 28px;
  color: #666;
  font-size: .8rem;
  text-align: center;
}

@media (max-width: 850px) {
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .report-stats {
    grid-template-columns: 1fr 1fr;
  }
}

@media print {
  .no-print {
    display: none !important;
  }

  .report-page {
    max-width: none;
    padding: 0;
  }

  .report-table {
    font-size: 10pt;
  }

  @page {
    margin: 14mm;
  }
}


.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 16px;
}

.library-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  background: #fbfcfe;
  display: grid;
  gap: 12px;
}

.library-card h3 {
  margin: 7px 0 3px;
}

.library-card p {
  margin: 0;
}

.library-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge.neutral {
  background: #f0f2f5;
  color: #4b5563;
}

.badge.difficulty-facil {
  background: #eaf7ef;
  color: #237a4b;
}

.badge.difficulty-intermediario {
  background: #fff5df;
  color: #8a5a00;
}

.badge.difficulty-desafio {
  background: #fff0ef;
  color: #a63a30;
}

.library-objective {
  line-height: 1.5;
}

.library-classes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: .88rem;
}

.library-classes span {
  background: #eef3fb;
  border-radius: 999px;
  padding: 4px 8px;
}

.library-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: auto;
}

.text-meta-preview {
  margin: 10px 0 16px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}


.schedule-box {
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8fafd;
}

.schedule-heading {
  display: grid;
  gap: 3px;
  margin-bottom: 6px;
}

.schedule-heading span {
  color: var(--muted);
  font-size: .86rem;
}

.schedule-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  background: #f4f6f9;
  font-size: .82rem;
  color: var(--muted);
}

.badge.availability-disponível {
  background: #eaf7ef;
  color: #237a4b;
}

.badge.availability-agendado {
  background: #e8efff;
  color: #315cb5;
}

.badge.availability-encerrado {
  background: #f2f2f2;
  color: #666;
}

.badge.availability-inativo {
  background: #fff0ef;
  color: #a63a30;
}


.entry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.entry-icon {
  font-size: 2.5rem;
  margin-bottom: 6px;
}

.trail-entry {
  border-width: 2px;
}

.trail-label {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef3fb;
  font-weight: 800;
  margin-bottom: 8px;
}

.trail-list {
  display: grid;
  gap: 12px;
}

.trail-item {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: #fbfcfe;
}

.trail-number {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  background: #eef3fb;
}

.trail-content {
  display: grid;
  gap: 3px;
}

.trail-content span,
.trail-content small {
  color: var(--muted);
}

.trail-code-box {
  display: grid;
  gap: 4px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #f8fafd;
}

.trail-code-box span {
  font-size: .8rem;
  color: var(--muted);
}

.trail-code-box strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.35rem;
  letter-spacing: .08em;
}

.trail-mini-list {
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
}

.trail-check-list .check-item span {
  display: grid;
}

.trail-check-list small {
  color: var(--muted);
}

.result-origin-detail {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  max-width: 150px;
}

.badge.availability-disponível,
.badge.availability-disponivel {
  background: #eaf7ef;
  color: #237a4b;
}

.badge.availability-agendada {
  background: #e8efff;
  color: #315cb5;
}

.badge.availability-encerrada {
  background: #f2f2f2;
  color: #666;
}

.badge.availability-inativa {
  background: #fff0ef;
  color: #a63a30;
}

@media (max-width: 800px) {
  .entry-grid {
    grid-template-columns: 1fr;
  }

  .trail-item {
    grid-template-columns: 42px 1fr;
  }

  .trail-item .btn {
    grid-column: 1 / -1;
  }
}


.school-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 14px;
}

.school-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: #fbfcfe;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.school-card > div {
  display: grid;
  gap: 3px;
}

.school-card span {
  color: var(--muted);
  font-size: .85rem;
}

.year-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.year-chips span {
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef3fb;
  font-weight: 800;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.row-actions form {
  margin: 0;
}
