/* Madrona clerical UI — direction 1a Slate Card.
   Shared tokens + primitives. Light theme only. Colour = meaning. */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;1,400&display=swap');

:root {
  --brand: #284838;
  --brand-hover: #1a3226;
  --brand-tint: #eef3f0;
  --brand-tint-line: #c2d4c9;
  --brand-ink: #1f4436;
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-sunk: #f6f9fb;
  --surface-alt: #f4f7fa;
  --surface-filter: #fbfdfe;
  --ink: #22303f;
  --ink-2: #4a5763;
  --ink-muted: #61748a;
  --ink-faint: #6b7885;
  --border: #d3dde6;
  --border-soft: #e4eaf0;
  --border-input: #cbd6e0;
  --hover: #f1f5f9;
  --ok-bg: #dceae1; --ok-line: #79a892; --ok-ink: #1f4436;
  --info-bg: #cfdeed; --info-line: #6f9dc6; --info-ink: #123c66;
  --warn-bg: #f6e6c8; --warn-line: #cfa04a; --warn-ink: #6d4708;
  --danger-bg: #f6e9e6; --danger-line: #e0c4bd; --danger-ink: #8a3d2f;
  --off-bg: #e8ecf0; --off-line: #ccd4dc; --off-ink: #6f7a85;
  --held-bg: #efe6f4; --held-line: #c4a8d0; --held-ink: #5a3d6e;
  --conf-low: #d9a41c;
  --conf-ok: #c8ced5;
  --conf-strip: #fdf6e8;
  --conf-strip-line: #ecd9ae;
  --conf-field: #fffdf7;
  --viewer-bar: #1b2430;
  --viewer-stage: #141b23;
  --font: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --r-sm: 4px; --r-md: 6px; --r-lg: 8px; --r-pill: 999px;
  --shadow-card: 0 1px 3px rgba(20, 32, 44, 0.08);
  --shadow-modal: 0 16px 48px rgba(15, 23, 32, 0.28);
  --page-gutter: 20px;
  --type-page: 19px;
  --type-card: 16px;
  --type-body: 13.5px;
  --type-table: 12.5px;
  --type-label: 11.5px;
  --type-helper: 12.5px;
  --type-col: 10.5px;

  /* Aliases so leftover per-page CSS keeps working after :root deletion. */
  --bg-card: var(--surface);
  --bg-header: var(--surface);
  --text: var(--ink);
  --text-light: var(--ink-muted);
  --text-header: var(--ink);
  --accent: var(--brand);
  --accent-light: var(--brand-hover);
  --danger: var(--danger-ink);
  --success: var(--ok-ink);
  --warning: var(--warn-ink);
  --error: var(--danger-ink);
  --held: var(--held-ink);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: var(--type-body);
  line-height: 1.45;
}

.content {
  padding: var(--page-gutter);
  max-width: 1600px;
  margin: 0 auto;
}

h1, .page-title {
  font-size: var(--type-page);
  font-weight: 600;
  letter-spacing: -0.2px;
  margin: 0;
  color: var(--ink);
}

h2, .card-title {
  font-size: var(--type-card);
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--ink);
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.muted, .helper {
  color: var(--ink-muted);
  font-size: var(--type-helper);
}

.lede {
  color: var(--ink);
  font-size: var(--type-body);
  margin: 0 0 14px;
  line-height: 1.45;
}

.privacy-banner {
  background: var(--info-bg);
  border-bottom: 1px solid var(--info-line);
  padding: 10px var(--page-gutter);
  font-size: 12.5px;
  color: var(--info-ink);
  text-align: center;
}

/* —— Page header —— */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.page-header-copy { min-width: 0; flex: 1 1 280px; }
.page-header .page-title { margin-bottom: 4px; }
.page-header .page-sub {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-muted);
  max-width: 52rem;
}
.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* —— Buttons —— */
.btn {
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--brand);
  padding: 8px 14px;
  border-radius: var(--r-md);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
}
.btn:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost,
.btn-secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled),
.btn-secondary:hover:not(:disabled) {
  background: var(--hover);
  color: var(--ink);
  border-color: var(--border);
}
.btn-danger-quiet {
  background: #fff;
  color: var(--danger-ink);
  border: 1px solid var(--danger-line);
}
.btn-danger-quiet:hover:not(:disabled) {
  background: var(--danger-bg);
  color: var(--danger-ink);
  border-color: var(--danger-line);
}
.btn-danger {
  background: #fff;
  color: var(--danger-ink);
  border: 1px solid var(--danger-line);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-bg);
  color: var(--danger-ink);
  border-color: var(--danger-ink);
}
.btn-warn {
  background: #b36b00;
  color: #fff;
  border: 1px solid #b36b00;
}
.btn-warn:hover:not(:disabled) {
  background: #935800;
  border-color: #935800;
}

