:root {
  --bg: #f7f5f2;
  --card: #ffffff;
  --ink: #1f2328;
  --muted: #5e6670;
  --line: #e3ded7;
  --accent: #d9661f;
  --accent-ink: #ffffff;
  --accent-soft: #fbe9dc;
  --ok: #2f7d4f;
  --warn: #a86400;
  --warn-soft: #fff1d6;
  --bad: #b3261e;
  --bad-soft: #fde3e1;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.25rem; margin: 0 0 .5rem; }
h3 { font-size: 1.05rem; margin: 0; }
[hidden] { display: none !important; }

.loading, .empty { color: var(--muted); padding: 2rem 1rem; text-align: center; }
.error { background: var(--bad-soft); color: var(--bad); padding: .75rem 1rem; border-radius: var(--radius); margin: 1rem 0; }
.notice { background: var(--warn-soft); color: var(--warn); padding: .75rem 1rem; border-radius: var(--radius); margin: 0 0 1rem; }
.muted { color: var(--muted); }
.meta { color: var(--muted); font-size: .85rem; margin: .5rem 0 0; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
  padding: .6rem 1rem; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--ink); text-decoration: none; margin-right: auto; }
.topbar nav { display: flex; gap: .25rem; order: 3; width: 100%; overflow-x: auto; }
.topbar nav a {
  text-decoration: none; color: var(--muted); padding: .35rem .7rem; border-radius: 999px; white-space: nowrap;
}
.topbar nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.who { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
@media (min-width: 760px) {
  .topbar nav { order: 0; width: auto; }
  .brand { margin-right: 1rem; }
  .who { margin-left: auto; }
}

main { max-width: 980px; margin: 0 auto; padding: 1rem; }

/* ---------- buttons & forms ---------- */
.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 44px; padding: .5rem 1rem; border-radius: 10px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn.small { min-height: 34px; padding: .25rem .7rem; font-size: .9rem; }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn:disabled { opacity: .55; cursor: default; }
button.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: .25rem; text-decoration: underline; }

