:root {
  --navy: #1e3a5f;
  --navy-dark: #162d4a;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --slate: #475569;
  --slate-light: #f8fafc;
  --blue: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #d97706;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background: #f1f5f9;
  font-size: 14px;
  line-height: 1.5;
}

/* ══ Brand mark ══ */
/*
 * One asset for the whole site: /logo.svg. The mark is dark ink on a
 * transparent ground, so on the navy chrome it sits on a white chip rather
 * than being recoloured — the brand blue and black stay as supplied.
 * To swap in a different file, change the src in the three places that
 * render it: nav.js (.sb-brand), /order-form/ and /route/.
 */
.brand-chip {
  display: block;
  background: #fff;
  border-radius: 8px;
  padding: 5px 9px;
  flex-shrink: 0;
  line-height: 0;
}
.brand-chip img { display: block; height: 28px; width: auto; }

/* ══ App shell: left sidebar + top bar ══ */
:root { --sidebar-w: 232px; --topbar-h: 56px; }

.app-shell { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.app-sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 60;
  overflow-y: auto;
}

.sb-brand {
  display: flex; flex-direction: column; align-items: stretch; gap: 9px;
  text-decoration: none;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.09);
  flex-shrink: 0;
}
/* Full-width chip: at sidebar width the "CONSULTING" line is still legible. */
.sb-brand .brand-chip { padding: 9px 12px; }
.sb-brand .brand-chip img { height: auto; width: 100%; }
.sb-brandname { color: rgba(255,255,255,0.9); font-size: 14.5px; font-weight: 700; }

.sb-nav { flex: 1; padding: 14px 10px; }
.sb-group + .sb-group { margin-top: 22px; }
.sb-group-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.11em; color: rgba(255,255,255,0.38);
  padding: 0 10px; margin-bottom: 7px;
}
.sb-links { list-style: none; display: flex; flex-direction: column; gap: 1px; }
.sb-links a {
  display: flex; align-items: center; gap: 11px;
  color: rgba(255,255,255,0.72);
  text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  padding: 8px 10px;
  border-radius: 7px;
  transition: background 0.12s, color 0.12s;
}
.sb-links a:hover { background: rgba(255,255,255,0.09); color: #fff; }
.sb-links a.active { background: rgba(255,255,255,0.17); color: #fff; font-weight: 600; }
.sb-icon {
  width: 20px; text-align: center; font-size: 14px;
  opacity: 0.85; flex-shrink: 0;
}
.sb-foot {
  padding: 14px 18px;
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  border-top: 1px solid rgba(255,255,255,0.09);
  flex-shrink: 0;
}

.app-sidebar-backdrop { display: none; }

/* ── Body column ── */
.app-body {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

.app-topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-spacer { flex: 1; }
.topbar-burger {
  display: none;
  background: none; border: none; cursor: pointer;
  font-size: 19px; color: var(--slate); padding: 4px 8px; border-radius: 6px;
}
.topbar-burger:hover { background: var(--slate-light); }

.app-main { flex: 1; }

/* ── Profile menu ── */
.profile { position: relative; }
.profile-btn {
  display: flex; align-items: center; gap: 9px;
  background: none; border: 1px solid transparent;
  border-radius: 9px; padding: 5px 8px; cursor: pointer;
  font-family: inherit; transition: background 0.12s, border-color 0.12s;
}
.profile-btn:hover { background: var(--slate-light); border-color: var(--border); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em;
  flex-shrink: 0;
}
.avatar-lg { width: 42px; height: 42px; font-size: 15px; }
.avatar-sm { width: 25px; height: 25px; font-size: 10px; }
.profile-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.profile-name { font-size: 13px; font-weight: 600; color: var(--text); }
.profile-role { font-size: 11px; color: var(--text-muted); }
.profile-caret { font-size: 10px; color: var(--text-muted); }

.profile-menu {
  display: none;
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 292px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15,23,42,0.14);
  overflow: hidden;
  z-index: 200;
}
.profile.open .profile-menu { display: block; }

.pm-header { display: flex; gap: 12px; align-items: center; padding: 16px; background: var(--slate-light); border-bottom: 1px solid var(--border); }
.pm-name { font-size: 14px; font-weight: 700; }
.pm-email { font-size: 11.5px; color: var(--text-muted); margin-bottom: 5px; word-break: break-all; }
.pill-role { background: #e0e7ff; color: #3730a3; }

.pm-section { padding: 6px; border-bottom: 1px solid var(--border); }
.pm-section:last-child { border-bottom: none; }
.pm-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-muted); padding: 7px 10px 4px; }
.pm-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 7px;
  text-decoration: none; color: var(--text); font-size: 13.5px;
}
.pm-item:hover { background: var(--slate-light); }
.pm-ico { width: 17px; text-align: center; color: var(--text-muted); }
.pm-badge {
  margin-left: auto; background: var(--red); color: #fff;
  font-size: 10.5px; font-weight: 700;
  min-width: 19px; height: 19px; padding: 0 6px;
  border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
}

