/*
 * ClinicalMassage.UI presentational components (redesign spec #2911 § Components (presentational), plan T4).
 * Served at /_content/ClinicalMassage.UI/components.css, after tokens.css. Every rule is a pw- class on the
 * tokens: no framework classes, no raw colours (PresentationalComponentTests guards both).
 * Colour means status only; action blue marks the action to take.
 */

.pw-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.pw-icon { flex: none; }

/* Chips: status (icon + word + status colour) and type (neutral, never a status colour) */
.pw-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--pw-space-1);
  padding: 2px var(--pw-space-3);
  border-radius: var(--pw-radius-pill);
  font-family: var(--pw-font-body);
  font-size: var(--pw-fs-13);
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  background: var(--pw-neutral-bg);
  color: var(--pw-label);
}
.pw-chip--ok { background: var(--pw-ok-bg); color: var(--pw-ok-text); }
.pw-chip--warn { background: var(--pw-warn-bg); color: var(--pw-warn-text); }
.pw-chip--danger { background: var(--pw-danger-bg); color: var(--pw-danger-text); }
.pw-chip--info { background: var(--pw-tint); color: var(--pw-navy); }
.pw-chip--neutral { background: var(--pw-neutral-bg); color: var(--pw-label); }
.pw-chip--type { background: var(--pw-neutral-bg); color: var(--pw-label); }
.pw-chip__word { white-space: nowrap; }

/* Buttons: one primary per region. 44 px by default, 36 px dense. */
.pw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--pw-space-2);
  box-sizing: border-box;
  min-height: var(--pw-control-height);
  min-width: var(--pw-control-height-min);
  padding: 0 var(--pw-space-4);
  border: 1px solid transparent;
  border-radius: var(--pw-radius-control);
  font-family: var(--pw-font-body);
  font-size: var(--pw-fs-15);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}
.pw-btn--dense { min-height: var(--pw-control-height-dense); padding: 0 var(--pw-space-3); font-size: var(--pw-fs-13); }
.pw-btn--primary { background: var(--pw-action); color: var(--pw-white); }
.pw-btn--primary:hover { background: var(--pw-action-hover); color: var(--pw-white); text-decoration: none; }
.pw-btn--secondary { background: var(--pw-white); border-color: var(--pw-interactive-border); color: var(--pw-action); }
.pw-btn--secondary:hover { color: var(--pw-action-hover); text-decoration: none; }
.pw-btn--quiet { background: transparent; color: var(--pw-action); }
.pw-btn--quiet:hover { color: var(--pw-action-hover); text-decoration: underline; }
.pw-btn--danger { background: var(--pw-white); border-color: var(--pw-interactive-border); color: var(--pw-danger-text); }
.pw-btn--danger:hover { background: var(--pw-danger-bg); color: var(--pw-danger-text); text-decoration: none; }
.pw-btn:focus-visible,
.pw-metric:focus-visible,
.pw-filter-chip:focus-visible,
.pw-input:focus-visible { outline: var(--pw-focus-ring); outline-offset: var(--pw-focus-ring-offset); }

/* Metric tile: one colour, and a link */
.pw-metric {
  display: flex;
  flex-direction: column;
  gap: var(--pw-space-1);
  padding: var(--pw-space-4);
  border: 1px solid var(--pw-line);
  border-radius: var(--pw-radius-card-md);
  background: var(--pw-white);
  color: var(--pw-ink);
  text-decoration: none;
}
.pw-metric:hover { border-color: var(--pw-interactive-border); }
.pw-metric__value {
  font-family: var(--pw-font-heading);
  font-size: var(--pw-fs-28);
  font-weight: 700;
  color: var(--pw-navy);
  font-variant-numeric: tabular-nums;
}
.pw-metric__label { font-size: var(--pw-fs-13); color: var(--pw-muted); }

/* Record header */
.pw-record-header {
  display: flex;
  align-items: flex-start;
  gap: var(--pw-space-4);
  padding: var(--pw-space-4);
  border: 1px solid var(--pw-line);
  border-radius: var(--pw-radius-card-lg);
  background: var(--pw-white);
}
.pw-avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--pw-control-height);
  height: var(--pw-control-height);
  border-radius: var(--pw-radius-pill);
  background: var(--pw-avatar-bg);
  color: var(--pw-navy);
  font-family: var(--pw-font-heading);
  font-size: var(--pw-fs-15);
  font-weight: 700;
}
.pw-record-header__main { flex: 1; min-width: 0; }
.pw-record-header__name {
  margin: 0 0 var(--pw-space-2);
  font-family: var(--pw-font-heading);
  font-size: var(--pw-fs-22);
  font-weight: 700;
  color: var(--pw-navy);
}

/* Card with per-card Edit */
.pw-card {
  border: 1px solid var(--pw-line);
  border-radius: var(--pw-radius-card-md);
  background: var(--pw-white);
}
.pw-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--pw-space-3);
  padding: var(--pw-space-3) var(--pw-space-4);
  border-bottom: 1px solid var(--pw-line);
}
.pw-card__title {
  margin: 0;
  font-family: var(--pw-font-heading);
  font-size: var(--pw-fs-17);
  font-weight: 700;
  color: var(--pw-navy);
}
.pw-card__body { padding: var(--pw-space-4); color: var(--pw-ink); }

