*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #2563eb;
  --blue-dark: #1e40af;
  --blue-light: #eff6ff;
  --green: #16a34a;
  --green-light: #dcfce7;
  --red: #dc2626;
  --red-light: #fee2e2;
  --yellow: #d97706;
  --yellow-light: #fef9c3;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
}

/* ── TOP NAV ── */
.top-nav {
  background: #fff; border-bottom: 1px solid var(--gray-200);
  padding: 0 24px; height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.nav-logo {
  font-weight: 800; font-size: 1.05rem; color: var(--blue);
  text-decoration: none; letter-spacing: -.01em;
}
.nav-logo:hover { color: var(--blue-dark); }
.nav-links { display: flex; gap: 4px; }
.nav-links a {
  padding: 6px 14px; border-radius: 8px;
  font-size: .88rem; font-weight: 600; color: var(--gray-500);
  text-decoration: none; transition: all .15s;
}
.nav-links a:hover { background: var(--gray-100); color: var(--gray-900); }
.nav-links a.active { background: var(--blue-light); color: var(--blue); }
.nav-user { display: flex; align-items: center; gap: 10px; margin-left: 8px; }
.nav-username {
  font-size: .82rem; font-weight: 700; color: var(--gray-500);
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.btn-logout {
  padding: 5px 12px; border-radius: 7px; border: 1.5px solid var(--gray-200);
  background: #fff; color: var(--gray-500); font-size: .8rem; font-weight: 700;
  cursor: pointer; transition: all .15s;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); background: var(--red-light); }

@media (max-width: 480px) {
  .nav-username { display: none; }
}

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  line-height: 1.5;
}

#app { min-height: 100vh; }
.screen { min-height: 100vh; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px; border-radius: 8px; border: none;
  font-size: .95rem; font-weight: 600; cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-outline {
  background: #fff; color: var(--blue);
  border: 2px solid var(--blue-light);
}
.btn-outline:hover { background: var(--blue-light); }
.btn-full { width: 100%; margin-top: 8px; }
.btn-back {
  background: none; border: none; color: var(--blue);
  font-size: .95rem; font-weight: 600; cursor: pointer; padding: 4px 0;
}
.btn-back.small { font-size: 1.1rem; padding: 4px 8px; color: var(--gray-500); }
.btn-back:hover { color: var(--blue-dark); }

/* ── HOME SCREEN ── */
.site-header {
  background: var(--blue); color: #fff;
  padding: 32px 24px 28px;
}
.header-content {
  max-width: 900px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap;
}
.site-header h1 { font-size: 1.7rem; font-weight: 700; margin-bottom: 4px; }
.subtitle { opacity: .85; font-size: .95rem; }
.header-stats { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.stat-pill {
  background: rgba(255,255,255,.2); padding: 4px 12px;
  border-radius: 99px; font-size: .85rem; font-weight: 600;
}

.home-main { max-width: 900px; margin: 0 auto; padding: 32px 20px 48px; }
.section { margin-bottom: 40px; }
.section-title {
  font-size: 1.15rem; font-weight: 700; color: var(--gray-700);
  margin-bottom: 16px; padding-bottom: 8px;
  border-bottom: 2px solid var(--gray-200);
}

.areas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.area-card {
  background: #fff; border-radius: var(--radius);
  padding: 20px; cursor: pointer;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.area-card:hover {
  border-color: var(--blue); box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.area-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 8px; margin-bottom: 8px;
}
.area-header h3 { font-size: 1rem; font-weight: 700; color: var(--gray-900); flex: 1; }
.badge {
  background: var(--blue-light); color: var(--blue);
  font-size: .75rem; font-weight: 700; padding: 3px 8px;
  border-radius: 99px; white-space: nowrap;
}
.area-desc { font-size: .85rem; color: var(--gray-500); margin-bottom: 12px; line-height: 1.4; }
.card-footer { border-top: 1px solid var(--gray-100); padding-top: 10px; }
.start-link { color: var(--blue); font-weight: 600; font-size: .9rem; }

.simulado-card {
  background: var(--blue-dark); color: #fff; border-radius: var(--radius);
  padding: 24px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  box-shadow: var(--shadow-md);
  transition: opacity .15s;
}
.simulado-card:hover { opacity: .92; }
.simulado-card h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: 4px; }
.simulado-card p { opacity: .8; font-size: .9rem; }

.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  background: #fff; border-radius: 8px; padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow); font-size: .9rem;
}
.history-area { flex: 1; font-weight: 500; color: var(--gray-700); }
.history-score { font-weight: 700; }
.history-score.aprovado { color: var(--green); }
.history-score.reprovado { color: var(--red); }
.history-date { color: var(--gray-400); font-size: .8rem; }

/* ── CONFIG SCREEN ── */
.config-screen {
  display: flex; align-items: center; justify-content: center;
  padding: 40px 20px; background: var(--gray-50);
}
.config-card {
  background: #fff; border-radius: var(--radius);
  padding: 32px; width: 100%; max-width: 480px;
  box-shadow: var(--shadow-lg);
}
.config-card h2 { font-size: 1.4rem; font-weight: 700; margin: 12px 0 4px; }
.config-subtitle { color: var(--gray-500); margin-bottom: 28px; }
.config-group { margin-bottom: 24px; }
.config-label {
  display: block; font-weight: 700; font-size: .9rem;
  color: var(--gray-700); margin-bottom: 10px;
}
.options-row { display: flex; flex-wrap: wrap; gap: 8px; }
.option-btn {
  padding: 8px 16px; border-radius: 8px; border: 2px solid var(--gray-200);
  background: #fff; color: var(--gray-700); font-size: .9rem; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.option-btn:hover { border-color: var(--blue); color: var(--blue); }
.option-btn.selected { border-color: var(--blue); background: var(--blue-light); color: var(--blue); }

.toggle-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--gray-200); border-radius: 99px;
  transition: .3s;
}
.slider::before {
  content: ''; position: absolute;
  height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: .3s;
}
input:checked + .slider { background: var(--blue); }
input:checked + .slider::before { transform: translateX(20px); }
.timer-options { padding-top: 4px; }
.hidden { display: none !important; }

