/* Clinic layout is shared across work areas. These rules assign the same component
   roles to reception, clinical records, department tools and patient booking. */
:root {
  color: var(--ink);
  background: var(--surface);
  font: 100%/1.5 var(--font-body);
  font-variant-numeric: tabular-nums;
}
body { margin: 0; background: var(--surface); color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
button, input, textarea, select, summary, a { accent-color: var(--plum); }
a { color: var(--plum); text-underline-offset: .19em; }
:focus-visible { outline: 3px solid var(--plum); outline-offset: 3px; }
button:disabled { opacity: .58; }
h1, h2, h3, .patient-name { font-family: var(--font-display); font-weight: bold; letter-spacing: -.035em; }
h1, .patient-name { font-size: var(--type-title); line-height: var(--leading-title); }
h2 { font-size: var(--type-section); line-height: var(--leading-section); }
h3, .care-listing h2 { font-size: var(--type-subheading); line-height: var(--leading-subheading); }
:is(small, dt, .quiet, .date, .tagline, .scope-note, .location-note, .toolbar-note, .reviewline, .token, .care-topics, .result-count, .receiptstamp, .booking-foot, .chartpath, .casemeta, .caselabel, .staff-context, .context label, .row small, .slip) {
  color: var(--muted); font: .875rem/1.43 var(--font-body);
}
.lead p, .intro, .setup-hint, .booking-sheet .intro { color: var(--muted); }
body .work { padding: 32px; }
body .panel { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); padding: 24px; min-width: 0; }
body .context, dialog .section { background: var(--surface); color: var(--ink); }
.context { border-bottom: 1px solid var(--line); }
.context .right { gap: 12px; }
.mobile-wordmark { display: none; }
.return-products, .link { color: var(--plum); font-weight: bold; text-decoration: underline; text-underline-offset: .19em; }
.return-products { min-height: 44px; display: inline-flex; align-items: center; }
:is(.button,.primary,.ghost,.tab,.link,.planbtn,.bookline,summary) { min-height: 44px; }
.button,.primary,.ghost { border-radius: 999px; font-weight: bold; padding: 8px 16px; line-height: 1.5; }
.button,.ghost { border: 1px solid var(--muted); color: var(--ink); background: var(--surface); }
.primary { border: 1px solid var(--action-primary-bg); background: var(--action-primary-bg); color: var(--action-primary-fg); }
.primary:hover { text-decoration: underline; text-underline-offset: .2em; }
:is(.button,.ghost,.bookline):hover { color: var(--ink); background: var(--butter); }
.link,.planbtn,.bookline { color: var(--ink); background: transparent; }
button.on { color: var(--success); }
.on::before { background: var(--success); }
select,input:not([type=checkbox]),textarea { color: var(--ink); background: var(--surface); border: 1px solid var(--muted); border-radius: 12px; min-height: 44px; }
textarea:focus-visible,input:focus-visible,select:focus-visible { outline-offset: 2px; }
input[type=checkbox] { min-width: 18px; min-height: 18px; }
.context select { padding: 7px 26px 7px 10px; font-weight: bold; max-width: 100%; }
:where(.entry,.booking-sheet) :is(input:not([type=checkbox]),select,textarea) { padding: 9px 12px; }
::placeholder { color: var(--muted); opacity: 1; }