/* —— Segmented control —— */
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: #fff;
}
.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 0;
  margin: 0;
  font-weight: 500;
  font-size: 12.5px;
  color: var(--ink-2);
  padding: 6px 12px;
  border-right: 1px solid var(--border);
  cursor: pointer;
  background: #fff;
}
.seg-btn:last-child { border-right: 0; }
.seg-btn input { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.seg-btn:hover { background: var(--hover); }
.seg-btn:has(input:checked),
.seg-btn.is-active {
  background: var(--brand);
  color: #fff;
}
.seg-btn:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: -2px; }

/* —— Cards / fields —— */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}

.field { margin-bottom: 10px; min-width: 0; }
.field label,
.fields label {
  display: block;
  font-size: var(--type-label);
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 4px;
}
.field .opt,
.optional-mark { font-weight: 400; color: var(--ink-faint); }

.field input,
.field select,
.field textarea,
.fields input,
.fields select,
.fields textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-input);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: var(--type-body);
  background: #fff;
  color: var(--ink);
}
.field textarea,
.fields textarea { min-height: 72px; resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus,
.fields input:focus,
.fields select:focus,
.fields textarea:focus {
  outline: 2px solid var(--brand-tint-line);
  border-color: var(--brand);
}

.filter-row,
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: end;
  padding: 10px 12px;
  margin: 0 -20px 12px;
  background: var(--surface-filter);
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}
.filter-row label,
.filters label {
  margin: 0 0 4px;
  font-size: var(--type-label);
  font-weight: 600;
  color: var(--ink-2);
}
.filter-row select,
.filter-row input,
.filters select,
.filters input { width: auto; min-width: 140px; }
.filter-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faint);
  padding-bottom: 8px;
  margin-left: auto;
}
.fax-pull-status {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faint);
  padding-bottom: 8px;
  max-width: 28rem;
}
.fax-from-line {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: var(--type-col);
}
.phone-alt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.phone-alt-number {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-2);
}
.phone-alt .btn {
  padding: 4px 10px;
  color: var(--brand-ink);
  background: var(--brand-tint);
  border-color: var(--brand-tint-line);
}
.phone-alt .btn:hover:not(:disabled) {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}
.phone-ext {
  margin: 4px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faint);
}