/* ── QUIZ SCREEN ── */
.quiz-screen {
  display: flex; flex-direction: column;
  min-height: 100vh; background: var(--gray-50);
}
.quiz-header {
  background: #fff; border-bottom: 1px solid var(--gray-200);
  padding: 12px 20px;
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 10;
}
.progress-wrap { flex: 1; }
.progress-bar {
  background: var(--gray-200); border-radius: 99px;
  height: 6px; overflow: hidden; margin-bottom: 4px;
}
.progress-fill { background: var(--blue); height: 100%; border-radius: 99px; transition: width .3s; }
.progress-text { font-size: .8rem; color: var(--gray-500); font-weight: 600; }

.timer {
  font-size: .9rem; font-weight: 700; color: var(--gray-700);
  background: var(--gray-100); padding: 4px 10px; border-radius: 8px;
  min-width: 70px; text-align: center;
}
.timer.timer-warning { background: var(--red-light); color: var(--red); }

.quiz-body {
  flex: 1; max-width: 720px; width: 100%;
  margin: 0 auto; padding: 28px 20px;
}
.question-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.q-number { font-size: .85rem; font-weight: 700; color: var(--blue); }
.mark-btn {
  background: none; border: 1px solid var(--gray-200);
  border-radius: 8px; padding: 4px 10px;
  font-size: .82rem; font-weight: 600; color: var(--gray-500); cursor: pointer;
  transition: all .15s;
}
.mark-btn:hover, .mark-btn.marked {
  border-color: var(--yellow); color: var(--yellow);
  background: var(--yellow-light);
}

.enunciado {
  font-size: 1.05rem; line-height: 1.65;
  color: var(--gray-900); margin-bottom: 24px;
  font-weight: 500;
}
.alternativas { display: flex; flex-direction: column; gap: 10px; }
.alt-btn {
  display: flex; align-items: flex-start; gap: 12px;
  background: #fff; border: 2px solid var(--gray-200);
  border-radius: 10px; padding: 14px 16px;
  cursor: pointer; text-align: left; width: 100%;
  transition: border-color .15s, background .15s, box-shadow .15s;
  font-size: .95rem; color: var(--gray-900);
}
.alt-btn:hover {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}
.alt-btn.selected {
  border-color: var(--blue); background: var(--blue-light);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.alt-letra {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px;
  background: var(--gray-100); border-radius: 6px;
  font-weight: 700; font-size: .85rem; color: var(--gray-700);
  flex-shrink: 0;
}
.alt-btn.selected .alt-letra { background: var(--blue); color: #fff; }
.alt-texto { flex: 1; line-height: 1.5; padding-top: 2px; }

.quiz-footer {
  background: #fff; border-top: 1px solid var(--gray-200);
  padding: 12px 20px; position: sticky; bottom: 0;
}
.nav-dots {
  display: flex; flex-wrap: wrap; gap: 6px;
  justify-content: center; margin-bottom: 12px;
}
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--gray-200); cursor: pointer;
  transition: background .15s, transform .1s;
}
.dot:hover { transform: scale(1.3); }
.dot.current { background: var(--blue); transform: scale(1.2); }
.dot.answered { background: var(--gray-500); }
.dot.answered.current { background: var(--blue); }
.dot.marked-dot { outline: 2px solid var(--yellow); outline-offset: 2px; }

.nav-btns {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}

/* ── RESULTS SCREEN ── */
.results-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 40px 20px; background: var(--gray-50);
}
.results-card {
  background: #fff; border-radius: var(--radius);
  padding: 36px 32px; max-width: 520px; width: 100%;
  box-shadow: var(--shadow-lg); text-align: center;
}
.score-circle {
  width: 140px; height: 140px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  margin: 0 auto 28px;
  border: 6px solid;
}
.score-circle.aprovado { border-color: var(--green); background: var(--green-light); }
.score-circle.reprovado { border-color: var(--red); background: var(--red-light); }
.score-num { font-size: 2.2rem; font-weight: 800; line-height: 1; }
.score-circle.aprovado .score-num { color: var(--green); }
.score-circle.reprovado .score-num { color: var(--red); }
.score-label { font-size: .85rem; font-weight: 700; margin-top: 4px; }
.score-circle.aprovado .score-label { color: var(--green); }
.score-circle.reprovado .score-label { color: var(--red); }