.frame aside { color: var(--paper); background: var(--plum); border-right: none; }
aside .brand { border-color: var(--muted); padding-bottom: 22px; }
aside .brand img { display: block; }
aside nav { padding: 0; }
aside .nav-area { margin: 24px 0; }
aside .nav-area h3 { color: var(--paper); font: bold .875rem/1.43 var(--font-body); letter-spacing: 0; margin: 0 8px 8px; }
aside nav button { color: var(--paper); background: transparent; min-height: 44px; font: 1rem/1.35 var(--font-body); }
aside :focus-visible { outline-color: var(--paper); }
aside nav button:hover { text-decoration: underline; text-underline-offset: .2em; }
aside nav button[aria-current=page], .modulelist [aria-current=page] {
  background: var(--selection-bg); color: var(--selection-fg); font-weight: bold; box-shadow: inset 4px 0 var(--plum);
}
aside nav button[aria-current=page] { border-left: 4px solid var(--poppy); box-shadow: none; }
:is(.filters,.actions,.slotlist,.booking-times,.mode-switch) button[aria-pressed=true],.tab.chosen,.step.current {
  background: var(--selection-bg); color: var(--selection-fg); font-weight: bold;
}
.tab { padding: 8px 12px; color: var(--muted); border-radius: 12px 12px 0 0; }
.tab.chosen { box-shadow: inset 0 -3px var(--plum); }
.row, .bookline, .lineitem, .orderline { font-size: .875rem; line-height: 1.43; }
.row { padding: 12px 8px; }
.row:hover { background: var(--butter); }
.row.sel,.row[aria-pressed=true] { color: var(--selection-fg); background: var(--selection-bg); box-shadow: inset 3px 0 var(--plum); }
.row.sel :is(small,.token) { color: var(--ink); }
.pill, .step { font: .875rem/1.43 var(--font-body); background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.pill { padding: 3px 9px; }
.pill.saved { color: var(--success); }
.pill.saved::before { content: "✓ "; }
.pill.needs-review { color: var(--warning); }
.pill.needs-review::before { content: "⚠ "; }
.step.current { border-color: var(--plum); }
.step.current::before { content: '● '; }
body .summary { border: none; border-radius: 24px; background: var(--plum); color: var(--paper); }
.sum b,.sum span { color: var(--paper); }
.sum b { font: bold 2rem/1.14 var(--font-display); }
.sum span { font: .875rem/1.43 var(--font-body); }
.sum+.sum::before { background: var(--muted); }
body .ticket { background: var(--butter); color: var(--ink); border-color: var(--line); border-radius: 24px; }
.ticket .huge { font: bold 2.5rem/1.05 var(--font-display); color: var(--ink); }
.ticket h2 { font-size: 1.5rem; }
.ticket .slip { font-weight: bold; }
.ticket .rule { margin-block: 16px; }
.ticket .primary { background: var(--action-primary-bg); color: var(--action-primary-fg); }
.kv dd { color: var(--ink); }
.identity,.portal .hero,.confirmbar,.setup-progress,.device-preview,.room-stage { color: var(--ink); background: var(--butter); }
.identity { border-left: 4px solid var(--poppy); }
.portal .hero,.setup-progress { border-radius: 24px; }
.log { border-left-color: var(--poppy); }
.notice,.textwarn,.form-warning { color: var(--warning); }
.notice { background: var(--surface); border: 1px solid var(--warning); }
.notice::before,.form-warning::before { content: '⚠ '; }
.entry [aria-invalid=true] { border-color: var(--error); }
.statusmsg { background: var(--surface); color: var(--ink); border-left: 4px solid var(--poppy); }
.setup-progress progress { accent-color: var(--plum); }
.bed { color: var(--ink); background: var(--surface); border-color: var(--muted); }
.bed.occupied { border-left: 4px solid var(--plum); }
.bed.clean { background: var(--butter); }
.bed[aria-pressed=true] { background: var(--selection-bg); outline: 2px solid var(--plum); }
.bed[aria-pressed=true] small { color: var(--ink); }

.casebar { background: var(--plum); color: var(--paper); border-radius: 24px; }
.casebar :is(small,.casemeta,.caselabel,.chartpath,.link) { color: var(--paper); }
.casebar .caseid { border-color: var(--muted); }
.casebar :focus-visible { outline-color: var(--paper); }
.vital-strip,.docpaper { background: var(--surface); color: var(--ink); }
.vital-strip b { font: bold 1.25rem/1.3 var(--font-body); }
.vital-strip em { color: var(--muted); font: .875rem/1.43 var(--font-body); }
.segment h3 { font: bold 1rem/1.5 var(--font-body); letter-spacing: 0; }
.segment p { font-size: 1rem; line-height: 1.5; }
.planbtn::before,.diagram li::before { background: var(--butter); color: var(--ink); }
.bill-table th:not(:first-child),.bill-table td:not(:first-child) { text-align: right; }
.bill-table { font-size: .875rem; line-height: 1.43; }
.bill-table thead th { color: var(--ink); }
.bill-table-scroll { width: 100%; }
dialog { background: var(--surface); color: var(--ink); border: 1px solid var(--muted); border-radius: 24px; }
dialog::backdrop { background: color-mix(in srgb,var(--plum) 60%, transparent); }
.modulelist { padding-bottom: 8px; }

.booking-header,.booking-foot,.patient-mode #patient-booking { background: var(--surface); color: var(--ink); }
.booking-header { flex-wrap: wrap; }
.booking-header>span { flex: 1; color: var(--muted); font-size: .875rem; }
.booking-header .brand img { min-width: 84px; }
.booking-sheet { --gutter: clamp(16px,4vw,64px); }
.patient-mode { --gutter: clamp(16px,4vw,64px); }
.booking-sheet .care-hero { background: var(--butter); border-radius: 24px; padding: clamp(20px,4vw,44px); }
.care-hero h1,.booking-sheet h1 { font-size: var(--type-title); line-height: var(--leading-title); }
.booking-directory h2 { margin: 0; }
.booking-directory p { margin: 8px 0; }
.booking-directory a { display: block; padding: 12px 0; font-weight: bold; }
.booking-header a,.booking-sheet label,.clinic-offer small,.care-listing p,.device-preview p { line-height: 1.5; }
.clinic-line { color: var(--ink); }
.clinic-line span+span { color: var(--ink); font-weight: bold; text-decoration: underline; text-underline-offset: .19em; }
.booking-sheet .button,.booking-sheet .primary { padding: 10px 16px; }
.patient-mode .booking-sheet .link { color: var(--ink); }
.mode-switch { background: var(--surface); border: 1px solid var(--muted); }
.mode-switch button { color: var(--ink); }
.location-picker .link { vertical-align: middle; }
.review-handoff { background: var(--butter); color: var(--ink); }
.visit-pass { background: var(--surface); border-radius: 24px; }
.pass-heading,.pass-schedule { background: var(--butter); color: var(--ink); }
.pass-heading p,.pass-schedule small,.pass-reference span { color: var(--muted); }
.pass-status { color: var(--success); font-size: .875rem; font-weight: bold; }
.pass-date { background: var(--surface); color: var(--ink); }
.pass-date strong { font: bold 1.65rem/1.1 var(--font-display); }
.pass-schedule strong { font-size: 1.25rem; }
.room-status,.room-ready { color: var(--ink); font-weight: bold; }
.room-status::before { background: var(--poppy); }
.doctor-stage { background: var(--plum); color: var(--paper); }
.doctor-stage .room-status,.doctor-stage .room-ready,.doctor-stage small { color: var(--paper); }
.doctor-stage :focus-visible { outline-color: var(--paper); }
.booking-foot { font-size: .875rem; line-height: 1.43; color: var(--muted); }
*:disabled { cursor: default; }
@media(max-width:850px) {
  body .work { padding: 24px 16px; }
  .mobile-wordmark { display: inline-flex; align-items: center; min-height: 44px; }
  .mobile-wordmark img { display: block; }
  .context .right { width: auto; justify-content: flex-start; }
  .context .right .button { min-height: 44px; }
}
@media(max-width:625px) {
  body .panel { padding: 16px; }
  .context { gap: 8px; }
  .context .right { width: 100%; gap: 8px 12px; }
  .context .right .button { padding-inline: 12px; }
  .booking-header { gap: 8px 12px; }
  .return-products { font-size: .875rem; }
  .summary .sum { padding: 12px 8px; }
  .summary .sum b { font-size: 1.75rem; }
  .row { grid-template-columns: 26px minmax(70px,1fr) minmax(58px,auto); }
  .filters { gap: 4px 8px; }
  .tab { padding-inline: 8px; }
  .visit-pass .pass-reference { flex-wrap: wrap; }
  .casebar { padding: 16px; }
  .casebar .caseid { padding-left: 12px; }
}
@media print {
  body, .docpaper { background: white; color: black; }
  .docpaper { border: none; }
}

/* A quieter provider rail and a single scan line across visits, arrival and handoff. */
.frame aside {
  background: var(--surface);
  color: var(--ink);
  border-right: 1px solid var(--line);
}
aside .brand { border-color: var(--line); }
aside .nav-area { margin-block: 20px; }
aside .nav-area h3 { color: var(--muted); margin-bottom: 3px; }
aside nav button { color: var(--ink); font-size: .9375rem; padding: 8px 10px; }
aside nav button[aria-current=page] { box-shadow: inset 3px 0 var(--plum); border: 0; }
aside :focus-visible { outline-color: var(--plum); }
.desk-search { display: grid; gap: 6px; font-weight: bold; margin: 12px 0 20px; }
.desk-search input { width: 100%; padding: 10px 13px; font-weight: normal; }
.modulelist { gap: 6px 10px; }
.nav-area[hidden],.modulelist [hidden] { display: none; }
#desk-match:empty { display: none; }
.queue-workspace { display: grid; grid-template-columns: minmax(0,1.8fr) minmax(230px,.8fr); gap: 32px; align-items: start; }
.visit-list { min-width: 0; container: visit-queue / inline-size; }
.queue-row .field-label { display: none; }
.queue-filters { gap: 6px; padding-bottom: 12px; border-color: var(--line); }
.queue-filters .tab { border-radius: 6px; padding: 8px 10px; box-shadow: none; font-size: .875rem; }
.queue-filters .tab.chosen { text-decoration: underline; text-underline-offset: 4px; }
.queue-filters .tab span { font-size: .82rem; margin-left: 3px; }
.queue-row,.queue-head { display: grid; grid-template-columns: 52px minmax(96px,1.4fr) minmax(56px,.48fr) minmax(89px,.75fr); gap: 12px; align-items: center; padding-inline: 12px; }
.queue-head { color: var(--muted); font: bold .875rem/1.4 var(--font-body); padding-block: 12px 8px; border-bottom: 1px solid var(--line); }
.queue-row { width: 100%; padding-block: 12px; border-radius: 0; text-align: start; }
.queue-row strong { font: bold 1rem/1.35 var(--font-body); }
.queue-row small { margin-top: 2px; }
.queue-state { font-size: .875rem; }
.queue-row .arrival,.token { font-variant-numeric: tabular-nums; }
body .visit-detail { border-radius: 0; padding: 16px 0 0 24px; border: 0; border-left: 1px solid var(--line); color: var(--ink); background: transparent; }
.visit-detail h2 { margin: 5px 0 2px; }
.visit-detail dl { margin: 18px 0 4px; }
body .inline-visit { display: flex; gap: 8px 14px; align-items: center; justify-content: space-between; border-radius: 0; padding: 8px 12px 12px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); }
.inline-visit small { max-width: 24ch; }
body .inline-visit :is(.primary,.link) { width: auto; margin: 0; flex: none; }
.casebar { color: var(--ink); background: var(--butter); border-radius: 12px; }
.casebar :is(small,.casemeta,.caselabel,.chartpath,.link) { color: var(--ink); }
.casebar :focus-visible { outline-color: var(--plum); }
.docgrid .panel,.billing-grid .panel { border-radius: 0; border: 0; border-top: 1px solid var(--line); padding: 16px 0; }
.docgrid,.billing-grid { column-gap: 32px; }
@media (min-width: 851px) {
  .frame aside { align-self: start; position: sticky; top: 0; max-height: 100vh; overflow-y: auto; }
}
@media (max-width: 1000px) and (min-width:701px) {
  .queue-workspace { gap: 16px; grid-template-columns: minmax(0,1.8fr) minmax(180px,.72fr); }
  .queue-row,.queue-head { grid-template-columns: 40px minmax(85px,1fr) 44px 6.5rem; gap: 6px; padding-inline: 6px; }
}
@media (max-width: 700px) {
  .queue-workspace { display: block; }
  .queue-filters { gap: 4px; }
  .queue-filters .tab { padding-inline: 6px; font-size: .875rem; }
  .queue-head,.queue-row { grid-template-columns: 37px minmax(76px,1fr) 44px 76px; gap: 5px; padding-inline: 6px; }
}

