:root {
  --ink: #16202c;
  --muted: #5d6b7a;
  --line: #d8e0e8;
  --bg: #f4f7fa;
  --card: #ffffff;
  --accent: #1f6feb;
  --danger: #b4232c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

main { max-width: 960px; margin: 0 auto; padding: 24px 20px 64px; }

h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 28px 0 8px; }

/* Module 14 breakpoints, the only three (Material 3 window classes):
     phone    < 600px
     tablet   600px - 839px
     desktop >= 840px
   A custom property cannot be read inside @media, so the queries below repeat 599px / 600px
   literally; change them together with this comment. */

/* Top bar: one line at every width. */
#app-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 6px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
/* `display: flex` above beats the UA's `[hidden]` rule, so `showView` hiding the header on the
   sign-in screen needs saying again; without it Change password was clickable signed out. */
#app-header[hidden] { display: none; }
.brand { flex: none; font-weight: 600; letter-spacing: -0.01em; }
/* The one item that gives way on a narrow screen: min-width 0 lets it shrink below its text. */
#clinic-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.spacer { flex: 1; }
.top-nav { display: none; }
.top-nav button { min-height: 44px; padding: 0 10px; }
.top-nav button[aria-current="page"] { font-weight: 600; text-decoration: underline; text-underline-offset: 6px; }
.person-button {
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 50%;
}
/* Anchored under the person button, top right, instead of the popover's centred default. */
.person-menu {
  inset: 56px 12px auto auto;
  min-width: 200px;
  max-width: calc(100vw - 24px);
  margin: 0;
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgb(22 32 44 / 14%);
}
.person-name { margin: 4px 8px 6px; overflow-wrap: anywhere; font-weight: 600; }
.person-menu button { display: block; width: 100%; min-height: 44px; padding: 0 8px; text-align: left; }

/* Bottom tab bar: phone only, and only while `showView` leaves it unhidden. */
.tab-bar { display: none; }

@media (max-width: 599px) {
  .tab-bar:not([hidden]) {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 10;
    display: flex;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--card);
    border-top: 1px solid var(--line);
  }
  .tab-bar button {
    flex: 1;
    height: 56px;
    color: var(--muted);
    background: none;
    border-radius: 0;
  }
  .tab-bar button[aria-current="page"] { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
  /* Room under the last row so nothing ends up behind the bar. */
  body:has(.tab-bar:not([hidden])) main { padding-bottom: calc(56px + 32px + env(safe-area-inset-bottom)); }
}

