:root {
  --bg: #f3f6f9; --card: #fff; --ink: #14213d; --muted: #64748b; --line: #dfe5ec; --brand: #0f6e6a; --brand-2: #115e59; --brand-soft: #e7f1f0; --brand-line: #b7d4d2;
  --accent: #2563eb; --warn: #b45309; --warn-bg: #fff7ed; --danger: #b91c1c; --danger-bg: #fef2f2; --ok: #15803d; --ok-bg: #f0fdf4;
  --chip: #eef2f7; --chip-ink: #1e293b; --radius: 10px; --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 18px rgba(15, 23, 42, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; } h4 { font-size: .92rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .pad { padding: 1rem; } .right { text-align: right; } .center { text-align: center; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; } .gap { gap: .6rem; }
[hidden] { display: none !important; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 1.2rem; padding: 0 1.2rem; height: 54px; background: var(--brand); color: #fff; box-shadow: var(--shadow); position: sticky; top: 0; z-index: 20; }
.brand { color: #fff; font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
.brand .logo { font-size: 1.3rem; }
.navlinks { display: flex; gap: .1rem; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.navlinks a { color: #d6f1ee; padding: .45rem .65rem; border-radius: 8px; font-weight: 500; white-space: nowrap; }
.navlinks a.on, .navlinks a:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.navright { font-size: .85rem; display: flex; align-items: center; gap: .6rem; }
.navright .who { color: #fff; font-weight: 600; display: flex; align-items: center; gap: .4rem; }
.navright .btn.ghost { background: transparent; color: #d6f1ee; border-color: rgba(255, 255, 255, .35); }
.rolebadge { display: inline-block; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: .1rem .4rem; border-radius: 4px; background: #e2e8f0; color: #334155; margin-left: .25rem; }
.rolebadge.admin { background: #ede9fe; color: #5b21b6; } .rolebadge.doctor { background: #dbeafe; color: #1e40af; } .rolebadge.reception { background: #fef3c7; color: #92400e; }
.topbar .rolebadge { background: rgba(255, 255, 255, .2); color: #fff; }
/* auth pages */
body.auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.auth-card { background: #fff; border-radius: 16px; box-shadow: var(--shadow); padding: 2rem 1.6rem; width: min(420px, 100%); }
.auth-brand { text-align: center; margin-bottom: 1.2rem; } .auth-brand .logo { font-size: 2rem; color: var(--brand); } .auth-brand h2 { margin: .3rem 0 .1rem; }
.form-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; border-radius: 8px; padding: .5rem .7rem; font-size: .9rem; }
.modal.left { text-align: left; width: min(520px, 94vw); }
tr.inactive td { opacity: .55; }
.diff div { font-size: .82rem; } .diff s { color: var(--danger); } .diff span { color: var(--ok); }
.tbl.audit code { font-size: .8rem; background: #f1f5f9; padding: .1rem .35rem; border-radius: 4px; }

/* layout */
.wrap { max-width: 1240px; margin: 0 auto; padding: 1.2rem; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.row { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }

/* forms */
.field { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
.field > span { color: var(--muted); font-weight: 500; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #99d5d0; border-color: var(--brand); }
textarea { min-height: 72px; resize: vertical; }
input[type=checkbox] { width: auto; transform: scale(1.15); margin: 0 .4rem 0 0; }
label.check { display: inline-flex; align-items: center; gap: .2rem; font-size: .92rem; cursor: pointer; }
input.warn { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); font-weight: 600; }
.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: .5rem .9rem; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; }
.btn:hover { background: #f8fafc; } .btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn.primary:hover { background: var(--brand-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: #fecaca; } .btn.danger:hover { background: var(--danger-bg); }
.btn.small { padding: .3rem .6rem; font-size: .83rem; } .btn.block { width: 100%; justify-content: center; } .btn.big { padding: .8rem 1.2rem; font-size: 1.05rem; }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: .15rem .5rem; border-radius: 999px; background: #e2e8f0; color: #334155; white-space: nowrap; }
.badge.waiting { background: #fef3c7; color: #92400e; } .badge.called { background: #dbeafe; color: #1e40af; } .badge.with_doctor { background: #e0e7ff; color: #3730a3; }
.badge.done { background: var(--ok-bg); color: var(--ok); } .badge.no_show { background: #fee2e2; color: #991b1b; } .badge.cancelled { background: #f1f5f9; color: #475569; }
.badge.pri { background: #fee2e2; color: #991b1b; }
.badge.src { background: #f1f5f9; color: #475569; font-weight: 600; } .badge.src.qr { background: #ecfccb; color: #3f6212; } .badge.src.booked { background: #ede9fe; color: #5b21b6; }
.badge.qr { background: #ecfccb; color: #3f6212; }
.serving { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-bottom: 1rem; }
.serving .panel { border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem; } .serving h4 { margin-bottom: .4rem; }
.serving .now { display: flex; gap: .6rem; flex-wrap: wrap; } .serving .now > div { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 10px; padding: .4rem .7rem; min-width: 150px; }
.serving .now b { font-size: 1.4rem; color: var(--brand); margin-right: .3rem; }
.serving .next span { display: inline-block; background: #fef3c7; color: #92400e; font-weight: 700; padding: .2rem .55rem; border-radius: 8px; margin: 0 .3rem .3rem 0; }
.serving .next span.plain { background: none; color: var(--muted); font-weight: 500; font-size: .85rem; }
.qitem.called, .qitem.with_doctor { border-color: #93c5fd; background: #eff6ff; } .qitem.no_show { opacity: .7; }
@media (max-width: 760px) { .serving { grid-template-columns: 1fr; } }
.tbl.hours input[type=time] { padding: .3rem .4rem; min-width: 0; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.tbl tr:hover td { background: #f8fafc; }
.tok-cell { font-weight: 800; font-size: 1.1rem; color: var(--brand); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.stat { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: .8rem 1rem; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.1; } .stat span { color: var(--muted); font-size: .82rem; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .35rem 0 .2rem; }
.chip { font: inherit; font-size: .82rem; border: 1px solid transparent; background: var(--chip); color: var(--chip-ink); border-radius: 999px; padding: .22rem .65rem; cursor: pointer; line-height: 1.3; }
.chip:hover { border-color: var(--brand); }
.chip.on { background: var(--brand); color: #fff; }
.chipgroup { margin-top: .5rem; } .chipgroup > b { font-size: .8rem; color: var(--muted); }

/* toasts */
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; }
.toast { background: #1e293b; color: #fff; padding: .6rem .9rem; border-radius: 8px; box-shadow: var(--shadow); font-size: .9rem; max-width: 360px; }
.toast.ok { background: var(--ok); } .toast.err { background: var(--danger); }

/* home */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.tile { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.3rem; color: var(--ink); display: block; border-top: 4px solid var(--brand); }
.tile:hover { transform: translateY(-2px); transition: .15s; }
.tile .ico { font-size: 1.8rem; } .tile h3 { margin: .4rem 0 .2rem; } .tile p { margin: 0; color: var(--muted); font-size: .9rem; }

/* reception */
.reception-grid { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 1.2rem; }
.reception-grid .tbl { font-size: .86rem; } .reception-grid .tbl td b { white-space: nowrap; }
.reception-grid .tbl td, .reception-grid .tbl th { padding: .4rem .45rem; }
.tbl td.acts { text-align: right; min-width: 180px; } .tbl td.acts .btn { margin: .1rem 0 .1rem .2rem; white-space: nowrap; }
.tbl select.docsel { width: auto; max-width: 150px; padding: .3rem .4rem; }
@media (max-width: 900px) { .reception-grid { grid-template-columns: minmax(0, 1fr); } }
.results { max-height: 230px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: .4rem; }
.res { padding: .5rem .7rem; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; justify-content: space-between; gap: .5rem; }
.res:hover { background: #f1f5f9; } .res:last-child { border-bottom: 0; }
.selected { border: 1px solid #99d5d0; background: #f0fdfa; border-radius: 8px; padding: .7rem .9rem; margin-top: .6rem; }
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 14px; padding: 1.5rem; width: min(420px, 92vw); text-align: center; }
.slip .tokhuge { font-size: 5rem; font-weight: 900; color: var(--brand); line-height: 1; }

/* doctor */
.doctor-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 1rem; padding: 1rem; max-width: 1500px; margin: 0 auto; min-height: calc(100vh - 54px); }
@media (max-width: 950px) { .doctor-layout { grid-template-columns: minmax(0, 1fr); } }
.pane { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem; align-self: start; position: sticky; top: 66px; max-height: calc(100vh - 80px); overflow: auto; }
.pane-head { display: flex; justify-content: space-between; align-items: baseline; margin: .9rem 0 .4rem; }
.qlist { display: flex; flex-direction: column; gap: .35rem; }
.qitem { display: grid; grid-template-columns: 44px 1fr auto; gap: .6rem; align-items: center; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: #fff; }
.qitem:hover { border-color: var(--brand); } .qitem.sel { border-color: var(--brand); background: #f0fdfa; }
.qitem.done, .qitem.cancelled { opacity: .55; }
.qitem .tok { font-weight: 800; font-size: 1.25rem; color: var(--brand); text-align: center; }
.qitem .qname { font-weight: 600; } .qmeta { text-align: right; }
.empty-state { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 3rem; text-align: center; color: var(--muted); }
.phead { display: grid; grid-template-columns: auto 1fr auto; gap: 1rem; align-items: center; margin-bottom: .8rem; }
.tokbig { font-size: 2.4rem; font-weight: 900; color: var(--brand); background: #f0fdfa; border-radius: 12px; padding: .2rem .9rem; }
.phead-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.eyebar { display: flex; align-items: center; gap: .8rem; margin-bottom: .8rem; padding: .5rem .9rem; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); position: sticky; top: 60px; z-index: 10; }
.eyesel { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.eyesel button { font: inherit; font-weight: 700; border: 0; background: #fff; padding: .35rem .8rem; cursor: pointer; color: var(--muted); }
.eyesel button.on { background: var(--brand); color: #fff; }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: .8rem; }
.tabs button { font: inherit; font-weight: 600; font-size: .88rem; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: .35rem .8rem; cursor: pointer; color: var(--muted); }
.tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.section { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.section h3 { padding-bottom: .5rem; border-bottom: 1px solid var(--line); margin-bottom: .8rem; }
.sub { font-weight: 700; font-size: .9rem; margin: 1rem 0 .3rem; color: var(--brand-2); }
.eye-table { width: 100%; border-collapse: collapse; }
.eye-table th, .eye-table td { padding: .3rem .4rem; text-align: left; vertical-align: top; }
.eye-table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--line); }
.eye-table thead th.od { color: #1d4ed8; } .eye-table thead th.os { color: #047857; }
.eye-table tbody th { font-weight: 600; font-size: .9rem; width: 170px; color: #334155; padding-top: .6rem; }
.eye-table tr.chiprow td { padding-top: 0; padding-bottom: .5rem; border-bottom: 1px dashed var(--line); }
.eye-table input, .eye-table select { padding: .4rem .5rem; }
.rx-table th, .rx-table td { text-align: center; }
.rx-table td:first-child { text-align: left; font-weight: 700; }
.rx-table input { text-align: center; width: 100%; }
.hist { display: block; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 8px; margin-top: .4rem; color: var(--ink); }
.hist:hover { border-color: var(--accent); }
.aibox { background: #f8fafc; border: 1px dashed var(--line); border-radius: 8px; padding: .8rem; }
.aibox textarea { min-height: 170px; background: #fff; }
.inline-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .7rem; }

/* report sheet */
.report-bar { display: flex; gap: .6rem; justify-content: center; padding: .8rem; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.sheet { width: 194mm; min-height: 275mm; margin: 1rem auto; background: #fff; padding: 10mm 10mm 12mm; box-shadow: var(--shadow); color: #111; font-size: 11.5px; line-height: 1.4; position: relative; }
.sheet .rhead { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 3px double var(--brand); padding-bottom: 6px; margin-bottom: 8px; }
.sheet .rhead h1 { font-size: 20px; color: var(--brand); margin: 0; }
.sheet .rbrand { display: flex; align-items: center; gap: 10px; } .sheet .rlogo { height: 46px; width: auto; max-width: 120px; object-fit: contain; }
.sheet .rsign { display: block; height: 40px; max-width: 160px; object-fit: contain; margin: 0 0 2px auto; } .sheet .rhead .tag { color: #555; font-size: 11px; }
.sheet .rhead .contact { text-align: right; font-size: 10.5px; color: #333; }
.sheet .rtitle { text-align: center; font-weight: 800; letter-spacing: .12em; font-size: 12px; margin: 6px 0; color: #333; }
.sheet .pgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px 10px; border: 1px solid #ccc; border-radius: 6px; padding: 6px 8px; margin-bottom: 8px; font-size: 11px; }
.sheet .pgrid b { color: #555; font-weight: 600; margin-right: 4px; }
.sheet h2 { font-size: 12.5px; color: var(--brand); border-bottom: 1px solid #cfd8dc; padding-bottom: 2px; margin: 10px 0 5px; text-transform: uppercase; letter-spacing: .05em; }
.sheet table { width: 100%; border-collapse: collapse; font-size: 11px; margin-bottom: 4px; }
.sheet table th, .sheet table td { border: 1px solid #cfd8dc; padding: 3px 6px; text-align: left; vertical-align: top; }
.sheet table th { background: #f1f5f9; font-weight: 600; }
.sheet table.c td, .sheet table.c th { text-align: center; } .sheet table.c td:first-child, .sheet table.c th:first-child { text-align: left; }
.sheet ul, .sheet ol { margin: 2px 0 4px 18px; padding: 0; } .sheet li { margin: 1px 0; }
.sheet .two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.sheet .summary { background: #f8fafc; border: 1px solid #cfd8dc; border-left: 4px solid var(--brand); padding: 6px 10px; border-radius: 4px; white-space: pre-wrap; }
.sheet .sign { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 26px; }
.sheet .sign .doc { text-align: right; } .sheet .sign .doc b { display: block; font-size: 12px; }
.sheet .foot { margin-top: 10px; border-top: 1px solid #cfd8dc; padding-top: 4px; font-size: 9.5px; color: #555; display: flex; justify-content: space-between; }
/* two-column prescription: tinted side panel (clinic, doctor, vitals, eyes, advised, follow-up) + main column */
.sheet.rx { padding: 0; display: grid; grid-template-columns: 60mm minmax(0, 1fr); min-height: 276mm; /* one A4 page after html2pdf scales 194 mm to the 202 mm printable width */ }
.rx-side { background: var(--brand-soft); padding: 9mm 6mm 8mm; display: flex; flex-direction: column; gap: 4mm; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.rx-logo { display: block; max-width: 100%; max-height: 24mm; object-fit: contain; margin-bottom: 3mm; border-radius: 6px; background: #fff; }
.sheet .rx-clinic h1 { font-size: 17px; line-height: 1.2; color: var(--ink); margin: 0; }
.rx-local { font-size: 14px; font-weight: 700; color: var(--brand); margin-top: 1px; } .rx-tag { font-size: 10px; color: var(--brand); font-style: italic; margin-top: 1px; }
.rx-clinic p { margin: 2mm 0 0; color: #475569; font-size: 10.5px; }
.rx-doc { border-top: 1px solid var(--brand-line); border-bottom: 1px solid var(--brand-line); padding: 3mm 0; display: flex; flex-direction: column; }
.rx-doc b { font-size: 13px; } .rx-doc span { color: #475569; font-size: 10.5px; }
.sheet .rx-side h3 { font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--brand); margin: 0 0 1.5mm; }
.rx-dl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1.4mm 3mm; margin: 0; }
.rx-dl dt { color: #475569; } .rx-dl dd { margin: 0; font-weight: 700; text-align: right; } .rx-dl .flag { color: #b91c1c; }
.rx-flagword { font-size: 8.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.sheet .rx-side ul { margin: 0; padding-left: 4mm; } .rx-side p { margin: 0; }
.rx-fu { border: 1.5px solid var(--brand); border-radius: 8px; padding: 3mm 4mm; background: #fff; display: flex; flex-direction: column; }
.rx-fu span { font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--brand); font-weight: 700; } .rx-fu b { font-size: 15px; } .rx-fu small { color: #475569; }
.rx-opd { margin-top: auto; font-size: 9.5px; color: #475569; } .rx-opd span { display: block; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 1mm; }
.rx-main { padding: 9mm 9mm 8mm; display: flex; flex-direction: column; gap: 3mm; position: relative; min-width: 0; }
.rx-main { -webkit-print-color-adjust: exact; print-color-adjust: exact; } /* keep the watermark image when printing */
.rx-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 4mm; }
.rx-title { font-size: 28px; font-weight: 800; line-height: 1; color: var(--ink); }
.rx-chip { display: inline-block; margin-top: 2mm; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 10.5px; padding: .8mm 3mm; border-radius: 99px; }
.rx-when { text-align: right; color: #475569; } .rx-when b { color: var(--ink); font-size: 12px; }
.rx-patient { border: 1px solid #d5dbe3; border-radius: 8px; padding: 3mm 4mm; display: grid; grid-template-columns: 1.4fr .8fr 1fr; gap: 2.5mm 4mm; }
.rx-patient span, .rx-visit span { display: block; font-size: 9.5px; color: #64748b; } .rx-patient b, .rx-visit b { font-size: 12px; }
.rx-patient .wide { grid-column: span 2; } .rx-patient .allergy { grid-column: 1 / -1; } .rx-patient .allergy span, .rx-patient .allergy b { color: #b91c1c; }
.rx-visit { display: grid; grid-template-columns: 1fr 1fr; gap: 3mm; } .rx-visit > div { background: var(--brand-soft); border-radius: 8px; padding: 2.5mm 4mm; }
.rx-visit .next { background: var(--brand); color: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; } .rx-visit .next span { color: rgba(255, 255, 255, .85); }
.rx-dx { background: var(--brand-soft); border-radius: 8px; padding: 2.5mm 4mm; display: flex; gap: 4mm; align-items: baseline; }
.rx-dx span { font-size: 9.5px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--brand); white-space: nowrap; } .rx-dx b { font-size: 12.5px; }
.sheet.rx .rx-main h2 { border-bottom: 0; letter-spacing: .12em; font-size: 10.5px; margin: 2mm 0 1.2mm; }
.rx-sign { margin-top: auto; padding-top: 8mm; display: flex; justify-content: space-between; align-items: flex-end; gap: 6mm; color: #64748b; }
.rx-note { font-size: 9.5px; max-width: 70mm; }
.rx-sign .doc { text-align: right; min-width: 58mm; display: flex; flex-direction: column; } .rx-sign .doc b { border-top: 2px solid var(--ink); padding-top: 1.5mm; color: var(--ink); font-size: 12px; }
.rx-foot { border-top: 2px solid var(--brand); padding-top: 2mm; display: flex; justify-content: space-between; gap: 6mm; font-size: 9.5px; color: #475569; }
.sheet .draft { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-30deg); font-size: 90px; font-weight: 900; color: rgba(185, 28, 28, .08); letter-spacing: .2em; pointer-events: none; }
.keep { break-inside: avoid; page-break-inside: avoid; }
/* billing */
.billing-grid { display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 1.2rem; }
@media (max-width: 900px) { .billing-grid { grid-template-columns: minmax(0, 1fr); } }
.badge.appt-booked { background: #dbeafe; color: #1e40af; } .badge.appt-late { background: #fef3c7; color: #92400e; } .badge.appt-checked_in { background: #e0e7ff; color: #3730a3; }
.badge.appt-completed { background: var(--ok-bg); color: var(--ok); } .badge.appt-no_show { background: #fee2e2; color: #991b1b; } .badge.appt-cancelled { background: #e2e8f0; color: #475569; text-decoration: line-through; }
.pick-list { display: grid; gap: .3rem; max-height: 280px; overflow: auto; } .pick-list:empty { display: none; }
.pick { text-align: left; font: inherit; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .5rem .7rem; cursor: pointer; } .pick:hover, .pick:focus-visible { border-color: var(--brand); }
.badge.bill-draft { background: #f1f5f9; color: #475569; } .badge.bill-unpaid { background: #fee2e2; color: #991b1b; } .badge.bill-partial { background: #fef3c7; color: #92400e; }
.badge.bill-paid { background: var(--ok-bg); color: var(--ok); } .badge.bill-cancelled { background: #e2e8f0; color: #475569; text-decoration: line-through; }
.tbl.items input { padding: .35rem .45rem; }
.tbl.items .c-qty { width: 70px; } .tbl.items .c-price { width: 110px; } .tbl.items .c-amt { width: 100px; } .tbl.items .c-del { width: 36px; }
.totals { margin-left: auto; max-width: 320px; border: 1px solid var(--line); border-radius: 10px; padding: .6rem .9rem; }
.totals div { display: flex; justify-content: space-between; padding: .15rem 0; } .totals .grand { font-size: 1.15rem; border-top: 1px solid var(--line); margin-top: .3rem; padding-top: .4rem; }
.totals .due b { color: var(--danger); }
.paybox { background: #f0fdfa; border: 1px solid #99d5d0; border-radius: 10px; padding: .8rem 1rem; }
.sheet.receipt { min-height: 0; }
.test-banner { background: #fef3c7; color: #92400e; border-bottom: 1px solid #fcd34d; padding: .35rem 1rem; font-size: .85rem; text-align: center; }
.auth-brand .test-banner { border: 1px solid #fcd34d; border-radius: 8px; margin-top: .6rem; }
.pw-wrap { position: relative; display: block; } .pw-wrap input { width: 100%; padding-right: 4.4rem; }
.pw-toggle { position: absolute; right: .35rem; top: .35rem; border: 0; border-radius: 6px; background: var(--chip); color: var(--chip-ink); font: inherit; font-size: .8rem; font-weight: 600; padding: .3rem .65rem; cursor: pointer; }
.pw-toggle:hover, .pw-toggle:focus-visible { background: #e2e8f0; } .pw-caps { display: block; margin-top: .25rem; font-size: .8rem; color: var(--warn); font-weight: 600; }
.brand .clinic-logo { height: 30px; width: auto; max-width: 90px; object-fit: contain; background: #fff; border-radius: 6px; padding: 2px; }
.auth-local { font-weight: 700; color: var(--brand); }
.auth-logo { height: 72px; max-width: 200px; object-fit: contain; display: block; margin: 0 auto .4rem; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; } .checklist li.done { color: var(--muted); } .checklist li span[aria-hidden] { display: inline-block; width: 1.2rem; font-weight: 700; color: var(--brand); }
.setup { border-left: 4px solid #a86200; }
.doc-card { border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem; } .doc-card.inactive { opacity: .6; }
.logo-box img { height: 48px; max-width: 160px; object-fit: contain; } .sig-box img { height: 34px; max-width: 140px; object-fit: contain; vertical-align: middle; }
.alert-line { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; border-radius: 8px; padding: .45rem .7rem; font-size: .92rem; }
.summary-box { white-space: pre-wrap; background: #f8fafc; border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 6px; padding: .5rem .8rem; margin-top: .3rem; font-size: .9rem; }
.wa-group { display: inline-flex; gap: .2rem; align-items: center; } .wa-group select { width: auto; padding: .28rem .3rem; font-size: .82rem; }

/* dashboard */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: .8rem; margin-bottom: 1rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { font: inherit; font-weight: 600; font-size: .9rem; border: 0; background: none; padding: .5rem .8rem; cursor: pointer; color: var(--muted); min-height: 40px; }
.seg button + button { border-left: 1px solid var(--line); } .seg button.on { background: var(--brand); color: #fff; }
#body.loading { opacity: .55; transition: opacity .15s; }
.hero { margin-bottom: 1rem; }
.dash #kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.hero-label { color: var(--muted); font-weight: 600; font-size: .9rem; }
.hero-num { font-size: 3rem; font-weight: 700; line-height: 1.1; letter-spacing: -.01em; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 1rem; align-items: start; }
.dash-grid h3 { margin-bottom: .6rem; }
.mini-row { display: flex; align-items: center; gap: .6rem; justify-content: space-between; padding: .4rem 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.mini-row:last-child { border-bottom: 0; } .mini-row > span:first-of-type { flex: 1; min-width: 0; } .mini-row .tok-cell { min-width: 1.8rem; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.facts div { background: #f8fafc; border-radius: 8px; padding: .5rem .7rem; } .facts span, .facts a { display: block; font-size: .8rem; color: var(--muted); } .facts b { font-size: 1.15rem; }
.meter-row { display: grid; grid-template-columns: 4.5rem 1fr auto; align-items: center; gap: .6rem; padding: .25rem 0; font-size: .9rem; }
.meter { height: 8px; background: #ccfbf1; border-radius: 999px; overflow: hidden; } .meter div { height: 100%; background: #0d9488; border-radius: 999px; }
.links { display: flex; flex-wrap: wrap; gap: .5rem; }
/* column chart: one series, thin bars on one baseline, recessive grid; bar colour validated (#0d9488, dataviz check) */
.chart { position: relative; height: 170px; margin: 1.4rem 0 0 2.6rem; }
.chart .grid { position: absolute; left: 0; right: 0; border-top: 1px solid #e8edf2; }
.chart .grid span { position: absolute; left: -2.6rem; width: 2.3rem; text-align: right; transform: translateY(-50%); font-size: .7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart .cols { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 2px; }
.chart .col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; position: relative; outline: none; }
.chart .bar { width: 100%; max-width: 24px; background: #0d9488; border-radius: 4px 4px 0 0; }
.chart .col:hover .bar, .chart .col:focus-visible .bar { background: #14b8a6; }
.chart .col:focus-visible { box-shadow: inset 0 0 0 2px #99d5d0; border-radius: 4px; }
.chart .peak { position: absolute; margin-bottom: 2px; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.chart-tip { position: absolute; transform: translate(-50%, -6px); pointer-events: none; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 8px; padding: .3rem .55rem; font-size: .78rem; color: var(--muted); white-space: nowrap; z-index: 5; }
.chart-tip b { display: block; color: var(--ink); font-size: .95rem; }
.chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .88rem; }
.xaxis { display: flex; gap: 2px; margin-left: 2.6rem; margin-top: .25rem; } .xaxis span { flex: 1; text-align: center; font-size: .68rem; color: var(--muted); white-space: nowrap; }
.chart-table { margin-top: .5rem; font-size: .85rem; } .chart-table summary { cursor: pointer; color: var(--accent); font-size: .82rem; }
.chart-table .tbl { display: table; font-variant-numeric: tabular-nums; }

/* phone / tablet overrides — kept last so they win over the base rules above */
@media (max-width: 950px) {
  .pane { position: static; max-height: 45vh; }
}
@media (max-width: 760px) {
  .topbar { height: auto; flex-wrap: wrap; padding: .45rem .7rem; gap: .4rem .8rem; }
  .brand-name { max-width: 40vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .navlinks { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: .2rem; }
  .navlinks a { white-space: nowrap; padding: .35rem .6rem; }
  .navright { margin-left: auto; } .navright .roles { display: none; }
  .wrap { padding: .8rem; }
  .tbl { display: block; overflow-x: auto; }
  .phead { grid-template-columns: auto 1fr; gap: .6rem .8rem; }
  .phead .phead-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .tokbig { font-size: 1.8rem; padding: .1rem .6rem; }
  .eyebar { position: static; flex-wrap: wrap; } .eyebar .help { display: none; }
  .eye-table tbody th { width: 110px; font-size: .82rem; }
  .doctor-layout { padding: .6rem; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .tbl.items { display: table; font-size: .85rem; } .tbl.items th, .tbl.items td { padding: .35rem .25rem; }
  .tbl.items .c-qty { width: 46px; } .tbl.items .c-price { width: 76px; } .tbl.items .c-amt { width: 70px; } .tbl.items .c-del { width: 30px; }
  .tbl.items input { padding: .3rem .3rem; } .tbl.items .btn.small { padding: .2rem .4rem; }
  /* list tables whose rows carry actions become one card per row on phones */
  .tbl.cards { display: block; } .tbl.cards thead { display: none; }
  .tbl.cards tbody, .tbl.cards tr, .tbl.cards td { display: block; width: auto; }
  .tbl.cards tr { border: 1px solid var(--line); border-radius: 10px; padding: .5rem .7rem; margin-bottom: .6rem; }
  .tbl.cards td { border: 0; padding: .15rem 0; } .tbl.cards td.acts { text-align: left; min-width: 0; padding-top: .4rem; }
  .tbl.cards tr:hover td { background: none; }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .dash #kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-num { font-size: 2.6rem; }
  .seg button { padding: .45rem .6rem; font-size: .85rem; }
  /* medicine rows stack: name on its own line, the rest two per line */
  .med-table thead { display: none; }
  .med-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .3rem; padding: .4rem 0; border-bottom: 1px solid var(--line); }
  .med-table td { padding: 0; } .med-table td:first-child { grid-column: 1 / -1; } .med-table td:last-child { grid-column: 1 / -1; justify-self: end; }
  /* eye grids and refraction tables scroll inside their card instead of widening the page */
  .section { overflow-x: auto; }
}

/* paper fallback: today's list with write-in rows */
.daylist table.c td, .daylist table.c th { text-align: left; } .daylist tr.write td { height: 24px; }

@page { size: A4; margin: 10mm; }
/* token slips go to an 80 mm receipt printer: a named page so only the slip uses that size */
@page slip { size: 80mm 110mm; margin: 3mm; }
@media print {
  body { background: #fff; } .no-print, #nav, #toasts { display: none !important; }
  .sheet { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; }
  body.print-slip > *:not(.overlay) { display: none !important; } body.print-slip .overlay { position: static; background: none; } body.print-slip .modal { box-shadow: none; }
  body.print-slip .modal.slip { page: slip; width: 74mm; max-width: none; padding: 0; margin: 0; } body.print-slip .slip .row { display: none; }
  .daylist { font-size: 10.5px; }
}
