:root {
  --cta:            #1a67cc;
  --cta-dark:       #14509f;
  --accent:         #18d6c4;
  --accent-dark:    #13a89a;
  --cream:          #f4eed7;
  --cream-border:   #e9ddaf;
  --cream-light:    #fffcf0;
  --cool:           #e5eef8;
  --cool-border:    #bdd4ed;
  --dark:           #333;
  --grey:           #4d4d4d;
  --grey-soft:      #676767;
  --grey-line:      #e0e0e0;
  --light:          #fff;
  --danger:         #c12727;
  --pw-green:       #16a34a;
  --pw-green-bg:    #f0fdf4;
  --pw-green-bdr:   #bbf7d0;
  --pw-yellow:      #ca8a04;
  --pw-yellow-bg:   #fefce8;
  --pw-yellow-bdr:  #fef08a;
  --pw-red:         #dc2626;
  --pw-red-bg:      #fef2f2;
  --pw-red-bdr:     #fecaca;
  --font-heading:   "Inter", system-ui, sans-serif;
  --font-body:      "DM Sans", system-ui, sans-serif;
  --radius-sm:      0.5rem;
  --radius-md:      1.5rem;
  --radius-pill:    100em;
  --shadow-soft:    0 3px 6px 0 rgba(0,0,0,0.06);
  --content-max:    112rem;
  --gutter:         clamp(2rem, 5vw, 6rem);
}

html { font-size: 62.5%; }
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0; background: var(--light); color: var(--dark);
  font-family: var(--font-body); font-size: 1.7rem; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(ellipse 90rem 50rem at 8% -10%, rgba(229,238,248,0.9), transparent 60%),
    radial-gradient(ellipse 70rem 40rem at 100% 5%, rgba(244,238,215,0.65), transparent 55%);
  background-repeat: no-repeat;
}

a { color: var(--cta); text-decoration: none; }
a:hover { color: var(--cta-dark); text-decoration: underline; }

/* ── Header ────────────────────────────────────────────────────────────── */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 2rem; padding: 2.4rem var(--gutter);
  max-width: var(--content-max); margin: 0 auto;
}
.brand-group { display: flex; flex-direction: column; gap: 0.6rem; }
.brand img { height: 3.6rem; width: auto; display: block; }
.back-link {
  font-family: var(--font-heading); font-size: 1.3rem; font-weight: 600;
  color: var(--cta); text-decoration: none;
}
.back-link:hover { color: var(--cta-dark); text-decoration: underline; }
.chip {
  font-family: var(--font-heading); font-size: 1.2rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  padding: 0.6rem 1.2rem; border-radius: var(--radius-pill);
  background: var(--cream); color: var(--cta-dark);
  border: 1px solid var(--cream-border); white-space: nowrap;
}

/* ── Layout ────────────────────────────────────────────────────────────── */
main {
  max-width: var(--content-max); margin: 0 auto;
  padding: 4rem var(--gutter) 8rem;
  display: flex; flex-direction: column; gap: 4rem;
}

/* ── Intro ──────────────────────────────────────────────────────────────── */
.intro { max-width: 72rem; }
.kicker {
  font-family: var(--font-heading); font-size: 1.3rem; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--cta);
  margin: 0 0 1.4rem; display: inline-flex; align-items: center; gap: 0.8rem;
}
.kicker::before {
  content: ""; width: 2.4rem; height: 0.2rem;
  background: var(--accent); border-radius: 2px;
}
h1 {
  font-family: var(--font-heading); font-weight: 600;
  font-size: clamp(3.8rem, 5.6vw, 6.4rem); line-height: 1.05;
  letter-spacing: -0.02em; margin: 0 0 2rem;
}
.lede {
  font-size: clamp(1.8rem, 1.6vw, 2.1rem); line-height: 1.5;
  color: var(--grey); margin: 0; max-width: 56rem;
}

/* ── Workspace grid ────────────────────────────────────────────────────── */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38rem;
  gap: 3.2rem; align-items: start;
}
@media (max-width: 960px) {
  .workspace { grid-template-columns: 1fr; }
}

