/* RxPH — mobile-first, one stylesheet, no build step. */

:root {
  --accent: #12805C; --accent-dark: #0C6346; --accent-soft: #E3F2EA; --accent-ink: #0A4A35;
  --ink: #18211D; --muted: #66716C; --faint: #98A29D;
  --bg: #F3F6F4; --surface: #FFFFFF; --line: #DCE4DF; --line-strong: #B9C6BF;
  --danger: #BE3A2B; --danger-soft: #FBEAE7; --danger-line: #EBB8B0;
  --warn: #8A5A05; --warn-soft: #FBF0D6; --warn-line: #EDD59B;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(17, 33, 26, .05), 0 8px 24px -16px rgba(17, 33, 26, .25);
  --nav-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; line-height: 1.5; color: var(--ink); background: var(--bg);
}
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.125rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .95em; }
button { font: inherit; }
[hidden] { display: none !important; }

.wrap { width: min(100% - 2rem, 900px); margin-inline: auto; }
.wrap-narrow { width: min(100% - 2rem, 480px); margin-inline: auto; }
.muted { color: var(--muted); } .small { font-size: .875rem; } .tiny { font-size: .78rem; }
.right { text-align: right; } .center { text-align: center; }
.text-danger { color: var(--danger); }
.stack > * + * { margin-top: .85rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .85rem; }
@media (max-width: 560px) {
  .grid-2:not(.keep), .grid-3 { grid-template-columns: 1fr; }
}

/* ---------- top bar + navigation ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; gap: 1rem; }
.logo { font-weight: 800; font-size: 1.3rem; color: var(--ink); text-decoration: none; letter-spacing: -.03em; }
.logo span { color: var(--accent); }
.logo-big { display: block; font-size: 2rem; margin-bottom: 1rem; }
.nav { display: flex; gap: .25rem; }
.nav a { display: flex; align-items: center; gap: .4rem; padding: .45rem .8rem; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem; }
.nav a svg { width: 20px; height: 20px; flex: none; }
.nav a:hover { color: var(--ink); background: var(--bg); }
.nav a.on { color: var(--accent-ink); background: var(--accent-soft); }
.nav a.nav-new { color: #fff; background: var(--accent); }
.nav a.nav-new:hover { background: var(--accent-dark); }
.nav-plain { display: flex; gap: .25rem 1rem; align-items: center; }
.nav-plain a:not(.btn) { text-decoration: none; font-weight: 600; color: var(--muted); } /* :not(.btn) so a button in the nav keeps its own colors */
@media (max-width: 720px) {
  .nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding: 0 .25rem env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); z-index: 20; justify-content: space-around; gap: 0; }
  .nav a { flex: 1; flex-direction: column; gap: 2px; padding: .45rem 0 .25rem; font-size: .68rem; border-radius: 0; background: none !important; color: var(--muted); }
  .nav a svg { width: 24px; height: 24px; }
  .nav a.on, .nav a.nav-new { color: var(--accent); }
  .nav a.nav-new svg { width: 30px; height: 30px; margin-top: -3px; }
  body.app { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
}

