:root {
  --ink: #1a1533;
  --ink-soft: #4a4368;
  --bg: #f4f1ff;
  --card: #ffffff;
  --purple: #6d28d9;
  --purple-dark: #4c1d95;
  --pink: #ec4899;
  --teal: #0d9488;
  --orange: #f97316;
  --red: #dc2626;
  --green: #16a34a;
  --border: #e4defc;
  --shadow: 0 8px 24px rgba(76, 29, 149, 0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  background-image:
    radial-gradient(circle at 10% 0%, rgba(109,40,217,0.10) 0, transparent 45%),
    radial-gradient(circle at 90% 10%, rgba(236,72,153,0.10) 0, transparent 40%);
  background-attachment: fixed;
}

/* ---------- Password gate ---------- */
#gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--purple-dark), var(--purple) 45%, var(--pink) 110%);
}
#gate[hidden], #site[hidden] {
  display: none;
}

.gate-card {
  background: var(--card);
  border-radius: 20px;
  padding: 40px 36px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

.gate-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  color: white;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}

.gate-card h1 {
  font-size: 1.4rem;
  line-height: 1.3;
  margin: 0 0 6px;
  color: var(--purple-dark);
}

.gate-sub {
  color: var(--ink-soft);
  margin: 0 0 24px;
  font-size: 0.95rem;
}

#gate-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#gate-password {
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px solid var(--border);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
}
#gate-password:focus { border-color: var(--purple); }

#gate-form button {
  padding: 14px 16px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  color: white;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
}
#gate-form button:hover { opacity: 0.92; }
#gate-form button:active { transform: scale(0.98); }

.gate-error {
  color: var(--red);
  font-weight: 600;
  font-size: 0.9rem;
  margin: 12px 0 0;
}

.gate-note {
  margin: 20px 0 0;
  font-size: 0.78rem;
  color: #948da8;
}

/* ---------- Main site ---------- */
.site-header {
  background: linear-gradient(120deg, var(--purple-dark), var(--purple) 60%, var(--pink) 130%);
  color: white;
  padding: 28px 24px 20px;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(255,255,255,0.18);
  font-weight: 800;
  flex-shrink: 0;
}

.header-title h1 {
  margin: 0;
  font-size: 1.3rem;
}
.header-title p {
  margin: 2px 0 0;
  font-size: 0.85rem;
  opacity: 0.85;
}

#lock-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.35);
  color: white;
  padding: 8px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  flex-shrink: 0;
}
#lock-btn:hover { background: rgba(255,255,255,0.25); }

.search-row {
  max-width: 960px;
  margin: 20px auto 0;
}

#search {
  width: 100%;
  padding: 14px 18px;
  border-radius: 12px;
  border: none;
  font-size: 1rem;
  outline: none;
  box-shadow: var(--shadow);
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.protocol-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.protocol-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
}

.protocol-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

.protocol-toggle:hover { background: #faf8ff; }

.protocol-toggle .chev {
  color: var(--purple);
  transition: transform 0.2s;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.protocol-card.open .protocol-toggle .chev {
  transform: rotate(180deg);
}

.protocol-body {
  padding: 0 22px 24px;
  display: none;
}
.protocol-card.open .protocol-body {
  display: block;
}

.crit-block {
  margin-bottom: 18px;
}

.crit-block h3 {
  margin: 0 0 8px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 999px;
}

.crit-block.inclusion h3 { background: #dcfce7; color: #15803d; }
.crit-block.exclusion h3 { background: #fee2e2; color: #b91c1c; }
.crit-block.interventions h3 { background: #dbeafe; color: #1d4ed8; }
.crit-block.discharge h3 { background: #ede9fe; color: #6d28d9; }
.crit-block.admission h3 { background: #ffedd5; color: #c2410c; }

.crit-block ul {
  margin: 0;
  padding-left: 20px;
}
.crit-block li {
  margin: 5px 0;
  line-height: 1.45;
  font-size: 0.94rem;
}

.criteria-note {
  background: #fff7ed;
  border: 1px dashed #fdba74;
  color: #9a3412;
  font-size: 0.85rem;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
}

.algorithms {
  margin-top: 18px;
}
.algorithms-label {
  font-weight: 800;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--orange);
  margin-bottom: 10px;
}
.algorithms-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.algorithm-thumb {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: 160px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: white;
  padding: 8px;
  cursor: pointer;
  text-align: left;
  transition: box-shadow 0.15s, transform 0.1s;
}
.algorithm-thumb:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.algorithm-thumb img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  object-position: top;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fafafa;
}
.algorithm-thumb span {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink-soft);
  line-height: 1.3;
}

.thumb-broken-msg {
  width: 100%;
  height: 110px;
  border-radius: 8px;
  border: 1px dashed var(--red);
  background: #fef2f2;
  color: var(--red);
  font-size: 0.72rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lightbox[hidden] { display: none; }

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 21, 51, 0.75);
}

.lightbox-panel {
  position: relative;
  background: white;
  border-radius: 16px;
  max-width: min(900px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  color: var(--purple-dark);
}

#lightbox-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-soft);
  padding: 0 4px;
}
#lightbox-close:hover { color: var(--red); }

.lightbox-body {
  overflow: auto;
  padding: 12px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.lightbox-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.orderset-section {
  margin-top: 20px;
  border-radius: 14px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.orderset-tab {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(120deg, var(--teal), #0d5f66);
  color: white;
  border: none;
  font-weight: 700;
  font-size: 0.98rem;
  cursor: pointer;
}
.orderset-tab .chev {
  transition: transform 0.2s;
}
.orderset-section.open .orderset-tab .chev {
  transform: rotate(180deg);
}
.orderset-content {
  display: none;
  padding: 4px 20px 20px;
  background: linear-gradient(135deg, #faf5ff, #fff);
}
.orderset-section.open .orderset-content {
  display: block;
}

.order-set {
  margin-top: 16px;
}
.order-set:first-child {
  margin-top: 4px;
}

.order-set h3 {
  margin: 0 0 12px;
  color: var(--purple-dark);
  font-size: 1rem;
}

.order-set .os-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.order-set .os-meta span {
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.order-set .os-meta b { color: var(--ink); }

.os-field {
  margin-bottom: 14px;
}
.os-field-label {
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--teal);
  margin-bottom: 4px;
}
.os-field-sub {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin: 6px 0 2px;
}

.os-list {
  margin: 0;
  padding-left: 20px;
}
.os-list li {
  padding: 3px 0;
  font-size: 0.92rem;
  line-height: 1.45;
}

.order-set-note {
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-style: italic;
}

.no-results {
  text-align: center;
  color: var(--ink-soft);
  padding: 40px 0;
}

/* ---------- Supplemental ---------- */
.supplemental {
  margin-top: 32px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.supplemental-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  background: linear-gradient(120deg, var(--orange), var(--pink));
  color: white;
  border: none;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.98rem;
}

.supplemental-body {
  background: var(--card);
  padding: 18px 22px;
}

.excl-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.excl-item:last-child { border-bottom: none; }
.excl-item b { color: var(--purple-dark); display: block; margin-bottom: 3px; font-size: 0.92rem; }
.excl-item span { font-size: 0.88rem; color: var(--ink-soft); }

.site-footer {
  text-align: center;
  padding: 20px;
  font-size: 0.78rem;
  color: #a79fc4;
}

@media (max-width: 600px) {
  .header-inner { flex-wrap: wrap; }
  .gate-card { padding: 30px 22px; }
}