/* —— Tables —— */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
table.table,
table.queue {
  border-collapse: collapse;
  width: 100%;
  min-width: 720px;
  font-size: var(--type-table);
}
table.table th,
table.table td,
table.queue th,
table.queue td {
  border-bottom: 1px solid var(--border-soft);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
table.table th,
table.queue th {
  font-family: var(--font-mono);
  font-size: var(--type-col);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  background: var(--surface-sunk);
  position: sticky;
  top: 0;
}
table.table tbody tr,
table.queue tbody tr { cursor: pointer; }
table.table tbody tr:hover,
table.queue tbody tr:hover { background: var(--hover); }
table.table tbody tr.is-selected,
table.queue tbody tr.is-selected { background: var(--brand-tint); }
.empty { color: var(--ink-muted); padding: 16px; }

/* —— Chips —— */
.chip,
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  line-height: 1.3;
}
.chip-needs_review, .badge-needs_review,
.chip-failed, .badge-failed,
.chip-md_followup, .badge-md_followup { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.chip-saved, .badge-saved,
.chip-booked, .badge-booked,
.chip-approved, .badge-approved { background: var(--info-bg); color: var(--info-ink); border-color: var(--info-line); }
.chip-ocr_empty, .badge-ocr_empty,
.chip-rejected, .badge-rejected,
.chip-archived, .badge-archived,
.chip-clerk_closed, .badge-clerk_closed { background: var(--off-bg); color: var(--off-ink); border-color: var(--off-line); }
.chip-open, .badge-open { background: var(--ok-bg); color: var(--ok-ink); border-color: var(--ok-line); }
.chip-held, .badge-held { background: var(--held-bg); color: var(--held-ink); border-color: var(--held-line); }
.chip-declined, .badge-declined { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.chip-asap { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.chip-routine { background: var(--ok-bg); color: var(--ok-ink); border-color: var(--ok-line); }
.chip-semi-urgent { background: var(--info-bg); color: var(--info-ink); border-color: var(--info-line); }

.inbox-patient { min-width: 12rem; }
.inbox-name { font-weight: 600; color: var(--ink); }
.inbox-name.is-missing { font-weight: 500; color: var(--ink-muted); }
.inbox-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin-top: 2px;
  font-size: var(--type-col);
  font-family: var(--font-mono);
  color: var(--ink-faint);
}
.inbox-pager {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.inbox-pager .btn { padding: 6px 10px; font-size: 12px; }
.filter-row input[type="search"] { min-width: 200px; }

.friction-cell { display: flex; align-items: center; gap: 8px; }
.friction-bar {
  display: inline-block;
  width: 5px;
  height: 16px;
  border-radius: 2px;
  background: var(--ok-line);
  flex-shrink: 0;
}
.friction-bar.is-hot { background: var(--warn-line); }
.friction-bar.is-max { background: var(--danger-ink); }

.error { color: var(--danger-ink); margin: 8px 0; }
.ok { color: var(--ok-ink); margin: 8px 0; }

/* —— Intake review —— */
.review {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  height: min(72vh, 860px);
  min-height: 520px;
}
.review-viewer,
.review-fields {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
}
.review-viewer {
  display: flex;
  flex-direction: column;
}
.review-fields {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
}
@media (max-width: 980px) {
  .review {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: 0;
  }
  .review-viewer,
  .review-fields { height: auto; max-height: min(72vh, 860px); }
}

.viewer {
  background: var(--viewer-stage);
  border-radius: var(--r-lg);
  min-height: 0;
  position: relative;
  overflow: hidden;
  user-select: none;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  height: 100%;
}
.viewer-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 8px;
  background: var(--viewer-bar);
  color: #d5dde5;
  flex-shrink: 0;
}
.viewer-toolbar .btn-ghost {
  background: transparent;
  color: #d5dde5;
  border-color: #3a4654;
}
.viewer-toolbar .btn-ghost:hover:not(:disabled) {
  background: #243040;
  color: #fff;
}
.viewer-toolbar .btn-ghost:disabled {
  opacity: 0.4;
  cursor: default;
}
.viewer-toolbar #pageLabel {
  min-width: 7.5rem;
  font-variant-numeric: tabular-nums;
}
.viewer-stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--viewer-stage);
}
.viewer-stage.is-panning { cursor: grabbing; }
.viewer-stage img,
.viewer-stage embed,
.viewer-stage iframe,
.viewer-stage object {
  display: block;
  transform-origin: center center;
}
.viewer-stage img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  margin: auto;
}
.viewer-stage iframe,
.viewer-stage object,
.viewer-stage embed {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border: 0;
  align-self: stretch;
}

.low-conf {
  background: var(--conf-strip);
  border: 1px solid var(--conf-strip-line);
  border-radius: var(--r-md);
  padding: 8px 10px;
  font-size: 12.5px;
  color: var(--warn-ink);
  margin-bottom: 12px;
}
.low-conf .mono {
  font-size: var(--type-col);
  font-variant-numeric: tabular-nums;
}
.low-conf[hidden] { display: none; }

