:root {
  --sidebar-bg: #0f2440;
  --sidebar-bg2: #16335c;
  --sidebar-text: #c9d6e8;
  --accent: #f59e0b;
  --accent-dark: #d97706;
  --primary: #1d4ed8;
  --primary-light: #3b82f6;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --green: #16a34a;
  --red: #dc2626;
  --orange: #ea580c;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.1), 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.15);
  --radius: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 290px;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg2) 100%);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 30;
}

.sidebar-header { padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.08); }

.logo { display: flex; align-items: center; gap: 12px; }
.logo-mark {
  width: 42px; height: 42px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 22px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.4);
}
.logo h1 { font-size: 15px; color: #fff; line-height: 1.2; }
.logo p { font-size: 12px; color: #8fa8c8; }

.sidebar-nav { flex: 1; padding: 12px 10px 20px; }

.nav-section { margin-bottom: 6px; }

.nav-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7f97ba;
  cursor: pointer;
  border-radius: 8px;
  user-select: none;
}
.nav-section-header:hover { background: rgba(255,255,255,0.05); }
.nav-chevron { transition: transform 0.2s; font-size: 10px; }
.nav-section.open .nav-chevron { transform: rotate(90deg); }

.nav-section-body { max-height: 0; overflow: hidden; transition: max-height 0.25s ease; }
.nav-section.open .nav-section-body { max-height: 1000px; }

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px 8px 22px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 13.5px;
  transition: background 0.15s;
}
.nav-item:hover { background: rgba(255,255,255,0.07); }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav-item .nav-check {
  width: 16px; height: 16px; flex-shrink: 0;
  border: 2px solid #5c7499;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; color: #fff;
}
.nav-item.done .nav-check { background: var(--green); border-color: var(--green); }
.nav-item.done .nav-check::after { content: "\\2713"; }

.nav-item.nav-link-dash {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  font-size: 14px; font-weight: 600;
}
.nav-item.nav-link-dash .nav-check { border-color: var(--accent); border-radius: 8px; }
.nav-item.nav-link-dash.active .nav-check { background: var(--accent); }

.nav-sub {
  padding: 2px 10px 2px 22px;
  font-size: 12.5px;
  color: #8fa8c8;
}

.sidebar-footer { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.btn-reset {
  width: 100%;
  padding: 9px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: #c9d6e8;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.btn-reset:hover { background: rgba(220, 38, 38, 0.2); border-color: var(--red); color: #fff; }

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex; align-items: center; gap: 16px;
}
.menu-toggle { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text); }
.topbar-title { font-size: 17px; font-weight: 700; flex: 1; }
.topbar-progress { display: flex; align-items: center; gap: 10px; }
.topbar-progress-text { font-size: 12.5px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.progress-track { width: 140px; height: 8px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--green); border-radius: 99px; transition: width 0.4s; width: 0; }

.content { padding: 28px; max-width: 1100px; width: 100%; margin: 0 auto; }

/* Cards / Dashboard */
.greeting { margin-bottom: 24px; }
.greeting h2 { font-size: 26px; font-weight: 800; }
.greeting p { color: var(--text-muted); margin-top: 4px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  border-top: 4px solid var(--primary);
}
.stat-card.green { border-top-color: var(--green); }
.stat-card.orange { border-top-color: var(--orange); }
.stat-card.accent { border-top-color: var(--accent); }
.stat-value { font-size: 30px; font-weight: 800; }
.stat-label { font-size: 13px; color: var(--text-muted); }

.section-title { font-size: 18px; font-weight: 700; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }

.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }

.subject-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid transparent;
}
.subject-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--primary-light); }
.subject-card .subject-icon {
  width: 46px; height: 46px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; color: #fff; margin-bottom: 14px;
}
.subject-card h3 { font-size: 16.5px; margin-bottom: 4px; }
.subject-card .subject-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }
.subject-card .mini-progress { font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.subject-card .progress-track { width: 100%; }

.simulado-strip {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 28px;
  border-left: 5px solid var(--accent);
}
.simulado-strip h3 { font-size: 19px; margin-bottom: 6px; }
.simulado-strip p { color: var(--text-muted); font-size: 14px; margin-bottom: 16px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px;
  border-radius: 10px;
  border: none;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-outline { background: #fff; color: var(--text); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #15803d; }
.btn-red { background: var(--red); color: #fff; }
.btn-danger-outline { background: #fff; color: var(--red); border: 1.5px solid var(--red); }
.btn-danger-outline:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* Topic page */
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.breadcrumb a { color: var(--primary); cursor: pointer; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

.topic-header { margin-bottom: 22px; }
.topic-tag {
  display: inline-block;
  background: #eff6ff; color: var(--primary);
  font-size: 12px; font-weight: 700;
  padding: 4px 12px; border-radius: 99px;
  margin-bottom: 10px;
}
.topic-header h2 { font-size: 24px; font-weight: 800; line-height: 1.3; }
.topic-summary {
  background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534;
  padding: 14px 18px; border-radius: 10px;
  font-size: 14px; margin-top: 14px;
}

.content-block {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}
.content-block h3 { font-size: 17px; margin-bottom: 12px; color: var(--primary); }
.content-block p { font-size: 14.5px; margin-bottom: 10px; color: #334155; }
.content-block ul, .content-block ol { margin: 0 0 12px 22px; font-size: 14.5px; color: #334155; }
.content-block li { margin-bottom: 7px; }

.tips-block {
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 18px;
}
.tips-block h3 { font-size: 16px; color: var(--accent-dark); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.tips-block li { font-size: 14px; margin-bottom: 8px; color: #78350f; }

/* Quiz */
.quiz-question {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 16px;
}
.quiz-question .q-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 12.5px; color: var(--text-muted); }
.quiz-question .q-text { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.option {
  display: block;
  width: 100%;
  text-align: left;
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 9px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
  font-family: inherit;
  color: var(--text);
}
.option:hover { border-color: var(--primary); background: #eff6ff; }
.option.selected { border-color: var(--primary); background: #eff6ff; font-weight: 600; }
.option.correct { border-color: var(--green); background: #f0fdf4; color: var(--green); font-weight: 700; }
.option.incorrect { border-color: var(--red); background: #fef2f2; color: var(--red); font-weight: 700; }
.option.disabled { pointer-events: none; }
.option .option-letter { font-weight: 800; margin-right: 8px; }

.q-explain {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #eff6ff;
  border-left: 4px solid var(--primary);
  font-size: 13.5px;
  color: #1e3a8a;
  display: none;
}
.q-explain.show { display: block; }
.q-explain .ok { color: var(--green); font-weight: 700; }
.q-explain .no { color: var(--red); font-weight: 700; }

.quiz-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.quiz-title { font-size: 19px; font-weight: 800; }
.quiz-timer {
  font-size: 14px; font-weight: 700;
  background: #f1f5f9; padding: 8px 14px; border-radius: 99px;
  display: flex; align-items: center; gap: 8px;
}
.quiz-timer.warning { background: #fef2f2; color: var(--red); }

.quiz-progressbar { margin-bottom: 18px; }
.quiz-progressbar .progress-track { width: 100%; height: 10px; }
.quiz-progressbar-text { font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }

/* Results */
.result-hero {
  text-align: center;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 44px 28px;
  margin-bottom: 20px;
}
.result-score { font-size: 58px; font-weight: 800; line-height: 1.1; }
.result-score.good { color: var(--green); }
.result-score.medium { color: var(--orange); }
.result-score.bad { color: var(--red); }
.result-message { font-size: 17px; font-weight: 600; margin-top: 8px; }
.result-sub { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.result-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.result-stat { background: var(--card); border-radius: 10px; box-shadow: var(--shadow); padding: 16px; text-align: center; }
.result-stat .v { font-size: 24px; font-weight: 800; }
.result-stat .l { font-size: 12.5px; color: var(--text-muted); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
}
.modal h3 { font-size: 20px; margin-bottom: 8px; }
.modal p { color: var(--text-muted); font-size: 14px; margin-bottom: 18px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.form-group select, .form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
.form-group select:focus, .form-group input:focus { outline: none; border-color: var(--primary); }

/* Simulado config */
.config-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 16px; }
.config-card h3 { font-size: 16px; margin-bottom: 14px; }

.preset-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.preset-btn {
  text-align: left;
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.preset-btn:hover { border-color: var(--primary); background: #eff6ff; }
.preset-btn .p-name { font-weight: 700; font-size: 14px; }
.preset-btn .p-desc { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

.empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty h3 { font-size: 20px; color: var(--text); margin-bottom: 8px; }

/* Review list */
.review-item { border-bottom: 1px solid var(--border); padding: 14px 0; }
.review-item:last-child { border-bottom: none; }
.review-item .r-q { font-size: 14.5px; font-weight: 600; margin-bottom: 8px; }
.review-item .r-tag { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.review-item .r-user { font-size: 13px; color: var(--green); font-weight: 600; }
.review-item .r-correct { font-size: 13px; color: var(--red); font-weight: 600; }
.review-item .r-explain { font-size: 13px; color: #475569; margin-top: 6px; background: #f8fafc; padding: 10px; border-radius: 8px; }

/* Responsive */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform 0.25s;
    width: 280px;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: block; }
  .content { padding: 18px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr; }
  .topbar-progress { display: none; }
  .content { padding: 14px; }
  .quiz-timer { font-size: 13px; }
}

/* Scrollbar */
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }
.content::-webkit-scrollbar { width: 8px; }
.content::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
