/* Abundance Healthcare — Policies & Procedures */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #1d2a2a;
  --muted: #5d6b6a;
  --line: #e2ded5;
  --brand: #1f5f5b;
  --brand-ink: #ffffff;
  --brand-soft: #e3efed;
  --accent: #e3a857;
  --ok: #2f7d4f;      --ok-bg: #e2f2e7;
  --warn: #8a5a00;    --warn-bg: #fdf0d5;
  --bad: #a3322b;     --bad-bg: #fbe3e0;
  --info: #2b5c8a;    --info-bg: #e3edf8;
  --idle: #6b7472;    --idle-bg: #eceae5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 40, 40, .06), 0 2px 8px rgba(20, 40, 40, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141a1a; --surface: #1c2424; --ink: #e7ecea; --muted: #9aa8a5; --line: #2e3a39;
    --brand: #5bb3a9; --brand-ink: #0d1a19; --brand-soft: #1f3331; --accent: #e3a857;
    --ok: #7fd09c; --ok-bg: #1d3326; --warn: #f0c46c; --warn-bg: #3a2f17;
    --bad: #f19a90; --bad-bg: #3d2120; --info: #8ebdf0; --info-bg: #1c2c3d;
    --idle: #a5adab; --idle-bg: #262d2c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.75rem; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
img { max-width: 100%; height: auto; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand span { display: flex; flex-direction: column; line-height: 1.15; }
.brand small { color: var(--muted); font-size: .78rem; }
.topsearch { flex: 1; max-width: 420px; }
.topsearch input { width: 100%; }
.mainnav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.mainnav > a { padding: 8px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 500; }
.mainnav > a:hover { background: var(--brand-soft); }
.mainnav > a.on { background: var(--brand-soft); color: var(--brand); }
.who { display: flex; align-items: center; gap: 8px; margin-left: 8px; }
.who form { margin: 0; }
.menu-toggle { display: none; }
.avatar {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand); color: var(--brand-ink); font-size: .8rem; font-weight: 600; text-decoration: none;
}
.avatar.big { width: 56px; height: 56px; font-size: 1.2rem; }
.subnav { display: flex; gap: 4px; padding: 6px 24px; background: var(--brand-soft); border-bottom: 1px solid var(--line); overflow-x: auto; }
.subnav a { padding: 6px 12px; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: .92rem; white-space: nowrap; }
.subnav a.on { background: var(--surface); color: var(--brand); font-weight: 600; }

main.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 24px 48px; }
main.wrap.wide { max-width: 1320px; }
.narrow { max-width: 560px; margin: 0 auto; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px; }