.fields [data-field],
.fields [data-field].is-ok,
.field.conf {
  padding-left: 8px;
  border-left: 3px solid var(--conf-ok);
}
.fields [data-field].is-low,
.field.conf.is-low {
  border-left-color: var(--conf-low);
}
.fields .is-low input,
.fields .is-low select,
.fields .is-low textarea {
  border-color: var(--conf-strip-line);
  background: var(--conf-field);
}
.fields .is-low .seg {
  background: var(--conf-field);
  border-color: var(--conf-strip-line);
}
.flag {
  font-family: var(--font-mono);
  font-size: var(--type-col);
  color: var(--warn-ink);
  margin: 4px 0 8px;
}

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.span2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.reject-panel {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-sunk);
}
.reject-panel h3 { font-size: 13px; font-weight: 600; margin: 0 0 6px; }
.reject-choices { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 10px; }
.reject-pane { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
#useOcrReferringFax { margin-top: 6px; }
#useOcrReferringFax[hidden] { display: none; }
.followup-card {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: var(--r-md);
  color: var(--warn-ink);
}
.invite {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--ok-bg);
  border: 1px solid var(--ok-line);
  border-radius: var(--r-md);
  color: var(--ok-ink);
}

#upload-req { border: 1px dashed var(--border); background: var(--surface-filter); }
#upload-req.is-drop-target { border-color: var(--brand); background: var(--brand-tint); }
#upload-req .file-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}
#upload-req .file-row label { display: inline; margin: 0; font-weight: 600; }
#upload-req input[type="file"] { font-family: inherit; font-size: 13px; width: auto; }

/* —— Modals —— */
.modal,
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 32, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal.hidden { display: none; }
.modal-card,
.dialog {
  background: #fff;
  border-radius: var(--r-lg);
  width: min(560px, 94vw);
  max-height: 92vh;
  overflow: auto;
  box-shadow: var(--shadow-modal);
  border: 1px solid var(--border);
}
.modal-card h2 { font-size: 16px; font-weight: 600; padding: 16px 20px 0; margin: 0; }
.modal-body { padding: 16px 20px 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.preview-line {
  background: var(--info-bg);
  border: 1px solid var(--info-line);
  color: var(--info-ink);
  padding: 10px 12px;
  border-radius: var(--r-md);
  font-weight: 600;
  margin: 12px 0 0;
}

/* —— Rooms calendar (1a Slate Card) —— */
.rooms-note {
  margin: -8px 0 16px;
  max-width: 52rem;
}
.rooms-card { padding-top: 14px; }

.cal-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 16px;
  align-items: center;
  margin: 0 -20px 12px;
  padding: 0 20px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.cal-toolbar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.cal-nav-btn {
  width: 34px;
  padding: 8px 0;
  flex-shrink: 0;
}
.period {
  font-size: var(--type-page);
  font-weight: 600;
  letter-spacing: -0.2px;
  min-width: 0;
  line-height: 1.2;
  color: var(--ink);
}
.cal-toolbar-views {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.tz-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
}
.cal-toolbar-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.cal-toolbar-actions .muted { font-size: 12px; color: var(--ink-faint); }
.crumb {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.crumb-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink-2);
  cursor: pointer;
}
.crumb-pill.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }
.crumb-pill:hover:not(.is-active) { background: var(--hover); }

.legend {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--type-label);
  font-weight: 600;
  color: var(--ink-2);
  padding: 3px 8px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface-filter);
}
.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid transparent;
  box-sizing: border-box;
  flex-shrink: 0;
}
.swatch-open { background: var(--ok-bg); border-color: var(--ok-line); }
.swatch-held { background: var(--held-bg); border-color: var(--held-line); }
.swatch-booked { background: var(--info-bg); border-color: var(--info-line); }
.swatch-closed { background: var(--off-bg); border-color: var(--off-line); }

.month-grid {
  display: grid;
  grid-template-columns: 44px repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.month-grid .dow,
.month-grid .week-num {
  font-family: var(--font-mono);
  font-size: var(--type-col);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  text-align: center;
  padding: 4px 0;
}
.month-grid .week-num {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 88px;
  background: var(--surface-sunk);
  border-radius: var(--r-sm);
}
.month-day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-height: 88px;
  padding: 7px 8px 8px;
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
  cursor: pointer;
}
.month-day:hover { border-color: var(--brand); background: var(--hover); }
.month-day.weekend { background: var(--surface-sunk); color: var(--ink-faint); }
.month-day.closed-day { background: var(--off-bg); border-color: var(--off-line); }
.month-day.is-today { box-shadow: inset 0 0 0 1px var(--brand-tint-line); }
.month-day.is-today .num { color: var(--brand); }
.month-day.selected { outline: 2px solid var(--brand); background: var(--brand-tint); }
.month-day .num { font-weight: 600; margin-bottom: 6px; font-size: 12.5px; }
.room-strips { display: flex; flex-direction: column; gap: 3px; }
.room-strip {
  height: 7px;
  border-radius: 2px;
  background: var(--ok-bg);
  border: 1px solid var(--ok-line);
}
.room-strip.busy { background: var(--warn-bg); border-color: var(--warn-line); }
.room-strip.shut { background: var(--off-bg); border-color: var(--off-line); }
.room-strip.unknown { background: var(--surface-alt); border-color: var(--border-soft); }

