/* ── BLS Training — design tokens ─────────────────────────────────── */
:root {
  --bg: #faf9f7;
  --card: #ffffff;
  --ink: #26141a;
  --muted: #7a6167;
  --line: #ead9d8;
  --brand: #a4161a;      /* blood red */
  --brand-deep: #7a0e12;
  --brand-tint: #f8e8e7;
  --pulse: #d8232a;      /* brighter arterial red: pulse line, fail states */
  --green: #178a5c;
  --green-tint: #e3f3ec;
  --red-tint: #fdeae8;
  --amber: #b26a00;
  --amber-tint: #fbf0dd;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 16, 20, .05), 0 6px 20px rgba(60, 16, 20, .07);
  --display: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100dvh;
}
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3, .brand { font-family: var(--display); }

/* ── Layout shell ─────────────────────────────────────────────────── */
.shell { max-width: 640px; margin: 0 auto; padding: 0 16px 96px; }
.shell.wide { max-width: 1080px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: env(safe-area-inset-top) 0 0;
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.05rem; letter-spacing: .02em; }
.brand svg { display: block; }
.brand .sub { font-family: var(--body); font-weight: 400; font-size: .72rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; display: block; line-height: 1.2; }

.linklike { background: none; border: none; color: var(--brand); font-weight: 600; padding: 6px 8px; border-radius: 8px; }
.linklike:hover { background: var(--brand-tint); }

/* Bottom tab bar (mobile-first) */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; background: none; border: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 6px; color: var(--muted);
  font-size: .68rem; font-weight: 600; letter-spacing: .02em;
}
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.active { color: var(--brand-deep); }
.tabbar button.active svg { stroke: var(--brand); }

@media (min-width: 768px) {
  .shell { padding-bottom: 40px; }
  .tabbar { position: sticky; top: 0; bottom: auto; border-top: none; border-bottom: 1px solid var(--line); max-width: none; justify-content: center; gap: 8px; }
  .tabbar button { flex: 0 0 auto; flex-direction: row; gap: 8px; padding: 12px 18px; font-size: .85rem; }
}

/* ── Cards & general ──────────────────────────────────────────────── */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-top: 16px;
}
.card h2 { font-size: 1.15rem; margin-bottom: 4px; }
.eyebrow { font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--brand); }
.muted { color: var(--muted); font-size: .9rem; }
.spacer { height: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--brand); color: #fff; border: none;
  border-radius: 10px; padding: 13px 20px; font-weight: 700; font-size: 1rem;
  width: 100%; margin-top: 14px;
  transition: background .15s;
}
.btn:hover { background: var(--brand-deep); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--brand-tint); color: var(--brand-deep); }
.btn.secondary:hover { background: #f0d6d4; }
.btn:active { transform: translateY(1px); }
.btn.danger { background: var(--pulse); }
.btn.slim { width: auto; padding: 9px 14px; font-size: .85rem; margin-top: 0; }

.field { margin-top: 14px; }
.field label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 5px; color: var(--ink); }
.field input, .field select {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink);
}
.field input:focus { border-color: var(--brand); outline: none; }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 560px) { .form-grid { grid-template-columns: 1fr 1fr; } }

.error-box {
  background: var(--red-tint); color: #a1271d; border-radius: 10px;
  padding: 10px 14px; margin-top: 14px; font-size: .9rem; font-weight: 500;
}

/* ── Auth screens ─────────────────────────────────────────────────── */
.auth-wrap { max-width: 460px; margin: 0 auto; padding: 40px 20px 60px; }
.auth-hero { text-align: center; margin-bottom: 8px; }
.auth-hero h1 { font-size: 2.1rem; font-weight: 800; letter-spacing: -.01em; line-height: 1.1; }
.auth-hero .muted { margin-top: 6px; }
.pulseline { width: 100%; max-width: 320px; margin: 12px auto 0; display: block; }
.pulseline path {
  fill: none; stroke: var(--pulse); stroke-width: 2.5;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 640; stroke-dashoffset: 640;
  animation: drawpulse 2.2s ease-out forwards;
}
@keyframes drawpulse { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
  .pulseline path { animation: none; stroke-dashoffset: 0; }
}

