/* ZhamZhmer (ژەمژمێر) — dashboard layout: sidebar navigation, soft neutral canvas, white cards, KPI tiles, one navy accent.
   Inter for Latin, Vazirmatn for Kurdish; logical properties so RTL and LTR share one sheet. */
@font-face { font-family: "Inter"; src: url(../assets/fonts/Inter-Regular.otf) format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url(../assets/fonts/Inter-Medium.otf) format("opentype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Inter"; src: url(../assets/fonts/Inter-SemiBold.otf) format("opentype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Inter"; src: url(../assets/fonts/Inter-Bold.otf) format("opentype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url(../assets/fonts/Vazirmatn-UI-NL-Regular.ttf) format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url(../assets/fonts/Vazirmatn-UI-NL-Medium.ttf) format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url(../assets/fonts/Vazirmatn-UI-NL-SemiBold.ttf) format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url(../assets/fonts/Vazirmatn-UI-NL-Bold.ttf) format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --navy: #0B2545; --navy-2: #163A6B; --navy-soft: #EAF0F8; --navy-line: #D3DFEE;
  --canvas: #F4F4F5; --side: #FAFAFA; --card: #FFFFFF; --sunken: #F7F7F8;
  --line: #E7E7EA; --line-2: #D9D9DE;
  --ink: #18181B; --ink-2: #3F3F46; --muted: #71717A; --subtle: #A1A1AA;
  --red: #B42318; --red-bg: #FEF3F2; --red-line: #FBD5D1;
  --amber: #9A5B06; --amber-bg: #FFF8EB; --amber-line: #F8DFA8;
  --green: #067647; --green-bg: #ECFDF3;
  --r-xl: 20px; --r-lg: 16px; --r: 12px; --r-sm: 9px;
  --shadow: 0 1px 2px rgba(24,24,27,.04), 0 1px 1px rgba(24,24,27,.02);
  --shadow-pop: 0 12px 32px -12px rgba(24,24,27,.18);
  --font: "Inter", "Vazirmatn", "Segoe UI", system-ui, sans-serif;
  --side-w: 300px;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; overflow-x: clip; }
body { font-family: var(--font); color: var(--ink); background: var(--canvas); font-size: 14.5px; line-height: 1.55; -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1, "cv11" 1; }
[dir="rtl"] body { line-height: 1.7; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2.5px solid var(--navy-2); outline-offset: 2px; border-radius: 8px; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.clin { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] p.clin, [dir="rtl"] div.clin { text-align: right; }
.sources ol, .sources li { text-align: left; }
.muted { color: var(--muted); } .small { font-size: .84rem; }

/* ================================================================ app shell */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }

/* ---- sidebar */
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--side); border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.side-top { padding: 1.1rem 1.1rem .9rem; display: flex; align-items: center; gap: .65rem; }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); min-width: 0; }
.brand img { width: 32px; height: 32px; flex: none; }
.brand b { font-size: 1.08rem; font-weight: 700; letter-spacing: -.01em; direction: ltr; display: block; line-height: 1.2; }
.brand b span { color: var(--navy-2); }
.brand b.ku { direction: rtl; font-family: "Vazirmatn", var(--font); font-size: 1.15rem; }
/* the capsule logo carries the name; the tagline sits under it */
.brand.capsule { flex-direction: column; align-items: flex-start; gap: .35rem; }
.brand.capsule img { width: 168px; height: auto; }
.brand small { display: block; color: var(--muted); font-size: .74rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-search { padding: 0 1.1rem; }
.search { position: relative; }
.search svg { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-start: .7rem; color: var(--subtle); pointer-events: none; }
.search input { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: .55rem .9rem; padding-inline-start: 2.2rem; font-size: .9rem; box-shadow: var(--shadow); }
.search input:focus { outline: none; border-color: var(--navy-line); box-shadow: 0 0 0 3px var(--navy-soft); }
.search kbd { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-end: .55rem; font: 600 .68rem var(--font); color: var(--subtle); border: 1px solid var(--line); border-radius: 6px; padding: .05rem .35rem; background: var(--sunken); direction: ltr; }
.side-hint { color: var(--subtle); font-size: .72rem; margin: .4rem .2rem 0; }
.side-label { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.3rem .35rem; font-size: .72rem; font-weight: 600; color: var(--muted); }
.quick { display: flex; flex-wrap: wrap; gap: .3rem; padding: 0 1.1rem; }
.quick button { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: .18rem .6rem; font-size: .76rem; color: var(--ink-2); font-weight: 500; direction: ltr; }
.quick button:hover { border-color: var(--navy-line); color: var(--navy); }
.nav { flex: 1; overflow-y: auto; padding: .2rem .6rem 1rem; }
.item { display: flex; align-items: center; gap: .6rem; width: 100%; border: 0; background: transparent; padding: .42rem .6rem; border-radius: 10px; text-align: start; }
.item:hover { background: #F0F0F2; }
.item[aria-current="true"] { background: var(--card); box-shadow: var(--shadow), 0 0 0 1px var(--line); }
.av { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: .76rem; flex: none; direction: ltr; }
.item .tx { min-width: 0; flex: 1; }
.item .nm { display: block; font-weight: 600; font-size: .88rem; color: var(--ink); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { display: block; font-size: .72rem; color: var(--muted); line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[dir="rtl"] .item .clin { text-align: right; }
.draft-pill { flex: none; font-size: .66rem; padding: .1rem .45rem; }
.empty-list { padding: 1.5rem 1rem; text-align: center; color: var(--muted); font-size: .86rem; }
.side-foot { border-top: 1px solid var(--line); padding: .8rem 1.1rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.ver { font-size: .7rem; color: var(--subtle); direction: ltr; }

/* pill segmented controls (shared) */
.seg { display: inline-flex; background: #EDEDF0; border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: .32rem .8rem; border-radius: 999px; font-weight: 600; font-size: .82rem; color: var(--ink-2); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--navy); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.seg.light button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px var(--line); }

/* ---- main */
.main { min-width: 0; padding: 1.4rem clamp(1rem, 2.5vw, 2rem) 2.5rem; }
.topline { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.topline h1 { margin: 0; font-size: 1.45rem; letter-spacing: -.015em; }
.topline p { margin: .15rem 0 0; color: var(--muted); font-size: .88rem; }
.menu-btn { display: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: .4rem .85rem; font-weight: 600; font-size: .85rem; }

/* patient KPI tiles */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: .85rem 1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .45rem; min-width: 0; }
.tile-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.tile-head .lbl { font-size: .78rem; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: .45rem; }
.chip-ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--sunken); border: 1px solid var(--line); color: var(--ink-2); }
.tile-body { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; min-height: 42px; }
.big-in { width: 4.6rem; border: 0; border-bottom: 2px solid var(--line-2); background: transparent; padding: .1rem .15rem; font-size: 1.75rem; font-weight: 700; color: var(--ink); direction: ltr; text-align: center; letter-spacing: -.02em; border-radius: 0; }
.big-in:focus { outline: none; border-bottom-color: var(--navy); }
.big-in.est { color: var(--amber); border-bottom-color: var(--amber-line); }
.unit { color: var(--muted); font-weight: 600; font-size: .9rem; direction: ltr; }
.est-note { align-self: flex-start; font-size: .72rem; color: var(--amber); font-weight: 600; background: var(--amber-bg); border: 1px solid var(--amber-line); padding: .1rem .55rem; border-radius: 8px; line-height: 1.5; }
.switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; font-weight: 600; color: var(--ink-2); user-select: none; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 40px; height: 22px; border-radius: 999px; background: var(--line-2); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: inset-inline-start .15s; }
.switch input:checked + .track { background: #C2410C; }
.switch input:checked + .track::after { inset-inline-start: 21px; }
.switch input:focus-visible + .track { outline: 2.5px solid var(--navy-2); outline-offset: 2px; }

/* ---- content grid */
.content { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: .9rem; margin-top: .9rem; align-items: start; }
.col { display: grid; gap: .9rem; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; min-width: 0; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin: 0 0 .75rem; font-size: .92rem; font-weight: 600; color: var(--ink); }
.card-title .sub { font-weight: 500; color: var(--muted); font-size: .8rem; }

.d-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.d-id { display: flex; gap: .85rem; align-items: center; min-width: 0; }
.d-id .av { width: 48px; height: 48px; border-radius: 14px; font-size: 1rem; }
.d-head h2 { margin: 0; font-size: 1.5rem; letter-spacing: -.02em; line-height: 1.15; }
.d-head .meta { color: var(--muted); font-size: .86rem; margin-top: .15rem; }
.pill { display: inline-flex; align-items: center; gap: .35rem; font-size: .76rem; font-weight: 600; padding: .22rem .65rem; border-radius: 999px; background: var(--navy-soft); color: var(--navy); border: 1px solid var(--navy-line); white-space: nowrap; }
.pill.gray { background: var(--sunken); color: var(--ink-2); border-color: var(--line); }
.pill.danger { background: var(--red-bg); color: var(--red); border-color: var(--red-line); }
.back { display: none !important; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 600; padding: .38rem .8rem; border-radius: 999px; margin-bottom: .75rem; font-size: .85rem; }

.inds { display: grid; gap: .4rem; }
.ind { display: flex; align-items: center; gap: .65rem; border: 1px solid var(--line); background: var(--card); border-radius: var(--r); padding: .55rem .75rem; text-align: start; width: 100%; }
.ind:hover { border-color: var(--line-2); }
.ind .dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); flex: none; display: grid; place-items: center; }
.ind[aria-checked="true"] { border-color: var(--navy); background: var(--navy-soft); }
.ind[aria-checked="true"] .dot { border-color: var(--navy); }
.ind[aria-checked="true"] .dot::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--navy); }
.ind .name { flex: 1; font-weight: 500; font-size: .9rem; }
[dir="rtl"] .ind .name { text-align: right; }
.ind.off .name { color: var(--muted); }
.ind .why { font-size: .74rem; color: var(--muted); white-space: nowrap; }