.week-ramp {
  display: grid;
  grid-template-columns: 56px repeat(7, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: auto;
  background: var(--border);
}
.week-ramp .head,
.week-ramp .time {
  background: var(--surface-sunk);
  font-family: var(--font-mono);
  font-size: var(--type-col);
  color: var(--ink-faint);
  padding: 8px 6px;
  text-align: center;
}
.week-ramp .time {
  position: sticky;
  left: 0;
  z-index: 1;
}
.week-ramp .time.is-hour { color: var(--ink-2); font-weight: 500; }
.week-ramp .head {
  position: sticky;
  top: 0;
  z-index: 2;
  cursor: pointer;
  font-weight: 600;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.week-ramp .head.time { z-index: 3; left: 0; cursor: default; }
.week-ramp .head:hover { background: var(--hover); color: var(--ink); }
.week-ramp .head.is-today { background: var(--brand-tint); color: var(--brand-ink); }
.ramp {
  min-height: 24px;
  border: 0;
  cursor: pointer;
  width: 100%;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-2);
}
.ramp-0 { background: var(--ok-bg); color: transparent; }
.ramp-1 { background: #cfe3d6; color: var(--ok-ink); }
.ramp-2 { background: #b7d2c2; color: var(--ok-ink); }
.ramp-3 { background: var(--warn-bg); color: var(--warn-ink); }
.ramp-4 { background: #efd3a0; color: var(--warn-ink); }
.ramp-5 { background: var(--info-bg); color: var(--info-ink); }
.ramp-shut { background: var(--off-bg); color: var(--off-ink); cursor: default; }
.ramp-unknown { background: var(--surface-alt); color: var(--ink-faint); }
.ramp:hover:not(:disabled):not(.ramp-shut) { filter: brightness(0.97); }

.day-grid {
  display: grid;
  grid-template-columns: 64px repeat(var(--rooms, 5), minmax(0, 1fr));
  grid-auto-rows: 24px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: auto;
  background: var(--border);
  gap: 1px;
  max-height: min(72vh, 860px);
}
.day-grid .dg-head,
.day-grid .dg-time {
  background: var(--surface-sunk);
  font-family: var(--font-mono);
  font-size: var(--type-col);
  color: var(--ink-faint);
  padding: 6px 8px;
  position: sticky;
  z-index: 1;
}
.day-grid .dg-head {
  top: 0;
  z-index: 3;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.day-grid .dg-time {
  left: 0;
  z-index: 2;
  text-align: right;
}
.day-grid .dg-head.dg-time { z-index: 4; left: 0; justify-content: flex-end; }
.day-grid .dg-time.is-hour { color: var(--ink-2); font-weight: 500; }
.day-grid.is-today .dg-head:not(.dg-time) { box-shadow: inset 0 -2px 0 var(--brand); }
.dg-closed {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--off-ink);
}
.dg-room-layer {
  position: relative;
  z-index: 2;
  pointer-events: none;
  min-height: 0;
}
.dg-room-layer .slot {
  position: absolute;
  left: 0;
  right: 0;
  width: auto;
  height: auto;
  pointer-events: auto;
  box-sizing: border-box;
}

.slot {
  display: block;
  width: 100%;
  height: 100%;
  text-align: left;
  padding: 3px 7px 3px 8px;
  border: 0;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  border-left: 3px solid transparent;
}
.slot.open {
  background: var(--ok-bg);
  color: transparent;
  border-left-color: var(--ok-line);
}
.slot.held {
  background: var(--held-bg);
  color: var(--held-ink);
  border-left-color: var(--held-line);
}
.slot.booked {
  background: var(--info-bg);
  color: var(--info-ink);
  border-left-color: var(--info-line);
}
.slot.closed {
  background: var(--off-bg);
  color: var(--off-ink);
  cursor: default;
  border-left-color: var(--off-line);
}
.slot:hover:not(.closed) { filter: brightness(0.97); }
.slot.preview { outline: 2px solid var(--brand); outline-offset: -2px; box-shadow: inset 0 0 0 1px var(--brand); }
.slot .who { display: block; font-weight: 600; }
.slot .exam {
  display: block;
  font-weight: 500;
  color: inherit;
  opacity: 0.82;
}
.slot .source {
  display: inline-block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.75;
}

.rooms-meta { margin-bottom: 16px; }
.rooms-meta-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 24px;
  align-items: stretch;
}
.rooms-meta-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.rooms-meta-col + .rooms-meta-col {
  padding-left: 24px;
  border-left: 1px solid var(--border-soft);
}
.rooms-meta-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  margin: 0 0 12px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--border-soft);
}
.rooms-meta-head .card-title { margin: 0; }
.rooms-meta-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.rooms-meta-lede { margin: 0 0 12px; }
.hours-form { display: flex; flex-direction: column; gap: 8px; }
.hours-row.row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1fr) 110px;
  gap: 10px;
  align-items: end;
  margin: 0;
}
.hours-day {
  padding-bottom: 10px;
  font-weight: 600;
  font-size: var(--type-label);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.hours-row .field { margin-bottom: 0; min-width: 0; }
.hours-row .field-interval { width: auto; }
.closed-add {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr);
  gap: 10px;
  align-items: end;
  margin: 0 0 12px;
}
.closed-add .field { margin-bottom: 0; }
.closed-list {
  list-style: none;
  max-height: 240px;
  overflow: auto;
  padding: 0;
  margin: 0;
  flex: 1 1 auto;
}
.closed-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
}
.modal-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px 0;
}
.modal-title-row h2 { padding: 0; }
.block-details {
  display: grid;
  gap: 8px 16px;
  margin: 12px 0 0;
  padding: 10px 12px;
  background: var(--surface-sunk);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
}
.block-detail {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 4px 12px;
  align-items: start;
}
.block-details dt {
  margin: 0;
  font-size: var(--type-col);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-top: 2px;
}
.block-details dd {
  margin: 0;
  color: var(--ink);
  word-break: break-word;
  white-space: pre-wrap;
}
.modal-card-wide { width: min(640px, 94vw); }
a.btn { text-decoration: none; display: inline-block; }
.relative-fields { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.relative-fields input { max-width: 100px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .cal-toolbar { grid-template-columns: 1fr; }
  .cal-toolbar-views { justify-content: flex-start; }
  .rooms-meta-grid { grid-template-columns: 1fr; gap: 16px; }
  .rooms-meta-col + .rooms-meta-col {
    padding-left: 0;
    border-left: 0;
    padding-top: 16px;
    border-top: 1px solid var(--border-soft);
  }
}

.banner {
  background: var(--info-bg);
  border: 1px solid var(--info-line);
  color: var(--info-ink);
  padding: 12px 16px;
  border-radius: var(--r-lg);
  margin-bottom: 16px;
  font-size: 13px;
}
.banner-link { background: var(--brand-tint); border-color: var(--brand-tint-line); color: var(--brand-ink); }
.banner-error { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger-ink); }