/* Side panel */
.pw-side-panel {
  box-sizing: border-box;
  border: 1px solid var(--pw-line);
  border-radius: var(--pw-radius-card-lg);
  background: var(--pw-surface-3);
}
.pw-side-panel__header { padding: var(--pw-space-3) var(--pw-space-4); border-bottom: 1px solid var(--pw-line); }
.pw-side-panel__title {
  margin: 0;
  font-family: var(--pw-font-heading);
  font-size: var(--pw-fs-17);
  font-weight: 700;
  color: var(--pw-navy);
}
.pw-side-panel__body { padding: var(--pw-space-4); color: var(--pw-ink); }

/* Filter bar and its toggle chips */
.pw-filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--pw-space-3); }
.pw-filter-bar__label { font-size: var(--pw-fs-13); font-weight: 600; color: var(--pw-label); }
.pw-filter-bar__chips { display: flex; flex-wrap: wrap; gap: var(--pw-space-2); }
.pw-input {
  box-sizing: border-box;
  min-height: var(--pw-control-height);
  padding: 0 var(--pw-space-3);
  border: 1px solid var(--pw-interactive-border);
  border-radius: var(--pw-radius-control);
  background: var(--pw-white);
  color: var(--pw-ink);
  font-family: var(--pw-font-body);
  font-size: var(--pw-fs-15);
}
.pw-filter-chip {
  min-height: var(--pw-control-height-dense);
  padding: 0 var(--pw-space-3);
  border: 1px solid var(--pw-interactive-border);
  border-radius: var(--pw-radius-pill);
  background: var(--pw-white);
  color: var(--pw-ink);
  font-family: var(--pw-font-body);
  font-size: var(--pw-fs-13);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
/* 36 px is for dense desktop actions only; at phone widths every control is 44 px */
@media (max-width: 640px) {
  .pw-btn--dense,
  .pw-filter-chip { min-height: var(--pw-control-height); }
}
/* Selected is aria-pressed (and a heavier weight and border), never colour alone */
.pw-filter-chip[aria-pressed="true"] {
  background: var(--pw-tint);
  border-color: var(--pw-navy);
  border-width: 2px;
  color: var(--pw-navy);
}

/* Alert banner */
.pw-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--pw-space-3);
  padding: var(--pw-space-3) var(--pw-space-4);
  border-radius: var(--pw-radius-card-sm);
  font-size: var(--pw-fs-15);
}
.pw-alert__body { flex: 1; min-width: 0; }
.pw-alert--ok { background: var(--pw-ok-bg); color: var(--pw-ok-text); }
.pw-alert--warn { background: var(--pw-warn-bg); color: var(--pw-warn-text); }
.pw-alert--danger { background: var(--pw-danger-bg); color: var(--pw-danger-text); }
.pw-alert--info { background: var(--pw-tint); color: var(--pw-navy); }
.pw-alert--neutral { background: var(--pw-neutral-bg); color: var(--pw-label); }

/* Dialog and confirm (plan T5; dialog.js). The surface fills the dialog box, so a click on the dialog
   element itself is a click on the backdrop. Base styles are set here, not left to a host reboot. */
.pw-dialog {
  box-sizing: border-box;
  width: min(520px, calc(100vw - 2 * var(--pw-space-4)));
  max-height: calc(100% - 2 * var(--pw-space-4));
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--pw-radius-card-lg);
  background: var(--pw-white);
  color: var(--pw-ink);
  font-family: var(--pw-font-body);
  font-size: var(--pw-fs-15);
  line-height: 1.5;
}
/* A neutral scrim. ::backdrop does not inherit custom properties on every supported browser (iPadOS 15-16),
   so this one colour is literal. */
.pw-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
/* The surface scrolls, never the dialog: a press on the dialog's own scrollbar would read as a backdrop click. */
.pw-dialog[open] { display: flex; flex-direction: column; }
.pw-dialog__surface { flex: 1 1 auto; min-height: 0; overflow: auto; padding: var(--pw-space-5); }
.pw-dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--pw-space-3);
}
.pw-dialog__title {
  margin: 0 0 var(--pw-space-3);
  font-family: var(--pw-font-heading);
  font-size: var(--pw-fs-17);
  font-weight: 700;
  color: var(--pw-navy);
}
.pw-dialog__close {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--pw-control-height);
  height: var(--pw-control-height);
  margin: calc(-1 * var(--pw-space-3)) calc(-1 * var(--pw-space-3)) 0 0;
  padding: 0;
  border: 0;
  border-radius: var(--pw-radius-control);
  background: transparent;
  color: var(--pw-label);
  cursor: pointer;
}
.pw-dialog__close:hover { background: var(--pw-neutral-bg); color: var(--pw-ink); }
.pw-dialog__body { color: var(--pw-ink); }
.pw-dialog__message { margin: 0 0 var(--pw-space-4); color: var(--pw-ink); }
.pw-dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--pw-space-3); }
.pw-dialog--confirm .pw-dialog__title { margin-bottom: var(--pw-space-2); }
/* A drawer (#3681; first on Settings > ADL): the same dialog pinned to the right edge, full height. */
.pw-dialog[data-drawer] { margin: 0 0 0 auto; height: 100%; max-height: 100%; width: min(440px, 100vw); border-radius: 0; }
.pw-dialog__close:focus-visible,
.pw-toast__dismiss:focus-visible { outline: var(--pw-focus-ring); outline-offset: var(--pw-focus-ring-offset); }

