/* === Quiz Patente — Blue & White stylesheet (subitopatente.online palette) === */
:root {
  --primary:        #0d4495;
  --primary-600:    #0e4ba6;
  --primary-700:    #0a3576;
  --primary-50:     #eaf0fb;
  --primary-100:    #d6e2f7;
  --accent:         #f7b500;
  --accent-soft:    #fff5d6;
  --success:        #1f8f5d;
  --success-soft:   #d6efe1;
  --danger:         #d8332b;
  --danger-soft:    #fbdcda;
  --bg-page:        #f1f5fb;
  --card-bg:        #ffffff;
  --text-dark:      #14223e;
  --text-muted:     #6a7896;
  --shadow-card:    0 12px 28px -10px rgba(13, 68, 149, .25);
  --shadow-soft:    0 4px 14px rgba(13, 68, 149, .08);
  --shadow-nav:     0 -8px 24px -8px rgba(13, 68, 149, .18);
  --radius-xl:      22px;
  --radius-lg:      16px;
  --radius-md:      12px;
  --radius-pill:    999px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  color: var(--text-dark);
  background:
    radial-gradient(900px 500px at 50% -200px, rgba(13,68,149,.08) 0%, transparent 60%),
    var(--bg-page);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ========== App shell (mobile-first card) ========== */
#app {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  background: #fff;
  position: relative;
  padding-bottom: 86px; /* room for fixed bottom nav */
  box-shadow: 0 0 60px rgba(13,68,149,.10);
  overflow: hidden;
}

/* ========== Top bar ========== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 14px;
  color: var(--text-dark);
  background: #fff;
  border-bottom: 1px solid var(--primary-50);
  position: sticky; top: 0; z-index: 30;
}
.topbar .icon-btn {
  background: transparent;
  border: 0;
  color: var(--primary);
  font-size: 22px;
  width: 40px; height: 40px;
  border-radius: 12px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease;
}
.topbar .icon-btn:hover { background: var(--primary-50); }
.topbar .right-actions { display: flex; align-items: center; gap: 6px; }
.topbar-brand { display: flex; align-items: center; }
.topbar-brand img { height: 45px; max-height: 45px; width: auto; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Page title (replaces full page-header) */
.page-title {
  padding: 14px 18px 4px;
}
.page-title h2 {
  font-weight: 800;
  font-size: 20px;
  color: var(--primary);
  margin: 0;
}
.page-title small { color: var(--text-muted); font-size: 13px; }

/* ========== Language switcher ========== */
.lang-switch {
  display: inline-flex;
  background: #fff;
  border: 1px solid var(--primary-100);
  border-radius: var(--radius-pill);
  padding: 4px;
  gap: 2px;
  box-shadow: var(--shadow-soft);
}
.lang-switch .flag-btn {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
  padding: 0;
}
.lang-switch .flag-btn:hover { background: var(--primary-50); }
.lang-switch .flag-btn.active {
  background: var(--primary);
  box-shadow: 0 4px 10px rgba(13,68,149,.30);
  transform: scale(1.05);
}
.lang-switch .flag-btn.active .flag-img { box-shadow: 0 0 0 2px #fff inset; }
.flag-img {
  width: 22px; height: 22px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

/* small inline spinner for lang change */
.lang-spinner {
  position: fixed; top: 14px; right: 14px;
  z-index: 200;
  background: #fff;
  border: 1px solid var(--primary-100);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--primary);
  display: none;
  box-shadow: var(--shadow-soft);
}
.lang-spinner.show { display: inline-flex; align-items: center; gap: 6px; }
.lang-spinner .spinner-border { width: 12px; height: 12px; border-width: 2px; color: var(--primary); }

/* ========== Login ========== */
.login-card {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 26px 22px;
  margin: 6px 18px 18px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--primary-100);
}
.login-card h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  margin: 0 0 16px;
}
.login-card .form-control {
  border-radius: 12px;
  padding: 12px 14px;
  border-color: #e3e9f3;
}
.login-card .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 .2rem rgba(13, 68, 149, .15);
}
.login-card .form-label { font-weight: 600; color: var(--text-dark); font-size: 13px; }
.login-card .btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  border-radius: var(--radius-pill);
  padding: 12px 18px;
  font-weight: 700;
  letter-spacing: .3px;
  box-shadow: 0 8px 20px -6px rgba(13,68,149,.4);
}
.login-card .btn-primary:hover { background: var(--primary-700); border-color: var(--primary-700); }
.login-card .hint { font-size: 13px; color: var(--text-muted); margin-top: 12px; text-align: center; }

