:root {
  --bg: #f3eee4; --paper: #fffaf2; --ink: #2b241e; --muted: #6f675e; --line: #e4dccf;
  --accent: #c45d32; --accent-soft: #f6dfd2; --accent-ink: #fff8f1;
  --ok: #2f6f4e; --ok-soft: #dcefe3; --warn: #9a5b12; --warn-soft: #f8ead3; --danger: #9b2f2f;
  --radius: 16px; --shadow: 0 1px 2px rgba(43,36,30,.06), 0 4px 14px rgba(43,36,30,.06);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: env(safe-area-inset-bottom); }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--paper); border-bottom: 1px solid var(--line); }
.brand { white-space: nowrap; min-width: 0; display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; color: var(--ink); font-size: 17px; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 18px; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
main { max-width: 760px; margin: 0 auto; padding: 14px 14px 80px; }
.boot { color: var(--muted); text-align: center; margin-top: 30vh; }
h1 { font-size: 24px; margin: 6px 0 4px; line-height: 1.2; }
h2 { font-size: 18px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin: 12px 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.danger { color: var(--danger); }
.btn.on { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-size: 14px; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
input[type=text], input[type=password], select { width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 16px; }
input:focus, select:focus, .btn:focus-visible, .task:focus-within { outline: 3px solid var(--accent-soft); outline-offset: 1px; border-color: var(--accent); }
label.field { display: block; margin: 10px 0; font-weight: 600; font-size: 14px; }
label.field > input, label.field > select { margin-top: 4px; font-weight: 400; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.login { max-width: 380px; margin: 12vh auto 0; text-align: center; }
.login .logo { width: 56px; height: 56px; font-size: 32px; border-radius: 16px; }
.login form { text-align: left; }
.error { color: var(--danger); font-weight: 600; min-height: 1.4em; }
.note { background: var(--warn-soft); border: 1px solid #ecd3aa; color: #5d3a0b; border-radius: 12px; padding: 10px 12px; font-size: 15px; }
.practice-link { display: block; text-decoration: none; color: inherit; }
.practice-link .row { justify-content: space-between; }
.count { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.count.done { color: var(--ok); }
progress { -webkit-appearance: none; appearance: none; width: 100%; height: 10px; border: 0; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 8px; display: block; }
progress::-webkit-progress-bar { background: var(--line); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--ok); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--ok); border-radius: 99px; }
.archived-tag { font-size: 12px; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 1px 8px; margin-left: 6px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; position: sticky; top: 58px; z-index: 5; background: var(--bg); padding: 6px 0; }
.toolbar .btn { flex: 1 1 0; padding: 0 10px; }
.person-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.role { display: inline-block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.role.Clinicians { background: #dfe8f3; color: #2c5480; }
.role.Nurses { background: #e9e0f1; color: #5b3a7a; }
.tasks { list-style: none; margin: 10px -6px 0; padding: 0; }
.task { display: flex; gap: 12px; align-items: flex-start; padding: 10px 8px; border-radius: 12px; cursor: pointer; min-height: 56px; -webkit-tap-highlight-color: transparent; }
.task + .task { border-top: 1px solid var(--line); }
.task input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.box { flex: none; width: 30px; height: 30px; border-radius: 9px; border: 2px solid #b9ad9c; background: #fff; display: grid; place-items: center; margin-top: 1px; transition: background .12s, border-color .12s; }
.box::after { content: ""; width: 14px; height: 8px; border-left: 3px solid #fff; border-bottom: 3px solid #fff; transform: rotate(-45deg) translate(1px, -2px); opacity: 0; }
.task.ticked .box { background: var(--ok); border-color: var(--ok); }
.task.ticked .box::after { opacity: 1; }
.task.ticked .text { color: var(--muted); }
.task.pending .box { opacity: .6; }
.task.outstanding-hl { background: var(--warn-soft); }
.text { display: block; }
.meta { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.meta.ok { color: var(--ok); }
.person-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 24px 10px; }
details.add > summary { list-style: none; cursor: pointer; }
details.add > summary::-webkit-details-marker { display: none; }
.catchup { border-left: 4px solid var(--warn); }
.catchup ul { margin: 6px 0 0; padding-left: 20px; }
.all-done { color: var(--ok); font-weight: 700; }
dialog { border: 0; border-radius: 18px; padding: 0; width: min(92vw, 420px); box-shadow: 0 20px 60px rgba(0,0,0,.25); background: var(--paper); color: var(--ink); }
dialog::backdrop { background: rgba(43,36,30,.4); }
dialog form { padding: 18px; }
dialog h2 { margin-bottom: 6px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.toast { visibility: hidden; opacity: 0; position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(150%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 12px; font-size: 14px; transition: transform .2s; max-width: 90vw; z-index: 50; }
.toast.show { visibility: visible; opacity: 1; transform: translateX(-50%) translateY(0); }
.sync { font-size: 12px; color: var(--muted); text-align: right; margin-top: 6px; }

/* Print sheets */
.sheet { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 22px; margin: 14px 0; color: #000; }
.sheet h2 { font-size: 20px; margin-bottom: 4px; }
.sheet .sheet-practice { font-size: 13px; color: #555; }
.sheet .sheet-note { font-size: 13px; margin: 6px 0 12px; }
.sheet .lines { display: flex; gap: 24px; flex-wrap: wrap; margin: 10px 0 14px; font-size: 15px; }
.sheet .lines span b { display: inline-block; min-width: 150px; border-bottom: 1px solid #000; font-weight: 400; padding: 0 4px; }
.sheet ol { list-style: none; padding: 0; margin: 0; }
.sheet li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid #ddd; font-size: 15px; break-inside: avoid; }
.sheet .pbox { flex: none; width: 18px; height: 18px; border: 1.5px solid #000; border-radius: 3px; text-align: center; line-height: 16px; font-size: 14px; font-weight: 700; }
.sheet .who { display: block; font-size: 11px; color: #555; }
.sheet .signoff { display: flex; gap: 24px; margin-top: 18px; font-size: 14px; }
.sheet .signoff span b { display: inline-block; min-width: 140px; border-bottom: 1px solid #000; }

@media (min-width: 640px) {
  main { padding-top: 22px; }
  .toolbar .btn { flex: 0 0 auto; }
}
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  .noprint, .topbar, .toolbar, .print-intro, .person-actions, details.add, .sync, .catchup { display: none !important; }
  main { max-width: none; padding: 0; }
  .sheet { border: 0; border-radius: 0; padding: 0; margin: 0; page-break-after: always; break-after: page; }
  .sheet:last-child { page-break-after: auto; break-after: auto; }
}
.btn.full { width: 100%; }
@media (max-width: 420px) { .brand .long { display: none; } }
.head-right { display: flex; align-items: center; gap: 6px; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-size: 20px; color: var(--accent); }
.icon-btn:active { transform: translateY(1px); }
.role-warn { margin: 4px 0 8px; font-size: 14px; }