.results-details {
  display: flex; justify-content: center; gap: 32px;
  margin-bottom: 28px;
}
.detail-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.detail-label { font-size: .8rem; color: var(--gray-500); font-weight: 600; text-transform: uppercase; }
.detail-value { font-size: 1.4rem; font-weight: 800; color: var(--gray-900); }

.area-breakdown {
  background: var(--gray-50); border-radius: 8px; padding: 16px;
  margin-bottom: 24px; text-align: left;
}
.area-breakdown h4 { font-size: .9rem; font-weight: 700; color: var(--gray-700); margin-bottom: 12px; }
.area-stat {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: .85rem;
}
.area-stat-name { flex: 1; color: var(--gray-700); font-size: .8rem; }
.mini-bar { flex: 1; max-width: 120px; height: 6px; background: var(--gray-200); border-radius: 99px; overflow: hidden; }
.mini-fill { height: 100%; border-radius: 99px; }
.mini-fill.ok { background: var(--green); }
.mini-fill.nok { background: var(--red); }
.area-stat-score { font-weight: 700; color: var(--gray-700); min-width: 36px; text-align: right; }

.results-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.results-actions .btn { flex: 1; }

/* ── GABARITO SCREEN ── */
.gabarito-screen { background: var(--gray-50); min-height: 100vh; }
.gabarito-header {
  background: #fff; border-bottom: 1px solid var(--gray-200);
  padding: 16px 24px;
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 10;
}
.gabarito-header h2 { flex: 1; font-size: 1.1rem; }
.gab-score { font-weight: 700; color: var(--blue); font-size: .95rem; }

.gabarito-list {
  max-width: 720px; margin: 0 auto; padding: 24px 20px;
  display: flex; flex-direction: column; gap: 20px;
}
.gabarito-item {
  background: #fff; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--gray-200);
}
.gabarito-item.acerto { border-left-color: var(--green); }
.gabarito-item.erro { border-left-color: var(--red); }

.gabarito-q-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px 0; font-size: .85rem;
}
.q-status {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; font-size: .85rem; font-weight: 700;
}
.gabarito-item.acerto .q-status { background: var(--green-light); color: var(--green); }
.gabarito-item.erro .q-status { background: var(--red-light); color: var(--red); }
.tag-sem-resp { font-size: .75rem; background: var(--yellow-light); color: var(--yellow); padding: 2px 8px; border-radius: 99px; font-weight: 600; }

.enunciado-gab {
  font-size: .95rem; line-height: 1.6; font-weight: 500;
  padding: 10px 20px 12px; color: var(--gray-900);
}
.gabarito-alts { padding: 0 20px; display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.gabarito-alt {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: 8px; font-size: .88rem;
  border: 1px solid var(--gray-200); color: var(--gray-700);
}
.gabarito-alt.gabarito-certa { background: var(--green-light); border-color: var(--green); color: var(--green); }
.gabarito-alt.gabarito-errada { background: var(--red-light); border-color: var(--red); color: var(--red); }
.tag-certa { margin-left: auto; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.tag-errada { margin-left: auto; font-size: .75rem; font-weight: 700; white-space: nowrap; }

.explicacao {
  background: var(--gray-50); border-top: 1px solid var(--gray-200);
  padding: 14px 20px; font-size: .88rem; line-height: 1.6; color: var(--gray-700);
}
.explicacao strong { color: var(--blue); }

/* ── FONTE BAR (gabarito) ── */
.fonte-bar {
  background: var(--blue-light);
  border-top: 1px solid #bfdbfe;
  padding: 10px 20px;
  display: flex; align-items: center; gap: 8px;
  font-size: .82rem; flex-wrap: wrap;
}
.fonte-icon { flex-shrink: 0; }
.fonte-ref { flex: 1; color: var(--blue-dark); font-weight: 600; }
.fonte-date {
  font-size: .76rem; color: var(--gray-400); white-space: nowrap;
  font-style: italic;
}
.fonte-link {
  color: var(--blue); font-weight: 700; text-decoration: none;
  white-space: nowrap; border-bottom: 1px solid transparent;
  transition: border-color .15s;
}
.fonte-link:hover { border-bottom-color: var(--blue); }
.fonte-bar--missing { background: #fff7ed; border-top-color: #fed7aa; }
.fonte-bar--missing .fonte-ref { color: #c2410c; font-weight: 500; }

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .site-header h1 { font-size: 1.3rem; }
  .areas-grid { grid-template-columns: 1fr; }
  .results-card { padding: 24px 20px; }
  .results-details { gap: 20px; }
  .results-actions { flex-direction: column; }
  .simulado-card { flex-direction: column; align-items: flex-start; }
  .quiz-body { padding: 20px 16px; }
}