/* amount-to-give card */
.dose-card { padding: 0; overflow: hidden; }
.dose-top { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .9rem 1.2rem 0; flex-wrap: wrap; }
.hero { padding: 1rem 1.2rem 1.2rem; }
.hero-label { color: var(--muted); font-size: .86rem; font-weight: 500; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
[dir="rtl"] .hero-label .clin { text-align: right; }
.hero-amount { display: flex; align-items: baseline; gap: .45rem; flex-wrap: wrap; margin: .3rem 0 .2rem; direction: ltr; }
[dir="rtl"] .hero-amount { justify-content: flex-end; }
.hero-amount .v { font-size: clamp(2.8rem, 6vw, 4rem); font-weight: 700; letter-spacing: -.04em; line-height: 1; color: var(--navy); }
.hero-amount .u { font-size: 1.2rem; font-weight: 600; color: var(--muted); }
.hero.small .hero-amount .v { font-size: 1.3rem; letter-spacing: 0; line-height: 1.4; color: var(--ink); }
.hero-freq { font-weight: 600; font-size: .98rem; color: var(--ink); }
.hero-meta { color: var(--muted); font-size: .86rem; margin-top: .1rem; }
.dose-band { height: 6px; background: linear-gradient(90deg, var(--navy), #3B7DD8); }
.notes-in { padding: 0 1.2rem 1rem; display: grid; gap: .5rem; }

.note { display: flex; gap: .6rem; padding: .65rem .85rem; border-radius: var(--r); font-size: .87rem; border: 1px solid var(--line); background: var(--sunken); color: var(--ink-2); }
.note svg { flex: none; margin-top: .12rem; }
.note b { display: block; }
.note[dir="ltr"] { text-align: left; font-family: "Inter", var(--font); }
.note.warning { background: var(--amber-bg); border-color: var(--amber-line); color: var(--amber); }
.note.danger { background: var(--red-bg); border-color: var(--red-line); color: var(--red); }
.note.info { background: var(--navy-soft); border-color: var(--navy-line); color: var(--navy); }
.note p { margin: 0; white-space: pre-line; }
.stack { display: grid; gap: .5rem; }

/* KPI tiles for the dose */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: .8rem .95rem; box-shadow: var(--shadow); min-width: 0; }
.kpi .k { font-size: .76rem; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: .4rem; }
.kpi .v { font-size: 1.55rem; font-weight: 700; color: var(--ink); direction: ltr; line-height: 1.2; letter-spacing: -.02em; margin-top: .25rem; }
[dir="rtl"] .kpi .v { text-align: right; }
.kpi .v small { font-size: .82rem; color: var(--muted); font-weight: 600; letter-spacing: 0; margin-inline-start: .2rem; }
.kpi .s { font-size: .74rem; color: var(--muted); margin-top: .1rem; }

.str-table { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.str-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; width: 100%; border: 0; border-bottom: 1px solid var(--line); background: var(--card); padding: .55rem .85rem; text-align: start; font-size: .9rem; }
.str-row:last-child { border-bottom: 0; }
.str-row:hover { background: var(--sunken); }
.str-row[aria-pressed="true"] { background: var(--navy-soft); font-weight: 600; }
[dir="rtl"] .str-row .clin { text-align: right; }
.str-row .a { direction: ltr; color: var(--navy); font-weight: 600; white-space: nowrap; }
.str-row .a.none { color: var(--subtle); font-weight: 500; }
details.custom { margin-top: .75rem; }
details.custom > summary { cursor: pointer; font-weight: 600; color: var(--navy-2); font-size: .86rem; list-style: none; }
details.custom > summary::-webkit-details-marker { display: none; }
details.custom > summary::before { content: "+ "; }
details.custom[open] > summary::before { content: "– "; }
.custom-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; direction: ltr; margin-top: .6rem; }
[dir="rtl"] .custom-row { justify-content: flex-end; }
.custom-row input { width: 5.5rem; border: 1px solid var(--line-2); border-radius: 999px; padding: .4rem .6rem; text-align: center; font-weight: 600; }
.custom-row input:focus { outline: none; border-color: var(--navy-line); box-shadow: 0 0 0 3px var(--navy-soft); }
.custom-out { margin-top: .5rem; font-weight: 700; color: var(--navy); }

.tabs { display: inline-flex; }

.rx-box { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.rx { flex: 1 1 280px; font-size: .84rem; color: var(--ink-2); direction: ltr; unicode-bidi: isolate; background: var(--sunken); border: 1px dashed var(--line-2); border-radius: var(--r); padding: .6rem .75rem; }
[dir="rtl"] .rx { direction: rtl; }
.btn { display: inline-flex; align-items: center; gap: .45rem; border: 0; background: var(--navy); color: #fff; border-radius: 999px; padding: .55rem 1rem; font-weight: 600; font-size: .86rem; white-space: nowrap; }
.btn:hover { background: var(--navy-2); }

.dl { display: grid; gap: .6rem; margin: 0; }
.dl > div { display: grid; gap: .1rem; }
.dl dt { font-size: .74rem; font-weight: 600; color: var(--muted); }
.dl dd { margin: 0; font-size: .87rem; color: var(--ink-2); }
.sources ol { margin: 0; padding-inline-start: 1.1rem; display: grid; gap: .35rem; }
.sources li { font-size: .83rem; color: var(--ink-2); }
.sources a { color: var(--navy-2); text-decoration: none; }
.sources a:hover { text-decoration: underline; }
.safety { background: var(--sunken); box-shadow: none; }
.safety p { margin: 0 0 .45rem; font-size: .8rem; color: var(--muted); }
.safety p:last-child { margin: 0; }

/* empty state */
.welcome { display: grid; place-items: center; text-align: center; padding: 3rem 1.5rem; }
.welcome .ic { width: 64px; height: 64px; border-radius: 18px; background: var(--navy-soft); color: var(--navy); display: grid; place-items: center; margin: 0 auto 1rem; }
.welcome h2 { margin: 0 0 .4rem; font-size: 1.3rem; }
.welcome p { color: var(--muted); margin: 0 auto .6rem; max-width: 520px; }
.steps { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; margin-top: 1rem; }
.steps span { display: inline-flex; align-items: center; gap: .45rem; background: var(--sunken); border: 1px solid var(--line); border-radius: 999px; padding: .3rem .8rem .3rem .4rem; font-size: .82rem; font-weight: 500; color: var(--ink-2); }
[dir="rtl"] .steps span { padding: .3rem .4rem .3rem .8rem; }
.steps b { width: 22px; height: 22px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: .72rem; }

#toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: .6rem 1.1rem; border-radius: 999px; font-weight: 600; font-size: .88rem; opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; box-shadow: var(--shadow-pop); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ================================================================ responsive */
@media (max-width: 1280px) {
  .content { grid-template-columns: minmax(0, 1fr); }
  .side-col { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}
@media (max-width: 1100px) {
  .tiles, .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* ---------------------------------------------------------------- phones and small tablets (mobile-first screens) */
.mbar { display: none; }
.pstrip { display: none; }
.dose-ind { display: block; font-weight: 500; color: var(--muted); font-size: .8rem; margin-top: .1rem; }
@media (max-width: 900px) {
  body { font-size: 15px; padding-bottom: env(safe-area-inset-bottom); }
  .app { display: flex; flex-direction: column; min-height: 100dvh; }
  /* top app bar: back, logo / drug name, language */
  .mbar { display: flex; align-items: center; gap: .55rem; position: sticky; top: 0; z-index: 30; height: 56px;
    padding: 0 max(.85rem, env(safe-area-inset-left)) 0 max(.85rem, env(safe-area-inset-right));
    background: rgba(250,250,250,.92); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
  .mbar .brand img { width: 30px; height: 30px; }
  .mbar .brand.capsule img { width: 116px; height: auto; }
  .mbar .brand b { font-size: 1.05rem; }
  .mbar-back { display: none; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 1.15rem; font-weight: 700; flex: none; }
  .mbar-title { flex: 1; min-width: 0; font-weight: 700; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; unicode-bidi: isolate; }
  [dir="rtl"] .mbar-title { text-align: right; }
  .mbar .seg button { padding: .3rem .65rem; font-size: .8rem; min-height: 32px; }
  body.has-drug .mbar-back { display: grid; place-items: center; }
  body.has-drug .mbar .brand { display: none; }
  body:not(.has-drug) .mbar-title { display: none; }
  body:not(.has-drug) .mbar .brand { flex: 1; }

  /* order: patient first, then the drug list (home) or the dose (drug page) */
  .main { order: 1; padding: .85rem .85rem 0; }
  .sidebar { order: 2; position: static; height: auto; border: 0; background: transparent; }
  .side-top, .side-foot { display: none; }
  body.has-drug .sidebar { display: none; }
  body:not(.has-drug) .content { display: none; }
  body.has-drug .main { padding-bottom: 1.5rem; }

  .topline { margin-bottom: .7rem; }
  .topline h1 { font-size: 1.2rem; }
  .topline p { display: none; }
  body.has-drug .topline { display: none; }

  /* patient tiles: compact 2 × 2 */
  .tiles { grid-template-columns: 1fr 1fr; gap: .55rem; }
  .tile { padding: .65rem .75rem; border-radius: 14px; gap: .35rem; }
  .tile-head .lbl { font-size: .76rem; }
  .chip-ic { width: 22px; height: 22px; border-radius: 7px; }
  .tile-body { min-height: 0; gap: .4rem; }
  .big-in { font-size: 1.5rem; width: 3.6rem; padding: .05rem; }
  .tile .seg { width: 100%; }
  .tile .seg button { flex: 1; min-height: 36px; padding: .3rem .4rem; font-size: .82rem; }
  .est-note { font-size: .68rem; }

  /* drug list */
  .side-search { position: sticky; top: 56px; z-index: 20; background: var(--canvas); padding: .75rem .85rem .4rem; }
  .search input { font-size: 16px; padding: .7rem 1rem; padding-inline-start: 2.4rem; }
  .search kbd { display: none; }
  .side-hint { margin: .35rem .3rem 0; }
  .side-label { padding: .8rem 1.1rem .35rem; }
  .quick { padding: 0 .85rem; gap: .4rem; }
  .quick button { padding: .4rem .8rem; font-size: .84rem; min-height: 36px; }
  .nav { padding: .2rem .6rem 1.5rem; overflow: visible; }
  .item { padding: .6rem .65rem; min-height: 56px; background: var(--card); border: 1px solid var(--line); margin-bottom: .4rem; border-radius: 14px; }
  .item .nm { font-size: .95rem; }
  .item .sub { font-size: .76rem; }
  .av { width: 36px; height: 36px; }

  /* drug page: the patient folds into one line; tap to edit */
  body.has-drug:not(.edit-patient) .tiles { display: none; }
  body.has-drug .pstrip { display: flex; align-items: center; justify-content: space-between; gap: .6rem; width: 100%; min-height: 48px;
    background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: .55rem .9rem; font-weight: 600; font-size: .92rem; color: var(--ink); text-align: start; box-shadow: var(--shadow); }
  body.has-drug.edit-patient .pstrip { margin-top: .55rem; border-color: var(--navy-line); background: var(--navy-soft); }
  .ps-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ps-edit { flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--sunken); border: 1px solid var(--line); color: var(--navy); }
  .est-dot { color: var(--amber); font-size: .7rem; vertical-align: middle; }
  /* phones: the dose first */
  .col > .head-card { order: 0; } .col > .dose-card { order: 1; } .col > .kpis { order: 2; } .col > .ind-card { order: 3; }
  .col > .str-card { order: 4; } .col > .rx-card { order: 5; }
  .dose-card .card-title { flex-direction: column; align-items: flex-start; }

  /* drug page */
  .content { margin-top: .7rem; gap: .65rem; }
  .col { gap: .65rem; }
  .card { padding: .95rem 1rem; border-radius: 16px; }
  .d-head h2 { font-size: 1.3rem; }
  .d-id .av { width: 42px; height: 42px; }
  .ind { padding: .7rem .75rem; min-height: 48px; flex-wrap: wrap; }
  .ind .why { white-space: normal; flex-basis: 100%; padding-inline-start: 1.65rem; }
  .dose-top { padding: .85rem 1rem 0; }
  .dose-top .seg { width: 100%; overflow-x: auto; }
  .dose-top .seg button { flex: 1; min-height: 38px; }
  .hero { padding: .8rem 1rem 1rem; }
  .hero-amount .v { font-size: 3.1rem; }
  .notes-in { padding: 0 1rem .9rem; }
  .kpis { grid-template-columns: 1fr 1fr; gap: .55rem; }
  .kpi { padding: .7rem .8rem; border-radius: 14px; }
  .kpi .v { font-size: 1.3rem; }
  .str-row { min-height: 48px; padding: .6rem .8rem; }
  .custom-row input { font-size: 16px; width: 5.2rem; padding: .5rem; }
  .rx-box { flex-direction: column; align-items: stretch; }
  .rx-box .btn { justify-content: center; min-height: 46px; font-size: .92rem; }
  .side-col { grid-template-columns: 1fr; }
  .welcome { padding: 2rem 1rem; }
}
@media (max-width: 360px) {
  .tiles { gap: .45rem; }
  .big-in { font-size: 1.3rem; width: 3.1rem; }
  .tile .seg button { font-size: .76rem; padding: .3rem .25rem; }
  .hero-amount .v { font-size: 2.6rem; }
  .kpi .v { font-size: 1.15rem; }
}
@media print {
  .sidebar, .tiles, .back, .btn, #toast, .topline .seg { display: none !important; }
  .app, .content { display: block; }
  .card { box-shadow: none; break-inside: avoid; margin-bottom: .6rem; }
}

/* contact email for corrections */
.contact { font-size: .82rem; color: var(--muted); margin: .6rem 0 0; }
.contact a { color: var(--navy-2); font-weight: 600; text-decoration: none; unicode-bidi: isolate; }
.contact a:hover { text-decoration: underline; }