/* Toasts (plan T5; toast.js). One polite status region and one alert region, stacked bottom right. */
.pw-toasts {
  position: fixed;
  right: var(--pw-space-4);
  bottom: var(--pw-space-4);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--pw-space-2);
  width: min(380px, calc(100vw - 2 * var(--pw-space-4)));
  pointer-events: none;
}
.pw-toasts__region { display: flex; flex-direction: column; gap: var(--pw-space-2); }
.pw-toast {
  display: flex;
  align-items: flex-start;
  gap: var(--pw-space-3);
  box-sizing: border-box;
  padding: var(--pw-space-3) var(--pw-space-2) var(--pw-space-3) var(--pw-space-4);
  border: 1px solid var(--pw-line);
  border-left-width: 4px;
  border-radius: var(--pw-radius-card-sm);
  background: var(--pw-white);
  color: var(--pw-ink);
  font-family: var(--pw-font-body);
  font-size: var(--pw-fs-15);
  pointer-events: auto;
}
.pw-toast--success { border-left-color: var(--pw-ok-text); }
.pw-toast--info { border-left-color: var(--pw-navy); }
.pw-toast--warning { border-left-color: var(--pw-warn-text); background: var(--pw-warn-bg); color: var(--pw-warn-text); }
.pw-toast--error { border-left-color: var(--pw-danger-text); background: var(--pw-danger-bg); color: var(--pw-danger-text); }
.pw-toast__message { flex: 1; min-width: 0; margin: var(--pw-space-1) 0 0; }
.pw-toast__action { flex: none; margin: var(--pw-space-1) 0 0; color: var(--pw-action); font-weight: 600; }
.pw-toast__action:focus-visible { outline: var(--pw-focus-ring); outline-offset: var(--pw-focus-ring-offset); }
.pw-toast__dismiss {
  flex: none;
  width: var(--pw-control-height);
  height: var(--pw-control-height);
  margin: calc(-1 * var(--pw-space-2)) 0;
  padding: 0;
  border: 0;
  border-radius: var(--pw-radius-control);
  background: transparent;
  color: inherit;
  font-size: var(--pw-fs-22);
  line-height: 1;
  cursor: pointer;
}
@media (max-width: 640px) {
  .pw-toasts { right: var(--pw-space-2); left: var(--pw-space-2); width: auto; }
}
/* Form validation (plan T7; validate.js). The message under the field says what is wrong, so the red border is
   never the only signal. The summary region stays in place, empty, so its first message is announced. */
.pw-field-error { display: block; margin-top: var(--pw-space-1); color: var(--pw-danger-text); font-size: var(--pw-fs-13); }
.pw-field-error:empty { display: none; }
input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] { border-color: var(--pw-danger-text); box-shadow: 0 0 0 1px var(--pw-danger-text); }
.pw-validate-summary__body {
  margin-bottom: var(--pw-space-4);
  padding: var(--pw-space-3) var(--pw-space-4);
  border-radius: var(--pw-radius-card-sm);
  background: var(--pw-danger-bg);
  color: var(--pw-danger-text);
  font-size: var(--pw-fs-15);
}
.pw-validate-summary__title { margin: 0 0 var(--pw-space-1); font-weight: 700; }
.pw-validate-summary__list { margin: 0; padding-left: var(--pw-space-5); }

/* Tabs (plan T6; tabs.js). Selected is a heavier weight and an underline, never colour alone. */
.pw-tabs { font-family: var(--pw-font-body); }
.pw-tabs__list {
  display: flex;
  gap: var(--pw-space-1);
  overflow-x: auto;
  border-bottom: 1px solid var(--pw-line);
}
.pw-tabs__tab {
  flex: none;
  min-height: var(--pw-control-height);
  padding: 0 var(--pw-space-4);
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--pw-label);
  font-family: var(--pw-font-body);
  font-size: var(--pw-fs-15);
  font-weight: 400;
  white-space: nowrap;
  cursor: pointer;
}
.pw-tabs__tab:hover { color: var(--pw-ink); }
.pw-tabs__tab[aria-selected="true"] { border-bottom-color: var(--pw-action); color: var(--pw-navy); font-weight: 700; }
.pw-tabs__panel { padding-top: var(--pw-space-4); }
.pw-tabs__panel[hidden] { display: none; }
.pw-tabs__panel[aria-busy="true"] { min-height: var(--pw-control-height); }

/* Menu (plan T6; menu.js). Shown by its own --open class in both paths: with the popover API it is in the top layer;
   on iPadOS 15-16, which ignores the popover attribute, display and z-index here are all there is. */