/* ========== Welcome banner on home ========== */
.welcome-card {
  margin: 12px 18px 14px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-600) 100%);
  color: #fff;
  border-radius: var(--radius-xl);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}
.welcome-card.compact { padding: 12px 16px; }
.welcome-card.compact .avatar { width: 44px; height: 44px; font-size: 18px; }
.welcome-card::before {
  content: "";
  position: absolute;
  top: -40px; right: -40px;
  width: 160px; height: 160px;
  background: rgba(255,255,255,.10);
  border-radius: 50%;
}
.welcome-card::after {
  content: "";
  position: absolute;
  bottom: -50px; left: -30px;
  width: 140px; height: 140px;
  background: rgba(255,255,255,.06);
  border-radius: 50%;
}
.welcome-card .avatar {
  width: 54px; height: 54px;
  background: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  font-weight: 800;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
  z-index: 1;
}
.welcome-card .who { z-index: 1; }
.welcome-card .who .hi { font-size: 13px; opacity: .9; }
.welcome-card .who .name { font-weight: 800; font-size: 18px; }

/* ========== Home menu (modern cards) ========== */
.section-title {
  margin: 4px 18px 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-title small { color: var(--text-muted); font-weight: 500; }

.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 4px 18px 16px;
}
.home-grid .menu-card {
  aspect-ratio: 1 / 1;
  background: #fff;
  border: 1px solid var(--primary-100);
  border-radius: 22px;
  padding: 18px 12px;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
}
.home-grid .menu-card::before {
  content: "";
  position: absolute;
  bottom: -40px; right: -40px;
  width: 110px; height: 110px;
  border-radius: 50%;
  background: currentColor;
  opacity: .06;
  transition: transform .25s ease;
}
.home-grid .menu-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 30px -10px rgba(13,68,149,.30);
  border-color: currentColor;
}
.home-grid .menu-card:hover::before {
  transform: scale(1.6);
}
.home-grid .menu-card .icn {
  width: 70px; height: 70px;
  border-radius: 50%;
  background: currentColor;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px;
  position: relative;
  z-index: 1;
  box-shadow: 0 8px 18px -8px currentColor;
}
.home-grid .menu-card .icn i { color: #fff; }
.home-grid .menu-card .title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-dark);
  line-height: 1.15;
  position: relative;
  z-index: 1;
}
.home-grid .menu-card .desc {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.25;
  position: relative;
  z-index: 1;
  padding: 0 4px;
}