.pm-users { max-height: 216px; overflow-y: auto; }
.pm-user {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: none; border: none; cursor: pointer;
  padding: 7px 10px; border-radius: 7px; text-align: left; font-family: inherit;
}
.pm-user:hover { background: var(--slate-light); }
.pm-user.current { background: #eff6ff; }
.pm-user-meta { display: flex; flex-direction: column; line-height: 1.3; font-size: 13px; }
.pm-user-role { font-size: 10.5px; color: var(--text-muted); }
.pm-check { margin-left: auto; color: var(--blue); font-weight: 700; }
.pm-note { font-size: 10.5px; color: var(--text-muted); padding: 7px 10px 9px; line-height: 1.45; }

/* ── Feedback widget ── */
.feedback-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 300;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--navy); color: #fff;
  border: none; border-radius: 24px;
  padding: 11px 18px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(15,23,42,0.26);
  transition: transform 0.12s, background 0.15s;
}
.feedback-fab:hover { background: var(--navy-dark); transform: translateY(-1px); }

.feedback-modal-backdrop {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(15,23,42,0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.feedback-modal-backdrop[hidden] { display: none; }
.feedback-modal {
  background: #fff; border-radius: 14px;
  width: 100%; max-width: 940px; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
  overflow: hidden;
}
.fb-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.fb-head h2 { font-size: 16px; font-weight: 700; }
.fb-close { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--text-muted); padding: 4px 8px; border-radius: 6px; }
.fb-close:hover { background: var(--slate-light); color: var(--text); }

.fb-body { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; padding: 20px; overflow-y: auto; }
.fb-shot-label, .fb-context { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 6px; }
.fb-shot-frame {
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--slate-light);
  min-height: 230px; max-height: 330px;
  display: flex; align-items: center; justify-content: center;
  overflow: auto;
}
.fb-shot-frame img { width: 100%; height: auto; display: block; }
.fb-shot-loading { font-size: 12.5px; color: var(--text-muted); padding: 20px; text-align: center; line-height: 1.5; }
.fb-include { margin-top: 10px; font-size: 12.5px; }
.fb-context { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 11.5px; word-break: break-all; }

.fb-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--slate-light); }

body.modal-open { overflow: hidden; }

/* ══ Collection outcome modal & signature pad (items B1/B2) ══ */
/* Sized for a tablet held in the hand at a bedside, not a desk: one column,
   large tap targets, and the pad tall enough to sign with a finger. */