.pw-menu { display: inline-block; position: relative; }
.pw-menu__list {
  display: none;
  position: fixed;
  inset: auto;
  box-sizing: border-box;
  min-width: 200px;
  max-width: calc(100vw - 2 * var(--pw-space-2));
  margin: 0;
  padding: var(--pw-space-1);
  overflow-y: auto;
  border: 1px solid var(--pw-line);
  border-radius: var(--pw-radius-card-sm);
  background: var(--pw-white);
  color: var(--pw-ink);
  font-family: var(--pw-font-body);
  box-shadow: var(--pw-shadow-popover);
}
.pw-menu__list--open { display: flex; flex-direction: column; z-index: 1900; }
.pw-menu__item {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  min-height: var(--pw-control-height-dense);
  padding: 0 var(--pw-space-3);
  border: 0;
  border-radius: var(--pw-radius-control);
  background: transparent;
  color: var(--pw-ink);
  font-family: var(--pw-font-body);
  font-size: var(--pw-fs-15);
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.pw-menu__item:hover,
.pw-menu__item:focus { background: var(--pw-tint); color: var(--pw-ink); text-decoration: none; }
.pw-menu__item:disabled,
.pw-menu__item[aria-disabled="true"] { color: var(--pw-muted); cursor: default; }

/* Switch (plan T6; switch.js). On moves the thumb as well as filling the track, so it never relies on colour alone. */
.pw-switch-field { display: inline-flex; align-items: center; gap: var(--pw-space-3); }
.pw-switch {
  position: relative;
  flex: none;
  box-sizing: border-box;
  width: 48px;
  height: 28px;
  padding: 0;
  border: 2px solid var(--pw-interactive-border);
  border-radius: var(--pw-radius-pill);
  background: var(--pw-white);
  cursor: pointer;
}
/* A form field, so a 44 px target at every width (spec § Shape and size): the hit area grows past the 28 px track */
.pw-switch::before {
  content: "";
  position: absolute;
  top: 50%;
  right: -2px;
  left: -2px;
  min-height: var(--pw-control-height);
  transform: translateY(-50%);
}
.pw-switch__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: var(--pw-radius-pill);
  background: var(--pw-interactive-border);
  transition: transform 0.15s ease;
}
.pw-switch[aria-checked="true"] { border-color: var(--pw-action); background: var(--pw-action); }
.pw-switch[aria-checked="true"] .pw-switch__thumb { background: var(--pw-white); transform: translateX(20px); }
.pw-switch:disabled { cursor: default; opacity: 0.5; }
.pw-switch__label {
  display: inline-flex;
  align-items: center;
  min-height: var(--pw-control-height);
  color: var(--pw-ink);
  font-family: var(--pw-font-body);
  font-size: var(--pw-fs-15);
  cursor: pointer;
}
@media (prefers-reduced-motion: reduce) {
  .pw-switch__thumb { transition: none; }
}
.pw-tabs__tab:focus-visible,
.pw-menu__item:focus-visible,
.pw-switch:focus-visible { outline: var(--pw-focus-ring); outline-offset: var(--pw-focus-ring-offset); }
/* At phone widths every target is 44 px, menu items included */
@media (max-width: 640px) {
  .pw-menu__item { min-height: var(--pw-control-height); }
}

/* Combobox (plan T9; combobox.js). The control looks like a pw-input; the real <select> stays in the form, visually
   hidden but rendered, so validators that skip hidden fields still check it. The highlighted option has an outline
   as well as a tint, and a selected one a check mark and weight, so neither relies on colour alone. */
