:root {
  --navy: #12303f;
  --navy-2: #1c4759;
  --teal: #0e7c86;
  --teal-light: #e3f2f3;
  --accent: #f0a441;
  --ink: #1d2a30;
  --muted: #5b6d75;
  --line: #d8e2e6;
  --bg: #f4f7f8;
  --card: #ffffff;
  --good: #217a3c;
  --good-bg: #e7f4ec;
  --bad: #b3372e;
  --bad-bg: #fbeae8;
  --warn-bg: #fdf3e3;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(18, 48, 63, 0.10), 0 4px 14px rgba(18, 48, 63, 0.06);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
}
a { color: var(--teal); }
h1, h2, h3 { line-height: 1.25; color: var(--navy); }
small { color: var(--muted); }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.55rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 0.55rem; text-decoration: none; color: #fff; }
.brand-mark {
  background: linear-gradient(135deg, var(--teal), #14a8b4);
  width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 1.15rem;
}
.brand-logo {
  width: 38px; height: 38px; border-radius: 9px; object-fit: cover;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}
.brand-text { font-weight: 700; font-size: 1.02rem; }
.brand-text small { display: block; font-size: 0.68rem; font-weight: 400; color: #b7cdd6; letter-spacing: 0.04em; }
.main-nav { display: flex; gap: 0.15rem; flex-wrap: wrap; }
.main-nav a {
  color: #cfe0e6; text-decoration: none; padding: 0.45rem 0.7rem;
  border-radius: 7px; font-size: 0.92rem;
}
.main-nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.main-nav a.active { background: var(--teal); color: #fff; }
.topbar-right { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; position: relative; }

.network-menu { position: relative; }
.network-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); min-width: 270px; padding: 0.5rem; z-index: 60;
}
.network-dropdown a {
  display: block; padding: 0.55rem 0.65rem; border-radius: 8px; text-decoration: none;
}
.network-dropdown a:hover { background: var(--teal-light); }
.network-dropdown .net-name { font-weight: 700; color: var(--navy); }
.network-dropdown .net-tag { font-size: 0.8rem; color: var(--muted); }

/* ---------- Buttons / forms ---------- */
.btn {
  border: 1px solid transparent; border-radius: 8px;
  padding: 0.5rem 0.95rem; font-size: 0.92rem; font-weight: 600;
  cursor: pointer; transition: background 0.15s ease;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: #0b6a73; }
.btn-secondary { background: var(--card); color: var(--navy); border-color: var(--line); }
.btn-secondary:hover { background: var(--teal-light); }
.btn-ghost { background: transparent; color: #cfe0e6; border-color: rgba(255,255,255,0.25); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-lg { padding: 0.7rem 1.3rem; font-size: 1rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; padding: 0.55rem 0.7rem; border: 1px solid var(--line);
  border-radius: 8px; font-size: 0.95rem; background: #fff; color: var(--ink);
}
label { font-size: 0.88rem; font-weight: 600; color: var(--navy); display: block; margin: 0.6rem 0 0.25rem; }

/* ---------- Layout ---------- */
.view { max-width: 1180px; margin: 0 auto; padding: 1.4rem 1rem 3rem; min-height: 60vh; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
}
.card h3 { margin-top: 0; }
.card.clickable { cursor: pointer; transition: transform 0.12s ease, border-color 0.12s ease; }
.card.clickable:hover { transform: translateY(-2px); border-color: var(--teal); }

.hero {
  background: linear-gradient(135deg, var(--navy), var(--navy-2) 55%, var(--teal));
  color: #fff; border-radius: 14px; padding: 2.2rem 1.8rem; margin-bottom: 1.4rem;
}
.hero h1 { color: #fff; margin: 0 0 0.5rem; font-size: 1.9rem; }
.hero p { max-width: 720px; color: #dcebef; margin: 0.3rem 0 1.1rem; }
.hero .btn { margin-right: 0.5rem; }

.pill {
  display: inline-block; background: var(--teal-light); color: var(--teal);
  font-size: 0.75rem; font-weight: 700; padding: 0.16rem 0.6rem;
  border-radius: 999px; letter-spacing: 0.03em; text-transform: uppercase;
}
.pill.warn { background: var(--warn-bg); color: #9a6b13; }
.pill.navy { background: #e4ebef; color: var(--navy); }

.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.9rem 1.2rem; flex: 1 1 140px; box-shadow: var(--shadow);
}
.stat .num { font-size: 1.7rem; font-weight: 800; color: var(--teal); }
.stat .lbl { font-size: 0.82rem; color: var(--muted); }

.progress-bar { background: #e4ebef; border-radius: 999px; height: 10px; overflow: hidden; }
.progress-bar > div { background: var(--teal); height: 100%; border-radius: 999px; transition: width 0.3s ease; }

table.simple { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
table.simple th, table.simple td { border: 1px solid var(--line); padding: 0.5rem 0.65rem; text-align: left; }
table.simple th { background: var(--teal-light); color: var(--navy); }

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

/* ---------- Quiz items ---------- */
.q-stem { font-size: 1.05rem; margin-bottom: 1rem; white-space: pre-wrap; }
.q-meta { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.8rem; flex-wrap: wrap; }
.option {
  display: flex; gap: 0.6rem; align-items: flex-start;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 0.6rem 0.8rem; margin: 0.4rem 0; cursor: pointer; background: #fff;
}
.option:hover { border-color: var(--teal); }
.option.selected { border-color: var(--teal); background: var(--teal-light); }
.option.correct { border-color: var(--good); background: var(--good-bg); }
.option.incorrect { border-color: var(--bad); background: var(--bad-bg); }
.option input { margin-top: 0.3rem; }

.cloze-select { display: inline-block; width: auto; margin: 0 0.2rem; }

.bowtie-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.8rem; }
.bowtie-col { border: 1px dashed var(--line); border-radius: 8px; padding: 0.6rem; }
.bowtie-col h4 { margin: 0 0 0.4rem; font-size: 0.88rem; color: var(--navy); }

.ordered-item {
  display: flex; align-items: center; gap: 0.5rem;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 0.5rem 0.7rem; margin: 0.35rem 0;
}
.ordered-item .move { display: flex; gap: 0.25rem; margin-left: auto; }
.ordered-item .move button { padding: 0.1rem 0.5rem; }

.hl-token {
  display: inline-block; margin: 0.25rem; padding: 0.4rem 0.7rem;
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: #fff;
}
.hl-token.selected { background: #fff3cd; border-color: var(--accent); }
.hl-token.correct { background: var(--good-bg); border-color: var(--good); }
.hl-token.incorrect { background: var(--bad-bg); border-color: var(--bad); }

.feedback { border-radius: var(--radius); padding: 1rem 1.2rem; margin-top: 1rem; }
.feedback.good { background: var(--good-bg); border: 1px solid var(--good); }
.feedback.partial { background: var(--warn-bg); border: 1px solid var(--accent); }
.feedback.bad { background: var(--bad-bg); border: 1px solid var(--bad); }
.feedback h4 { margin: 0 0 0.4rem; }
.refs { font-size: 0.84rem; color: var(--muted); margin-top: 0.6rem; }
.refs a { word-break: break-all; }

/* ---------- EHR chart ---------- */
.ehr { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.ehr-tabs { display: flex; background: var(--navy); flex-wrap: wrap; }
.ehr-tabs button {
  background: transparent; color: #cfe0e6; border: none; padding: 0.6rem 1rem;
  cursor: pointer; font-size: 0.88rem; font-weight: 600;
}
.ehr-tabs button.active { background: var(--teal); color: #fff; }
.ehr-body { padding: 1rem 1.2rem; white-space: pre-wrap; font-size: 0.92rem; max-height: 330px; overflow-y: auto; }

/* ---------- Lessons ---------- */
.lesson-body { max-width: 800px; }
.lesson-body h1, .lesson-body h2, .lesson-body h3 { margin-top: 1.4rem; }
.lesson-body ul { padding-left: 1.3rem; }
.keypoints { background: var(--teal-light); border-radius: var(--radius); padding: 1rem 1.3rem; margin: 1rem 0; }
.keypoints h4 { margin: 0 0 0.5rem; color: var(--teal); }

.crumbs { font-size: 0.86rem; margin-bottom: 0.8rem; color: var(--muted); }
.crumbs a { text-decoration: none; }

/* ---------- Flashcards ---------- */
.flashcard {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 2rem; min-height: 210px;
  display: grid; place-items: center; text-align: center; font-size: 1.12rem;
  max-width: 640px; margin: 0 auto 1rem;
}
.srs-row { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }

/* ---------- Video player ---------- */
.video-frame {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background: #0a1920; border-radius: var(--radius); overflow: hidden;
}
.video-frame iframe, .video-frame > div { position: absolute; inset: 0; width: 100%; height: 100%; }
.video-placeholder {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #cfe0e6; text-align: center; padding: 2rem;
}
.checkpoint-panel {
  border: 2px solid var(--accent); border-radius: var(--radius);
  background: var(--warn-bg); padding: 1.1rem 1.3rem; margin-top: 1rem;
}
.checkpoint-panel .cp-head { font-weight: 800; color: #9a6b13; margin-bottom: 0.6rem; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 25, 33, 0.55);
  display: grid; place-items: center; z-index: 100; padding: 1rem;
}
.modal {
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  width: 100%; max-width: 430px; padding: 1.5rem 1.6rem; max-height: 92vh; overflow-y: auto;
}
.modal h2 { margin-top: 0; }
.modal .tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; }
.modal .tabs button { flex: 1; }
.form-error { color: var(--bad); font-size: 0.88rem; margin-top: 0.6rem; }
.terms-note { font-size: 0.8rem; color: var(--muted); }

/* ---------- Footer ---------- */
.footer { background: var(--navy); color: #b7cdd6; margin-top: 2rem; }
.footer-inner {
  max-width: 1180px; margin: 0 auto; padding: 2rem 1rem 0.5rem;
  display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.footer-col strong { color: #fff; display: block; margin-bottom: 0.5rem; }
.footer-col a { display: block; color: #b7cdd6; text-decoration: none; padding: 0.15rem 0; font-size: 0.9rem; }
.footer-col a:hover { color: #fff; }
.footer-col p { font-size: 0.86rem; margin: 0; }
.footer-legal {
  max-width: 1180px; margin: 0 auto; padding: 1rem; font-size: 0.76rem;
  border-top: 1px solid rgba(255,255,255,0.12); color: #8fa8b2;
}

@media (max-width: 720px) {
  .bowtie-grid { grid-template-columns: 1fr; }
  .topbar-inner { gap: 0.5rem; }
  .hero { padding: 1.5rem 1.2rem; }
}

/* ---------- Patient simulator ---------- */
.monitor {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: stretch;
  background: var(--navy); border-radius: var(--radius); padding: 0.6rem 0.8rem;
  box-shadow: var(--shadow); margin-bottom: 1rem;
}
.monitor-clock {
  color: #fff; font-weight: 700; display: flex; align-items: center;
  padding: 0 0.8rem 0 0.2rem; font-variant-numeric: tabular-nums;
}
.vital {
  background: var(--navy-2); border-radius: 8px; padding: 0.35rem 0.8rem;
  min-width: 86px; text-align: center; color: #9fd8db;
}
.vital-label { font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.8; }
.vital-value { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; color: #e6f6f7; }
.vital-trend { font-size: 0.8rem; vertical-align: middle; }
.vital-unit { font-size: 0.68rem; opacity: 0.7; }
.vital-alarm { background: #5e1f1a; }
.vital-alarm .vital-value { color: #ffb0a6; animation: vital-blink 1.2s step-end infinite; }
@keyframes vital-blink { 50% { opacity: 0.45; } }

.sim-columns { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1rem; }
@media (max-width: 900px) { .sim-columns { grid-template-columns: 1fr; } }
.sim-presentation p { margin: 0.3rem 0 0; }
.sim-action-group { margin-top: 0.8rem; }
.sim-action-head {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 0.3rem;
}
.sim-action { display: block; width: 100%; text-align: left; margin-top: 0.35rem; }
.sim-action:disabled { opacity: 0.45; cursor: default; }
.sim-log { max-height: 260px; overflow-y: auto; font-size: 0.88rem; }
.sim-log-entry { padding: 0.25rem 0; border-bottom: 1px dashed var(--line); }
.sim-log-t { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 700; margin-right: 0.4rem; }
.sim-log-event { color: var(--bad); }
.sim-log-patient { color: var(--navy-2); font-style: italic; }
.sim-rubric { width: 100%; border-collapse: collapse; }
.sim-rubric td { padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.rubric-mark { font-size: 1.05rem; width: 2rem; }
.rubric-earned .rubric-mark { color: var(--good); }
.rubric-missed .rubric-mark, .rubric-late .rubric-mark { color: var(--bad); }
.rubric-pts { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