.co-backdrop {
  position: fixed; inset: 0; z-index: 420;
  background: rgba(15,23,42,0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.co-backdrop[hidden] { display: none; }
.co-modal {
  background: #fff; border-radius: 14px;
  width: 100%; max-width: 560px; max-height: 92vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
  overflow: hidden;
}
.co-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.co-head h2 { font-size: 16px; font-weight: 700; }
.co-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.co-close {
  background: none; border: none; font-size: 16px; cursor: pointer;
  color: var(--text-muted); padding: 4px 8px; border-radius: 6px;
}
.co-close:hover { background: var(--slate-light); color: var(--text); }

.co-body { padding: 18px 20px; overflow-y: auto; }
.co-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 8px;
}
.co-req {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  background: #fee2e2; color: #b91c1c; border-radius: 4px; padding: 1px 6px; margin-left: 6px;
}

.co-codes { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.co-code {
  display: flex; align-items: center; gap: 11px;
  border: 1px solid var(--border); border-radius: 9px;
  padding: 12px 14px; cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.co-code:hover { background: var(--slate-light); }
.co-code:has(input:checked) { border-color: var(--navy); background: #f8fafc; box-shadow: inset 0 0 0 1px var(--navy); }
.co-code input { width: 17px; height: 17px; flex-shrink: 0; accent-color: var(--navy); }
.co-code-body { display: flex; flex-direction: column; gap: 2px; }
.co-code-label { font-size: 14px; font-weight: 600; color: var(--text); }
.co-code-flags { font-size: 11px; color: var(--text-muted); }

.co-sig { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 4px; }
.co-attest {
  font-size: 12.5px; line-height: 1.55; color: var(--text);
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px;
  padding: 10px 12px; margin-bottom: 14px;
}
.co-sig-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.co-pad-wrap { position: relative; border: 1px solid var(--border); border-radius: 9px; background: #fff; overflow: hidden; }
.co-pad {
  display: block; width: 100%; height: 170px;
  touch-action: none;            /* or the browser scrolls instead of drawing */
  cursor: crosshair;
}
.co-pad-baseline {
  position: absolute; left: 24px; right: 24px; bottom: 34px;
  border-bottom: 1px dashed #cbd5e1; pointer-events: none;
}
.co-pad-hint {
  position: absolute; left: 28px; bottom: 12px;
  font-size: 12px; color: #cbd5e1; pointer-events: none;
}
.co-pad-actions { display: flex; gap: 8px; margin-top: 8px; }

.co-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border); background: var(--slate-light);
}

/* The inline reason on a route row — this is what lets the route page itself
   answer the facility's question without opening a report. */
.co-row-reason { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.co-row-reason-label { font-size: 11.5px; color: #b45309; font-weight: 600; }
.co-row-signed {
  font-size: 10px; font-weight: 700; background: #dcfce7; color: #166534;
  border-radius: 4px; padding: 1px 6px;
}
.co-row-attempt {
  font-size: 10px; font-weight: 700; background: #fef3c7; color: #92400e;
  border-radius: 4px; padding: 1px 6px;
}
.co-row-by { font-size: 10.5px; color: #94a3b8; }

@media (max-width: 520px) {
  .co-sig-fields { grid-template-columns: 1fr; }
  .co-backdrop { padding: 0; align-items: stretch; }
  .co-modal { max-height: 100vh; border-radius: 0; }
}

/* ── Page ── */
.page-wrap { max-width: 1180px; margin: 0 auto; padding: 30px 26px 60px; }

/* ── Responsive: sidebar becomes off-canvas ── */
@media (max-width: 900px) {
  .app-sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
  body.nav-open .app-sidebar { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.3); }
  .app-body { margin-left: 0; }
  .topbar-burger { display: block; }
  body.nav-open .app-sidebar-backdrop {
    display: block; position: fixed; inset: 0;
    background: rgba(15,23,42,0.45); z-index: 55;
  }
  .profile-meta { display: none; }
  .fb-body { grid-template-columns: 1fr; }
  .fab-text { display: none; }
  .feedback-fab { border-radius: 50%; width: 48px; height: 48px; justify-content: center; padding: 0; }
  .page-wrap { padding: 22px 16px 60px; }
}

/* ── Print: chrome disappears, content fills the page ── */
@media print {
  .app-sidebar, .app-sidebar-backdrop, .app-topbar,
  .feedback-fab, .feedback-modal-backdrop { display: none !important; }
  .app-body { margin-left: 0 !important; }
  .app-shell { display: block; }
}

.page-hero { margin-bottom: 32px; }
.page-hero .eyebrow { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 6px; }
.page-hero h1 { font-size: 26px; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.page-hero p { color: var(--text-muted); font-size: 14px; max-width: 560px; }

/* ── Cards ── */
.card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }

.stat-chip {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-muted);
  min-width: 80px;
}
.stat-chip strong { color: var(--text); font-size: 18px; display: block; }

/* ── Form ── */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(147,197,253,0.25);
}
.field textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* ── Buttons ── */
.btn {
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--navy-dark); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--slate-light); color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  background: var(--slate-light);
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--slate);
  border-bottom: 2px solid var(--border);
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: #334155;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--slate-light); }

/* ── Pills ── */
.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.pill-pending    { background: #fef9c3; color: #92400e; }
.pill-scheduled  { background: #dbeafe; color: #1e40af; }
.pill-inprogress { background: #ede9fe; color: #5b21b6; }
.pill-collected  { background: #dcfce7; color: #166534; }
/* Amber, deliberately distinct from Cancelled's grey: a stop somebody drove to
   and could not collect is an operational event, not an administrative one. */
.pill-notcollected { background: #ffedd5; color: #9a3412; }
.pill-cancelled  { background: #f1f5f9; color: #475569; }

.pill-nursing    { background: #fce7f3; color: #9d174d; }
.pill-skilled    { background: #dbeafe; color: #1e40af; }
.pill-assisted   { background: #dcfce7; color: #166534; }
.pill-other      { background: #f1f5f9; color: #475569; }

/* ── Toolbar ── */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.search-input, .filter-select {
  padding: 7px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.search-input { width: 200px; }
.search-input:focus, .filter-select:focus { outline: 2px solid #93c5fd; border-color: #93c5fd; }

/* ── States ── */
.loading, .empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 13.5px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.form-msg { margin-top: 10px; font-size: 12.5px; border-radius: 6px; padding: 8px 10px; display: none; }
.form-msg.success { background: #dcfce7; color: #166534; display: block; }
.form-msg.error   { background: #fee2e2; color: #991b1b; display: block; }

/* ── Category cards ── */
.category-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.category-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); border-color: #93c5fd; }
.category-icon { width: 44px; height: 44px; border-radius: 10px; font-size: 22px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.category-card h2 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.category-card p { font-size: 13px; color: var(--text-muted); }
.category-card .arrow { margin-top: 12px; font-size: 12px; color: var(--blue); font-weight: 600; }

.section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 12px; }

.site-footer {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 60px;
  background: #fff;
}

.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.checkbox-label input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }

/* ── Fasting badge ── */
.fasting-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: #d97706; background: #fef3c7; padding: 2px 8px; border-radius: 8px; }