.pw-combobox { position: relative; display: block; font-family: var(--pw-font-body); }
.pw-combobox__control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--pw-space-1);
  box-sizing: border-box;
  min-height: var(--pw-control-height);
  padding: var(--pw-space-1) var(--pw-space-6) var(--pw-space-1) var(--pw-space-3);
  position: relative;
  border: 1px solid var(--pw-interactive-border);
  border-radius: var(--pw-radius-control);
  background: var(--pw-white);
  color: var(--pw-ink);
  cursor: text;
}
/* The chevron: a bordered square turned 45 degrees, in the label colour */
.pw-combobox__control::after {
  content: "";
  position: absolute;
  right: var(--pw-space-3);
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -6px;
  border-right: 2px solid var(--pw-label);
  border-bottom: 2px solid var(--pw-label);
  transform: rotate(45deg);
  pointer-events: none;
}
.pw-combobox__control:focus-within { outline: var(--pw-focus-ring); outline-offset: var(--pw-focus-ring-offset); }
.pw-combobox--invalid .pw-combobox__control { border: 2px solid var(--pw-danger-text); }
.pw-combobox__input {
  flex: 1 1 8em;
  min-width: 4em;
  min-height: var(--pw-control-height-dense);
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--pw-ink);
  font-family: var(--pw-font-body);
  font-size: var(--pw-fs-15);
}
.pw-combobox__input::placeholder { color: var(--pw-muted); opacity: 1; }
.pw-combobox__input:disabled { cursor: default; }
.pw-combobox__chips { display: contents; }
.pw-combobox__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--pw-space-1);
  max-width: 100%;
  padding: 0 0 0 var(--pw-space-3);
  border-radius: var(--pw-radius-pill);
  background: var(--pw-neutral-bg);
  color: var(--pw-ink);
  font-size: var(--pw-fs-13);
  font-weight: 600;
}
.pw-combobox__chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pw-combobox__chip-remove,
.pw-combobox__clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--pw-control-height-min);
  min-height: var(--pw-control-height-min);
  margin: 0;
  padding: 0 var(--pw-space-2);
  border: 0;
  border-radius: var(--pw-radius-pill);
  background: transparent;
  color: var(--pw-label);
  font-family: var(--pw-font-body);
  font-size: var(--pw-fs-17);
  line-height: 1;
  cursor: pointer;
}
.pw-combobox__chip-remove:hover,
.pw-combobox__clear:hover { background: var(--pw-tint); color: var(--pw-ink); }
.pw-combobox__chip-remove:focus-visible,
.pw-combobox__clear:focus-visible { outline: var(--pw-focus-ring); outline-offset: 0; }
.pw-combobox__clear[hidden],
.pw-combobox__popup[hidden],
.pw-combobox__message[hidden] { display: none; }
.pw-combobox__popup {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 1900;
  margin-top: var(--pw-space-1);
  box-sizing: border-box;
  border: 1px solid var(--pw-line);
  border-radius: var(--pw-radius-card-sm);
  background: var(--pw-white);
  box-shadow: var(--pw-shadow-popover);
}
.pw-combobox__listbox {
  max-height: 280px;
  margin: 0;
  padding: var(--pw-space-1);
  overflow-y: auto;
  list-style: none;
}
.pw-combobox__listbox:empty { display: none; }
.pw-combobox__option {
  display: flex;
  align-items: center;
  gap: var(--pw-space-2);
  box-sizing: border-box;
  min-height: var(--pw-control-height-dense);
  padding: var(--pw-space-1) var(--pw-space-3);
  border-radius: var(--pw-radius-control);
  color: var(--pw-ink);
  font-size: var(--pw-fs-15);
  cursor: pointer;
}
.pw-combobox__option::before { content: ""; flex: none; width: 1em; }
.pw-combobox__option[aria-selected="true"] { font-weight: 600; }
.pw-combobox__option[aria-selected="true"]::before { content: "\2713"; color: var(--pw-navy); }
.pw-combobox__option:hover { background: var(--pw-surface-3); }
.pw-combobox__option--active,
.pw-combobox__option--active:hover { background: var(--pw-tint); outline: 2px solid var(--pw-navy); outline-offset: -2px; }
.pw-combobox__option[aria-disabled="true"] { color: var(--pw-muted); cursor: default; }
.pw-combobox__message { padding: var(--pw-space-3); color: var(--pw-muted); font-size: var(--pw-fs-15); }
/* The real field: rendered (so a validator that skips :hidden fields still checks it) but out of sight */
.pw-combobox__field {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
}
@media (max-width: 640px) {
  /* pw-combobox: every option, chip remove and clear button is a 44 px target at phone width */
  .pw-combobox__option { min-height: var(--pw-control-height); }
  .pw-combobox__chip-remove,
  .pw-combobox__clear { min-width: var(--pw-control-height); min-height: var(--pw-control-height); }
}

/* Grid (plan T8; grid.js). A semantic table: headers on surface-2, sortable headers are buttons, the sorted column
   carries aria-sort and an arrow, and a selected row has a checked box as well as the tint, never colour alone. */