/* ── Card / panel base ─────────────────────────────────────────────────── */
.card {
  background: var(--light); border: 1px solid var(--grey-line);
  border-radius: var(--radius-md); box-shadow: var(--shadow-soft);
}
.tool-panel { padding: 4rem clamp(2.4rem, 4vw, 5rem); }

/* ── Steps ──────────────────────────────────────────────────────────────── */
.step + .step { margin-top: 3.2rem; padding-top: 3.2rem; border-top: 1px solid var(--grey-line); }
.step__label {
  display: block; font-family: var(--font-heading);
  font-weight: 600; font-size: clamp(1.8rem, 2vw, 2.2rem);
  color: var(--dark); margin: 0 0 1.6rem;
}

/* ── Search ─────────────────────────────────────────────────────────────── */
.search-wrap { position: relative; }
.search-input {
  font-family: var(--font-body); font-size: 1.8rem; font-weight: 500;
  color: var(--dark); width: 100%;
  padding: 1.4rem 1.6rem; background: var(--light);
  border: 1.5px solid var(--grey-line); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.search-input:focus {
  outline: none; border-color: var(--cta);
  box-shadow: 0 0 0 3px rgba(26,103,204,0.18);
}
.search-input::placeholder { color: #aeb7c2; font-weight: 400; }

.search-results {
  list-style: none; margin: 0.4rem 0 0; padding: 0.6rem 0;
  position: absolute; left: 0; right: 0; z-index: 10;
  background: var(--light); border: 1px solid var(--grey-line);
  border-radius: var(--radius-sm); box-shadow: 0 12px 32px -8px rgba(0,0,0,0.14);
  max-height: 36rem; overflow-y: auto;
}
.search-results[hidden] { display: none; }
.search-item {
  padding: 1.2rem 1.6rem; cursor: pointer;
  display: flex; gap: 1.2rem; align-items: baseline;
  transition: background .1s;
}
.search-item:hover, .search-item:focus { background: var(--cool); outline: none; }
.search-item__code {
  font-family: var(--font-heading); font-weight: 700;
  font-size: 1.4rem; color: var(--cta); min-width: 6rem;
}
.search-item__name { font-size: 1.5rem; color: var(--dark); flex: 1; }
.search-item__unit { font-size: 1.3rem; color: var(--grey-soft); }
.search-empty { padding: 1.6rem; color: var(--grey-soft); font-size: 1.4rem; }

.test-selected {
  display: flex; align-items: center; gap: 1.2rem;
}
.test-badge {
  font-family: var(--font-heading); font-weight: 600;
  font-size: 1.6rem; color: var(--cta-dark);
  padding: 1.2rem 1.6rem; border-radius: var(--radius-sm);
  background: var(--cool); border: 1px solid var(--cool-border);
  flex: 1;
}
.test-clear {
  width: 4rem; height: 4rem; border-radius: 50%;
  border: 1.5px solid var(--grey-line); background: var(--light);
  font-size: 2rem; color: var(--grey); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .1s, color .1s;
}
.test-clear:hover { background: var(--danger); color: var(--light); border-color: var(--danger); }

/* ── Patient fields ────────────────────────────────────────────────────── */
.patient-fields { display: flex; gap: 2.4rem; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 0.8rem; }
.field__label {
  font-family: var(--font-heading); font-weight: 600;
  font-size: 1.4rem; color: var(--grey);
}
input[type="number"] {
  font-family: var(--font-body); font-size: 1.9rem; font-weight: 500;
  color: var(--dark); padding: 1.2rem 1.6rem;
  background: var(--light); border: 1.5px solid var(--grey-line);
  border-radius: var(--radius-sm); min-width: 12rem;
  transition: border-color .15s, box-shadow .15s;
}
input[type="number"]:focus {
  outline: none; border-color: var(--cta);
  box-shadow: 0 0 0 3px rgba(26,103,204,0.18);
}
input::placeholder { color: #aeb7c2; font-weight: 400; }

.pill-group { display: flex; gap: 1rem; }
.pill {
  font-family: var(--font-heading); font-size: 1.5rem; font-weight: 600;
  color: var(--dark); background: var(--light);
  border: 1.5px solid var(--grey-line); border-radius: var(--radius-pill);
  padding: 1rem 2rem; cursor: pointer; line-height: 1;
  transition: background .15s, border-color .15s, color .15s;
}
.pill:hover { border-color: var(--cta); color: var(--cta-dark); }
.pill[aria-checked="true"] {
  background: var(--cta); border-color: var(--cta); color: var(--light);
  box-shadow: 0 6px 14px -6px rgba(26,103,204,0.4);
}

/* ── Result field ──────────────────────────────────────────────────────── */
.result-field { display: flex; align-items: center; gap: 1.2rem; }
.result-unit {
  font-family: var(--font-heading); font-weight: 600;
  font-size: 1.6rem; color: var(--grey-soft);
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  position: sticky; top: 2.4rem;
  padding: 3rem 2.8rem; border-radius: var(--radius-md);
  background: linear-gradient(180deg, #fffcf0 0%, var(--cream) 100%);
  border: 1px solid var(--cream-border); box-shadow: var(--shadow-soft);
}
.sidebar-empty { color: var(--grey-soft); font-size: 1.5rem; text-align: center; padding: 3rem 0; }
.sidebar__eyebrow {
  font-family: var(--font-heading); font-size: 1.2rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--cta-dark);
  margin: 0 0 0.8rem; display: inline-flex; align-items: center; gap: 0.8rem;
}
.sidebar__eyebrow::before {
  content: ""; width: 2rem; height: 0.2rem;
  background: var(--accent); border-radius: 2px;
}
.sidebar__title {
  font-family: var(--font-heading); font-size: 2.2rem; font-weight: 600;
  line-height: 1.2; color: var(--dark); margin: 0 0 0.6rem;
}
.sidebar__unit {
  font-size: 1.4rem; color: var(--grey-soft); margin: 0 0 2rem;
}
.sidebar__unit strong { color: var(--cta-dark); }
.sidebar__foot {
  font-size: 1.1rem; color: var(--grey-soft); margin: 1.6rem 0 0;
  text-transform: uppercase; letter-spacing: 0.1em;
  font-family: var(--font-heading); font-weight: 500;
  padding-top: 1.2rem; border-top: 1px dashed var(--cream-border);
}

/* ── Range table ───────────────────────────────────────────────────────── */
.range-table-wrap { overflow-x: auto; margin: 0 -0.5rem; }
.range-table {
  width: 100%; border-collapse: collapse; font-size: 1.3rem;
  font-family: var(--font-heading);
}
.range-table th {
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  font-size: 1.1rem; color: var(--grey-soft); text-align: left;
  padding: 0.8rem 0.6rem; border-bottom: 1px solid var(--cream-border);
}
.range-table td {
  padding: 0.8rem 0.6rem; border-bottom: 1px solid rgba(233,221,175,0.4);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.th--green, .td--green { color: var(--pw-green); }
.th--yellow, .td--yellow { color: var(--pw-yellow); }
.th--red, .td--red { color: var(--pw-red); }

/* ── Pathway result ────────────────────────────────────────────────────── */
.pathway-result[hidden] { display: none; }

.pw {
  border-radius: var(--radius-md); padding: 3.2rem;
  border: 2px solid; position: relative; overflow: hidden;
  animation: pw-in 0.4s cubic-bezier(.22,1,.36,1) forwards;
  opacity: 0; transform: translateY(0.5rem);
}
@keyframes pw-in { to { opacity: 1; transform: none; } }

.pw--green  { background: var(--pw-green-bg);  border-color: var(--pw-green-bdr); }
.pw--yellow { background: var(--pw-yellow-bg); border-color: var(--pw-yellow-bdr); }
.pw--red    { background: var(--pw-red-bg);    border-color: var(--pw-red-bdr); }
.pw--none   { background: var(--cool); border-color: var(--cool-border); padding: 2.4rem; }
.pw--none .pw__title { font-size: 1.8rem; margin: 0 0 0.8rem; }
.pw--none .pw__body  { font-size: 1.5rem; color: var(--grey); margin: 0; }

.pw__header { display: flex; align-items: center; gap: 2rem; margin-bottom: 2rem; }
.pw__signal {
  width: 5.6rem; height: 5.6rem; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.pw--green  .pw__signal { background: var(--pw-green);  box-shadow: 0 0 0 8px rgba(22,163,74,0.12); }
.pw--yellow .pw__signal { background: var(--pw-yellow); box-shadow: 0 0 0 8px rgba(202,138,4,0.12); }
.pw--red    .pw__signal { background: var(--pw-red);    box-shadow: 0 0 0 8px rgba(220,38,38,0.15); }
/* Inner glow dot */
.pw__signal::after {
  content: ""; width: 2rem; height: 2rem; border-radius: 50%; background: rgba(255,255,255,0.7);
}

.pw__label {
  font-family: var(--font-heading); font-size: 1.2rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; display: block; margin-bottom: 0.4rem;
}
.pw--green  .pw__label { color: var(--pw-green); }
.pw--yellow .pw__label { color: var(--pw-yellow); }
.pw--red    .pw__label { color: var(--pw-red); }

.pw__title {
  font-family: var(--font-heading); font-weight: 700;
  font-size: clamp(2.4rem, 2.4vw, 3.2rem); line-height: 1.15;
  margin: 0; color: var(--dark);
}

.pw__value {
  font-size: 1.8rem; margin: 0 0 1.2rem; color: var(--dark);
}
.pw__num {
  font-family: var(--font-heading); font-weight: 700;
  font-size: 3.2rem; font-variant-numeric: tabular-nums;
  margin: 0 0.4rem;
}
.pw--green  .pw__num { color: var(--pw-green); }
.pw--yellow .pw__num { color: var(--pw-yellow); }
.pw--red    .pw__num { color: var(--pw-red); }
.pw__unit { font-size: 1.5rem; color: var(--grey-soft); }

.pw__action {
  font-size: 1.6rem; line-height: 1.5; color: var(--dark);
  margin: 0 0 2.4rem; padding: 1.6rem; border-radius: var(--radius-sm);
  font-weight: 500;
}
.pw--green  .pw__action { background: rgba(22,163,74,0.08); }
.pw--yellow .pw__action { background: rgba(202,138,4,0.08); }
.pw--red    .pw__action { background: rgba(220,38,38,0.08); }

/* ── Range visual ──────────────────────────────────────────────────────── */
.pw__ranges { padding-top: 2rem; border-top: 1px solid; }
.pw--green  .pw__ranges { border-color: var(--pw-green-bdr); }
.pw--yellow .pw__ranges { border-color: var(--pw-yellow-bdr); }
.pw--red    .pw__ranges { border-color: var(--pw-red-bdr); }

.pw__ranges-title {
  font-family: var(--font-heading); font-size: 1.2rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--grey-soft); margin: 0 0 1.4rem;
}

.range-visual { display: flex; gap: 0.3rem; border-radius: var(--radius-sm); overflow: hidden; }
.rv {
  flex: 1; padding: 1rem 1.2rem; text-align: center; min-width: 8rem;
}
.rv--green  { background: var(--pw-green-bdr);  }
.rv--yellow { background: var(--pw-yellow-bdr); }
.rv--red    { background: var(--pw-red-bdr);    }
.rv__label {
  font-family: var(--font-heading); font-weight: 700; font-size: 1.3rem;
}
.rv--green  .rv__label { color: var(--pw-green); }
.rv--yellow .rv__label { color: var(--pw-yellow); }
.rv--red    .rv__label { color: var(--pw-red); }

/* ── Footer ────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--grey-line);
  padding: 3rem var(--gutter) 4rem;
  max-width: var(--content-max); margin: 4rem auto 0;
  color: var(--grey-soft); font-size: 1.35rem;
}
.site-footer p { margin: 0; max-width: 64rem; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .sidebar { position: static; }
}
@media (max-width: 720px) {
  main { padding: 2.4rem var(--gutter) 6rem; gap: 2.8rem; }
  .tool-panel { padding: 2.8rem 2rem; }
  .patient-fields { flex-direction: column; gap: 1.6rem; }
  .pw { padding: 2.4rem 2rem; }
  .pw__signal { width: 4.2rem; height: 4.2rem; }
  .pw__signal::after { width: 1.4rem; height: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  .pw { animation: none !important; opacity: 1 !important; transform: none !important; }
}