/* —— Patient self-book (/book) — 1a Slate Card, patient posture ——
   Same tokens/card language as staff. No staff nav. 44px touch; 16px on
   fields so iOS does not zoom. Hierarchy matches 1a, not a second theme. */
body.patient-book {
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

.patient-book .wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px var(--page-gutter) 40px;
}

.patient-book .book-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 20px 22px;
}

.patient-book .book-logo {
  display: block;
  height: 30px;
  width: auto;
  margin: 0 0 16px;
}

.patient-book h1 {
  font-size: var(--type-page);
  font-weight: 600;
  letter-spacing: -0.2px;
  margin: 0 0 6px;
  color: var(--ink);
}

.patient-book h2 {
  font-size: var(--type-card);
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--ink);
}

.patient-book p {
  margin: 0 0 12px;
}

.patient-book .muted,
.patient-book .helper,
.patient-book .calendar-intro,
.patient-book .more-days {
  color: var(--ink-muted);
  font-size: 13.5px;
  line-height: 1.45;
}

.patient-book .field {
  margin-bottom: 12px;
}

.patient-book label,
.patient-book .field label,
.patient-book .fields label {
  display: block;
  font-size: var(--type-label);
  font-weight: 600;
  color: var(--ink-2);
  margin: 0 0 4px;
}