.pw-grid { font-family: var(--pw-font-body); color: var(--pw-ink); }
.pw-grid > .pw-filter-bar { margin-bottom: var(--pw-space-4); }
.pw-grid__table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--pw-line);
  border-radius: var(--pw-radius-card-md);
  background: var(--pw-white);
  font-size: var(--pw-fs-15);
}
.pw-grid__table th,
.pw-grid__table td {
  padding: var(--pw-space-3) var(--pw-space-4);
  border-bottom: 1px solid var(--pw-line);
  text-align: left;
  vertical-align: middle;
}
.pw-grid__table thead th {
  background: var(--pw-surface-2);
  color: var(--pw-ink);
  font-size: var(--pw-fs-13);
  font-weight: 700;
  white-space: nowrap;
}
.pw-grid__table thead th:first-child { border-top-left-radius: var(--pw-radius-card-md); }
.pw-grid__table thead th:last-child { border-top-right-radius: var(--pw-radius-card-md); }
.pw-grid__table tbody tr:last-child > td { border-bottom: 0; }
.pw-grid__table[aria-busy="true"] tbody { opacity: 0.6; }
.pw-grid__sort {
  display: inline-flex;
  align-items: center;
  gap: var(--pw-space-1);
  min-height: var(--pw-control-height-min);
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.pw-grid__sort:hover { color: var(--pw-action-hover); }
.pw-grid__sort-icon { display: inline-block; min-width: 1em; }
.pw-grid__table th[aria-sort="ascending"] .pw-grid__sort-icon::after { content: "\25B2"; }
.pw-grid__table th[aria-sort="descending"] .pw-grid__sort-icon::after { content: "\25BC"; }
.pw-grid__select { width: 1%; }
.pw-grid__checkbox { width: 20px; height: 20px; margin: 2px; accent-color: var(--pw-action); cursor: pointer; }
.pw-grid__row--selected > td { background: var(--pw-tint); }
.pw-grid__actions { width: 1%; white-space: nowrap; text-align: right; }
.pw-grid__empty > td { padding: var(--pw-space-6) var(--pw-space-4); color: var(--pw-muted); text-align: center; }
.pw-grid__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--pw-space-3) var(--pw-space-5);
  padding: var(--pw-space-4) 0;
}
.pw-grid__size { display: inline-flex; align-items: center; gap: var(--pw-space-2); }
.pw-grid__size-label { color: var(--pw-muted); font-size: var(--pw-fs-13); }
.pw-grid__size-select { min-height: var(--pw-control-height-dense); }
.pw-grid__info { margin: 0; color: var(--pw-muted); font-size: var(--pw-fs-13); font-variant-numeric: tabular-nums; }
.pw-grid__pager { display: flex; flex-wrap: wrap; align-items: center; gap: var(--pw-space-2); margin-left: auto; }
.pw-grid__page {
  min-width: var(--pw-control-height-dense);
  min-height: var(--pw-control-height-dense);
  padding: 0 var(--pw-space-2);
  border: 1px solid transparent;
  border-radius: var(--pw-radius-control);
  background: transparent;
  color: var(--pw-action);
  font-family: var(--pw-font-body);
  font-size: var(--pw-fs-13);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.pw-grid__page:hover { color: var(--pw-action-hover); text-decoration: underline; }
/* The current page is aria-current, shown by a border and weight as well as the fill */
.pw-grid__page[aria-current="page"] { border-color: var(--pw-navy); background: var(--pw-tint); color: var(--pw-navy); font-weight: 700; }
.pw-grid__gap { color: var(--pw-muted); }
.pw-grid__nav { white-space: nowrap; }
.pw-grid__sort:focus-visible,
.pw-grid__page:focus-visible,
.pw-grid__checkbox:focus-visible { outline: var(--pw-focus-ring); outline-offset: var(--pw-focus-ring-offset); }

@media (max-width: 640px) {
  /* pw-grid stacks at phone width: each row is a card, each cell labelled by its header (data-label, set by
     grid.js). grid.js restores the table roles that display: block drops. */
  .pw-grid__table,
  .pw-grid__table tbody,
  .pw-grid__table td { display: block; }
  .pw-grid__table { border: 0; background: transparent; }
  .pw-grid__table tr {
    display: block;
    margin-bottom: var(--pw-space-3);
    border: 1px solid var(--pw-line);
    border-radius: var(--pw-radius-card-sm);
    background: var(--pw-white);
  }
  .pw-grid__table td {
    display: flex;
    gap: var(--pw-space-3);
    justify-content: space-between;
    align-items: center;
    min-height: var(--pw-control-height);
    box-sizing: border-box;
    text-align: right;
  }
  .pw-grid__table td::before {
    content: attr(data-label);
    flex: none;
    color: var(--pw-label);
    font-size: var(--pw-fs-13);
    font-weight: 600;
    text-align: left;
  }
  /* The header row stays: it holds the sort buttons and Select all, laid out as a wrapping row of controls. */
  .pw-grid__table thead { display: block; }
  .pw-grid__table thead tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--pw-space-2);
    border: 0;
    background: transparent;
  }
  .pw-grid__table thead th { display: block; padding: 0; border: 0; background: transparent; }
  .pw-grid__th--static {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .pw-grid__sort {
    min-height: var(--pw-control-height);
    padding: 0 var(--pw-space-3);
    border: 1px solid var(--pw-interactive-border);
    border-radius: var(--pw-radius-pill);
    background: var(--pw-white);
  }
  .pw-grid__table thead .pw-grid__select { display: flex; align-items: center; min-height: var(--pw-control-height); }
  .pw-grid__table tbody tr:last-child > td { border-bottom: 1px solid var(--pw-line); }
  .pw-grid__table tr > td:last-child { border-bottom: 0; }
  .pw-grid__empty > td { justify-content: center; }
  .pw-grid__checkbox { width: 24px; height: 24px; }
  .pw-grid__select,
  .pw-grid__actions { width: auto; }
  .pw-grid__page,
  .pw-grid__size-select { min-width: var(--pw-control-height); min-height: var(--pw-control-height); }
  .pw-grid__pager { margin-left: 0; }
}

/* Stepper (plan T10; stepper.js). The current step is aria-current="step", shown by the navy fill and a heavier
   weight; a finished step has a check mark and the words "(done)", so neither relies on colour alone. Horizontal by
   default (New client); pw-stepper--vertical puts the list beside the step above phone width (SOAP builder). */