/* ---------- Building blocks ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; align-items: start; }
.cols-wide { grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: .875rem; color: var(--muted); margin: 0 0 8px; }
.crumbs a { color: var(--muted); }
.lead { font-size: 1.08rem; color: var(--muted); }
.empty { text-align: center; padding: 40px 20px; }
.dim td { opacity: .55; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.plain li:last-child { border-bottom: 0; }
.plain li.on { font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; line-height: 1.2;
}
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn.wide { width: 100%; justify-content: center; }
.linkish { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.linkish.danger { color: var(--bad); }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; max-width: 100%;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 1px; }
.form label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; font-weight: 500; }
.form label input, .form label select, .form label textarea { font-weight: 400; width: 100%; }
.form fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 0 0 14px; }
.form legend { font-weight: 600; padding: 0 4px; }
label.check { flex-direction: row !important; align-items: flex-start; gap: 8px !important; font-weight: 400 !important; }
label.check input { width: auto !important; margin-top: 4px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 2px 12px; }
.checks label.check { margin-bottom: 4px; }
.row2, .row3 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.row3 { grid-template-columns: 1fr 1fr 1fr; }
.row2 .grow { grid-column: span 1; }
.w-emoji input { max-width: 100px; }
details > summary { cursor: pointer; margin: 6px 0; }
.inline-h { display: inline; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid transparent; }
.flash-ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash-error { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.flash-info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }

/* ---------- Status ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.st-complete { background: var(--ok-bg); color: var(--ok); }
.st-expiring { background: var(--warn-bg); color: var(--warn); }
.st-expired, .st-overdue { background: var(--bad-bg); color: var(--bad); }
.st-resign { background: var(--warn-bg); color: var(--warn); }
.st-in_progress { background: var(--info-bg); color: var(--info); }
.st-not_started, .st-draft { background: var(--idle-bg); color: var(--idle); }
.bar { display: inline-block; width: 90px; height: 6px; border-radius: 3px; background: var(--idle-bg); overflow: hidden; vertical-align: middle; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.bar.big { width: 100%; height: 8px; margin: 8px 0 14px; }
.ok-mark { color: var(--ok); font-weight: 700; }

/* ---------- Home ---------- */
.hello { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 24px; }
.ring {
  --p: 0; width: 104px; height: 104px; border-radius: 50%; flex-shrink: 0;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--idle-bg) 0);
  display: grid; place-content: center; text-align: center; position: relative;
}
.ring::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--bg); }
.ring span, .ring small { position: relative; }
.ring span { font-size: 1.35rem; font-weight: 700; }
.ring small { color: var(--muted); font-size: .72rem; }
.tasklist { list-style: none; padding: 0; margin: 0 0 28px; display: grid; gap: 8px; }
.task { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; border-left: 4px solid var(--line); }
.task.st-row-overdue, .task.st-row-expired { border-left-color: var(--bad); }
.task.st-row-resign, .task.st-row-expiring { border-left-color: var(--accent); }
.task.st-row-in_progress { border-left-color: var(--info); }
.task.st-row-complete { border-left-color: var(--ok); }
.task-main { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; min-width: 0; }
.task-main strong { display: block; }
.task-main:hover strong { color: var(--brand); }
.task-side { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.emoji { font-size: 1.5rem; line-height: 1; width: 1.6em; text-align: center; flex-shrink: 0; }
.resp { margin: 6px 0 12px; padding-left: 20px; font-size: .92rem; }
.resp li { margin-bottom: 4px; }

/* ---------- Library ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 28px; }
.tile { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.tile:hover { border-color: var(--brand); transform: translateY(-1px); }
.tile .emoji { text-align: left; }
.tile-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 6px; }
.tile.is-draft { border-style: dashed; }

/* ---------- Reader ---------- */
.reader { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 32px; align-items: start; }
.reader-side { position: sticky; top: 76px; }
.outline { max-height: calc(100vh - 100px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; font-size: .9rem; }
.outline-title { display: block; font-weight: 700; color: var(--ink); text-decoration: none; padding: 4px 6px 10px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.outline-doc { margin-bottom: 10px; }
.outline-doc-title { font-weight: 600; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding: 4px 6px; }
.outline a:not(.outline-title) { display: flex; gap: 8px; align-items: flex-start; padding: 5px 6px; border-radius: 6px; color: var(--ink); text-decoration: none; }
.outline a:not(.outline-title):hover { background: var(--brand-soft); }
.outline a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.tick { flex-shrink: 0; width: 14px; height: 14px; margin-top: 3px; border-radius: 50%; border: 2px solid var(--line); }
.tick.yes { background: var(--ok); border-color: var(--ok); box-shadow: inset 0 0 0 2px var(--surface); }
.reader-main { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px 40px; box-shadow: var(--shadow); min-width: 0; }
.meta { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 20px; }
.status-card { display: grid; gap: 4px; background: var(--bg); box-shadow: none; }
.status-card p { margin: 6px 0 0; }
.status-card .btn { justify-self: start; }
.contents { padding-left: 20px; }
.contents > li { margin-bottom: 12px; }
.contents ul { padding-left: 18px; margin: 4px 0; }
.contents ul li { margin: 3px 0; }
.sign { border: 2px solid var(--brand); margin-top: 28px; }
.sign input[type=text] { font-size: 1.1rem; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--line); }
.pager form { margin: 0; }

/* Page content */
.prose { font-size: 1.02rem; line-height: 1.65; overflow-wrap: anywhere; }
.prose h2 { font-size: 1.35rem; margin-top: 1.6em; }
.prose h3 { font-size: 1.15rem; margin-top: 1.4em; }
.prose h4 { font-size: 1rem; margin-top: 1.2em; }
.prose p { margin: 0 0 1em; }
.prose ul, .prose ol { padding-left: 1.5em; margin: 0 0 1em; }
.prose li { margin: .25em 0; }
.prose li > p { margin: 0; }
.prose blockquote { margin: 1em 0; padding: 10px 16px; border-left: 4px solid var(--accent); background: var(--bg); border-radius: 0 8px 8px 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.prose figure { margin: 1.2em 0; text-align: center; }
.prose figure.align-left { text-align: left; }
.prose figure.align-right { text-align: right; }
.prose figure img { border-radius: 6px; border: 1px solid var(--line); }
.prose table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: .95rem; display: block; overflow-x: auto; }
.prose td, .prose th { border: 1px solid var(--line); padding: 8px 10px; vertical-align: top; text-align: left; }
.prose td > p:last-child, .prose th > p:last-child { margin-bottom: 0; }
.prose tr:first-child td { background: var(--bg); font-weight: 600; }
.prose ul.tasks { list-style: none; padding-left: .5em; }
.prose ul.tasks li::before { content: "☐ "; color: var(--muted); }
.prose ul.tasks li.done::before { content: "☑ "; color: var(--ok); }
.prose ul.tasks li > p { display: inline; }
.prose .video { position: relative; aspect-ratio: 16 / 9; margin: 1.2em 0; }
.prose .video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 8px; }
.prose .attachment a { display: inline-block; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); text-decoration: none; margin: 4px 0; }
.prose mark, .results mark { padding: 0 2px; border-radius: 3px; }