/* Keep the same field order on small screens while bringing the day's first work item into view. */
@media (max-width:700px) {
  .context {
    display: grid; grid-template-columns: 84px minmax(0,1fr) auto;
    align-items: center; gap: 2px 8px; padding: 6px 16px 9px;
  }
  .context .right { display: contents; }
  .mobile-wordmark { grid-column: 1; grid-row: 1; }
  .context .return-products { grid-column: 2; grid-row: 1; justify-self: end; }
  #screens { grid-column: 3; grid-row: 1; justify-self: end; }
  .facility-select { grid-column: 1 / 3; grid-row: 2; min-width: 0; }
  .facility-select label { clip-path: inset(50%); height: 1px; width: 1px; position: absolute; overflow: hidden; }
  .context select { font: bold .875rem/1.4 var(--font-body); width: 100%; padding-inline: 8px; }
  #connection { grid-column: 3; grid-row: 2; justify-self: stretch; font-size: .875rem; }
  .network-detail { display: none; }
  body .work { padding-top: 18px; }
  .is-reception .lead { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px; }
  .is-reception .lead .primary { font-size: .875rem; padding-inline: 12px; }
  .is-reception .lead p { margin-top: 4px; font-size: .875rem; }
  .queue-filters { flex-wrap: wrap; column-gap: 3px; padding-bottom: 8px; }
  .queue-head,.queue-row { grid-template-columns: 41px minmax(74px,1fr) 45px 78px; gap: 8px; }
  .casebar .caseid { border: 0; padding: 0; text-align: left; }
  .casebar:not(.bill-case) { display: grid; gap: 10px; }
  .casebar .caseid { display: flex; flex-wrap: wrap; column-gap: 8px; align-items: baseline; }
  .caseid small:last-child { flex-basis: 100%; }
}
/* From 390px the status column fits the cash desk note on one line and the patient column still fits a service. */
@media (min-width: 390px) and (max-width: 700px) {
  .queue-head,.queue-row { grid-template-columns: 41px minmax(74px,1fr) 45px 6.5rem; }
}
@media (max-width: 360px) {
  .is-reception .lead { display: flex; align-items: start; }
  .queue-head,.queue-row { gap: .5rem; grid-template-columns: 2.55rem minmax(0,1fr) 2.75rem 4.8125rem; padding-inline: 4px; }
  .context { padding-inline: 12px; gap: 2px 6px; }
  .context .return-products { font-size: .8125rem; }
}
@media (max-width:700px) {
  .context,.casebar,.content,.docgrid,.billing-grid,.section,.clinic-offer,.care-listing>div { min-width: 0; }
  .context .return-products,#screens,#connection { overflow-wrap: anywhere; min-width: 0; }
  .context #screens,.context #connection { max-width: 100%; }
  .inline-visit,.orderline,.lineitem,.editorhead { flex-wrap: wrap; }
  .inline-visit .primary,.chart-actions .link,.orderline .link,.pill { max-width: 100%; overflow-wrap: anywhere; }
  .vital-strip { grid-template-columns: repeat(auto-fit,minmax(min(100%,6.25rem),1fr)); }
  .vital-strip div,.caseid,.booking-sheet dd,.booking-sheet h1,.queue-state,.queue-name { min-width: 0; overflow-wrap: anywhere; }
  .bookline { flex-wrap: wrap; }
}
@media (max-width:700px) {
  .lead>div,.section>h2 { min-width: 0; max-width: 100%; }
  .work :is(h1,h2,h3) { overflow-wrap: anywhere; hyphens: auto; }
  .slotlist { grid-template-columns: repeat(auto-fit,minmax(min(100%,5.75rem),1fr)); }
  .summary { grid-template-columns: repeat(auto-fit,minmax(min(100%,6.3rem),1fr)); }
  .summary .sum { min-width: 0; overflow-wrap: anywhere; }
}