@media (min-width: 600px) {
  #app-header { gap: 12px; padding: 6px 20px; }
  .top-nav { display: flex; gap: 4px; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  margin: 16px 0;
}
.narrow { max-width: 360px; margin: 64px auto; }

label { display: block; margin: 12px 0 4px; font-size: 0.85rem; color: var(--muted); }

input, select, textarea {
  width: 100%;
  padding: 9px 10px;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
}
textarea { resize: vertical; }
input[type="file"] { padding: 6px; background: none; border: none; }
.checkbox-label { display: flex; align-items: center; gap: 6px; margin-top: 8px; cursor: pointer; }
.checkbox-label input { width: auto; margin: 0; }
#patient-search { margin: 12px 0 4px; }

/* T-111 recently seen strip: one scrolling line under search, so it costs no list space. */
.recent-strip { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
.recent-strip[hidden] { display: none; }
.recent-label { flex: none; font-size: 0.8rem; color: var(--muted); }
.recent-list { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: thin; }
.recent-list button {
  flex: none;
  padding: 3px 10px;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  white-space: nowrap;
}
.recent-list time { color: var(--muted); }

/* Named for screen readers, invisible on screen: the placeholder already says what to type. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

button {
  padding: 9px 14px;
  font: inherit;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.link {
  padding: 4px 2px;
  color: var(--accent);
  background: none;
  font-weight: 400;
}
button.primary { margin-top: 12px; }
#login-submit { width: 100%; min-height: 44px; margin-top: 20px; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-end { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 16px; }
.row-start { display: flex; align-items: center; gap: 12px; }
.inline-form { display: flex; align-items: center; gap: 12px; }

.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); font-size: 0.9rem; margin: 10px 0 0; }

.list { list-style: none; margin: 8px 0 0; padding: 0; }
.list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
}
.list li .grow { flex: 1; }

/* Module 14: a patient or visit row is one button filling its card, so the whole row is the
   target; the card keeps its border and the button supplies the padding. */
.list li.row-item { padding: 0; }
.row-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  font-weight: 400;
  color: var(--ink);
  text-align: left;
  background: none;
  border-radius: 8px;
}
.row-button:hover { background: #f4f7fa; filter: none; }
.row-button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.row-title { display: block; font-weight: 600; overflow-wrap: anywhere; }
.row-meta { display: block; font-size: 0.9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
/* min-width: 0 lets the flex child shrink below its text, so the ellipsis can cut it. */
#visit-list .grow { min-width: 0; }
.row-preview {
  display: block; font-size: 0.9rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.tag {
  padding: 2px 8px;
  font-size: 0.75rem;
  border-radius: 999px;
  background: #eaf1fb;
  color: var(--accent);
}

.tabs { display: flex; gap: 6px; margin: 8px 0 14px; }
.tab { background: #e7edf4; color: var(--muted); }
.tab.active { background: var(--accent); color: #fff; }

#pad {
  width: 100%;
  height: 320px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  touch-action: none;   /* let Pointer Events own the gesture, or the browser scrolls instead */
  cursor: crosshair;
}

/* --- records navigator --- */

.navigator {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-top: 8px;
}
/* The navigator takes focus so the arrow keys can drive it, so it has to be able to show
   that it has focus. */
.navigator:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.record-page { margin: 0; }
.record-caption { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 0.9rem; color: var(--muted); }
.record-caption .grow { flex: 1; min-width: 0; }
.icon-button { flex: none; width: 44px; height: 44px; padding: 0; font-size: 1.25rem; color: var(--accent); background: none; }
.record-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}
.record-body img { max-width: 100%; max-height: 58vh; object-fit: contain; }
.record-text { margin: 0; align-self: flex-start; white-space: pre-wrap; }
.record-unavailable { margin: 0; color: var(--muted); font-size: 0.9rem; }

/* The fullscreen backdrop is black by default, which frames a scanned page in the way that
   makes it hardest to read — the opposite of the reason to go fullscreen. */
#records-navigator:fullscreen,
#record-page:fullscreen {
  background: var(--card);
  padding: 20px;
  overflow: auto;
}
#record-page:fullscreen { display: flex; flex-direction: column; }
#record-page:fullscreen .record-body { flex: 1; }
#records-navigator:fullscreen .record-body img,
#record-page:fullscreen .record-body img { max-height: none; }

.navigator-controls { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
/* tabular-nums so the position label doesn't shift the buttons sideways as it counts up. */
.position { min-width: 70px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }

.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.thumbs img, .rx-image {
  max-width: 260px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.rx-image { max-width: 100%; display: block; margin-top: 6px; }
/* fit-content so the row-end under the preview aligns to the picture's own right edge
   rather than the full panel width, which left the link stranded across the page. */
#photo-preview-wrap { width: fit-content; }
#photo-preview { max-height: 260px; width: auto; }
.rx-text { margin: 6px 0 0; white-space: pre-wrap; }

/* Role-aware UI (module 7). One rule keyed on the signed-in role rather than `hidden` flags
   set per element: several of these (the capture panels) have their own `hidden` toggled by
   the mode tabs, and an operator must stay read-only whatever those toggles do. The server
   refuses the writes regardless; this only stops the page offering them. */
body[data-role="operator"] .doctor-only { display: none; }
/* Module 9: the super admin has no clinic, so clinic screens (Dues) are not offered. */
body[data-role="super_admin"] .clinic-only { display: none; }

/* Today rows hold a <details>, so the row is a block rather than the list's flex line. */
#today-list > li { display: block; }
#today-list summary { cursor: pointer; }
#today-list .today-body { margin: 10px 0 0; white-space: pre-wrap; }
#today-list .today-body img { max-width: 100%; max-height: 58vh; object-fit: contain; }
#today-panel .grow { flex: 1; margin: 0; }

/* --- dispensing panel (module 8) --- */

.dispensing-panel {
  margin-top: 12px;
  padding: 12px 14px;
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: normal;
}
.panel-status { margin: 0; font-weight: 500; }
.panel-courier { margin: 4px 0 0; }
.dispensing-panel .inline-form,
.dispensing-panel .row-start { flex-wrap: wrap; margin-top: 10px; }
.dispensing-panel input { width: auto; flex: 1; min-width: 140px; }
.payment-list { list-style: none; margin: 10px 0 0; padding: 0; }
.payment-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 0;
  background: none;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
}
.payment-list li .grow { flex: 1; }
.payment-list li.voided .grow { color: var(--muted); text-decoration: line-through; }
.void-note { color: var(--muted); font-size: 0.85rem; }

/* Today chips and filters (module 8). */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.filters button { padding: 5px 12px; font-size: 0.85rem; color: var(--muted); background: #e7edf4; }
.filters button[aria-pressed="true"] { color: #fff; background: var(--accent); }
.chips { display: inline-flex; gap: 6px; margin-left: 10px; vertical-align: middle; }
.chip {
  padding: 1px 8px;
  font-size: 0.75rem;
  border-radius: 999px;
  color: var(--muted);
  background: #e7edf4;
}
.chip[data-state="prepared"] { color: #8a5a00; background: #fdf1d6; }
.chip[data-state="handed_over"],
.chip[data-state="couriered"],
.chip[data-state="paid"] { color: #1d6b3a; background: #dcf2e3; }
.chip[data-state="unpaid"],
.chip[data-state="part_paid"] { color: var(--danger); background: #fbe3e4; }
#today-list > li[hidden] { display: none; }

/* Due popup and badges (module 8). */
#due-dialog {
  max-width: 420px;
  padding: 20px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
}
#due-dialog::backdrop { background: rgb(22 32 44 / 0.35); }
.due-summary { margin: 0; font-size: 1.1rem; font-weight: 600; color: var(--danger); }
.due-visits { margin: 10px 0 0; padding-left: 18px; color: var(--muted); }
.due-badge {
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
  color: var(--danger);
  background: #fbe3e4;
}

/* Dues screen (module 8). */
.dues-total { margin: 0; font-weight: 600; color: var(--danger); }
.dues-table, .admin-table {
  width: 100%;
  margin-top: 12px;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.dues-table th, .dues-table td, .admin-table th, .admin-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.dues-table th, .admin-table th { font-size: 0.8rem; font-weight: 500; color: var(--muted); }
.dues-table .num, .admin-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.dues-table tbody tr { cursor: pointer; }
.dues-table tbody tr:hover { background: #f4f7fa; }
.dues-table tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Admin screen (module 9). */
.choice { margin: 12px 0 0; padding: 0; border: none; }
.choice legend { padding: 0; font-size: 0.85rem; color: var(--muted); }
.choice label { display: inline-flex; align-items: center; gap: 6px; margin: 6px 18px 0 0; color: var(--ink); font-size: 1rem; }
.choice input { width: auto; }
.credentials { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 8px 0; }
.credentials dt { color: var(--muted); }
.credentials dd { margin: 0; font-family: ui-monospace, Menlo, monospace; font-size: 1.1rem; }
.admin-table .actions { text-align: right; white-space: nowrap; }
.admin-table .actions button + button { margin-left: 12px; }
.admin-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 20px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.admin-dialog::backdrop { background: rgb(22 32 44 / 0.35); }
.admin-dialog h2 { margin-top: 0; }

/* --- backups panel (module 10) --- */
.backups h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
.backups p { margin: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex: none; }
.dot.ok { background: #1a7f37; }
.dot.stale { background: var(--danger); }

/* --- admin dashboard and clinic page (module 13) --- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 12px 0; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.tile-label { font-size: 0.8rem; color: var(--muted); }
.tile-value { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.tile-note { font-size: 0.8rem; color: var(--muted); }
#clinics-table tbody tr { cursor: pointer; }
#clinics-table tbody tr:hover { background: #f4f7fa; }
#clinics-table tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.admin-table tr.deactivated td { color: var(--muted); }
.badge { display: inline-block; padding: 1px 8px; font-size: 0.75rem; color: var(--muted); background: #e7edf4; border-radius: 999px; }
#admin-clinic-view h2 { margin: 16px 0 0; }
#admin-clinic-view .actions button + button { margin-left: 12px; }

/* --- doctor home queue and the consultation's Finish buttons (module 15) --- */
.now-seeing { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 12px 0 0; padding: 14px 16px; }
.now-seeing .grow { flex: 1; min-width: 0; }
.now-label { flex-basis: 100%; margin: 0; font-size: 0.8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.now-empty { margin: 0; }
#doctor-queue h2 { margin: 18px 0 0; }
/* A waiting row is the Start button plus its menu; the menu's actions wrap onto their own line. */
.list li.queue-row { flex-wrap: wrap; gap: 0; }
.queue-row .row-button { flex: 1; width: auto; min-width: 0; }
.queue-row .entry-menu { margin-right: 4px; }
.entry-actions { display: flex; flex-basis: 100%; gap: 20px; padding: 0 14px 8px; }
.entry-actions[hidden] { display: none; }
.row-item .see-now { flex: none; margin-right: 8px; }
.done-today { margin-top: 20px; }
.done-today summary { cursor: pointer; font-weight: 600; }
.queue-actions { flex-wrap: wrap; margin-top: 12px; }
/* `.row-start` sets `display: flex`, which beats the UA's `[hidden]` rule. */
.queue-actions[hidden] { display: none; }
.queue-actions button:disabled { cursor: default; filter: none; opacity: 0.45; }

/* --- Module 14: phone layout for every view (under 600 px; see the breakpoints above) --- */

@media (max-width: 599px) {
  main { padding: 16px 16px 64px; }
  .card { padding: 16px; }
  .row-between { flex-wrap: wrap; }
  .inline-form { flex-wrap: wrap; }

  /* 44 px targets. Link-style buttons keep their look and only grow their hit area. */
  button, summary { min-height: 44px; }
  button.link { padding: 10px 4px; }
  summary { padding: 8px 0; }

  /* Mode tabs scroll inside their own row instead of widening the page. */
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tab { flex: none; }

  /* Records: the date filter wraps; the controls are icons plus one Fullscreen. */
  /* A two-column grid keeps each label on the line of its own date. */
  #records-filter { display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; }
  #records-filter label { margin: 0; }
  #records-filter input { min-width: 0; }
  #records-clear { grid-column: 2; justify-self: start; }
  .navigator { padding: 10px; }
  .navigator-controls { gap: 4px; }
  .navigator-controls button:not(.link) { width: 44px; padding: 0; }
  .position { min-width: 56px; }

  /* Tables become two-line blocks: the first cell bold, the rest as `label: value` pairs
     (labels copied from the header by `labelCells` in app.js). */
  .dues-table, .admin-table,
  .dues-table tbody, .admin-table tbody { display: block; }
  /* `display: block` beats the UA's `[hidden]` rule, and app.js hides an empty table. */
  .dues-table[hidden], .admin-table[hidden] { display: none; }
  .dues-table thead, .admin-table thead { display: none; }
  .dues-table tr, .admin-table tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .dues-table tr:last-child, .admin-table tr:last-child { border-bottom: 0; }
  .dues-table td, .admin-table td {
    display: inline-block;
    margin-right: 14px;
    padding: 0;
    text-align: left;
    border: 0;
  }
  .dues-table td:first-child, .admin-table td:first-child { display: block; font-weight: 600; }
  .dues-table td[data-label]:not(:first-child)::before,
  .admin-table td[data-label]:not(:first-child)::before { content: attr(data-label) ": "; color: var(--muted); }
  .dues-table .num, .admin-table .num { text-align: left; }
  .admin-table .actions { display: block; text-align: left; white-space: normal; }
  .admin-table .actions button + button { margin-left: 0; }
  .admin-table .actions button { margin-right: 14px; }

  /* Consultation: Save lives in a bar fixed above the tab bar, so it is in reach whatever
     the pad or a long transcript has pushed down the page. */
  #save-prescription {
    position: fixed;
    right: 16px;
    bottom: calc(56px + 8px + env(safe-area-inset-bottom));
    left: 16px;
    z-index: 9;
    margin: 0;
    box-shadow: 0 4px 16px rgb(22 32 44 / 20%);
  }
  body[data-role="doctor"]:has(#visit-view:not([hidden])) main {
    padding-bottom: calc(56px + 64px + 32px + env(safe-area-inset-bottom));
  }
}

/* --- operator home: Queue and Billing tabs (module 15) --- */
/* `.tabs` and `.row-start` set `display: flex`, which beats the UA's `[hidden]` rule. */
#operator-tabs[hidden], .checkin-doctor[hidden] { display: none; }
.checkin-doctor { gap: 10px; margin: 0 0 8px; }
.checkin-doctor label { margin: 0; }
.checkin-doctor select { flex: 1; min-width: 0; width: auto; }
.notice { margin: 0 0 8px; padding: 10px 14px; font-weight: 600; color: var(--accent); background: #eaf1fb; border-radius: 8px; }
#register-new { margin-top: 4px; }
#operator-queue h2 { margin: 18px 0 0; }
.desk-line h3 { margin: 14px 0 0; font-size: 1rem; }
.list li.desk-row { flex-wrap: wrap; gap: 4px 12px; }
.desk-row .grow { min-width: 0; }
.entry-status { display: block; font-size: 0.85rem; color: var(--muted); }
.status-with_doctor { color: var(--accent); font-weight: 600; }
.desk-actions { display: flex; gap: 20px; }

/* --- patient page: header card, tabs, reports (module 16) --- */
.patient-card { margin-top: 8px; }
.patient-card h1 { overflow-wrap: anywhere; }
.patient-card p { margin: 0; }
.patient-action-row { flex-wrap: wrap; margin-top: 12px; }
.patient-action-row select { width: auto; min-width: 0; }
.patient-action-row select[hidden] { display: none; }
.patient-card .notice { margin: 10px 0 0; }
.patient-tabs { background: var(--bg); }
.patient-tabs .tab { min-height: 44px; }
#ppanel-visits #start-visit { margin-bottom: 4px; }
.visit-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.report-list .report-group h3 { margin: 18px 0 0; font-size: 1rem; }
.report-thumb { flex: none; width: 48px; height: 48px; object-fit: cover; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pdf-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--danger);
  background: #fbe3e4;
  border-radius: 6px;
}
.report-full:fullscreen { object-fit: contain; background: #000; }
.record-pdf { display: flex; align-items: center; gap: 14px; padding: 18px 0; }

/* Add report: five large chips, one radio each; the checked one is filled. */
.type-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; border: none; }
.type-chips legend { margin-bottom: 6px; padding: 0; font-size: 0.85rem; color: var(--muted); }
.type-chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin: 0;
  padding: 0 14px;
  font-size: 0.95rem;
  color: var(--ink);
  background: #e7edf4;
  border-radius: 999px;
  cursor: pointer;
}
.type-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.type-chip:has(input:checked) { color: #fff; background: var(--accent); }
.type-chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.report-pick { flex-wrap: wrap; margin-top: 14px; }
.button-like {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin: 0;
  padding: 0 14px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--accent);
  background: #eaf1fb;
  border-radius: 7px;
  cursor: pointer;
}
#report-chosen { margin: 8px 0 0; overflow-wrap: anywhere; }

/* Reports over the consultation: a right-hand panel from 600 px, the whole screen below. */
.reports-sheet {
  width: min(420px, 100vw);
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0 0 0 auto;
  padding: 16px 20px;
  color: var(--ink);
  background: var(--bg);
  border: none;
  border-left: 1px solid var(--line);
}
.reports-sheet::backdrop { background: rgb(22 32 44 / 0.35); }
.reports-sheet h2 { margin: 0; }

@media (max-width: 599px) {
  /* The tabs stay in reach while a long history or visit list scrolls under them. */
  .patient-tabs { position: sticky; top: 0; z-index: 5; margin: 0 -16px 14px; padding: 6px 16px; }
  .patient-tabs .tab { flex: 1; }
  .reports-sheet { width: 100vw; border-left: none; }
}