label { display: block; font-weight: 600; font-size: .92rem; margin: .75rem 0 .25rem; }
label .hint { display: block; font-weight: 400; color: var(--muted); font-size: .85rem; }
input, select, textarea {
  width: 100%; font: inherit; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.row { display: grid; gap: 0 1rem; }
@media (min-width: 640px) { .row.two { grid-template-columns: 1fr 1fr; } .row.three { grid-template-columns: 1fr 1fr 1fr; } }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.search { margin-bottom: 1rem; }

/* ---------- badges ---------- */
.badge { display: inline-block; font-size: .78rem; font-weight: 600; padding: .1rem .55rem; border-radius: 999px; background: #eceae6; color: var(--muted); white-space: nowrap; }
.badge.role-manager { background: #e7e3fb; color: #4b3aa8; }
.badge.role-senior { background: #dff0f7; color: #1b5e7a; }
.badge.role-carer { background: #e3f2e8; color: var(--ok); }
.badge.overdue { background: var(--bad-soft); color: var(--bad); }
.badge.due { background: var(--warn-soft); color: var(--warn); }
.badge.archived { background: #eceae6; color: var(--muted); }
.badge.inactive { background: var(--bad-soft); color: var(--bad); }

/* ---------- avatars ---------- */
.avatar { flex: none; border-radius: 50%; object-fit: cover; background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.avatar.sm { width: 56px; height: 56px; font-size: 1.1rem; }
.avatar.lg { width: 112px; height: 112px; font-size: 2rem; border: 3px solid #fff; box-shadow: var(--shadow); }

/* ---------- residents grid ---------- */
.grid { display: grid; gap: .75rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 920px) { .grid { grid-template-columns: 1fr 1fr 1fr; } }
.res-card { display: flex; align-items: center; gap: .85rem; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; box-shadow: var(--shadow); }
.res-card:hover { border-color: var(--accent); }
.res-card .name { font-weight: 700; }
.res-card .sub { color: var(--muted); font-size: .88rem; }

/* ---------- resident header ---------- */
.res-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }
.res-head .info { flex: 1; min-width: 200px; }
.res-head .facts { display: flex; flex-wrap: wrap; gap: .25rem 1rem; color: var(--muted); font-size: .92rem; margin-top: .25rem; }
.res-head .facts b { color: var(--ink); font-weight: 600; }
.res-head .actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin: 1rem 0; }
.tabs a { padding: .6rem 1rem; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 600; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- care plan ---------- */
.sec-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.sec-head h3 { margin-right: auto; }
.field { margin: .6rem 0 0; }
.field .lbl { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; }
.field .val { white-space: pre-wrap; }
.editor { border-top: 1px dashed var(--line); margin-top: .75rem; padding-top: .25rem; }

/* ---------- notes ---------- */
.note { border-left: 4px solid var(--accent); }
.note.correction { border-left-color: var(--warn); }
.note .top { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; }
.note .text { white-space: pre-wrap; margin: .5rem 0; }
.correction-banner { background: var(--warn-soft); color: var(--warn); padding: .5rem .75rem; border-radius: 8px; margin: .5rem 0; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }

/* ---------- photo picker ---------- */
.photo-pick { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: .5rem; }
.photo-pick input[type=file] { width: auto; border: 0; padding: 0; }

/* ---------- tables (staff, audit) ---------- */
.list { width: 100%; border-collapse: collapse; }
.list th, .list td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.list th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.list td select { min-width: 130px; }
.list .when { white-space: nowrap; color: var(--muted); font-size: .88rem; }
.table-wrap { overflow-x: auto; }
@media (max-width: 640px) {
  .list.stack thead { display: none; }
  .list.stack tr { display: block; border-bottom: 1px solid var(--line); padding: .5rem 0; }
  .list.stack td { display: block; border: 0; padding: .2rem .25rem; }
}
details summary { cursor: pointer; color: var(--accent); font-size: .88rem; }
details pre { white-space: pre-wrap; font: .85rem/1.4 ui-monospace, monospace; background: var(--bg); padding: .5rem; border-radius: 8px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login { width: 100%; max-width: 380px; }
.login h1 { margin-bottom: .1rem; }
.login .btn { width: 100%; margin-top: 1rem; }
.login .foot { text-align: center; margin-top: .75rem; }

.toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 10px; z-index: 50; max-width: calc(100% - 2rem); }

/* ================= v2: forms, designer, alerts ================= */
.mt { margin-top: 1.25rem; }
.back { display: inline-block; margin-bottom: .75rem; text-decoration: none; font-weight: 600; }
.badge.ok { background: #e3f2e8; color: var(--ok); }
.count { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 999px; background: var(--bad); color: #fff; font-size: .75rem; font-weight: 700; text-align: center; line-height: 1.4em; }
h3 .count { background: #eceae6; color: var(--muted); }

/* alert badges on residents */
.flags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }
.flag { display: inline-flex; align-items: center; gap: .25rem; font-size: .78rem; font-weight: 700; padding: .12rem .55rem; border-radius: 6px; }
.flag.red { background: var(--bad-soft); color: var(--bad); border: 1px solid #f3b8b3; }
.flag.amber { background: var(--warn-soft); color: var(--warn); border: 1px solid #f1d39b; }
.flag-add { display: grid; grid-template-columns: 1fr auto auto; gap: .5rem; margin-top: .5rem; }
.flag-add select { width: auto; }
.tx-inline { background: none; border: 0; color: inherit; cursor: pointer; font-size: .8rem; padding: 0 0 0 .2rem; }
.res-info { min-width: 0; }

/* section tiles */
.sec-grid { display: grid; gap: .75rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .sec-grid { grid-template-columns: 1fr 1fr; } }
.sec-tile { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.sec-tile:hover, .sec-tile:focus { border-color: var(--accent); }
.sec-tile .t-title { font-weight: 700; font-size: 1.05rem; }
.sec-tile .t-badges { display: flex; flex-wrap: wrap; gap: .3rem; margin: .4rem 0; }

/* answers */
.chip { display: inline-block; background: #eceae6; border-radius: 999px; padding: .1rem .6rem; font-size: .88rem; margin: .1rem 0; }
.chip.alert { background: var(--bad-soft); color: var(--bad); font-weight: 700; }
.gq { font-weight: 600; font-size: .9rem; margin-top: .4rem; }
.ga { margin-bottom: .2rem; }
.form-heading { margin: 1.25rem 0 .25rem; padding-bottom: .25rem; border-bottom: 2px solid var(--accent-soft); font-size: 1.05rem; }
.info-block { background: var(--bg); border-left: 4px solid var(--line); border-radius: 8px; padding: .6rem .8rem; margin: .75rem 0; }
.info-img { max-width: 100%; max-height: 360px; display: block; margin-top: .5rem; border-radius: 8px; cursor: zoom-in; }
.thumbs { display: flex; flex-wrap: wrap; gap: .5rem; margin: .35rem 0; }
.thumb { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); cursor: zoom-in; }
.tw { position: relative; display: inline-block; }
.tx { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; cursor: pointer; font-size: .75rem; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
details.version { border-top: 1px solid var(--line); padding: .6rem 0; }
details.version summary { color: var(--ink); font-size: .95rem; }
details.version .vbody { padding: .25rem 0 .5rem .75rem; border-left: 3px solid var(--accent-soft); margin-top: .5rem; }

/* form inputs */
.ffield { margin-bottom: .25rem; }
.ffield.invalid textarea, .ffield.invalid input, .ffield.invalid select, .ffield.invalid .choices { outline: 2px solid var(--bad); outline-offset: 2px; border-radius: 10px; }
.qlabel { display: block; font-weight: 600; font-size: .95rem; margin: 1rem 0 .3rem; }
.req { color: var(--bad); }
.choices { display: flex; flex-wrap: wrap; gap: .4rem; }
.choices.col { flex-direction: column; gap: .2rem; }
label.opt { display: inline-flex; align-items: center; gap: .45rem; font-weight: 400; margin: 0; padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-size: .95rem; }
.choices.col label.opt { border: 0; padding: .3rem 0; background: none; }
label.opt input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--accent); }
.gprompt { margin: .5rem 0; padding-left: .75rem; border-left: 3px solid var(--accent-soft); }
.gprompt .gq { margin: 0 0 .25rem; }
.unit-wrap { display: flex; align-items: center; gap: .5rem; }
.unit-wrap input { max-width: 200px; }
.file-btn { position: relative; }
.quick { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .25rem; }

/* alerts page & log */
.alert-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .6rem 0; border-top: 1px solid var(--line); }
.alert-row:first-of-type { border-top: 0; }
.alert-row.done { opacity: .75; }
.note.alerting { border-left-color: var(--bad); }
.ack { background: #e3f2e8; color: var(--ok); border-radius: 8px; padding: .4rem .7rem; font-size: .9rem; margin: .5rem 0; }

/* designer */
.sticky-head { position: sticky; top: 56px; z-index: 5; background: var(--bg); padding: .5rem 0; }
.d-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; padding: .4rem 0; }
.d-row > input { flex: 1 1 200px; font-weight: 600; }
.d-row.sel > input { border-color: var(--accent); }
.hidden-item { opacity: .6; }
button.icon { min-width: 36px; min-height: 36px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font: inherit; }
button.icon:disabled { opacity: .35; cursor: default; }
button.icon.danger { color: var(--bad); }
.d-fields { display: flex; flex-direction: column; gap: .6rem; margin-top: .5rem; }
.d-field { border: 1px solid var(--line); border-radius: 10px; padding: .7rem; background: #fcfbfa; display: flex; flex-direction: column; gap: .45rem; }
.d-field-head { display: flex; gap: .4rem; align-items: center; }
.d-field-head select { flex: 1; font-weight: 600; }
.d-num { width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .8rem; display: inline-flex; align-items: center; justify-content: center; }
.d-field label.opt { align-self: flex-start; }
.d-alerts { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.d-alerts .hint { width: 100%; color: var(--muted); font-size: .85rem; }
.d-info-img { display: flex; flex-direction: column; align-items: flex-start; gap: .4rem; }
.d-add { display: flex; gap: .5rem; margin-top: .6rem; }
.d-add select { flex: 1; }
.hint { color: var(--muted); font-weight: 400; font-size: .85rem; }

/* security page */
.mt-s { margin-top: .75rem; }
.steps { margin: .5rem 0 0 1.1rem; padding: 0; }
.steps li { margin: .35rem 0; }
.checks { list-style: none; margin: .75rem 0 0; padding: 0; }
.checks li { display: flex; gap: .6rem; align-items: flex-start; padding: .5rem 0; border-top: 1px solid var(--line); }
.checks .ci { flex: none; width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; color: #fff; }
.checks .pass .ci { background: var(--ok); }
.checks .warn .ci { background: var(--warn); }
.checks .fail .ci { background: var(--bad); }
.dev-name { max-width: 240px; }

/* ================= v3: sites, Today, handover, diary, dashboard, reports ================= */
.site-pick { width: auto; min-height: 36px; padding: .25rem .5rem; font-weight: 600; }
.badge.site { background: var(--accent-soft); color: var(--accent); }
label.opt.sm { padding: .25rem .5rem; font-size: .85rem; }
label.opt.sm input { width: 16px; height: 16px; }

/* Today */
.todo-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .6rem .75rem; margin: .4rem 0; border-radius: 10px; text-decoration: none; color: inherit; border: 1px solid var(--line); border-left-width: 5px; }
.todo-row.late { border-left-color: var(--bad); background: #fff8f7; }
.todo-row.soon { border-left-color: var(--warn); background: #fffaf0; }
.todo-row:hover { border-color: var(--accent); }
.todo-right { font-weight: 700; white-space: nowrap; font-size: .9rem; }
.todo-row.late .todo-right { color: var(--bad); }
.todo-row.soon .todo-right { color: var(--warn); }
.pinned-card { border: 2px solid #f3b8b3; background: #fff8f7; }
.pin-item { padding: .5rem 0; border-top: 1px solid #f3d2cf; }
.pin-item:first-of-type { border-top: 0; }
.ev-row { display: flex; gap: .75rem; align-items: flex-start; padding: .55rem 0; border-top: 1px solid var(--line); }
.ev-row:first-of-type { border-top: 0; }
.ev-time { min-width: 72px; font-weight: 700; color: var(--accent); }
.ev-row.activity .ev-time { color: #1b5e7a; }
.ev-row.cancelled { opacity: .55; }
.ev-row.cancelled b { text-decoration: line-through; }
.ev-body { flex: 1; min-width: 0; }
.ev-actions { display: flex; gap: .3rem; flex-wrap: wrap; }
.res-events { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; }
.ev-chip { font-size: .8rem; padding: .12rem .55rem; border-radius: 6px; background: #e7f1f7; color: #1b5e7a; }
.ev-chip.appointment { background: var(--accent-soft); color: var(--accent); }
.res-picks { max-height: 220px; overflow-y: auto; padding: .25rem; border: 1px solid var(--line); border-radius: 10px; }

/* fluids & weight */
.fl-top { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.bar { position: relative; height: 12px; background: #eceae6; border-radius: 999px; margin: .6rem 0 .35rem; overflow: visible; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--ok); width: 0; }
.fluid-card.amber .bar > span, .todo-row.soon .bar > span { background: var(--warn); }
.fluid-card.red .bar > span, .todo-row.late .bar > span { background: var(--bad); }
.bar > i { position: absolute; top: -4px; width: 2px; height: 20px; background: var(--ink); }
.todo-row .bar { width: 100%; min-width: 180px; }
.quick-add { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; align-items: center; }
.quick-add select { width: auto; }
.spark { width: 100%; max-width: 360px; height: 80px; color: var(--accent); margin-top: .5rem; }
.spark circle { fill: var(--accent); }
.spark text { font-size: 10px; fill: var(--muted); }

/* handover */
.handover.pinned { border: 2px solid #f3b8b3; }
.handover.resolved { opacity: .7; }
.handover .text { white-space: pre-wrap; margin: .5rem 0; font-size: 1.02rem; }
.h-actions { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }

/* dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.7rem; }
.stat span { color: var(--muted); font-size: .88rem; }
.stat.alert b { color: var(--bad); }
.kv { display: flex; justify-content: space-between; padding: .3rem 0; border-top: 1px solid var(--line); }
.kv:first-of-type { border-top: 0; }
details.feed { border-top: 1px solid var(--line); padding: .55rem 0; }
details.feed summary { cursor: pointer; color: var(--ink); list-style: none; }
details.feed summary::-webkit-details-marker { display: none; }
details.feed.alerting { border-left: 4px solid var(--bad); padding-left: .5rem; }
.feed-time { color: var(--muted); font-size: .85rem; margin-right: .35rem; }
details.feed .vbody { margin-top: .5rem; padding-left: .75rem; border-left: 3px solid var(--accent-soft); }

/* reports */
table.report td { font-size: .88rem; }
table.report tr.flagged td { background: var(--bad-soft); }
.d-core { flex: 1; font-weight: 600; }

/* ================= sign-in page and banner ================= */
.leaf { width: 26px; height: 26px; color: var(--accent); flex: none; }
.brand { display: inline-flex; align-items: center; gap: .45rem; line-height: 1.2; }
.brand .leaf { width: 22px; height: 22px; }
@media (max-width: 520px) { .brand span { font-size: .9rem; } }

.login-split { min-height: 100vh; display: grid; grid-template-columns: 1fr; background: var(--card); }
@media (min-width: 900px) { .login-split { grid-template-columns: 1.1fr 1fr; } }
.login-art { position: relative; overflow: hidden; min-height: 200px; max-height: 260px; background: #fbeadc; }
@media (min-width: 900px) { .login-art { min-height: 100vh; max-height: none; } }
.login-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.login-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 55%, rgba(40,20,5,.45) 100%); }
.art-caption { position: absolute; left: 1.5rem; bottom: 1.25rem; z-index: 1; color: #fff; font-size: 1.15rem; line-height: 1.35; text-shadow: 0 1px 3px rgba(0,0,0,.35); }
@media (min-width: 900px) { .art-caption { left: 2.5rem; bottom: 2.5rem; font-size: 1.6rem; } }

.login-panel { display: flex; flex-direction: column; justify-content: center; padding: 1.5rem 1.25rem; max-width: 480px; width: 100%; margin: 0 auto; }
@media (min-width: 900px) { .login-panel { padding: 3rem; } }
.login-brand { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.75rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.login-brand .leaf { width: 44px; height: 44px; }
.login-brand .org { font-weight: 800; font-size: 1.15rem; line-height: 1.25; color: var(--ink); }
.login-brand .org-sub { color: var(--muted); font-size: .9rem; }
.login-form h1 { font-size: 1.6rem; margin-bottom: .25rem; }
.login-form .btn { width: 100%; margin-top: 1.1rem; min-height: 48px; font-size: 1.02rem; }
.login-form .foot { text-align: center; margin-top: .75rem; }
.login-notice { margin-top: 1.75rem; padding: .85rem 1rem; border-left: 4px solid var(--accent); background: var(--bg); border-radius: 8px; font-size: .83rem; color: var(--muted); line-height: 1.45; }
.login-notice b { color: var(--ink); }
.login-foot { margin-top: 1.25rem; font-size: .78rem; color: var(--muted); text-align: center; }
@media (max-width: 899px) { .login-art img { object-position: 60% 62%; } }
.login-art img.photo { object-position: center; }

/* ================= official app design ================= */
:root { --brand-dark: #2e2621; --brand-dark-2: #3d332c; --brand-muted: #d8c8ba; --radius: 10px; }
body { background: #f4f2ef; }
.appbar { background: var(--brand-dark); color: #fff; }
.appbar-top { max-width: 1180px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1.25rem; padding: .75rem 1rem; }
.appbar .brand { color: #fff; text-decoration: none; display: inline-flex; align-items: center; gap: .6rem; margin: 0; }
.appbar .brand .leaf { width: 30px; height: 30px; color: #f08a3c; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text b { font-size: 1.02rem; letter-spacing: .01em; }
.brand-text small { color: var(--brand-muted); font-size: .76rem; letter-spacing: .02em; }
.appbar .who { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; font-size: .9rem; margin: 0; }
.site-label { display: inline-flex; align-items: center; gap: .4rem; margin: 0; font-weight: 600; color: var(--brand-muted); font-size: .82rem; }
.appbar .site-pick { background: var(--brand-dark-2); color: #fff; border: 1px solid #5a4c42; min-height: 34px; padding: .2rem .5rem; border-radius: 8px; }
.site-chip { background: var(--brand-dark-2); border: 1px solid #5a4c42; padding: .25rem .65rem; border-radius: 8px; font-weight: 600; }
.user { display: inline-flex; flex-direction: column; line-height: 1.15; text-align: right; }
.user-name { font-weight: 600; }
.user-role { color: var(--brand-muted); font-size: .76rem; }
.signout { background: transparent; color: #fff; border: 1px solid #6b5b4f; border-radius: 8px; padding: .35rem .8rem; font: inherit; font-size: .85rem; cursor: pointer; }
.signout:hover { background: var(--brand-dark-2); }

.appnav { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 1px 3px rgba(0,0,0,.04);
  display: flex; gap: .1rem; overflow-x: auto; padding: 0 max(1rem, calc((100% - 1180px) / 2 + 1rem)); scrollbar-width: none; }
.appnav::-webkit-scrollbar { display: none; }
.appnav a { flex: none; padding: .85rem .8rem .75rem; color: #4a4f55; font-weight: 600; font-size: .93rem; text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; }
.appnav a:hover { color: var(--ink); }
.appnav a.on { color: var(--accent); border-bottom-color: var(--accent); }
.nav-sep { flex: none; width: 1px; margin: .7rem .4rem; background: var(--line); }
.appnav .count { margin-left: .15rem; }

main { max-width: 1180px; padding: 1.25rem 1rem 2rem; }
.page-head { padding-bottom: .8rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.page-head h1 { font-size: 1.5rem; font-weight: 750; letter-spacing: -.01em; display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.page-head h1::before { content: ""; width: 5px; height: 1.3em; border-radius: 3px; background: var(--accent); }
.sticky-head { top: 47px; background: #f4f2ef; }
.card { border-radius: var(--radius); border-color: #e6e0d8; }
.card > h3:first-child, .card > .sec-head:first-child h3 { font-size: 1.05rem; }
.btn, button.btn { border-radius: 8px; }
.tabs a { font-size: .95rem; }
.badge { border-radius: 6px; }

.appfoot { max-width: 1180px; margin: 0 auto; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1rem;
  padding: 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
.appfoot b { color: var(--ink); }

@media (max-width: 640px) {
  .brand-text small { display: none; }
  .brand-text b { font-size: .92rem; }
  .appbar .brand .leaf { width: 24px; height: 24px; }
  .user-role { display: none; }
  .page-head h1 { font-size: 1.3rem; }
}
/* company name on one line on the sign-in page */
.login-panel { max-width: 540px; }
.login-brand .org { white-space: nowrap; font-size: clamp(.86rem, 3.7vw, 1.12rem); }
.login-brand .leaf { width: clamp(30px, 9vw, 42px); height: clamp(30px, 9vw, 42px); }
/* fluid quick entry */
.quick-entry { margin-top: .9rem; padding-top: .8rem; border-top: 1px dashed var(--line); }
.qe-label { font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: .4rem; }
.qe-offer { margin-bottom: .5rem; }
.qe-decline { margin-top: .6rem; }
.declined-count { color: var(--bad); }
/* Bristol Stool Chart */
.bristol-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }
.bristol-opt { display: flex; flex-direction: column; gap: .15rem; margin: 0; padding: .55rem; border: 2px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-weight: 400; position: relative; }
.bristol-opt input { position: absolute; opacity: 0; pointer-events: none; }
.bristol-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); }
.bristol-opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.bristol-opt b { font-size: .95rem; }
.bristol-opt span { font-size: .82rem; line-height: 1.3; }
.bristol-opt em { font-size: .78rem; font-style: normal; color: var(--muted); }
.bristol-opt.warn em { color: var(--bad); font-weight: 600; }
.bristol-img { width: 100%; max-width: 130px; height: 52px; }
.bristol-view { display: inline-flex; align-items: center; gap: .6rem; }
.bristol-view .bristol-img { width: 90px; height: 40px; }
.bristol-view.alert b { color: var(--bad); }
.bristol-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
@media (min-width: 1000px) { .bristol-grid { grid-template-columns: repeat(7, 1fr); } }
/* links to other apps */
.appnav a.ext-link { color: #1b5e7a; }
.appnav a.ext-link:hover { color: #0f4258; }
.ext { font-size: .8em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.quick-links { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; }
.quick-links > div { flex: 1 1 220px; }
.quick-links h3 { margin: 0; }
.quick-links p { margin: .15rem 0 0; }
.app-links { display: inline-flex; gap: .4rem; margin-right: .4rem; }
.app-link { color: #fff; text-decoration: none; font-size: .85rem; font-weight: 600; padding: .35rem .7rem; border-radius: 8px; background: #4a3c33; border: 1px solid #6b5b4f; white-space: nowrap; }
.app-link:hover { background: #5a4a3f; }
@media (max-width: 640px) { .app-links { order: 9; width: 100%; } }
.app-links { flex-wrap: wrap; }
@media (max-width: 640px) { .app-link { font-size: .8rem; padding: .3rem .55rem; } }
@media (min-width: 641px) { .appbar .who { justify-content: flex-end; } }
