:root {
  --ink: #14182b; --muted: #5b6275; --line: #dde1ea; --bg: #f4f6fa; --card: #fff;
  --blue: #1d4ed8; --blue-soft: #e8efff; --green: #0f7a3d; --green-soft: #e3f5ea;
  --amber: #8a5a00; --amber-soft: #fff4dc; --red: #b42318; --red-soft: #fdecea;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--blue); }
h1 { font-size: 1.5rem; margin: 0 0 .4rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 1.2rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); } .center { text-align: center; }
main.staff { max-width: 1040px; margin: 0 auto; padding: 20px 16px 60px; }
main.plain { max-width: 760px; margin: 0 auto; padding: 24px 16px 120px; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; background: #0d1b3d; color: #fff; flex-wrap: wrap; }
.top .brand { color: #fff; text-decoration: none; font-weight: 700; }
.top .brand span { font-weight: 400; opacity: .7; margin-left: 8px; }
.top nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.top nav a { color: #dbe4ff; text-decoration: none; font-size: .95rem; }
.top nav a.btn { color: #fff; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin: 0 0 16px; }
.card.narrow { max-width: 420px; margin: 40px auto; }
.card.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.bar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.bar h1 { margin: 0; }

.btn { display: inline-block; border: 0; border-radius: 9px; padding: 11px 18px; background: var(--blue); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: var(--blue-soft); color: var(--blue); }
.btn.small { padding: 7px 12px; font-size: .9rem; }
.btn.big { width: 100%; padding: 16px; font-size: 1.1rem; }
.btn.danger { background: var(--red); }
.btns { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.btns form { margin: 0; }

label { display: block; font-weight: 600; font-size: .95rem; margin: 0 0 12px; }
input[type=text], input:not([type]), input[type=email], input[type=tel], input[type=date], input[type=password], input[type=search], select {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px; border: 1px solid #c8cdd8; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
label.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 4px 0 16px; padding: 10px 14px 2px; }
legend { font-weight: 700; padding: 0 6px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .row { grid-template-columns: 1fr; } }
form.inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-top: 14px; }
form.inline label { margin: 0; flex: 1 1 220px; }
form.void { margin-top: 16px; }
.search { display: flex; gap: 8px; } .search input { margin: 0; min-width: 220px; }

.flash { padding: 10px 14px; border-radius: 8px; margin: 0 0 14px; background: var(--green-soft); color: var(--green); }
.flash.err { background: var(--red-soft); color: var(--red); }
.flash.warn { background: var(--amber-soft); color: var(--amber); }

table.list { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
table.list th, table.list td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { background: #f0f2f7; font-size: .85rem; color: var(--muted); font-weight: 600; }
table.list tbody tr { cursor: pointer; } table.list tbody tr:hover { background: #f8faff; }
table.list.small { border: 0; font-size: .88rem; } table.list.small td { padding: 6px 8px; }
@media (max-width: 640px) { table.list th:nth-child(3), table.list td:nth-child(3), table.list th:nth-child(4), table.list td:nth-child(4) { display: none; } }

.pill { display: inline-block; padding: 4px 10px; border-radius: 99px; font-size: .85rem; font-weight: 600; background: var(--blue-soft); color: var(--blue); white-space: nowrap; }
.pill.wait { background: var(--amber-soft); color: var(--amber); }
.pill.done { background: var(--green-soft); color: var(--green); }
.pill.void { background: #eceef2; color: var(--muted); }

.send { display: grid; grid-template-columns: 260px 1fr; gap: 24px; align-items: start; }
@media (max-width: 720px) { .send { grid-template-columns: 1fr; } }
.send h2 { margin-top: 0; }
.qrwrap { max-width: 260px; width: 100%; margin: 0 auto; }
#qr svg { width: 100%; height: auto; display: block; }
img.mysig { height: 40px; vertical-align: middle; background: #fafbfd; border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; }
details.card summary { cursor: pointer; font-weight: 600; }
hr.thick { border: 0; border-top: 2px solid var(--line); margin: 28px 0; }

/* Signature pads */
.pad { position: relative; border: 2px dashed #b9c0cf; border-radius: 10px; background: #fcfdff; margin: 8px 0 12px; touch-action: none; }
.pad canvas { display: block; width: 100%; height: 170px; touch-action: none; cursor: crosshair; }
.pad.small canvas { height: 110px; }
.pad::before { content: "Draw here"; position: absolute; left: 14px; bottom: 10px; color: #a0a8b8; font-size: .85rem; pointer-events: none; }
.pad.inked::before { content: ""; }
.pad .clear { position: absolute; top: 8px; right: 8px; border: 0; background: #eef1f6; color: var(--muted); border-radius: 6px; padding: 5px 10px; font: inherit; font-size: .85rem; cursor: pointer; }
.need { outline: 3px solid #f59e0b; outline-offset: 3px; border-radius: 8px; }

/* The document, on screen */
.doc { font-size: 1rem; }
.doc h1 { font-size: 1.35rem; border-bottom: 2px solid var(--ink); padding-bottom: 6px; margin-bottom: 12px; }
.doc h2 { font-size: 1.1rem; margin-top: 1.6rem; }
.doc p { margin: 0 0 .8rem; } .doc ol { padding-left: 1.4rem; margin: 0 0 .8rem; } .doc li { margin-bottom: .35rem; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }
.acks { margin: 0 0 1rem; }
.ack { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid #f0f2f6; }
.box { display: inline-block; width: 18px; height: 18px; border: 1.5px solid #333; border-radius: 3px; vertical-align: -3px; text-align: center; line-height: 15px; font-weight: 700; margin-right: 6px; }
.box.on { background: var(--ink); color: #fff; }
span.init { display: inline-block; min-width: 64px; height: 30px; border-bottom: 1.5px solid #333; vertical-align: bottom; flex: none; }
span.init img, button.init img { height: 28px; max-width: 80px; object-fit: contain; display: block; margin: 0 auto; }
button.init { flex: none; min-width: 84px; min-height: 44px; border: 2px solid #f0b429; background: #fff8e1; color: #7a5300; border-radius: 8px; font: inherit; font-weight: 700; font-size: .9rem; cursor: pointer; padding: 4px 8px; }
button.init.ready { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
button.init.done { border-color: var(--green); background: var(--green-soft); }
img.sig { height: 44px; max-width: 220px; object-fit: contain; vertical-align: bottom; }
.sigline { display: inline-block; min-width: 160px; border-bottom: 1.5px solid #333; height: 22px; vertical-align: bottom; }
.sigline.pending { border: 0; color: var(--muted); font-style: italic; height: auto; min-width: 0; }
.dateline { display: inline-block; width: 90px; border-bottom: 1.5px solid #333; height: 20px; vertical-align: bottom; }
label.choice { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin: 0 0 10px; cursor: pointer; }
label.choice input { width: 24px; height: 24px; margin: 0; flex: none; }

/* Patient page */
body.patient { background: #eef1f6; }
.intro .practice { margin: 0 0 4px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.progress { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: #0d1b3d; color: #fff; z-index: 10; }
.progress.done { background: var(--green); }
.progress .btn { background: #fff; color: #0d1b3d; }

/* Visit page */
.step h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 0; }
.num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #0d1b3d; color: #fff; font-size: .9rem; }
.share .btns { margin: 8px 0; }
details.qrbox { margin: 0 0 8px; } details.qrbox summary { cursor: pointer; color: var(--blue); font-weight: 600; }
.qr svg { width: 100%; height: auto; display: block; }
ul.flags { margin: 0 0 14px; padding-left: 1.2rem; } ul.flags li { margin-bottom: 4px; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .8rem; background: #eef1f6; color: var(--muted); white-space: nowrap; }
.chip.wait { background: var(--amber-soft); color: var(--amber); } .chip.done { background: var(--green-soft); color: var(--green); }
textarea { display: block; width: 100%; margin-top: 5px; padding: 10px 12px; border: 1px solid #c8cdd8; border-radius: 8px; font: inherit; }
.doc ul { padding-left: 1.3rem; margin: 0 0 .8rem; } .doc li { margin-bottom: .35rem; }
table.answers { width: 100%; border-collapse: collapse; margin: 0 0 12px; font-size: .95rem; }
table.answers td { border-top: 1px solid var(--line); padding: 6px 8px 6px 0; vertical-align: top; }
table.answers td:first-child { width: 55%; color: var(--muted); }
table.answers tr.flag td { font-weight: 700; color: var(--ink); } table.answers tr.flag td:first-child { color: var(--amber); }

/* Medical history form */
.qgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 12px; }
.qgrid > * { grid-column: span 4; }
.qgrid > .half { grid-column: span 2; } .qgrid > .quarter { grid-column: span 1; }
@media (max-width: 560px) { .qgrid > .half, .qgrid > .quarter { grid-column: span 4; } }
.q { margin: 0 0 14px; }
.qlabel { font-weight: 600; margin-bottom: 6px; }
.opts { display: flex; gap: 8px; flex-wrap: wrap; }
label.opt { display: flex; gap: 8px; align-items: center; font-weight: 400; margin: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
label.opt input { width: 20px; height: 20px; margin: 0; }
.yesno { padding: 10px 0; border-bottom: 1px solid #f0f2f6; margin: 0; }
.yesno .detail { margin: 10px 0 0; font-weight: 400; }
.checklist .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; }
.checklist label.none { border-color: var(--blue); }
.emergency { background: var(--red-soft); color: var(--red); font-weight: 600; padding: 12px 16px; border-radius: 10px; margin: 0 0 14px; }

.foot { text-align: center; font-size: .85rem; color: var(--muted, #667); padding: 8px 16px 32px; }
.foot a { color: inherit; }