/* ── Home: journey steps ──────────────────────────────────────────── */
.steps { list-style: none; margin-top: 8px; }
.steps li {
  display: flex; gap: 14px; padding: 14px 0;
  border-bottom: 1px solid var(--line); align-items: flex-start;
}
.steps li:last-child { border-bottom: none; }
.step-dot {
  flex: 0 0 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-family: var(--display); font-size: .9rem;
  background: var(--brand-tint); color: var(--brand-deep);
}
.step-dot.done { background: var(--green); color: #fff; }
.step-dot.fail { background: var(--pulse); color: #fff; }
.step-body { flex: 1; }
.step-body strong { display: block; font-size: .95rem; }
.step-body .muted { font-size: .82rem; }

.badge {
  display: inline-block; font-size: .7rem; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 99px; margin-top: 4px;
}
.badge.pass { background: var(--green-tint); color: var(--green); }
.badge.fail { background: var(--red-tint); color: var(--pulse); }
.badge.pending { background: var(--amber-tint); color: var(--amber); }

/* ── Exam ─────────────────────────────────────────────────────────── */
.exam-progress { margin-top: 20px; }
.exam-progress .count { font-size: .78rem; font-weight: 700; color: var(--muted); letter-spacing: .06em; }
.progress-track { height: 6px; background: var(--line); border-radius: 99px; margin-top: 6px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--brand); border-radius: 99px; transition: width .25s ease; }

.question-text { font-size: 1.12rem; font-weight: 600; line-height: 1.45; margin-top: 10px; }

/* Per-question countdown donut */
.qhead { display: flex; gap: 14px; align-items: flex-start; }
.qhead .question-text { flex: 1; margin-top: 0; }
.qtimer { position: relative; flex: 0 0 54px; height: 54px; }
.qtimer svg { transform: rotate(-90deg); display: block; }
.qtimer .track { fill: none; stroke: var(--line); stroke-width: 4; }
.qtimer .arc {
  fill: none; stroke: var(--green); stroke-width: 4; stroke-linecap: round;
  transition: stroke-dashoffset .1s linear, stroke .3s;
}
.qtimer .qt-num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 800; font-size: 1.15rem; color: var(--green);
}
.qtimer.warn .arc { stroke: var(--amber); }
.qtimer.warn .qt-num { color: var(--amber); }
.qtimer.danger .arc { stroke: var(--pulse); }
.qtimer.danger .qt-num { color: var(--pulse); animation: qtpulse .45s ease-in-out infinite alternate; }
@keyframes qtpulse { from { transform: scale(1); } to { transform: scale(1.18); } }
@media (prefers-reduced-motion: reduce) {
  .qtimer.danger .qt-num { animation: none; }
}
.options { margin-top: 16px; display: grid; gap: 10px; }
.option {
  text-align: left; background: #fff; border: 1.5px solid var(--line);
  border-radius: 12px; padding: 13px 15px; font-size: .95rem; line-height: 1.4;
  display: flex; gap: 10px; align-items: flex-start; color: var(--ink);
  transition: border-color .12s, background .12s;
}
.option:hover { border-color: var(--brand); }
.option.selected { border-color: var(--brand); background: var(--brand-tint); font-weight: 600; }
.option .dot {
  flex: 0 0 20px; height: 20px; border-radius: 50%; margin-top: 1px;
  border: 2px solid var(--line);
}
.option.selected .dot { border-color: var(--brand); background: var(--brand); box-shadow: inset 0 0 0 3px var(--brand-tint); }

.exam-nav { display: flex; gap: 10px; margin-top: 18px; }
.exam-nav .btn { margin-top: 0; }