/* ---------- page scaffolding ---------- */
.page { padding: 1.25rem 0 3rem; }
.page-head { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head h1 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.back { text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.card + .card, .card + form.card, form.card + .card, .alert + .card, .stats + .card, .btn-block + .stats { margin-top: 1rem; }
.card-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .75rem; font-weight: 700; }
.card-title-row { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; }
.card-title-row .card-title { margin-bottom: .75rem; }
@media (min-width: 720px) { .card { padding: 1.25rem 1.5rem; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .6rem 1rem; min-height: 44px;
  border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: #F7FAF8; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-danger { color: var(--danger); border-color: var(--danger-line); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { min-height: 36px; padding: .4rem .75rem; font-size: .85rem; border-radius: 8px; }
.btn-lg { min-height: 52px; font-size: 1.05rem; }
.btn-block { display: flex; width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .85rem; }
.btn-row .btn { flex: 1 1 auto; }
@media (min-width: 720px) { .btn-row .btn { flex: 0 1 auto; } }
.actions { display: flex; gap: .5rem; margin-top: 1rem; }
.actions .btn { flex: 1; }
.sticky-actions { position: sticky; bottom: 0; margin-top: 1rem; padding: .6rem 0 .75rem; background: rgba(243, 246, 244, .94); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); box-shadow: 0 -10px 12px -12px rgba(17, 33, 26, .25); z-index: 10; }
@media (max-width: 720px) { .sticky-actions { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); } }

/* ---------- forms ---------- */
.field { display: block; }
.field > span { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: .3rem; }
.field > span .req { color: var(--danger); font-weight: 600; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; margin-left: .25rem; }
.field input, .field select, .field textarea, .search-bar input, .code-input {
  width: 100%; font: inherit; padding: .6rem .75rem; min-height: 44px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; color: var(--ink);
}
.field select { appearance: none; -webkit-appearance: none; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2366716C' stroke-width='2'/%3E%3C/svg%3E") no-repeat right .8rem center; padding-right: 2rem; }
.field textarea { min-height: 130px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .search-bar input:focus, .code-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.field input[readonly] { background: var(--bg); color: var(--muted); }
::placeholder { color: var(--muted); opacity: 1; } /* browser defaults (Safari's darkGray) are below AA on white */
.field .hint { font-size: .78rem; color: var(--muted); margin-top: .3rem; }
.code-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .1em; text-transform: uppercase; }
.check { display: flex; align-items: center; gap: .6rem; cursor: pointer; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; }
.check input[disabled] + span { color: var(--faint); }
.search-bar { display: flex; gap: .5rem; margin-bottom: 1rem; }
.search-bar input { flex: 1; }

.seg { display: flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: clip; background: #fff; } /* clip, not hidden: hidden is a scroll container and focusing the radio scrolled it */
.seg label { flex: 1; position: relative; text-align: center; padding: .6rem .5rem; cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--muted); }
.seg label + label { border-left: 1px solid var(--line-strong); }
.seg input { position: absolute; inset: 0 auto auto 0; width: 1px; height: 1px; min-height: 0; padding: 0; margin: 0; border: 0; opacity: 0; pointer-events: none; } /* no size, so it can never overflow the control */
.seg label:has(input:checked), .seg label.on { background: var(--accent-soft); color: var(--accent-ink); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.chips-tight { margin-top: .4rem; }
.chips button { border: 1px solid var(--line-strong); background: #fff; color: var(--ink); border-radius: 999px; padding: .3rem .7rem; font-size: .8rem; cursor: pointer; min-height: 32px; }
.chips button:hover { background: var(--accent-soft); border-color: var(--accent); }

/* ---------- alerts, banners, chips ---------- */
.alert { padding: .8rem 1rem; border-radius: 10px; border: 1px solid; margin-bottom: 1rem; font-size: .95rem; }
.alert a { font-weight: 600; color: inherit; text-decoration: underline; } /* the alert's own ink, not link green on a tint */
.alert-error { background: var(--danger-soft); border-color: var(--danger-line); color: #7A2216; }
.alert-ok { background: var(--accent-soft); border-color: #B7DCC8; color: var(--accent-ink); }
.alert-warn { background: var(--warn-soft); border-color: var(--warn-line); color: #5E3E02; }
.banner { display: flex; gap: .85rem; align-items: flex-start; padding: 1rem 1.1rem; border-radius: var(--radius); border: 1px solid; margin-bottom: 1rem; }
.banner-icon { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 1.1rem; color: #fff; }
.banner-ok { background: var(--accent-soft); border-color: #B7DCC8; color: var(--accent-ink); } .banner-ok .banner-icon { background: var(--accent); }
.banner-danger { background: var(--danger-soft); border-color: var(--danger-line); color: #7A2216; } .banner-danger .banner-icon { background: var(--danger); }
.banner-warn { background: var(--warn-soft); border-color: var(--warn-line); color: #5E3E02; } .banner-warn .banner-icon { background: var(--warn); }
.chip { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; vertical-align: middle; }
.chip-issued { background: var(--accent-soft); color: var(--accent-ink); }
.chip-draft { background: #EEF1EF; color: #56615C; }
.chip-voided { background: var(--danger-soft); color: var(--danger); }
.chip-partial { background: var(--warn-soft); color: #6B4500; }

/* ---------- dispensing (public page + doctor view) ---------- */
.dispense-title { font-size: 1rem; }
.dispense-items, .dispense-records { list-style: none; margin: .75rem 0 0; padding: 0; }
.dispense-items li { display: flex; gap: .6rem; align-items: flex-start; padding: .45rem 0; border-top: 1px solid var(--line); }
.dispense-items li:first-child { border-top: 0; }
.dispense-items .mark { flex: none; width: 1.4rem; height: 1.4rem; border-radius: 50%; display: grid; place-items: center; font-size: .85rem; font-weight: 800; background: #EEF1EF; color: var(--muted); }
.dispense-items .is-done .mark { background: var(--accent); color: #fff; }
.dispense-items .sub, .dispense-records .sub { display: block; font-size: .8rem; color: var(--muted); }
.dispense-records li { padding: .4rem 0; border-top: 1px solid var(--line); font-size: .9rem; }
.dispense-form { margin-top: .85rem; }
.dispense-form summary { list-style: none; width: 100%; }
.dispense-form summary::-webkit-details-marker { display: none; }
.dispense-form[open] summary { margin-bottom: .85rem; }
.check-list { display: flex; flex-direction: column; gap: .35rem; }
.check-list .check { font-weight: 500; }
.dispense .hint { font-size: .8rem; color: var(--muted); margin: .25rem 0 0; }
.filters { display: flex; gap: .4rem; margin-bottom: 1rem; overflow-x: auto; padding-bottom: 2px; }
.filter { flex: none; padding: .4rem .9rem; border-radius: 999px; border: 1px solid var(--line-strong); background: #fff; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .875rem; }
.filter.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: .75rem; padding: .75rem 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.list-row:first-child { border-top: 0; padding-top: 0; }
.list-row:last-child { padding-bottom: 0; }
.list-row .title { font-weight: 600; }
.list-row .sub { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
a.list-row:hover .title { color: var(--accent); }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.dl { margin: 0 0 .5rem; display: grid; gap: .5rem; }
.dl div { display: grid; grid-template-columns: 7rem 1fr; gap: .5rem; }
.dl dt { color: var(--muted); font-size: .85rem; } .dl dd { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; margin-top: 1rem; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { display: flex; flex-direction: column; padding: .8rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.stat b { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.stat span { font-size: .8rem; color: var(--muted); }
.linkbox { display: flex; align-items: center; gap: .5rem; padding: .5rem .5rem .5rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.linkbox span { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .btn { flex: 1 1 auto; }
@media (min-width: 720px) { .toolbar .btn { flex: 0 1 auto; } }

/* ---------- editor ---------- */
.patient-card { display: flex; align-items: center; gap: .75rem; padding: .75rem .9rem; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 10px; }
.patient-card .muted, .dropdown button:hover .sub, .dropdown button:focus .sub, .recent button:hover .sub, .recent button:focus .sub { color: var(--accent-ink); } /* muted gray is under AA on the tint */
.search { position: relative; }
.search input { width: 100%; font: inherit; padding: .6rem .75rem; min-height: 44px; border: 1px solid var(--line-strong); border-radius: 10px; }
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.dropdown { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 12px 32px -12px rgba(17, 33, 26, .35); list-style: none; margin: 0; padding: .25rem; z-index: 30; max-height: 280px; overflow: auto; }
.dropdown button, .recent button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: .55rem .6rem; border-radius: 8px; color: inherit; cursor: pointer; }
.dropdown button:hover, .dropdown button:focus, .recent button:hover, .recent button:focus { background: var(--accent-soft); outline: none; }
.dropdown .sub, .recent .sub { display: block; font-size: .8rem; color: var(--muted); }
.dropdown-empty { padding: .55rem .6rem; }
.recent-label { margin: .75rem 0 .2rem; }
.recent { list-style: none; margin: 0 0 .75rem; padding: 0; border: 1px solid var(--line); border-radius: 10px; }
.recent li + li { border-top: 1px solid var(--line); }
.recent button { border-radius: 0; }
.recent li:first-child button { border-radius: 10px 10px 0 0; } .recent li:last-child button { border-radius: 0 0 10px 10px; }
.items { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 10px; margin-bottom: .5rem; background: #fff; overflow: hidden; }
.item-main { flex: 1; display: flex; gap: .6rem; padding: .65rem .75rem; text-align: left; background: none; border: 0; color: inherit; cursor: pointer; min-width: 0; }
.item-main:hover { background: #F7FAF8; }
.item-qty { flex: none; color: var(--muted); font-size: .9rem; min-width: 3rem; padding-top: .1rem; }
.item-med { display: block; font-weight: 600; overflow-wrap: anywhere; }
.item-sig { display: block; color: var(--muted); font-size: .85rem; }
.item-notes { display: block; color: var(--muted); font-size: .8rem; white-space: pre-line; margin-top: .15rem; }
.private-note { margin: 0 0 .75rem; padding: .6rem .9rem; border: 1px dashed var(--line-strong); border-radius: 10px; font-size: .9rem; color: var(--muted); }
.private-note b { color: var(--ink); }
.item-tools { display: flex; flex-direction: column; border-left: 1px solid var(--line); }
.item-tools button { flex: 1; border: 0; background: none; padding: 0 .55rem; color: var(--muted); cursor: pointer; font-size: .95rem; min-width: 40px; }
.item-tools button + button { border-top: 1px solid var(--line); }
.item-tools button:hover { background: var(--bg); }
.item-tools button[disabled] { opacity: .3; cursor: default; }
.item-tools .del { color: var(--danger); font-size: 1.2rem; }
.tpl-list { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow: auto; }
.tpl { border-top: 1px solid var(--line); }
.tpl:first-child { border-top: 0; }
.tpl summary { display: flex; align-items: center; gap: .5rem; padding: .7rem 0; cursor: pointer; list-style: none; }
.tpl summary::-webkit-details-marker { display: none; }
.tpl summary::after { content: "›"; color: var(--muted); font-size: 1.3rem; transition: transform .15s; }
.tpl details[open] summary::after { transform: rotate(90deg); }
.tpl summary .sub { display: block; font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl-items { list-style: none; margin: 0; padding: 0 0 .5rem; }
.tpl-items label { display: flex; gap: .6rem; align-items: flex-start; padding: .35rem 0; cursor: pointer; }
.tpl-items input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.tpl-items .sub { display: block; font-size: .8rem; color: var(--muted); }
.tpl-body { padding: .25rem 0 .5rem; white-space: pre-wrap; font-size: .9rem; }
.tpl .btn-row { margin: 0 0 .75rem; }

/* ---------- dialogs ---------- */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(100% - 1.5rem, 520px); max-height: 90dvh; overflow: auto; color: var(--ink); box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .45); } /* tall dialogs (medicine + notes) scroll inside on short screens */
dialog::backdrop { background: rgba(17, 33, 26, .45); }
.dialog-body { padding: 1.25rem; }
.dialog-title { font-size: 1.1rem; font-weight: 700; margin-bottom: .75rem; }
/* Primary button first in the DOM (so Enter submits it), shown on the right. */
.dialog-actions { display: flex; flex-direction: row-reverse; gap: .5rem; justify-content: flex-start; margin-top: 1.1rem; flex-wrap: wrap; }
@media (max-width: 480px) {
  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 16px 16px 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); }
  .dialog-actions .btn { flex: 1; }
  /* Sig quick-picks as one swipeable row, so Notes and Save stay in reach on a phone. */
  #i-chips { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; scrollbar-width: none; }
  #i-chips::-webkit-scrollbar { display: none; }
  #i-chips button { flex: none; }
}

/* ---------- signature pad ---------- */
.sig-pad { display: block; width: 100%; height: 180px; border: 1px dashed var(--line-strong); border-radius: 10px; background: #fff; touch-action: none; cursor: crosshair; }
.sig-preview { display: inline-block; padding: .5rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; margin-bottom: .25rem; }
.sig-preview img { display: block; max-height: 80px; max-width: 260px; }
#sig-current { margin-bottom: 1rem; }

/* ---------- landing + auth ---------- */
.auth { padding-top: 2.5rem; }
.auth h1 { margin-bottom: .75rem; }
.auth .card { margin-top: 1rem; margin-bottom: 1rem; }
.hero { padding: 2rem 0 1.5rem; max-width: 720px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); letter-spacing: -.03em; margin-bottom: .75rem; }
.lede { font-size: 1.1rem; color: var(--muted); }
.hero-actions { margin-top: 1.25rem; }
.features { display: grid; gap: .75rem; margin: 1rem 0; }
@media (min-width: 720px) { .features { grid-template-columns: repeat(3, 1fr); } }
.features h3 { margin-bottom: .35rem; }
.verify-box { margin-top: 1.5rem; }
.verify-box .row { margin-top: .5rem; }
.verify-box .code-input { flex: 1; min-width: 200px; }
.site-foot { padding: 2rem 0; color: var(--muted); font-size: .85rem; }
.how h2 { font-size: 1rem; margin-bottom: .5rem; }
.foot-note { margin-top: 1.5rem; }

/* ---------- the prescription paper ---------- */
.paper-wrap { margin: 1rem 0; }
.paper {
  position: relative; background: #fff; color: #111; padding: 28px 32px; border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow);
  max-width: 760px; margin: 0 auto; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 15px; line-height: 1.4; overflow: hidden;
}
.paper-head { text-align: center; }
.paper-doctor { font-size: 1.35rem; font-weight: 700; }
.paper-specialty { font-size: 1rem; }
.paper-clinic { margin-top: .5rem; font-size: .85rem; line-height: 1.35; }
.paper-rule { border-top: 2px solid #111; margin: 14px 0 10px; }
.paper-patient .pp-row { display: flex; justify-content: space-between; gap: 1rem; }
.paper-patient .pp-row span:last-child:not(:first-child) { flex: none; min-width: 7.5rem; }
.paper-rx-row { display: flex; justify-content: space-between; align-items: flex-end; margin: 10px 0 6px; }
.rx-sym { font-family: "Times New Roman", Times, Georgia, serif; font-size: 3rem; line-height: 1; }
.paper-items { list-style: none; margin: 0; padding: 0 0 0 18px; }
.paper-items li { margin: 0 0 12px; }
.pi-head { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.pi-med { font-weight: 700; } .pi-qty { flex: none; font-weight: 600; }
.pi-sig { font-size: .95em; }
.pi-notes { font-size: .9em; color: #222; margin-top: 2px; padding-left: 1.4em; }
.paper-free h2 { font-size: 1.1rem; margin: 6px 0 8px; }
.paper-valid { margin: 12px 0 0; font-size: .9em; }
.paper-sign { display: flex; justify-content: flex-end; margin-top: 44px; }
.sign-block { text-align: center; min-width: 240px; }
.sign-img { max-height: 70px; max-width: 220px; display: block; margin: 0 auto -14px; }
.sign-space { height: 48px; }
.sign-name { font-weight: 700; border-top: 1px solid #111; padding-top: 4px; }
.sign-meta { font-size: .9em; }
.paper-verify { display: flex; gap: 14px; align-items: center; margin-top: 22px; padding-top: 12px; border-top: 2px solid #111; }
.pv-qr { flex: none; width: 92px; height: 92px; }
.pv-qr svg { width: 100%; height: 100%; display: block; }
.pv-qr-placeholder { width: 100%; height: 100%; border: 1px dashed #999; display: grid; place-items: center; color: #666; font-size: .76rem; text-align: center; padding: 4px; }
.pv-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; font-size: 1.05rem; letter-spacing: .08em; }
.pv-hint { font-size: .76rem; color: #333; line-height: 1.35; }
.pv-void { font-weight: 800; color: var(--danger); letter-spacing: .06em; margin-bottom: 2px; }
.void-stamp { position: absolute; inset: 0; display: grid; place-items: center; font-size: 9rem; font-weight: 900; color: rgba(190, 58, 43, .18); transform: rotate(-24deg); pointer-events: none; letter-spacing: .1em; }
@media (max-width: 520px) {
  .paper { padding: 20px 16px; font-size: 14px; }
  .paper-patient .pp-row { flex-direction: column; gap: 0; }
  .paper-patient .pp-row span:last-child:not(:first-child) { min-width: 0; }
  .sign-block { min-width: 0; width: 100%; }
  .void-stamp { font-size: 6rem; }
}

@media print {
  body, body.app { background: #fff; padding: 0; }
  .no-print, .topbar, .nav, dialog { display: none !important; }
  body * { visibility: hidden; }
  .paper-wrap, .paper-wrap * { visibility: visible; }
  .paper-wrap { position: absolute; left: 0; top: 0; width: 100%; margin: 0; }
  .paper { border: 0; box-shadow: none; max-width: none; border-radius: 0; padding: 0; font-size: 13pt; }
  .paper-patient .pp-row { flex-direction: row; }
  .void-stamp { -webkit-print-color-adjust: exact; print-color-adjust: exact; color: rgba(190, 58, 43, .35); }
  .pv-void { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { margin: 14mm; }
}
