/* The prescription sheet. On screen it is the preview (scaled with zoom by print.js); in print it
   is the only thing on the page. Sizes are in mm and pt so paper and preview agree. Black on white. */
.paper{background:#fff;color:#000;margin:0 auto;box-shadow:0 1px 6px rgba(0,0,0,.3)}
.paper[data-paper=A4]{width:210mm;padding:12mm}
.paper[data-paper=A5]{width:148mm;padding:8mm}
.sheet{color:#000;font:400 11pt/1.4 'Hind Siliguri','Noto Sans Bengali',sans-serif;overflow-wrap:anywhere}
.paper[data-paper=A5] .sheet{font-size:9pt}
.sheet [lang=en]{font-family:'Hind Siliguri',Arial,Helvetica,sans-serif}

/* Letterhead */
.lh{display:flex;gap:4mm;align-items:flex-start;border-bottom:1.2pt solid #000;padding-bottom:2.5mm}
.lh-logo{max-width:22mm;max-height:22mm;flex:none}
.lh-doc{flex:1;min-width:0}
.lh-ch{flex:1;min-width:0;text-align:right}
.lh-name{font-size:1.5em;font-weight:600;line-height:1.2}
.lh-ch-name{font-size:1.15em;font-weight:600}
.lh-small{font-size:.92em}
.lh-space{flex:none}

/* Patient line */
.pt{display:flex;flex-wrap:wrap;gap:0 5mm;border-bottom:.6pt solid #000;padding:1.6mm 0}
.pt-item{white-space:nowrap}
.pt-item.wide{white-space:normal}
.pt-name{flex:1 1 40%;white-space:normal}
.pt-label{font-weight:600}
.blank{display:inline-block;min-width:22mm;border-bottom:.6pt dotted #000;height:1em}
.pt-name .blank{min-width:45mm}

/* Body: notes in a left column on A4, in compact lines on top on A5 */
.body{padding-top:2.5mm}
.body::after{content:"";display:block;clear:both}
.notes{float:left;width:24%;padding-right:3mm}
.notes h3,.advice h3{font-size:1em;font-weight:600;margin:0}
.notes ul,.advice ul{margin:0 0 2.5mm;padding-left:4.2mm}
.notes li,.advice li{margin:0}
.body.has-notes .rx{margin-left:24%;border-left:.6pt solid #000;padding-left:3.5mm;min-height:60mm}
.paper[data-paper=A5] .notes{float:none;width:auto;padding:0 0 1mm;border-bottom:.6pt solid #000;margin-bottom:1.5mm}
.paper[data-paper=A5] .body.has-notes .rx{margin-left:0;border-left:0;padding-left:0;min-height:0}
.paper[data-paper=A5] .notes h3{display:inline}
.paper[data-paper=A5] .notes h3::after{content:": "}
.paper[data-paper=A5] .notes ul{display:inline;margin:0;padding:0}
.paper[data-paper=A5] .notes li{display:inline}
.paper[data-paper=A5] .notes li+li::before{content:"; "}
.paper[data-paper=A5] .notes ul::after{content:"";display:block}
.rx-mark{font:italic 600 1.8em/1 Georgia,'Times New Roman',serif;margin-bottom:1mm;break-after:avoid;page-break-after:avoid}

/* Medicines and their schedule */
.meds{width:100%;border-collapse:collapse;table-layout:auto;overflow-wrap:break-word}
.meds thead{display:table-header-group;break-after:avoid;page-break-after:avoid}
.meds th{font-weight:600;font-size:.9em;text-align:center;vertical-align:bottom;border-bottom:1pt solid #000;padding:.8mm .7mm;white-space:nowrap}
.meds th:first-child{text-align:left}
.meds td{border-bottom:.5pt solid #000;padding:1.3mm .7mm;vertical-align:top;text-align:center}
.meds tr{break-inside:avoid;page-break-inside:avoid}
.meds td.med{text-align:left;padding-left:0}
.meds td.slot,.meds td.timing,.meds td.nowrap,.meds td.total{white-space:nowrap}
.meds td.slot{font-size:1.15em;font-weight:600;min-width:7.5mm;white-space:nowrap}
.meds td.slot.zero{font-weight:400}
.meds td.slot .u{display:block;font-size:.7em;font-weight:400}
.meds td.free{text-align:left}
.meds td.nowrap,.meds td.total{white-space:nowrap}
.med-name{font-weight:600;font-size:1.08em;letter-spacing:.01em}
.med-n{display:inline-block;min-width:5mm;font-weight:400;padding-right:.8mm}
.med-gen,.med-note{font-size:.88em;padding-left:5mm}
.med-gen{font-style:italic}
.advice{margin-top:3.5mm;break-inside:avoid;page-break-inside:avoid}
.follow{margin:2.5mm 0 0;font-weight:600;break-inside:avoid;page-break-inside:avoid}

/* Footer: QR and credit on the left, signature on the right. On a one-page sheet print.js sets the
   height of .sf-gap so the footer sits at the bottom of the page. When the sheet needs a second
   page, the footer never goes there alone: no page break is wanted just before it, and print.js
   (fitPreview) first makes the footer lower (.tight: the credit line moves beside the QR, then the
   QR gets smaller) and, if that is not enough, starts the new page at the last medicine
   (.page-start), so the last lines of the prescription go with the signature. */
.page-start{break-before:page;page-break-before:always}
.sf.tight .sf-left{display:grid;grid-template-columns:auto 1fr;column-gap:2.5mm;align-items:end}
.sf.tight .qr{display:contents}
.sf.tight .qr svg{grid-row:1/3}
.sf.tight .made{margin:0;padding-bottom:1mm}
.body{break-after:avoid;page-break-after:avoid}
.sf-gap{height:0;break-before:avoid;page-break-before:avoid;break-after:avoid;page-break-after:avoid}
.sf{padding-top:5mm;display:flex;justify-content:space-between;align-items:flex-end;gap:5mm;break-inside:avoid;page-break-inside:avoid;break-before:avoid;page-break-before:avoid}
.sf-left{font-size:.78em;max-width:60%}
.qr{display:flex;align-items:flex-end;gap:2.5mm}
.qr svg{width:32mm;height:32mm;flex:none;display:block}
.qr-cap{max-width:32mm;padding-bottom:1mm}
.made{margin-top:1mm}
.sign{min-width:52mm;max-width:48%;text-align:center}
.sign-space{height:14mm}
.sign-line{border-top:.7pt solid #000;padding-top:.8mm;font-weight:600}
.sign-small{font-size:.88em}
.paper[data-paper=A5] .meds td{padding:.7mm .8mm}
.paper[data-paper=A5] .meds td.slot .u{font-size:.62em;line-height:1.1}
.paper[data-paper=A5] .meds td.slot{min-width:7.5mm}
.paper[data-paper=A5] .lh{padding-bottom:1.5mm}
.paper[data-paper=A5] .pt{padding:1mm 0}
.paper[data-paper=A5] .body{padding-top:1.5mm}
.paper[data-paper=A5] .advice{margin-top:2mm}
.paper[data-paper=A5] .follow{margin-top:1.5mm}
.paper[data-paper=A5] .sf{padding-top:3mm}
.paper[data-paper=A5] .sign-space{height:11mm}

@media print{
  .paper{box-shadow:none;margin:0;zoom:1!important}
  .paper[data-paper]{width:auto;padding:0}
  *{-webkit-print-color-adjust:exact;print-color-adjust:exact}
}