.pw-stepper { display: block; font-family: var(--pw-font-body); color: var(--pw-ink); }
.pw-stepper__list {
  display: grid;
  /* Whole steps wrap onto a new row when the row is too narrow; a label never breaks inside a word (#4303) */
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: var(--pw-space-3);
  margin: 0 0 var(--pw-space-5);
  padding: 0;
  list-style: none;
}
.pw-stepper__item { margin: 0; padding: 0; }
.pw-stepper__step {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: var(--pw-space-3);
  box-sizing: border-box;
  width: 100%;
  min-height: var(--pw-control-height);
  padding: var(--pw-space-3) var(--pw-space-4);
  border: 1px solid var(--pw-interactive-border);
  border-radius: var(--pw-radius-card-sm);
  background: var(--pw-white);
  color: var(--pw-ink);
  font-family: var(--pw-font-body);
  font-size: var(--pw-fs-17);
  text-align: left;
  cursor: pointer;
}
.pw-stepper__step[aria-disabled="true"] { border-style: dashed; color: var(--pw-muted); cursor: default; }
.pw-stepper__step[aria-current="step"] { background: var(--pw-navy); border-color: var(--pw-navy); color: var(--pw-white); font-weight: 700; }
.pw-stepper__step:focus-visible { outline: var(--pw-focus-ring); outline-offset: var(--pw-focus-ring-offset); }
.pw-stepper__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--pw-radius-pill);
  background: var(--pw-tint);
  color: var(--pw-navy);
  font-size: var(--pw-fs-13);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pw-stepper__step[aria-current="step"] .pw-stepper__num { background: var(--pw-white); color: var(--pw-navy); }
/* Done: the number gives way to a check mark (a bordered corner turned 45 degrees) on the ok chip colours */
.pw-stepper__step[data-pw-step-state="done"] .pw-stepper__num { background: var(--pw-ok-bg); color: transparent; position: relative; }
.pw-stepper__step[data-pw-step-state="done"] .pw-stepper__num::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 11px;
  margin-top: -3px;
  border: solid var(--pw-ok-text);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.pw-stepper__label { min-width: 0; }
.pw-stepper__hint { grid-column: 2; font-size: var(--pw-fs-13); font-weight: 400; color: var(--pw-muted); }
.pw-stepper__step[aria-current="step"] .pw-stepper__hint { color: var(--pw-white); }
.pw-stepper__done { font-weight: 400; }
/* The step announcements' live region; pw-visually-hidden keeps it off screen */
.pw-stepper__status { position: absolute; }
.pw-stepper__panel {
  box-sizing: border-box;
  padding: var(--pw-space-5);
  border: 1px solid var(--pw-line);
  border-radius: var(--pw-radius-card-lg);
  background: var(--pw-white);
}
.pw-stepper__panel[hidden] { display: none; }
.pw-stepper__heading {
  margin: 0 0 var(--pw-space-4);
  font-family: var(--pw-font-heading);
  font-size: var(--pw-fs-22);
  font-weight: 700;
  color: var(--pw-navy);
}
/* Focus lands on the heading when a step opens; it is not a control, so it shows no ring */
.pw-stepper__heading:focus { outline: none; }
.pw-stepper__nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--pw-space-3);
  margin-top: var(--pw-space-5);
  padding-top: var(--pw-space-4);
  border-top: 1px solid var(--pw-line);
}
.pw-stepper__nav > [data-pw-stepper-back] { margin-right: auto; }
@media (min-width: 641px) {
  .pw-stepper--vertical { display: grid; grid-template-columns: minmax(200px, 280px) minmax(0, 1fr); gap: var(--pw-space-5); align-items: start; }
  .pw-stepper--vertical > .pw-stepper__list { grid-template-columns: none; grid-auto-flow: row; grid-auto-columns: auto; margin: 0; }
  .pw-stepper--vertical > .pw-stepper__panel { grid-column: 2; grid-row: 1; }
}
@media (max-width: 640px) {
  /* pw-stepper: every step stays a 44 px target; only the current one keeps its words on screen */
  /* 4 px apart, so six steps (the SOAP builder) fit 288 px: a 320 px screen less its gutters */
  .pw-stepper__list { display: flex; gap: var(--pw-space-1); }
  /* No :has() (iPadOS 15.0-15.3): every item may shrink, the 44 px steps cannot, so the current one gives way */
  .pw-stepper__item { flex: 0 1 auto; min-width: 0; }
  .pw-stepper__step[aria-current="step"] .pw-stepper__label,
  .pw-stepper__step[aria-current="step"] .pw-stepper__hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pw-stepper__step { min-width: var(--pw-control-height); min-height: var(--pw-control-height); padding: var(--pw-space-2); justify-content: center; }
  .pw-stepper__step:not([aria-current="step"]) { grid-template-columns: auto; }
  .pw-stepper__step:not([aria-current="step"]) .pw-stepper__label,
  .pw-stepper__step:not([aria-current="step"]) .pw-stepper__hint {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .pw-stepper__panel { padding: var(--pw-space-4); }
  .pw-stepper__nav > .pw-btn { flex: 1 1 auto; }
}

/* Date range (plan T10; daterange.js). The presets are toggle chips (aria-pressed); the dates are native inputs. */
.pw-daterange { margin: 0; padding: 0; border: 0; min-inline-size: 0; font-family: var(--pw-font-body); }
.pw-daterange__legend,
.pw-daterange > legend { margin-bottom: var(--pw-space-2); padding: 0; font-size: var(--pw-fs-13); font-weight: 600; color: var(--pw-label); }
.pw-daterange__presets { display: flex; flex-wrap: wrap; gap: var(--pw-space-2); margin-bottom: var(--pw-space-3); }
.pw-daterange__preset { font-variant-numeric: tabular-nums; }
.pw-daterange__fields { display: flex; flex-wrap: wrap; gap: var(--pw-space-4); }
.pw-daterange__field { display: flex; flex: 1 1 160px; flex-direction: column; gap: var(--pw-space-1); font-size: var(--pw-fs-13); font-weight: 600; color: var(--pw-label); }
.pw-daterange__field > .pw-input { width: 100%; font-variant-numeric: tabular-nums; }
.pw-daterange__status { position: absolute; }

/* Report frame (#3676): page header, filter card (labels above controls, one row of Office / Therapist / Run / Export). */
.pw-report__header { margin-bottom: var(--pw-space-4); }
.pw-report__crumbs { font-size: var(--pw-fs-13); color: var(--pw-muted); }
.pw-report__crumbs a { color: var(--pw-action); text-decoration: none; }
.pw-report__crumbs a:hover { text-decoration: underline; }
.pw-report__title { margin: var(--pw-space-1) 0 0; font-family: var(--pw-font-heading); font-size: var(--pw-fs-28); font-weight: 700; color: var(--pw-navy); }
.pw-report__lead { margin: var(--pw-space-1) 0 0; font-size: var(--pw-fs-15); color: var(--pw-muted); }
.pw-report__filters { display: flex; flex-direction: column; align-items: stretch; gap: var(--pw-space-4); padding: var(--pw-space-4); border: 1px solid var(--pw-line); border-radius: var(--pw-radius-card-md); background: var(--pw-white); }
.pw-report__row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--pw-space-3) var(--pw-space-4); }
.pw-report__field { display: flex; flex: 0 1 220px; flex-direction: column; gap: var(--pw-space-1); font-size: var(--pw-fs-13); font-weight: 600; color: var(--pw-label); }
.pw-report__field > .pw-input { width: 100%; }
.pw-report__export { margin-left: auto; }
.pw-report__search { display: block; width: 100%; max-width: 320px; margin: var(--pw-space-4) 0; }
@media (max-width: 600px) {
  .pw-report__field { flex-basis: 100%; }
  .pw-report__export { margin-left: 0; }
}