/* Result ring */
.result-hero { text-align: center; padding: 10px 0; }
.ring { width: 150px; height: 150px; margin: 10px auto; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring .track { fill: none; stroke: var(--line); stroke-width: 10; }
.ring .value { fill: none; stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 1s ease; }
.ring .pct {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 800; font-size: 2rem; line-height: 1;
}
.ring .pct small { font-family: var(--body); font-weight: 600; font-size: .72rem; color: var(--muted); margin-top: 4px; }
.verdict { font-family: var(--display); font-size: 1.5rem; font-weight: 800; }
.verdict.pass { color: var(--green); }
.verdict.fail { color: var(--pulse); }

/* ── Results: final verdict + instructor star ─────────────────────── */
.verdict-banner {
  border-radius: var(--radius); padding: 26px 20px; margin-top: 16px;
  text-align: center; box-shadow: var(--shadow); background: var(--card);
  border-top: 5px solid var(--line);
}
.verdict-banner.pass { border-top-color: var(--green); }
.verdict-banner.fail { border-top-color: var(--pulse); }
.verdict-banner.progress { border-top-color: var(--amber); }
.verdict-title {
  font-family: var(--display); font-weight: 800; font-size: 2.1rem;
  letter-spacing: .04em; line-height: 1.1; margin-top: 4px;
}
.verdict-banner.pass .verdict-title { color: var(--green); }
.verdict-banner.fail .verdict-title { color: var(--pulse); }
.verdict-banner.progress .verdict-title { color: var(--amber); }
.verdict-note { color: var(--muted); font-size: .92rem; max-width: 420px; margin: 6px auto 0; }

.star-banner {
  display: flex; gap: 14px; align-items: flex-start;
  background: #fdf6e3; border: 1.5px solid #e8cf8a; border-radius: var(--radius);
  padding: 16px 18px; margin-top: 16px;
}
.star-banner .star-ico svg { width: 28px; height: 28px; color: #c9930a; }
.star-banner strong { font-family: var(--display); font-size: 1.02rem; }
.star-banner .muted { font-size: .85rem; }

.star-toggle {
  background: none; border: none; padding: 4px; border-radius: 8px; line-height: 0;
}
.star-toggle svg { width: 22px; height: 22px; color: #c8d4d0; fill: none; transition: color .15s; }
.star-toggle:hover svg { color: #c9930a; }
.star-toggle.on svg { color: #c9930a; fill: currentColor; }
.star-inline svg { width: 15px; height: 15px; color: #c9930a; vertical-align: -2px; }

/* ── Certificate ──────────────────────────────────────────────────── */
.cert {
  background: #fff; border: 3px double var(--brand);
  border-radius: 8px; padding: 34px 26px; margin-top: 16px;
  text-align: center; position: relative; overflow: hidden;
}
.cert .watermark {
  position: absolute; inset: auto -20px 12px; opacity: .08; pointer-events: none;
}
.cert .watermark path { fill: none; stroke: var(--pulse); stroke-width: 3; }
.cert .cert-org { font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.cert h2 { font-size: 1.7rem; font-weight: 800; margin: 8px 0 2px; color: var(--brand-deep); }
.cert .cert-sub { font-size: .85rem; color: var(--muted); }
.cert .cert-name { font-family: var(--display); font-size: 1.55rem; font-weight: 700; margin: 18px 0 2px; }
.cert .cert-detail { font-size: .88rem; color: var(--muted); }
.cert .cert-grid {
  display: flex; justify-content: center; gap: 28px; flex-wrap: wrap;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line);
}
.cert .cert-grid div { text-align: center; }
.cert .cert-grid .lbl { font-size: .65rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.cert .cert-grid .val { font-weight: 700; font-size: .95rem; }

/* ── Admin ────────────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 16px; }
@media (min-width: 768px) { .stats-row { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px;
}
.stat .num { font-family: var(--display); font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.stat .lbl { font-size: .75rem; color: var(--muted); font-weight: 600; }

.table-wrap { overflow-x: auto; margin-top: 12px; }
table.roster { width: 100%; border-collapse: collapse; font-size: .87rem; min-width: 760px; }
.roster th {
  text-align: left; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: 10px 10px; border-bottom: 2px solid var(--line);
  white-space: nowrap;
}
.roster td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.roster tr:hover td { background: var(--brand-tint); }
.roster .name-cell strong { display: block; }
.roster .name-cell span { font-size: .76rem; color: var(--muted); }

.search-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.search-row input { flex: 1; min-width: 180px; padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 10px; }
.search-row select { padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--card, #fff); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16, 38, 44, .45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--radius); padding: 22px;
  width: 100%; max-width: 440px; max-height: 90dvh; overflow-y: auto;
}
.modal h3 { font-size: 1.1rem; margin-bottom: 2px; }

.seg { display: flex; gap: 8px; margin-top: 8px; }
.seg button {
  flex: 1; padding: 10px; border-radius: 10px; border: 1.5px solid var(--line);
  background: #fff; font-weight: 700; font-size: .88rem; color: var(--muted);
}
.seg button.on-pass { border-color: var(--green); background: var(--green-tint); color: var(--green); }
.seg button.on-fail { border-color: var(--pulse); background: var(--red-tint); color: var(--pulse); }
.seg button.on-pending { border-color: var(--amber); background: var(--amber-tint); color: var(--amber); }

/* ── Toast ────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 99px;
  font-size: .88rem; font-weight: 600; z-index: 60; box-shadow: var(--shadow);
  max-width: calc(100vw - 40px); text-align: center;
}
@media (min-width: 768px) { .toast { bottom: 30px; } }

/* ── Payments ─────────────────────────────────────────────────────── */
.sched-box {
  margin-top: 10px; padding: 12px 14px; border-radius: 10px;
  background: var(--green-tint); border: 1px solid var(--green);
}
.sched-box.pending { background: var(--amber-tint); border-color: var(--amber); }
.sched-box strong { font-size: .88rem; }
.sched-box p { margin: 4px 0 0; font-size: .92rem; line-height: 1.45; }
.check-row {
  display: flex; align-items: flex-start; gap: 10px; margin: 12px 0;
  font-size: .92rem; line-height: 1.45; cursor: pointer;
}
.check-row input { margin-top: 3px; accent-color: var(--brand); }

/* ── Print: certificate only ──────────────────────────────────────── */
@media print {
  body { background: #fff; }
  .topbar, .tabbar, .no-print, .toast { display: none !important; }
  .shell { max-width: none; padding: 0; }
  .cert { border-width: 4px; box-shadow: none; page-break-inside: avoid; }
}