.patient-book .check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  margin: 0 0 12px;
}

.patient-book input,
.patient-book textarea,
.patient-book button {
  font-family: inherit;
}

.patient-book input[type="date"],
.patient-book input[type="email"],
.patient-book input[type="text"],
.patient-book textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  margin: 0;
  border: 1px solid var(--border-input);
  border-radius: var(--r-md);
  background: #fff;
  color: var(--ink);
  font-size: 16px;
}

.patient-book textarea {
  min-height: 96px;
  resize: vertical;
}

.patient-book input:focus,
.patient-book textarea:focus {
  outline: 2px solid var(--brand-tint-line);
  border-color: var(--brand);
}

.patient-book .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 16px;
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--brand);
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.patient-book .btn:hover:not(:disabled) {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

.patient-book .btn.btn-secondary,
.patient-book .btn.ghost,
.patient-book .btn-secondary,
.patient-book .ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--border);
}

.patient-book .btn.btn-secondary:hover:not(:disabled),
.patient-book .btn.ghost:hover:not(:disabled),
.patient-book .btn-secondary:hover:not(:disabled),
.patient-book .ghost:hover:not(:disabled) {
  background: var(--hover);
  color: var(--ink);
  border-color: var(--border);
}

.patient-book .btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.patient-book .error {
  color: var(--danger-ink);
  font-weight: 600;
  font-size: 13.5px;
  margin: 0 0 12px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  padding: 10px 12px;
  border-radius: var(--r-md);
}

.patient-book .status {
  color: var(--brand-ink);
  font-size: 13.5px;
  margin: 0 0 12px;
  background: var(--brand-tint);
  border: 1px solid var(--brand-tint-line);
  padding: 10px 12px;
  border-radius: var(--r-md);
}

.patient-book .empty-horizon,
.patient-book .confirm-box,
.patient-book .done-box {
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  padding: 16px 18px;
  border-radius: var(--r-lg);
  margin-top: 8px;
}

.patient-book .confirm-box h2,
.patient-book .request-form h2 {
  font-size: var(--type-card);
}

.patient-book .confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 0;
}

.patient-book #confirm {
  scroll-margin-top: 16px;
}

.patient-book .request-box {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}

.patient-book .request-form {
  margin-top: 12px;
}

.patient-book .month-block {
  margin: 4px 0 18px;
}

.patient-book .month-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin: 0 0 6px;
  padding: 8px 0 6px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
  border-bottom: 1px solid var(--border-soft);
}

.patient-book .cal {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0 0;
}

.patient-book .dow {
  font-family: var(--font-mono);
  font-size: var(--type-col);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  text-align: center;
  padding: 2px 0 4px;
}

.patient-book .day-spacer {
  min-height: 0;
}

.patient-book .day,
.patient-book .day-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  min-width: 44px;
  padding: 6px 2px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  text-align: center;
  cursor: default;
  pointer-events: auto;
  touch-action: manipulation;
  background: #f2f4f6;
  color: #b4bcc4;
}