/* CHECKERBOARD palette — alternating accent colors */
.home-grid .menu-card[data-color="primary"] { color: #0d4495; }
.home-grid .menu-card[data-color="accent"]  { color: #f7b500; }
.home-grid .menu-card[data-color="success"] { color: #1f8f5d; }
.home-grid .menu-card[data-color="danger"]  { color: #d8332b; }
.home-grid .menu-card[data-color="violet"]  { color: #7457d8; }
.home-grid .menu-card[data-color="teal"]    { color: #0aa6a3; }

/* ========== Page header ========== */
.page-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dark);
  padding: 6px 16px 14px;
}
.page-header .back-btn {
  background: var(--primary-50);
  border: 0;
  color: var(--primary);
  font-size: 18px;
  width: 38px; height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease;
}
.page-header .back-btn:hover { background: var(--primary-100); }
.page-header h2 {
  margin: 0;
  font-weight: 800;
  font-size: 18px;
}

/* ========== Capitoli list ========== */
.chapters-toolbar {
  display: flex; justify-content: flex-end;
  color: var(--text-muted);
  padding: 0 18px 8px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.chapter-card {
  background: #fff;
  border: 1px solid var(--primary-100);
  border-radius: var(--radius-lg);
  margin: 0 18px 12px;
  color: var(--text-dark);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}
.chapter-card .head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
}
.chapter-card .head .chip {
  width: 50px; height: 50px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-600) 100%);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 800; font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(13,68,149,.25);
}
.chapter-card .head .title { flex: 1; min-width: 0; }
.chapter-card .head .title .t1 { font-weight: 700; font-size: 15px; line-height: 1.25; }
.chapter-card .head .title .t2 { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.chapter-card .head .toggle {
  font-size: 18px; color: var(--primary); transition: transform .2s ease;
}
.chapter-card.open .head .toggle { transform: rotate(180deg); }
.chapter-card .subs {
  display: none;
  padding: 0 14px 10px 14px;
  border-top: 1px solid var(--primary-50);
}
.chapter-card.open .subs { display: block; }
.chapter-card .sub-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 6px; font-size: 14px;
  border-bottom: 1px dashed var(--primary-50);
  cursor: pointer;
  border-radius: 6px;
  color: var(--text-dark);
}
.chapter-card .sub-item:last-child { border-bottom: 0; }
.chapter-card .sub-item:hover { background: var(--primary-50); color: var(--primary); padding-left: 10px; }
.chapter-card .sub-item .count {
  background: var(--primary-50);
  color: var(--primary);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
}

/* ========== Exam / quiz screen ========== */
.exam-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-600) 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  margin: 4px 14px 12px;
  padding: 12px 14px 10px;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.exam-header .logo-row {
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.exam-header .logo-row img { height: 28px; filter: brightness(0) invert(1); }
.exam-header .title { font-weight: 800; font-size: 17px; letter-spacing: .4px; }
.exam-header .subtitle { font-size: 12px; opacity: .9; }

.exam-blocks {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  padding: 0 14px;
}
.exam-blocks .blk {
  background: #fff;
  border-radius: 10px;
  padding: 7px 4px;
  text-align: center;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.15;
  border: 1px solid var(--primary-100);
}
.exam-blocks .blk.active {
  background: var(--accent-soft);
  color: #b06a00;
  border-color: var(--accent);
}
.exam-grid {
  display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px;
  padding: 8px 14px 0;
}
.exam-grid .num {
  background: #fff;
  border: 1px solid var(--primary-100);
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 0;
  color: var(--text-dark);
  cursor: pointer;
  transition: background .12s ease;
}
.exam-grid .num:hover { background: var(--primary-50); }
.exam-grid .num.current { background: var(--accent); color: #4a3500; border-color: var(--accent); }
.exam-grid .num.answered { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.exam-grid .num.wrong { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

.question-card {
  background: #fff;
  margin: 12px 14px 0;
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--primary-100);
}
.question-card .qimg {
  background: var(--primary-50);
  border-radius: 12px;
  width: 130px;
  min-height: 100px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.question-card .qimg img { max-width: 100%; max-height: 130px; display: block; }
.question-card .qrow { display: flex; gap: 14px; align-items: flex-start; }
.question-card .qtext-wrap { flex: 1; position: relative; padding-right: 36px; }
.question-card .qtext { font-size: 15.5px; font-weight: 600; color: var(--text-dark); line-height: 1.4; }
.question-card .qmeta { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }

/* Dual-language layout (IT on top, target lang below) */
.qtext-dual { display: flex; flex-direction: column; gap: 10px; }
.qtext-dual .qline {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  line-height: 1.4;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dark);
}
.qtext-dual .qline.lang-it    { background: var(--primary-50); }
.qtext-dual .qline.lang-other { background: #fff8de; }
.qtext-dual .qtxt { flex: 1; }

.lang-tag {
  display: inline-block;
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary-100);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .5px;
  flex-shrink: 0;
  margin-top: 2px;
  text-transform: uppercase;
}
.qline.lang-other .lang-tag { color: #b18000; border-color: #f0d97a; }

/* Speak button */
.tts-btn {
  background: #fff;
  border: 1px solid var(--primary-100);
  color: var(--primary);
  border-radius: 50%;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
  flex-shrink: 0;
  font-size: 13px;
}
.tts-btn:hover { background: var(--primary); color: #fff; }
.tts-btn.inline { width: 24px; height: 24px; font-size: 11px; vertical-align: middle; }

/* Explain ? button */
.explain-btn {
  position: absolute;
  top: 0; right: 0;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #6a4900;
  border: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 4px 12px -4px rgba(247,181,0,.55);
  transition: transform .15s ease;
}
.explain-btn:hover { transform: scale(1.08); }

/* Bookmark button */
.bookmark-btn {
  position: absolute;
  top: 0; right: 38px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--primary-100);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, color .15s ease;
}
.bookmark-btn:hover { background: var(--primary); color: #fff; transform: scale(1.06); }
.bookmark-btn.saved { background: var(--accent); color: #6a4900; border-color: var(--accent); }
.question-card .qtext-wrap { padding-right: 76px; }

/* Osservazioni cards */
.oss-card {
  background: #fff;
  border: 1px solid var(--primary-100);
  border-radius: var(--radius-lg);
  margin: 12px 14px 0;
  padding: 14px;
  box-shadow: var(--shadow-soft);
}
.oss-head {
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 10px;
  position: relative;
  padding-right: 38px;
}
.oss-head .oss-num {
  width: 28px; height: 28px;
  background: var(--primary); color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
  flex-shrink: 0;
}
.oss-head .oss-title { flex: 1; font-weight: 700; color: var(--text-dark); line-height: 1.35; }
.oss-head .oss-remove { position: absolute; top: 0; right: 0; }
.oss-img {
  background: var(--primary-50);
  border-radius: 12px;
  padding: 8px;
  margin-bottom: 10px;
  text-align: center;
}
.oss-img img { max-height: 140px; max-width: 100%; }
.oss-section {
  background: var(--primary-50);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  margin-bottom: 8px;
  line-height: 1.4;
}
.oss-section .lang-tag { background: #fff; }
.oss-answer {
  background: var(--success-soft);
  color: var(--success);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  display: inline-block;
  margin-bottom: 8px;
}
.oss-note-wrap {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--primary-100);
}
.oss-note-label {
  font-size: 12px; color: var(--text-muted); font-weight: 700;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 6px;
}
.oss-note {
  width: 100%;
  border: 1px solid var(--primary-100);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
}
.oss-note:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,68,149,.12);
}
.oss-note-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Explanation block (dual-aware) */
.exp-dual { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.exp-line {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 14px; line-height: 1.4;
}
.exp-line .lang-tag { background: rgba(255,255,255,.7); }
.exp-line.single { margin-top: 4px; }
.exp-note {
  margin-top: 10px; padding-top: 8px;
  border-top: 1px dashed currentColor;
  font-size: 13px;
}

.question-explanation {
  margin: 10px 14px 0;
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 10px 14px;
  color: #5b4500;
  font-size: 14px;
  display: none;
  line-height: 1.4;
}
.question-explanation.show { display: block; }
.question-explanation.is-correct {
  background: var(--success-soft);
  border-left-color: var(--success);
  color: #105235;
}
.question-explanation.is-wrong {
  background: var(--danger-soft);
  border-left-color: var(--danger);
  color: #7a1d18;
}

.exam-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
  padding: 12px 14px 4px;
  align-items: stretch;
}
.exam-bottom .timer-box {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-600) 100%);
  color: #fff;
  border-radius: 12px;
  padding: 8px;
  text-align: center;
  box-shadow: var(--shadow-soft);
}
.exam-bottom .timer-box .label { font-size: 10px; opacity: .9; }
.exam-bottom .timer-box .value { font-size: 18px; font-weight: 800; }
.exam-bottom .summary-btn {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary-100);
  border-radius: 12px;
  padding: 10px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-weight: 700; cursor: pointer;
  font-size: 13px;
}
.exam-bottom .summary-btn:hover { background: var(--primary-50); }
.exam-bottom .tf-btn {
  background: #fff;
  border: 2px solid var(--primary);
  color: var(--primary);
  border-radius: 12px;
  padding: 10px 4px;
  font-weight: 800;
  display: flex; flex-direction: column; align-items: center;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease, color .12s ease;
}
.exam-bottom .tf-btn .lbl { font-size: 10px; font-weight: 700; letter-spacing: .4px; }
.exam-bottom .tf-btn .big { font-size: 22px; line-height: 1; }
.exam-bottom .tf-btn:hover { transform: translateY(-1px); }
.exam-bottom .tf-btn.correct { background: var(--success); color: #fff; border-color: var(--success); }
.exam-bottom .tf-btn.wrong { background: var(--danger); color: #fff; border-color: var(--danger); }
/* In esame mode: just highlight the chosen button without revealing correctness */
.exam-bottom .tf-btn.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

.nav-row {
  display: flex; justify-content: space-between; padding: 6px 14px 12px;
}
.nav-btn {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: 0; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 18px -6px rgba(13,68,149,.4);
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.nav-btn:hover { background: var(--primary-700); transform: translateY(-1px); }
.nav-btn[disabled] { opacity: .4; cursor: not-allowed; }

/* ========== Stats ========== */
.stat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 0 18px;
}
.stat-tile {
  background: #fff;
  border: 1px solid var(--primary-100);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow-soft);
  text-align: center;
}
.stat-tile .v { font-size: 22px; font-weight: 800; color: var(--primary); }
.stat-tile .l { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.stat-card {
  background: #fff;
  border: 1px solid var(--primary-100);
  border-radius: 14px;
  padding: 14px;
  margin: 12px 18px;
  box-shadow: var(--shadow-soft);
}
.session-row {
  display: flex; justify-content: space-between; padding: 9px 0;
  border-bottom: 1px dashed var(--primary-50); font-size: 14px;
}
.session-row:last-child { border-bottom: 0; }

/* ========== Empty state / generic ========== */
.empty-state {
  background: #fff;
  margin: 16px 18px;
  border: 1px solid var(--primary-100);
  border-radius: 14px;
  padding: 30px 16px;
  text-align: center;
  color: var(--text-muted);
  box-shadow: var(--shadow-soft);
}
.empty-state i { color: var(--primary); }

.toast-wrap {
  position: fixed;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast-msg {
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 8px 20px rgba(13,68,149,.30);
}

.spinner-wrap { display: flex; justify-content: center; padding: 30px; }
.spinner-wrap .spinner-border { color: var(--primary); }

.is-hidden { display: none !important; }

/* ========== Side drawer ========== */
.side-overlay {
  position: fixed; inset: 0;
  background: rgba(13,34,68,.45);
  z-index: 50;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.side-overlay.open { opacity: 1; pointer-events: auto; }
.side-menu {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 80%; max-width: 320px;
  background: #fff;
  z-index: 60;
  transform: translateX(-100%);
  transition: transform .25s ease;
  box-shadow: 0 0 30px rgba(0,0,0,.25);
  display: flex; flex-direction: column;
}
.side-menu.open { transform: translateX(0); }
.side-menu .side-head {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-600) 100%);
  color: #fff;
  padding: 18px 16px;
  display: flex; align-items: center; gap: 12px;
}
.side-menu .side-head img { height: 36px; filter: brightness(0) invert(1); }
.side-menu .side-head .name { font-weight: 800; }
.side-menu .side-head .user { font-size: 13px; opacity: .9; }
.side-menu nav { padding: 8px 0; flex: 1; }
.side-menu .side-link {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  color: var(--text-dark); cursor: pointer;
  border: 0; background: transparent; width: 100%; text-align: left;
  font-size: 15px;
  border-left: 3px solid transparent;
}
.side-menu .side-link:hover { background: var(--primary-50); border-left-color: var(--primary); }
.side-menu .side-link i { color: var(--primary); width: 22px; text-align: center; font-size: 18px; }
.side-menu .side-foot { padding: 14px 16px; border-top: 1px solid #eef2f8; }

/* ========== FIXED BOTTOM NAV (app style) ========== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 460px;
  background: #fff;
  border-top: 1px solid var(--primary-100);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
  z-index: 40;
  box-shadow: var(--shadow-nav);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav .nav-item {
  background: transparent;
  border: 0;
  padding: 10px 4px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  position: relative;
  transition: color .15s ease;
}
.bottom-nav .nav-item i { font-size: 22px; }
.bottom-nav .nav-item:hover { color: var(--primary); }
.bottom-nav .nav-item.active { color: var(--primary); }
.bottom-nav .nav-item.active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 4px 4px;
}
/* Center FAB-style item */
.bottom-nav .nav-item.fab-item {
  position: relative;
}
.bottom-nav .nav-item.fab-item .fab-circle {
  position: absolute;
  top: -22px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-600) 100%);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  box-shadow: 0 10px 22px -6px rgba(13,68,149,.55);
  border: 4px solid #fff;
}
.bottom-nav .nav-item.fab-item span { margin-top: 38px; color: var(--primary); font-weight: 700; }
.bottom-nav .nav-item.fab-item::before { display: none; }

/* Result screen */
.result-card {
  background: #fff;
  margin: 16px 18px;
  border-radius: 18px;
  padding: 24px 18px;
  text-align: center;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--primary-100);
}
.result-card .badge-result {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: .4px;
  margin-bottom: 12px;
}
.result-card.ok .badge-result { background: var(--success-soft); color: var(--success); }
.result-card.ko .badge-result { background: var(--danger-soft); color: var(--danger); }
.result-card h3 { margin: 8px 0 14px; color: var(--text-dark); font-weight: 800; }
.result-stats {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px;
  margin-bottom: 18px;
}
.result-stats .b {
  background: var(--primary-50);
  border-radius: 12px;
  padding: 10px 6px;
}
.result-stats .b .v { font-weight: 800; color: var(--primary); font-size: 20px; }
.result-stats .b .l { font-size: 11px; color: var(--text-muted); }

@media (max-width: 360px) {
  .home-grid { gap: 10px; padding: 0 14px 8px; }
  .home-grid .menu-card { padding: 14px 12px 12px; }
  .brand h1 { font-size: 22px; }
  .welcome-card .who .name { font-size: 16px; }
}
