:root {
  --bg: #f4f7fa; --card: #ffffff; --ink: #10233a; --muted: #5b6b7f; --line: #e3e9f0;
  --navy: #0f2a3d; --navy-2: #163a54; --teal: #0e9f8e; --teal-ink: #0a7a6d; --teal-soft: #e3f6f3;
  --amber: #b86e00; --amber-soft: #fff4e0; --red: #b42318; --red-soft: #fdecea; --green: #1d7a4c; --green-soft: #e6f5ec;
  --radius: 16px; --shadow: 0 1px 2px rgba(16,35,58,.06), 0 8px 24px -12px rgba(16,35,58,.18);
  --font: 'Heebo', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 17px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom); }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 700; }
p { margin: 0; }

.top { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 8px; padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--navy); color: #fff; }
.top-title { text-align: center; display: flex; flex-direction: column; line-height: 1.15; }
.brand { font-weight: 800; font-size: 18px; letter-spacing: .2px; }
.sub { font-size: 12px; opacity: .78; }
.top-btn { width: 44px; height: 44px; border: 0; border-radius: 12px; background: rgba(255,255,255,.1); color: #fff; font-size: 22px; cursor: pointer; }
#btn-back { transform: scaleX(1); } /* RTL: "›" already points to the right = back */
.top-btn[hidden] { visibility: hidden; display: block; }
.top-title { min-width: 0; white-space: nowrap; overflow: hidden; }

.app { max-width: 560px; margin: 0 auto; padding: 16px 16px 40px; }
.progress { display: flex; gap: 6px; margin: 0 0 14px; }
.progress i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.progress i.on { background: var(--teal); }
.step-kicker { color: var(--teal-ink); font-weight: 600; font-size: 13px; letter-spacing: .3px; margin-bottom: 4px; }
.step-title { font-size: 24px; margin-bottom: 6px; }
.step-help { color: var(--muted); font-size: 15px; margin-bottom: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.card h3 { font-size: 16px; margin-bottom: 10px; }
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.label { display: block; font-weight: 600; margin-bottom: 8px; }
.label small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.choices { display: grid; gap: 8px; }
.choices.cols2 { grid-template-columns: 1fr 1fr; }
.choices.cols3 { grid-template-columns: 1fr 1fr 1fr; }
.choice { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; min-height: 48px; text-align: right; width: 100%; }
.choice.on { border-color: var(--teal); background: var(--teal-soft); box-shadow: inset 0 0 0 1px var(--teal); }
.choice .dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #b8c4d1; flex: none; }
.choice.on .dot { border-color: var(--teal); background: var(--teal); box-shadow: inset 0 0 0 3px #fff; }
.choice.box .dot { border-radius: 5px; }
.choice small { color: var(--muted); font-size: 13px; display: block; }
.num-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; direction: ltr; } /* systolic on the LEFT, like 140/90 */
.num-row input::placeholder { color: #c3ccd6; font-weight: 500; }
.num-row input { width: 100%; font: inherit; font-size: 28px; font-weight: 700; text-align: center; padding: 10px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; direction: ltr; }
.num-row input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14,159,142,.18); }
.num-row .slash { font-size: 28px; color: var(--muted); }
.num-row small { display: block; text-align: center; color: var(--muted); font-size: 12px; margin-top: 4px; }
select, input[type=number].plain { width: 100%; font: inherit; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; }
.info { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--teal); color: var(--teal-ink); font-size: 13px; font-weight: 700; margin-inline-start: 6px; cursor: pointer; background: #fff; vertical-align: middle; }

.actions { position: sticky; bottom: 0; padding: 12px 0 calc(8px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); display: flex; gap: 10px; }
.btn { flex: 1; border: 0; border-radius: 14px; padding: 15px 18px; font-weight: 700; font-size: 17px; cursor: pointer; min-height: 52px; }
.btn.primary { background: var(--teal); color: #fff; }
.btn.primary:disabled { background: #b9c6d2; cursor: not-allowed; }
.btn.ghost { background: #fff; border: 1.5px solid var(--line); color: var(--ink); }
.btn.navy { background: var(--navy); color: #fff; }

.intro h1 { font-size: 26px; margin-bottom: 10px; }
.intro p { margin-bottom: 10px; }
.intro .pill { display: inline-block; background: var(--teal-soft); color: var(--teal-ink); font-weight: 600; font-size: 13px; padding: 4px 10px; border-radius: 999px; margin-bottom: 10px; }
.intro ul { margin: 0 0 10px; padding-inline-start: 20px; }
.intro li { margin-bottom: 4px; }
.notice { background: var(--amber-soft); border: 1px solid #f3dcae; color: #5a3a00; padding: 12px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 12px; }
.consent { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.consent input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--teal); }
.route { display: grid; gap: 10px; }
.route .choice { padding: 18px 16px; }
.route .choice strong { font-size: 18px; }

.verdict { border-radius: var(--radius); padding: 16px; margin-bottom: 12px; border: 1px solid transparent; }
.verdict .kicker { font-size: 13px; font-weight: 600; opacity: .8; margin-bottom: 4px; white-space: normal; overflow-wrap: anywhere; }
.verdict h2 { font-size: 21px; }
.verdict.treat_now, .verdict.dual, .verdict.mono, .verdict.hf, .verdict.step_up, .verdict.at_target, .verdict.target { background: var(--green-soft); border-color: #bfe3cd; color: #0f4d2c; }
.verdict.lifestyle, .verdict.lifestyle_3m, .verdict.consider, .verdict.individual, .verdict.too_early, .verdict.single, .verdict.none, .verdict.confirm_first, .verdict.adherence, .verdict.workup, .verdict.white_coat_uncontrolled, .verdict.de_escalate, .verdict.no_treatment { background: var(--amber-soft); border-color: #f3dcae; color: #5a3a00; }
.verdict.severe, .verdict.resistant, .verdict.refractory, .verdict.drug_check, .verdict.lab_action { background: #fff1e6; border-color: #f6c9a4; color: #7a2e00; }
.verdict.emergency { background: var(--red-soft); border-color: #f3b4ad; color: #7a160e; }

.rx { border: 2px solid var(--teal); }
.rx .rx-title { font-size: 20px; font-weight: 800; color: var(--navy); margin-bottom: 4px; }
.rx .rx-dose { font-size: 17px; font-weight: 600; color: var(--teal-ink); margin-bottom: 8px; }
.rx .brands { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.rx .brand { background: var(--teal-soft); color: var(--teal-ink); border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 600; }
.alt { padding: 10px 0; border-top: 1px solid var(--line); }
.alt:first-of-type { border-top: 0; }
.alt b { display: block; }
.alt span { color: var(--muted); font-size: 14px; }
.lines { list-style: none; margin: 0; padding: 0; }
.lines li { padding: 9px 0; border-top: 1px solid var(--line); font-size: 15px; }
.lines li:first-child { border-top: 0; }
.lines.avoid li { color: var(--red); }
.lines.check li { padding-inline-start: 26px; position: relative; }
.lines.check li::before { content: ''; position: absolute; inset-inline-start: 0; top: 12px; width: 16px; height: 16px; border: 1.5px solid var(--teal); border-radius: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin-bottom: 10px; }
.kv b { color: var(--muted); font-weight: 500; }
.ref { display: inline-block; border: 0; background: #eef4f9; color: #1f4e79; font-weight: 600; font-size: 12.5px; padding: 6px 9px; margin: 2px 4px 2px 0; border-radius: 8px; cursor: pointer; vertical-align: middle; white-space: nowrap; min-height: 32px; line-height: 1.2; position: relative; }
.ref::after { content: ''; position: absolute; inset: -6px -2px; } /* 44px hit area without growing the chip */
.info { position: relative; } .info::after { content: ''; position: absolute; inset: -11px; }
.modal-close { min-width: 44px; min-height: 44px; }
ul.sub { margin: 4px 0 0; padding-inline-start: 18px; } ul.sub li { padding: 2px 0; border: 0; font-size: 14px; }
bdi.n { direction: ltr; unicode-bidi: isolate; }
.ref:hover { background: #dbe8f5; }
.muted { color: var(--muted); font-size: 14px; }
.labs li { color: #7a2e00; }

.modal { position: fixed; inset: 0; z-index: 20; background: rgba(8,20,32,.6); display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; width: 100%; max-width: 760px; max-height: 94dvh; border-radius: 18px 18px 0 0; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 15px; }
.modal-close { width: 40px; height: 40px; border: 0; border-radius: 10px; background: #f1f4f8; font-size: 24px; cursor: pointer; flex: none; }
.modal-body { overflow: auto; padding: 8px; background: #e9eef3; -webkit-overflow-scrolling: touch; }
.page-wrap { position: relative; width: 100%; margin-inline-start: auto; }
.modal-tools { display: flex; gap: 6px; flex: none; }
.modal-close:disabled { opacity: .4; }
.modal-close[hidden] { display: none; }
.actions.two .btn { font-size: 15px; padding-inline: 10px; }
.page-wrap img { width: 100%; height: auto; display: block; border-radius: 6px; }
.hl { position: absolute; background: rgba(255, 214, 0, .42); border-radius: 3px; box-shadow: 0 0 0 2px rgba(255,190,0,.45); pointer-events: none; }
.modal-foot { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); font-size: 13.5px; color: var(--muted); }
.modal-foot a { color: #1f4e79; font-weight: 600; text-decoration: none; }
.modal-foot a:hover { text-decoration: underline; }
.modal-foot .btn { flex: none; min-height: 40px; padding: 8px 14px; font-size: 14px; }
.modal-body.text { background: #fff; padding: 16px; font-size: 15px; }
.modal-body.text ul { padding-inline-start: 18px; margin: 8px 0; }
.foot { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 24px; }
@media (min-width: 640px) { .modal { align-items: center; } .modal-card { border-radius: 18px; } }