/* Report frame (#3676): numeric columns right-aligned; the printable copy of all rows shows only when printing. */
.pw-report__num { text-align: right; font-variant-numeric: tabular-nums; }
.pw-report__pager { display: flex; gap: var(--pw-space-3); margin-top: var(--pw-space-3); }
.pw-report__print { display: none; }

/* Report frame (#3680): sortable headers (buttons, the arrow from aria-sort as in .pw-grid__sort) and group subtotal rows
   on surface-3 with a toggle whose caret turns when the group is collapsed. */
.pw-report__sort,
.pw-report__group-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--pw-space-1);
  min-height: var(--pw-control-height-min);
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.pw-report__sort:hover,
.pw-report__group-toggle:hover { color: var(--pw-action-hover); }
.pw-report__sort::after { content: ""; display: inline-block; min-width: 1em; }
.pw-grid__table th[aria-sort="ascending"] > .pw-report__sort::after { content: "\25B2"; }
.pw-grid__table th[aria-sort="descending"] > .pw-report__sort::after { content: "\25BC"; }
.pw-report__group > th,
.pw-report__group > td { background: var(--pw-surface-3); color: var(--pw-ink); font-size: var(--pw-fs-13); font-weight: 700; }
.pw-report__group-toggle::before { content: "\25BE"; display: inline-block; }
.pw-report__group-toggle[aria-expanded="false"]::before { transform: rotate(-90deg); }
.pw-report__sort:focus-visible,
.pw-report__group-toggle:focus-visible { outline: var(--pw-focus-ring); outline-offset: var(--pw-focus-ring-offset); }
@media (max-width: 640px) {
  /* The pw-grid phone rules above give every row display: block, which beats the UA [hidden] rule: a collapsed
     group's rows need their own. The group header's th and the sort buttons follow the thead th / .pw-grid__sort rules. */
  .pw-grid__table tr[hidden] { display: none; }
  .pw-report__group > th { display: block; }
  .pw-report__sort {
    min-height: var(--pw-control-height);
    padding: 0 var(--pw-space-3);
    border: 1px solid var(--pw-interactive-border);
    border-radius: var(--pw-radius-pill);
    background: var(--pw-white);
  }
  .pw-report__group-toggle { min-height: var(--pw-control-height); }
}
@media print {
    body:has([data-pw-report-print]) > *:not([data-pw-report-print]) { display: none !important; }
    .pw-report__print { display: block; }
}