/* ---------- Quiz ---------- */
.quiz fieldset { border: 1px solid var(--line); }
.quiz fieldset.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
.quiz legend { font-weight: 700; padding: 0 6px; }
.option { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.option:hover { background: var(--brand-soft); }
.option input { margin-top: 5px; }
.option p { margin: 0; }

/* ---------- Search ---------- */
.searchbig { display: flex; gap: 8px; margin-bottom: 16px; }
.searchbig input { flex: 1; font-size: 1.05rem; padding: 10px 14px; }
.results { padding-left: 20px; }
.results li { margin-bottom: 18px; }
.results p { margin: 4px 0 0; }

/* ---------- Dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-n { display: block; font-size: 2rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-l { color: var(--muted); font-size: .88rem; }
.stat-bad .stat-n { color: var(--bad); }
.stat-warn .stat-n { color: var(--warn); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; align-items: center; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.matrix-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 24px; }
.matrix { border-collapse: separate; border-spacing: 0; font-size: .88rem; }
.matrix th, .matrix td { border-bottom: 1px solid var(--line); padding: 6px; text-align: center; }
.matrix tbody th { text-align: left; white-space: nowrap; position: sticky; left: 0; background: var(--surface); z-index: 1; padding: 8px 14px; border-right: 1px solid var(--line); }
.matrix tbody th small { display: block; font-weight: 400; }
.matrix thead th.corner { position: sticky; left: 0; background: var(--surface); z-index: 2; text-align: left; vertical-align: bottom; padding: 8px 14px; border-right: 1px solid var(--line); }
.matrix th.rot { height: 170px; vertical-align: bottom; padding: 0 0 8px; width: 38px; min-width: 38px; }
.matrix th.rot > div { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; max-height: 160px; overflow: hidden; text-overflow: ellipsis; font-weight: 500; margin: 0 auto; }
.matrix th.rot a { color: var(--ink); text-decoration: none; }
.matrix tbody tr:hover td, .matrix tbody tr:hover th { background: var(--brand-soft); }
.matrix td.num { font-variant-numeric: tabular-nums; padding: 6px 14px; color: var(--muted); }
.cell { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; font-weight: 700; font-size: .85rem; cursor: default; }

table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 2px solid var(--line); }
table.list td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list.card { padding: 0; overflow: hidden; display: table; }
table.list.card th:first-child, table.list.card td:first-child { padding-left: 18px; }
td.num { font-variant-numeric: tabular-nums; }

.person-head { display: flex; align-items: center; gap: 16px; }
.person-head h1 { margin: 0; }
.person-head p { margin: 2px 0 0; }

/* ---------- Admin ---------- */
.doc-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.doc-title { flex: 1; min-width: 220px; font-weight: 600; }
.pages { margin: 0 0 12px; padding-left: 26px; }
.pages li { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.pages form { gap: 10px; }
.title-input { font-size: 1.5rem; font-weight: 700; flex: 1; min-width: 260px; border-color: transparent; background: transparent; padding-left: 0; }
.title-input:hover, .title-input:focus { border-color: var(--line); background: var(--surface); padding-left: 10px; }
.editor-form textarea#editor { width: 100%; min-height: 500px; font-family: ui-monospace, Menlo, monospace; }
.callout-key { border: 2px solid var(--accent); }
.temp-pw code { font-size: 1.5rem; padding: 8px 14px; background: var(--bg); border-radius: 8px; display: inline-block; letter-spacing: .02em; }

/* ---------- Sign in ---------- */
body.bare { display: grid; min-height: 100vh; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 400px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 32px; box-shadow: var(--shadow); text-align: center; }
.login-card h1 { margin: 12px 0 4px; font-size: 1.5rem; }
.login-card form { text-align: left; margin-top: 20px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; font-weight: 500; }
.login-card input { width: 100%; }

/* ---------- Certificate ---------- */
.cert { max-width: 720px; background: var(--surface); border: 1px solid var(--line); outline: 6px double var(--brand); outline-offset: -18px; padding: 56px 48px; text-align: center; border-radius: 6px; }
.cert-org { text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-size: .85rem; }
.cert h1 { font-size: 2rem; margin: 6px 0 24px; color: var(--brand); }
.cert-name { font-size: 1.7rem; font-weight: 700; margin: 4px 0; }
.cert-subject { font-size: 1.25rem; font-weight: 600; margin: 4px 0; }
.cert-meta { display: grid; grid-template-columns: auto auto; justify-content: center; gap: 4px 14px; text-align: left; font-size: .88rem; margin: 28px 0; }
.cert-meta dt { color: var(--muted); }
.cert-meta dd { margin: 0; }

/* ---------- Small screens ---------- */
@media (max-width: 900px) {
  .reader { grid-template-columns: 1fr; }
  .reader-side { position: static; order: 2; }
  .outline { max-height: none; }
  .reader-main { padding: 22px 18px; }
  .cols-wide { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  .topsearch { order: 3; flex-basis: 100%; max-width: none; }
  .menu-toggle { display: inline-flex; margin-left: auto; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; }
  .mainnav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; order: 4; }
  .mainnav.open { display: flex; }
  .who { margin: 8px 0 0; justify-content: space-between; }
  main.wrap { padding: 20px 16px 40px; }
  .hello { flex-direction: column; align-items: flex-start; }
  .task { flex-direction: column; align-items: flex-start; }
  .row2, .row3 { grid-template-columns: 1fr; }
  table.list.card { display: block; overflow-x: auto; }
  .cert { padding: 40px 22px; }
  h1 { font-size: 1.45rem; }
}

@media print {
  .topbar, .subnav, .foot, .noprint, .reader-side, .pager { display: none !important; }
  body, body.bare { background: #fff; display: block; }
  .cert { margin: 0 auto; box-shadow: none; }
  .reader { display: block; }
  .reader-main { border: 0; box-shadow: none; padding: 0; }
}