.patient-book .day-num {
  font-family: var(--font-mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  line-height: 1;
}

.patient-book .day.offer,
.patient-book .day-cell.offer {
  background: var(--ok-bg);
  border-color: var(--ok-line);
  color: var(--ok-ink);
  cursor: pointer;
}

.patient-book .day.offer .day-num,
.patient-book .day-cell.offer .day-num {
  color: var(--ok-ink);
}

.patient-book .day.offer:hover:not(:disabled):not(.is-selected),
.patient-book .day-cell.offer:hover:not(:disabled):not(.is-selected) {
  filter: brightness(0.97);
}

.patient-book .day.offer.busy,
.patient-book .day-cell.offer.busy {
  opacity: 0.7;
}

.patient-book .day.none,
.patient-book .day-cell.none {
  background: #f2f4f6;
  color: #b4bcc4;
  border-color: transparent;
}

.patient-book .day.none .day-num,
.patient-book .day-cell.none .day-num {
  color: #b4bcc4;
}

.patient-book .day.is-selected,
.patient-book .day-cell.is-selected,
.patient-book .day.offer.is-selected,
.patient-book .day-cell.offer.is-selected {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  filter: none;
}

.patient-book .day.is-selected .day-num,
.patient-book .day-cell.is-selected .day-num {
  color: #fff;
}

.patient-book .day:disabled,
.patient-book .day-cell:disabled {
  cursor: default;
}

.patient-book .day:focus-visible,
.patient-book .day-cell:focus-visible,
.patient-book .btn:focus-visible,
.patient-book input:focus-visible,
.patient-book textarea:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.patient-book .cal-legend {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  color: var(--ink-muted);
  font-size: var(--type-label);
  line-height: 1.4;
}

.patient-book .cal-legend-swatches {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 3px;
  flex-shrink: 0;
}

.patient-book .cal-legend .swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 0;
  box-sizing: border-box;
}

.patient-book .cal-legend .swatch-ok {
  background: var(--ok-bg);
  border: 1px solid var(--ok-line);
}

.patient-book .cal-legend .swatch-none {
  background: #f2f4f6;
  border: 1px solid #e1e5e8;
}

.patient-book .cal-legend .swatch-selected {
  background: var(--brand);
  border: 1px solid var(--brand);
}

@media (max-width: 420px) {
  .patient-book .wrap { padding: 12px 8px 28px; }
  .patient-book .book-card { padding: 16px 12px; }
  .patient-book .cal { gap: 4px; }
}

/* —— Shared patient dossier drawer (light only) —— */
.dossier-root {
  position: fixed;
  inset: 0;
  z-index: 1100;
  pointer-events: none;
}
.dossier-root.is-open { pointer-events: auto; }
.dossier-root[hidden] { display: none; }
.dossier-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 32, 0.32);
}
.dossier-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: min(480px, 100vw);
  height: 100%;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.dossier-root[data-surface="chase"] .dossier-drawer {
  width: min(560px, 100vw);
}
.dossier-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--brand-tint-line);
  background: var(--brand-tint);
}
.dossier-header h2 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 600;
  color: var(--brand-ink);
  letter-spacing: -0.2px;
}
.dossier-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip-dob {
  background: var(--surface);
  color: var(--ink-2);
  border-color: var(--border);
  font-family: var(--font-mono);
}
.dossier-body {
  flex: 1;
  overflow: auto;
  padding: 16px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.dossier-section h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-ink);
}
.dossier-dl {
  margin: 0;
  display: grid;
  gap: 8px;
}
.dossier-row {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  gap: 8px 12px;
  align-items: start;
}
.dossier-row dt {
  margin: 0;
  color: var(--ink-muted);
  font-size: var(--type-label);
  font-weight: 600;
}
.dossier-row dd {
  margin: 0;
  color: var(--ink);
  font-size: var(--type-body);
  word-break: break-word;
}
.dossier-row dd.is-empty {
  color: var(--ink-faint);
  font-style: italic;
}
.dossier-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.dossier-banner {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  background: var(--off-bg);
  border: 1px solid var(--off-line);
  color: var(--off-ink);
  font-size: var(--type-helper);
}
.dossier-image-stage {
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.dossier-image-stage img,
.dossier-image-stage iframe {
  max-width: 100%;
  max-height: 360px;
  border: 0;
  background: #fff;
  cursor: zoom-in;
}
.dossier-image-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--ink-muted);
}
.dossier-image-empty strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
}
.dossier-image-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}
.dossier-footer {
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}
.dossier-footer-note {
  margin: 0 0 10px;
  color: var(--ink-muted);
  font-size: var(--type-helper);
}
.dossier-host-panel .action-note {
  margin: 0;
}
.dossier-host-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.dossier-root[data-surface="chase"] .dossier-host-actions {
  justify-content: flex-start;
}
.dossier-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(15, 23, 32, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.dossier-lightbox[hidden] { display: none; }
.dossier-lightbox img,
.dossier-lightbox iframe {
  max-width: min(960px, 92vw);
  max-height: 88vh;
  background: #fff;
  border: 0;
}
.dossier-lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
}