/* The shared column headings need room for four full labels. When enlarged
   type no longer fits, keep the same labels alongside each patient's values. */
@container visit-queue (max-width: 17rem) {
  .queue-head { display: none; }
  .queue-row { grid-template-columns: repeat(2,minmax(0,1fr)); gap: .45rem 1rem; align-items: start; padding: .55rem .35rem; }
  .queue-row .field-label { display: block; margin-bottom: .15rem; color: var(--ink); font: bold .875rem/1.43 var(--font-body); }
}

/* Keep encounter context available at each clinical handoff. */
.outpatient-visit { display:grid; gap:.3rem; margin:.3rem 0 1rem; max-width:40rem; color:var(--muted); font-size:.875rem; }
.outpatient-visit select { width:100%; min-width:0; padding:.45rem .6rem; color:var(--ink); font-size:1rem; }
.example-caption { color:var(--muted); font-size:.9rem; margin:0 0 1rem; }
.order-tools { display:flex; flex-wrap:wrap; gap:.5rem; justify-content:flex-end; }
.order-tools .link { padding:0 .35rem; }
.identity-candidates { padding-inline-start:1.2rem; }
.identity-check { display:flex; align-items:start; gap:.6rem; margin:1rem 0; }
#separate-walk-in { border-top:1px solid var(--line); margin-top:1rem; }
.entry[hidden] { display:none; }
@media (max-width:600px) {
  .orderline { flex-wrap:wrap; }
  .order-tools { justify-content:start; }
}
