:root {
  --ink: #24312d;
  --muted: #667570;
  --line: #dde7e2;
  --paper: #f7fbf8;
  --panel: #ffffff;
  --teal: #187a74;
  --teal-dark: #0e4d49;
  --mint: #dff0ea;
  --mint-border: #b7ddd4;
  --sun: #f4c95d;
  --peach: #f6d3bf;
  --amber: #b7791f;
  --rose: #b84949;
  --green: #27815d;
  --violet: #5f5aa2;
  --blue: #2563eb;
  --soft-shadow: 0 10px 28px rgba(28, 48, 42, 0.07);
  --shadow: 0 18px 45px rgba(28, 48, 42, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
  background:
    linear-gradient(180deg, rgba(223, 240, 234, 0.58) 0, rgba(247, 251, 248, 0) 360px),
    var(--paper);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: block;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: auto;
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 12px clamp(24px, 4vw, 44px);
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  border-bottom: 1px solid rgba(14, 77, 73, 0.12);
  box-shadow: 0 2px 12px rgba(28, 48, 42, 0.07);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  margin-bottom: 0;
  flex: 0 0 auto;
}

.brand-logo {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  object-fit: contain;
  padding: 0;
  border: 0;
  background: transparent;
}

.brand strong {
  display: inline-block;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.brand small {
  color: var(--muted);
  margin-top: 2px;
}

.nav-list {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 4px;
  padding: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.nav-list::-webkit-scrollbar { height: 4px; }
.nav-list::-webkit-scrollbar-thumb { background: rgba(14,77,73,0.18); border-radius: 4px; }

.nav-button {
  width: auto;
  min-height: 48px;
  padding: 0 14px;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  background: transparent;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: color 120ms ease, border-color 120ms ease;
}

.nav-button:hover,
.nav-button:focus-visible {
  color: var(--ink);
  background: transparent;
  outline: none;
}

.nav-button.is-active {
  color: var(--teal-dark);
  background: transparent;
  border-bottom-color: var(--teal);
}

.workspace {
  min-width: 0;
  max-width: 1360px;
  margin: 0 auto;
  padding-top: calc(68px + 16px);
  padding-bottom: 56px;
  padding-left: clamp(20px, 3vw, 36px);
  padding-right: clamp(20px, 3vw, 36px);
}

.topbar,
.section-heading,
.panel-heading,
.form-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  min-height: 44px;
  margin-bottom: 14px;
  padding: 4px 0;
}

.topbar h1,
.section-heading h2,
.panel h3,
.form-title h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(20px, 1.8vw, 24px);
  font-weight: 800;
  line-height: 1.15;
  margin: 0;
}

.section-heading h2 {
  font-size: 24px;
  line-height: 1.2;
}

.panel h3,
.form-title h3 {
  font-size: 17px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar-actions,
.hero-facts,
.checkbox-row,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.status-pill,
.user-chip,
.chip,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill {
  color: var(--teal-dark);
  background: var(--mint);
  border-color: #c7e7df;
}

.facility-hero {
  min-height: 56px;
  margin-bottom: 0;
  border-radius: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  padding: 14px clamp(16px, 3vw, 22px);
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--soft-shadow);
}

.facility-hero .hero-copy { flex: 1 1 220px; min-width: 0; }
.facility-hero .hero-copy p { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
  .facility-hero .hero-copy h2 { font-size: 22px; font-weight: 800; line-height: 1.2; margin: 2px 0 0; }
.facility-hero .hero-facts { margin-left: 0; flex: 0 1 auto; }
.facility-hero .primary-action { margin-left: auto; }
}

.facility-hero::after {
  display: none;
}

.hero-copy {
  max-width: none;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
}

.hero-copy p,
.hero-copy h2 {
  margin: 0;
}

.hero-copy p {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

.sidebar.visual-static-sidebar {
  position: static;
}

.hero-copy h2 {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}

.hero-copy h2:empty {
  display: none;
}

.hero-facts {
  margin-left: auto;
  flex-shrink: 1;
  min-width: 0;
}

.hero-facts span {
  min-height: 24px;
  padding: 0 9px;
  font-size: 11px;
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: none;
}

.toast {
  display: none;
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(420px, calc(100vw - 48px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #26312f;
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 10;
}

.toast.is-visible {
  display: block;
}

.page-section {
  display: none;
}

.page-section.is-active {
  display: grid;
  gap: 28px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  min-height: 104px;
}

.metric {
  min-height: 72px;
  display: grid;
  align-content: space-between;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--soft-shadow);
}

.metric small {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric strong {
  font-size: 24px;
  line-height: 1.1;
}

.metric[data-tone="risk"] {
  border-left: 3px solid var(--rose);
}

.metric[data-tone="warning"] {
  border-left: 3px solid var(--amber);
}

.metric[data-tone="clinical"] {
  border-left: 3px solid var(--teal);
}

.metric[data-tone="finance"] {
  border-left: 3px solid var(--violet);
}

.metric[data-tone="steady"] {
  border-left: 3px solid var(--sun);
}

.metric[data-tone="positive"] {
  border-left: 3px solid var(--green);
}

.platform-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.platform-card {
  min-height: 88px;
  display: grid;
  align-content: space-between;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--soft-shadow);
}

.platform-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.platform-card strong {
  font-size: 19px;
  line-height: 1.15;
}

.platform-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.35;
}

.platform-card[data-tone="clinical"] {
  border-left: 3px solid var(--teal);
}

.platform-card[data-tone="resident"] {
  border-left: 3px solid var(--blue);
}

.platform-card[data-tone="finance"] {
  border-left: 3px solid var(--violet);
}

.platform-card[data-tone="compliance"] {
  border-left: 3px solid var(--green);
}

.two-column,
.resident-layout,
.three-column,
.form-row,
.access-layout,
.documentation-layout,
.emar-layout {
  display: grid;
  gap: 16px;
}

.two-column,
.access-layout {
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
}

/* Company Account and Compliance are secondary — muted panel style */
.panel-secondary {
  background: var(--panel);
  border-color: var(--line);
  box-shadow: none;
}

#section-dashboard #signupForm {
  display: none;
}

/* ── Forms: tile grid ── */
.compact-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.compact-label select {
  width: auto;
  min-height: 36px;
  padding: 4px 8px;
  font-size: 0.85rem;
}

.form-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

/* Resident-context form tiles — smaller, 3-4 per row */
.resident-form-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.resident-form-tile {
  padding: 14px 16px;
  border-radius: 12px;
}

.resident-form-tile .form-tile-purpose {
  -webkit-line-clamp: 2;
}

.resident-forms-panel .panel-heading {
  margin-bottom: 14px;
}

.form-tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 18px 20px;
  box-shadow: var(--soft-shadow);
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.1s;
  cursor: pointer;
}

.form-tile:hover {
  box-shadow: 0 4px 16px rgba(24,122,116,0.13);
  border-color: var(--teal);
  transform: translateY(-1px);
}

.form-tile-category {
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--teal);
}

.form-tile-title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
}

.form-tile-purpose {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
  flex: 1;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.form-tile-meta {
  font-size: 0.75rem;
  color: var(--muted);
  padding-top: 6px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

/* ── Forms: detail / full-page view ── */
.form-detail-topbar {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.back-btn {
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 4px;
}

.back-btn:hover {
  background: var(--hover, #f0f5f4);
}

.form-detail-meta {
  flex: 1;
  min-width: 0;
}

.form-detail-meta h2 {
  margin: 2px 0 4px;
  font-size: 1.15rem;
}

.form-detail-meta .muted {
  font-size: 0.8rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.form-detail-meta .eyebrow {
  margin: 0;
}

.form-detail-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.form-detail-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
}

.form-web-col,
.form-print-col {
  min-width: 0;
}

.form-print-preview {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px 28px;
  font-size: 0.85rem;
}

.workflow-spec h4 {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.form-section-outline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 0;
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
}

.form-section-outline span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.form-section-outline span + span::before {
  content: "·";
  margin: 0 6px;
  color: var(--muted);
}

.section-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  flex-shrink: 0;
}

.printable-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  width: fit-content;
  color: var(--teal-dark);
  font-weight: 900;
}

.emar-layout {
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  align-items: start;
}

.emar-order-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
  align-items: start;
}

.documentation-layout {
  grid-template-columns: minmax(320px, 0.55fr) minmax(0, 1fr);
  align-items: start;
}

.resident-documentation-layout,
.embedded-workflow {
  margin-top: 16px;
}

.embedded-workflow {
  display: grid;
  gap: 14px;
}

.emar-side {
  display: grid;
  gap: 16px;
}

.emar-card {
  min-height: 0;
}

.med-safety-panel {
  margin-bottom: 16px;
}
.med-safety-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.med-safety-status {
  font-size: 0.875rem;
  color: var(--text-muted, #5a6573);
}
.med-safety-summary {
  font-size: 0.875rem;
  color: var(--text-muted, #5a6573);
  margin-bottom: 8px;
}
.med-safety-empty {
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 8px;
  font-size: 0.9rem;
  background: #f3f5f7;
  color: #303841;
}
.med-safety-empty[data-tone="ok"]      { background: #e8f7ee; color: #1f6b3a; }
.med-safety-empty[data-tone="info"]    { background: #e8f1fb; color: #1f4f8a; }
.med-safety-empty[data-tone="warning"] { background: #fdf2e3; color: #8a5a17; }
.med-safety-alert-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.med-safety-alert {
  border-left: 4px solid #b5bcc6;
  background: #fafbfc;
  border-radius: 8px;
  padding: 12px 14px;
}
.med-safety-alert[data-tone="danger"]  { border-left-color: #c0392b; background: #fdecea; }
.med-safety-alert[data-tone="warning"] { border-left-color: #d68910; background: #fdf6e3; }
.med-safety-alert[data-tone="info"]    { border-left-color: #2e86c1; background: #ecf4fb; }
.med-safety-alert header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.med-safety-alert p {
  margin: 4px 0;
  font-size: 0.92rem;
}
.med-safety-mechanism em {
  color: #555;
}
.med-safety-alert-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.med-safety-source {
  font-size: 0.8rem;
  color: var(--text-muted, #5a6573);
}
.compact-action.is-success {
  background: #1f6b3a;
  color: #fff;
}

.compact-action {
  min-height: 36px;
  width: fit-content;
  padding: 0 12px;
}

.missing-document-item,
.med-pass-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.segmented-control {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.segmented-control button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--teal-dark);
  background: #f8fbf9;
  font-weight: 800;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

/* Hover/keyboard-focus is a subtle tint so it doesn't impersonate the
   selected state — otherwise users can't tell which range is currently
   active (the bug that made these buttons feel non-functional). */
.segmented-control button:hover,
.segmented-control button:focus-visible {
  color: var(--teal-dark);
  border-color: var(--teal);
  background: #e6f3ee;
  outline: none;
}

/* Selected state is a solid fill with a contrasting ring so it stays
   visibly distinct from hover even after the cursor moves away. */
.segmented-control button.is-active {
  color: #fff;
  border-color: var(--teal-dark);
  background: var(--teal);
  box-shadow: 0 0 0 2px rgba(13, 95, 79, 0.18);
}

.segmented-control button.is-active:hover,
.segmented-control button.is-active:focus-visible {
  color: #fff;
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

.med-pass-page,
.mar-pass-form {
  display: grid;
  gap: 12px;
}

.med-pass-list {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  align-items: start;
}

.med-pass-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mar-pass-form .form-grid.compact {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
}

.mar-pass-form textarea {
  min-height: 60px;
}

.med-pass-time {
  min-width: 66px;
  color: var(--teal-dark);
  font-size: 20px;
  font-weight: 900;
}

.completed-med-pass {
  padding: 10px 12px;
  border-left: 3px solid var(--green);
  background: #f6fbf8;
}

.emar-schedule-panel table {
  min-width: 780px;
}

.resident-layout {
  grid-template-columns: 360px minmax(0, 1fr);
}

.resident-roster-panel {
  overflow: hidden;
}

.resident-roster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  padding: 2px 2px 12px;
}

.resident-roster-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.resident-roster-filters {
  display: inline-flex;
  gap: 4px;
  background: #f1f5f4;
  padding: 3px;
  border-radius: 999px;
}

.resident-roster-filters .filter-chip {
  border: 0;
  background: transparent;
  color: var(--muted, #5b6c68);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.resident-roster-filters .filter-chip.is-active {
  background: #fff;
  color: var(--ink, #0f172a);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.resident-dob-line {
  margin: 4px 0;
  font-size: 12.5px;
  color: var(--muted, #5b6c68);
  letter-spacing: 0.01em;
}

.resident-dob-label {
  font-weight: 700;
  color: var(--ink, #0f172a);
  margin-right: 4px;
}

.resident-status-pill {
  display: inline-block;
  background: #fde68a;
  color: #78350f;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}

.resident-roster-search {
  /* UX audit: search input was collapsing to ~34px wide on dashboards where
     filter chips consumed the row. flex-basis 260px guarantees a usable
     target and lets the input wrap to its own line on narrow viewports. */
  flex: 1 1 260px;
  min-width: 240px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
}

.resident-roster-search:focus {
  outline: 2px solid var(--blue, #3b82f6);
  outline-offset: 1px;
}

.resident-roster-grid .resident-card {
  min-height: 220px;
  align-content: start;
}

@media (max-width: 640px) {
  .resident-roster-grid {
    grid-template-columns: 1fr;
  }
}

.resident-detail-page {
  max-width: 1040px;
  margin: 0 auto;
}

.three-column,
.form-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel,
.form-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--soft-shadow);
}

.panel {
  padding: 18px;
}

.form-panel {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 18px;
}

.panel-heading {
  min-height: 32px;
  margin-bottom: 12px;
}

.panel-heading span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.list-stack,
.timeline,
.resident-strip,
.aging-bars,
.time-chip-row {
  display: grid;
  gap: 10px;
}

.timeline-actions {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 10px;
}

[hidden] {
  display: none !important;
}

#accessDetails,
#facilityFacts {
  min-height: 32px;
}

#taskList,
#residentStrip,
#auditPreview {
  min-height: 156px;
}

.resident-workspace,
.admin-chart-shell {
  display: grid;
  gap: 14px;
}

.resident-chart-header {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.resident-photo {
  width: 110px;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--hairline, rgba(14, 77, 73, 0.12));
  border-radius: 12px;
  background: linear-gradient(150deg, #e6f4f3 0%, #cfe7e4 100%);
  color: var(--teal-dark, #0e4d49);
  overflow: hidden;
}

.resident-photo span {
  width: auto;
  height: auto;
  display: inline-block;
  border-radius: 0;
  color: var(--teal-dark, #0e4d49);
  background: transparent;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* P3 — Profile photo upload affordance. The avatar tile becomes a
   button when no photo is set yet; once a photo is uploaded the same
   click target shows a "Change" overlay on hover/focus. We wrap the
   <button> in .resident-photo-wrap so the sibling hidden <input
   type="file"> remains a sibling for querySelector lookup. */
.resident-photo-wrap {
  position: relative;
  display: inline-block;
}

.resident-photo-button {
  position: relative;
  appearance: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.resident-photo-button:focus-visible {
  outline: 2px solid var(--teal-dark, #0e4d49);
  outline-offset: 2px;
}

.resident-photo-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.resident-photo-overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  color: #fff;
  background: rgba(11, 62, 59, 0.78);
  opacity: 0;
  transition: opacity 0.12s ease-in-out;
  pointer-events: none;
}

.resident-photo-button:hover .resident-photo-overlay,
.resident-photo-button:focus-visible .resident-photo-overlay,
.resident-photo-button:not(.has-photo) .resident-photo-overlay {
  opacity: 1;
}

.resident-photo-button:not(.has-photo) .resident-photo-overlay {
  background: rgba(11, 62, 59, 0.55);
}

.resident-chart-summary {
  display: grid;
  gap: 10px;
}

.resident-name-row {
  margin-bottom: 0;
}

.resident-name-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 800;
}

.resident-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.resident-document-button,
.resident-report-start {
  min-height: 32px;
  padding: 0 14px;
  border: 1.5px solid var(--teal);
  border-radius: 999px;
  color: var(--teal-dark);
  background: transparent;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.resident-document-button:hover,
.resident-document-button:focus-visible,
.resident-document-button.is-active,
.resident-report-start:hover,
.resident-report-start:focus-visible {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
  outline: none;
}

.resident-chart-tabs,
.admin-chart-tabs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0;
  padding: 0;
  border: none;
  border-bottom: 2px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  scrollbar-width: none;
}

.resident-chart-tabs::-webkit-scrollbar,
.admin-chart-tabs::-webkit-scrollbar {
  display: none;
}

.resident-chart-tab,
.admin-chart-tab {
  flex-shrink: 0;
  min-height: 36px;
  padding: 0 13px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 0;
  color: var(--muted);
  background: transparent;
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.045em;
  white-space: nowrap;
}

.resident-chart-tab:hover,
.resident-chart-tab:focus-visible,
.admin-chart-tab:hover,
.admin-chart-tab:focus-visible {
  color: var(--ink);
  background: transparent;
  border-bottom-color: var(--line);
  outline: none;
}

.resident-chart-tab.is-active,
.admin-chart-tab.is-active {
  color: var(--teal-dark);
  background: transparent;
  border-bottom-color: var(--teal);
  outline: none;
}

.resident-tab-panel,
.admin-tab-panel {
  display: grid;
  gap: 14px;
}

.resident-document-preview,
.resident-action-panel,
.admin-action-panel {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid #c9d8d4;
  border-radius: 8px;
  background: #f7faf7;
}

.resident-workspace-status,
.admin-workspace-status {
  display: grid;
  gap: 3px;
  padding: 0 0 14px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
}

.resident-document-preview span,
.resident-action-panel span,
.admin-action-panel span,
.resident-signature-item span {
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.resident-document-preview strong {
  font-size: 18px;
  line-height: 1.2;
}

.resident-workspace-status strong,
.admin-workspace-status strong {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
}

.resident-action-panel h3,
.admin-action-panel h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.resident-document-preview p,
.resident-action-panel p,
.admin-action-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.resident-workspace-status p,
.admin-workspace-status p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.action-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.resident-action-body {
  display: grid;
  gap: 10px;
}

.resident-workflow-page {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.resident-workflow-copy {
  display: grid;
  gap: 6px;
}

.resident-workflow-copy span,
.resident-completed-form span {
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.resident-workflow-copy h3 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.resident-workflow-copy p,
.resident-completed-form p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.resident-workflow-page .form-panel {
  box-shadow: none;
}

.resident-completed-form {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--mint-border);
  border-radius: 8px;
  background: #f8fbf9;
}

.resident-completed-form.compact {
  border-color: var(--line);
  background: #fff;
}

.completed-form-header {
  display: grid;
  gap: 5px;
}

.completed-form-header strong,
.resident-completed-form > strong {
  font-size: 18px;
  line-height: 1.2;
}

.completed-field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.resident-record-actions {
  display: flex;
  justify-content: flex-start;
}

.resident-module-grid,
.admin-module-grid,
.resident-signature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
  padding: 8px 0;
}

.resident-module-grid-balanced .resident-module-card:last-child,
.admin-module-grid .admin-module-card:last-child:nth-child(odd) {
  max-width: 640px;
  justify-self: center;
  width: 100%;
}

.resident-module-card,
.admin-module-card {
  min-height: 96px;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  box-shadow: var(--soft-shadow);
}

.resident-module-card:hover,
.resident-module-card:focus-visible,
.admin-module-card:hover,
.admin-module-card:focus-visible,
.resident-report-option:hover,
.resident-report-option:focus-visible {
  border-color: var(--teal);
  background: var(--mint);
  outline: none;
}

.resident-module-icon,
.admin-module-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--teal-dark);
  background: var(--mint);
  font-size: 17px;
  font-weight: 900;
}

.resident-module-card strong,
.admin-module-card strong {
  display: block;
  font-size: 16px;
  line-height: 1.2;
}

.resident-module-card small,
.admin-module-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.resident-report-layout {
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  align-items: start;
}

.resident-report-layout .resident-workspace-status,
.resident-report-layout .resident-action-panel,
.resident-report-layout .resident-workflow-page {
  grid-column: 1 / -1;
}

.resident-report-select-label {
  gap: 8px;
  color: #41494c;
  font-size: 18px;
}

.resident-report-select-label select {
  min-height: 58px;
  font-size: 18px;
}

.resident-report-list {
  max-height: 390px;
  display: grid;
  overflow: auto;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 34px rgba(34, 47, 45, 0.14);
}

.resident-report-option {
  min-height: 58px;
  padding: 0 18px;
  border: 0;
  border-bottom: 1px solid #eef2f0;
  background: #fff;
  color: #35403e;
  text-align: left;
  font-size: 17px;
}

.resident-report-option.is-selected {
  background: var(--mint);
  color: var(--teal-dark);
  font-weight: 800;
}

.resident-report-side {
  display: grid;
  gap: 18px;
}

.resident-report-side div {
  display: grid;
  gap: 10px;
  justify-items: center;
  padding-top: 12px;
  border-top: 1px solid #aab4b7;
}

.resident-report-side span {
  color: #41494c;
  font-size: 16px;
  font-weight: 900;
  text-transform: uppercase;
}

.resident-report-side strong {
  color: #111;
  font-size: 18px;
}

.resident-report-side p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.4;
}

.resident-signature-item {
  display: grid;
  gap: 8px;
  min-height: 118px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfdfb;
}

.resident-signature-item strong {
  font-size: 17px;
}

.resident-signature-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.admin-workspace {
  display: grid;
  gap: 14px;
}

.resident-clinical-hub {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.profile-section {
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.detail-subhead {
  margin-bottom: 0;
}

.time-chip-row {
  grid-template-columns: repeat(auto-fit, minmax(64px, max-content));
  align-items: center;
}

.list-item,
.resident-card,
.timeline-item,
.report-item,
.integration-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfdfb;
}

.list-item header,
.resident-card header,
.report-item header,
.integration-item header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.list-item strong,
.resident-card strong,
.timeline-item strong,
.report-item strong,
.integration-item strong {
  line-height: 1.25;
}

.muted,
.list-item p,
.resident-card p,
.timeline-item p,
.report-item p,
.integration-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.resident-card {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
}

.resident-card button {
  grid-column: 1 / -1;
}

.avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #0b3e3b;
  background: #bfe8dc;
  font-weight: 800;
}

/* Clickable avatar in resident roster cards opens the file picker so
   admins can upload a profile photo without opening the resident
   chart. When a photo has been uploaded the avatar shows it cropped
   to a square; otherwise the initials placeholder remains. */
.avatar-button {
  appearance: none;
  padding: 0;
  margin: 0;
  border: 1px solid transparent;
  cursor: pointer;
  font: inherit;
  overflow: hidden;
}

.avatar-button:hover,
.avatar-button:focus-visible {
  border-color: var(--teal-dark, #0e4d49);
}

.avatar-button:focus-visible {
  outline: 2px solid var(--teal-dark, #0e4d49);
  outline-offset: 2px;
}

.avatar-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 8px;
}

.detail-grid,
.form-grid {
  display: grid;
  gap: 12px;
}

.detail-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.detail-field {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border-left: 3px solid #bfe8dc;
  background: #f7faf7;
  border-radius: 0 4px 4px 0;
}

.detail-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-field strong {
  font-size: 14px;
  line-height: 1.3;
}

.form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.detail-grid.compact,
.form-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.generated-form {
  display: grid;
  gap: 16px;
}

.generated-form-section {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.generated-form-section legend {
  padding: 0 6px;
  color: var(--teal-dark);
  font-weight: 900;
}

/* ── Typed form fields ── */
.form-grid.compact {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px 14px;
  align-items: start;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
}

.form-field input:not([type=radio]):not([type=checkbox]),
.form-field select,
.form-field textarea {
  font-size: 0.85rem;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

.form-field textarea { min-height: 72px; resize: vertical; }

.form-field-full,
.form-field.form-field-full {
  grid-column: 1 / -1;
}

/* Radio and checkbox groups */
.form-radio-group,
.form-check-group {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
}

.form-radio-group legend,
.form-check-group legend,
.form-adl-score legend,
.form-sat-table legend,
.form-table legend {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 4px;
}

.radio-row,
.check-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.inline-radio,
.inline-check {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 0.85rem;
}

.inline-radio input,
.inline-check input {
  accent-color: var(--teal);
  cursor: pointer;
}

/* ADL Score (0-3) */
.form-adl-score {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  gap: 6px;
}

.adl-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.score-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 0.83rem;
  line-height: 1.3;
}

.score-option:hover { background: var(--hover); }

.score-option.is-selected {
  background: color-mix(in srgb, var(--teal) 10%, transparent);
}

.score-option input { accent-color: var(--teal); margin-top: 2px; flex-shrink: 0; }

.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* IADL score — same layout as ADL score but badge uses letter */
.form-freq { font-size: 0.83rem; }
.form-freq legend { margin-bottom: 4px; }
.freq-radio { font-size: 0.83rem; }
.freq-radio.is-selected { font-weight: 700; color: var(--teal-dark); }

.trigger-star { color: var(--danger, #c0392b); font-size: 0.7rem; vertical-align: super; }

/* S/A/T coding table */
.form-sat-table {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  overflow-x: auto;
}

.sat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.sat-table th,
.sat-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.sat-table th { font-weight: 700; color: var(--text-muted); font-size: 0.78rem; }
.sat-table td:first-child { white-space: normal; width: 100%; }
.sat-table .inline-radio { justify-content: center; }

/* Repeating rows (medication / visitor log) */
.form-table {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}

.form-table-scroll { overflow-x: auto; }

.med-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 500px;
}

.med-table th,
.med-table td {
  padding: 4px 6px;
  border: 1px solid var(--line);
}

.med-table th { background: var(--surface-raised, #f7fafa); font-weight: 700; font-size: 0.77rem; }
.med-table td input { border: none; background: transparent; width: 100%; min-width: 80px; padding: 2px 0; }

.printable-preview,
.resident-action-panel,
.admin-action-panel {
  overflow: hidden;
}

.workflow-spec {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.workflow-spec h4 {
  margin: 0;
}

.workflow-spec-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.print-header {
  display: flex;
  gap: 14px;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 2px solid #26312f;
}

.print-header img {
  width: 96px;
  height: 48px;
  object-fit: contain;
}

.print-header p,
.print-header h1,
.print-header h3,
.print-purpose {
  margin: 0;
}

.print-header p,
.print-header span {
  color: var(--muted);
  font-weight: 800;
}

.print-purpose {
  margin: 12px 0;
  color: var(--muted);
  line-height: 1.45;
}

.print-section {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.print-section h3 {
  margin: 0;
  font-size: 16px;
}

.print-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.print-field {
  min-height: 58px;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid #cfd9d6;
  border-radius: 6px;
  background: #fff;
}

.print-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.print-field div {
  min-height: 24px;
  border-bottom: 1px solid #aab7b3;
  font-weight: 700;
}

.print-footer {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid #26312f;
  font-weight: 800;
}

.print-page {
  background: #fff;
}

.print-shell {
  max-width: 1020px;
  margin: 0 auto;
  padding: 24px;
}

.print-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: #35403e;
  font-size: 13px;
  font-weight: 800;
}

input:not([type=radio]):not([type=checkbox]),
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cfd9d6;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  outline: none;
}

input[type=radio],
input[type=checkbox] {
  width: auto;
  min-height: auto;
  border: none;
  padding: 0;
  background: transparent;
  accent-color: var(--teal);
  cursor: pointer;
}

textarea {
  min-height: 94px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(24, 122, 116, 0.12);
}

.checkbox-row label {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  gap: 8px;
}

.checkbox-row input {
  width: 16px;
  min-height: 16px;
}

.primary-action,
.secondary-action {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 14px;
  border: 1px solid transparent;
  font-weight: 800;
  text-decoration: none;
}

.primary-action {
  color: #fff;
  background: var(--teal-dark);
}

.primary-action:hover,
.primary-action:focus-visible {
  background: var(--teal);
}

.secondary-action {
  color: var(--teal-dark);
  border-color: #bddcd5;
  background: #eef8f5;
}

.secondary-action:hover,
.secondary-action:focus-visible {
  background: #dff0ea;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.tag[data-tone="risk"],
.chip[data-tone="risk"] {
  color: #8d2d2d;
  background: #fdebea;
  border-color: #f1c4c1;
}

.tag[data-tone="warning"],
.chip[data-tone="warning"] {
  color: #7a4d12;
  background: #fff5dd;
  border-color: #ecd7a9;
}

.tag[data-tone="positive"],
.chip[data-tone="positive"] {
  color: #14603f;
  background: #e7f6ee;
  border-color: #bee6d0;
}

.tag[data-tone="clinical"],
.chip[data-tone="clinical"] {
  color: #0b5c57;
  background: #e2f4ef;
  border-color: #bfe8dc;
}

.aging-row {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) 96px;
  align-items: center;
  gap: 10px;
}

.ar-progress {
  width: 100%;
  height: 12px;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #edf2ef;
}

.ar-progress::-webkit-progress-bar {
  border-radius: 8px;
  background: #edf2ef;
}

.ar-progress::-webkit-progress-value {
  border-radius: 8px;
  background: var(--teal);
}

.ar-progress::-moz-progress-bar {
  border-radius: 8px;
  background: var(--teal);
}

@media (max-width: 940px) {
  .metric-grid,
  .platform-grid,
  .three-column,
  .form-row,
  .resident-module-grid,
  .admin-module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 920px) {
  .sidebar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .nav-list {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-button {
    text-align: center;
  }

  .workspace {
    padding: 18px;
  }

  .facility-hero {
    height: auto;
    min-height: 56px;
    padding: 10px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .topbar,
  .section-heading {
    align-items: start;
    flex-direction: column;
  }

  .two-column,
  .resident-layout,
  .three-column,
  .form-row,
  .documentation-layout,
  .access-layout,
  .emar-layout,
  .emar-order-grid,
  .metric-grid,
  .platform-grid,
  .detail-grid,
  .action-detail-grid,
  .workflow-spec-grid,
  .completed-field-grid,
  .print-grid,
  .resident-chart-header,
  .resident-report-layout,
  .resident-module-grid,
  .admin-module-grid,
  .resident-signature-grid,
  .form-detail-body {
    grid-template-columns: 1fr;
  }

  .resident-quick-actions {
    grid-template-columns: 1fr;
  }

  .resident-photo {
    width: min(150px, 100%);
  }
}

@media print {
  .print-actions,
  .sidebar,
  .topbar,
  .nav-list {
    display: none !important;
  }

  body,
  .print-page {
    background: #fff;
  }

  .print-shell,
  .workspace {
    max-width: none;
    padding: 0;
  }

  .panel,
  .printable-preview {
    border: 0;
    box-shadow: none;
  }
}

@media (max-width: 620px) {
  .workspace {
    padding: 14px;
  }

  .facility-hero {
    padding: 8px 14px;
  }

  .hero-copy h2 {
    font-size: 14px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .nav-list {
    flex-wrap: nowrap;
  }

  .nav-button {
    flex: 0 0 auto;
  }

  .topbar-actions {
    width: 100%;
  }
}

/* ============================================================
   TYPOGRAPHY REFINEMENT — v20260601j
   Goal: clean modular scale, fewer weights, calmer hierarchy,
   tighter tracking on display, generous tracking on uppercase.
   ============================================================ */

:root {
  /* Type scale (15px base) */
  --fs-micro: 11px;     /* tags, badge labels */
  --fs-eyebrow: 12px;   /* uppercase eyebrows */
  --fs-meta: 13px;      /* secondary/meta */
  --fs-body: 15px;      /* default body */
  --fs-lead: 17px;      /* large body / card title */
  --fs-h3: 20px;        /* panel titles */
  --fs-h2: 24px;        /* section headers */
  --fs-h1: 30px;        /* page hero / metric numbers */
  --fs-display: 36px;   /* hero kpis */

  /* Weights — capped at 700 for body, 800 for display only */
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-display: 800;

  /* Tracking */
  --tr-display: -0.02em;
  --tr-tight: -0.01em;
  --tr-normal: 0;
  --tr-uppercase: 0.08em;
}

body {
  font-size: var(--fs-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01", "ss03";
}

/* --- Brand & nav --- */
.brand strong {
  font-size: 19px;
  font-weight: var(--fw-display);
  letter-spacing: var(--tr-tight);
}

.nav-button {
  font-size: 15px;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.005em;
}

/* --- Top bar / facility hero --- */
.topbar h1 {
  font-size: clamp(22px, 1.9vw, 26px);
  font-weight: var(--fw-display);
  letter-spacing: var(--tr-tight);
  line-height: 1.15;
}

.facility-hero { padding: 16px clamp(18px, 3vw, 24px); gap: 14px 22px; }
.facility-hero .hero-copy p {
  font-size: var(--fs-eyebrow);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tr-uppercase);
  color: var(--muted);
}
.facility-hero .hero-copy h2 {
  font-size: 24px;
  font-weight: var(--fw-display);
  letter-spacing: var(--tr-tight);
  line-height: 1.2;
  margin-top: 4px;
}

/* --- Section / panel headings --- */
.section-heading h2 {
  font-size: var(--fs-h2);
  font-weight: var(--fw-display);
  letter-spacing: var(--tr-tight);
}

.panel h3, .form-title h3 {
  font-size: var(--fs-lead);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tr-tight);
}

.eyebrow {
  font-size: var(--fs-eyebrow);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tr-uppercase);
}

/* --- Metric & platform cards --- */
.metric small,
.platform-card span {
  font-size: var(--fs-eyebrow);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tr-uppercase);
  color: var(--muted);
}

.metric strong {
  font-size: 28px;
  font-weight: var(--fw-display);
  letter-spacing: var(--tr-display);
  line-height: 1.05;
  color: var(--ink);
}

.platform-card strong {
  font-size: var(--fs-h3);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tr-tight);
  line-height: 1.2;
}

.platform-card p {
  font-size: var(--fs-meta);
  font-weight: var(--fw-medium);
  line-height: 1.45;
  color: var(--muted);
}

/* --- Pills & chips --- */
.status-pill, .user-chip, .chip, .tag {
  font-size: var(--fs-meta);
  font-weight: var(--fw-semibold);
  letter-spacing: 0;
}

/* --- Buttons / primary action --- */
.primary-action, .ghost-action, button.cta {
  font-size: 14px;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.01em;
}

/* --- Tone down stray 900-weights & oversize displays elsewhere --- */
[class*="-tab"], .resident-chart-tab, .admin-chart-tab {
  font-weight: var(--fw-semibold);
  letter-spacing: 0.01em;
}

/* --- Flow: tighten dashboard rhythm --- */
.page-section.is-active { gap: 24px; }
.metric-grid { gap: 14px; }
.platform-grid { gap: 14px; }

/* --- Focus ring for keyboard nav (accessibility + polish) --- */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================================================
   FLOW + DENSITY REFINEMENT — v20260601k
   ============================================================ */

/* Prevent horizontal overflow everywhere */
html, body { overflow-x: hidden; }
.workspace, .page-section { min-width: 0; }
.workspace * { min-width: 0; }

/* Dashboard: 4-up metric grid for density */
.metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

/* Calmer card accents: replace 3px colored left border with a subtle top accent dot */
.metric, .platform-card {
  border-left-width: 1px !important;
  border-left-color: var(--line) !important;
  position: relative;
}
.metric::before, .platform-card::before {
  content: "";
  position: absolute;
  top: 12px; left: 12px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted);
}
.metric[data-tone="risk"]::before    { background: var(--rose); }
.metric[data-tone="warning"]::before { background: var(--amber); }
.metric[data-tone="clinical"]::before{ background: var(--teal); }
.metric[data-tone="finance"]::before { background: var(--violet); }
.metric[data-tone="steady"]::before  { background: var(--sun); }
.metric[data-tone="positive"]::before{ background: var(--green); }
.platform-card[data-tone="clinical"]::before  { background: var(--teal); }
.platform-card[data-tone="resident"]::before  { background: var(--blue); }
.platform-card[data-tone="finance"]::before   { background: var(--violet); }
.platform-card[data-tone="compliance"]::before{ background: var(--green); }
.metric small, .platform-card span { padding-left: 14px; }

/* Two-column layout: allow columns to actually shrink */
.two-column { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 980px) {
  .two-column { grid-template-columns: 1fr; }
}

/* Topbar: smaller, less marketing */
.topbar h1 { font-size: clamp(18px, 1.5vw, 22px); font-weight: 700; }

/* Form actions row: visible Cancel next to primary */
.form-actions {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-top: 12px;
}
.ghost-action {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px; font-weight: 600;
  transition: background 120ms ease, color 120ms ease;
}
.ghost-action:hover { background: var(--paper); color: var(--ink); }

/* Service Plan multi-component cards */
.plan-area-stack {
  display: flex; flex-direction: column; gap: 10px;
  margin: 14px 0 4px;
}
.plan-area {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  overflow: hidden;
}
.plan-area[open] { background: var(--panel); box-shadow: var(--soft-shadow); }
.plan-area summary {
  list-style: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  gap: 12px;
}
.plan-area summary::-webkit-details-marker { display: none; }
.plan-area-toggle {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; color: var(--ink);
}
.plan-area-toggle input[type="checkbox"] {
  width: 18px; height: 18px; cursor: pointer;
  accent-color: var(--teal);
}
.plan-area-toggle strong { font-weight: 600; }
.plan-area-hint {
  font-size: 12px; color: var(--muted);
  letter-spacing: 0.02em;
}
.plan-area-body {
  padding: 4px 14px 14px;
  display: flex; flex-direction: column; gap: 10px;
  border-top: 1px solid var(--line);
}
.plan-area-body label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 13px; color: var(--muted); font-weight: 600;
}
.plan-area-body textarea,
.plan-area-body input {
  font-size: 14px; color: var(--ink);
  padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel);
  font-family: inherit;
  resize: vertical;
}
.plan-area-body textarea:focus,
.plan-area-body input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(24,122,116,0.15);
}

/* ============================================================
   ADMINISTRATION REFINEMENT — v20260601l
   Removes dev "Workflow spec" cruft, deduplicates status panels,
   makes admin tabs feel like proper tabs, tightens module grid.
   ============================================================ */

/* Hide developer/test-spec panels from end users */
.workflow-spec { display: none !important; }

/* Admin: kill the redundant "Administration action" eyebrow status
   (the action-panel already shows the same info, larger) */
.admin-workspace-status { display: none !important; }

/* Admin tab strip: real horizontal tabs, not pills */
.admin-chart-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin: 0 0 18px;
  padding: 0;
  background: transparent;
  box-shadow: none;
}
.admin-chart-tabs::-webkit-scrollbar { display: none; }
.admin-chart-tab {
  appearance: none;
  background: transparent !important;
  border: none !important;
  border-bottom: 2px solid transparent !important;
  border-radius: 0 !important;
  padding: 10px 16px !important;
  margin: 0 !important;
  color: var(--muted) !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  letter-spacing: 0 !important;
  box-shadow: none !important;
  min-height: 40px;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}
.admin-chart-tab:hover { color: var(--ink) !important; }
.admin-chart-tab.is-active {
  color: var(--teal-dark) !important;
  border-bottom-color: var(--teal) !important;
}

/* Admin action panel: clean header strip, not a verbose article */
.admin-action-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px !important;
  background: var(--panel) !important;
  border: 1px solid var(--line) !important;
  border-radius: 12px !important;
  box-shadow: var(--soft-shadow) !important;
  margin: 0 0 16px !important;
}
.admin-action-panel > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.admin-action-panel > div:first-child > span {
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase;
  color: var(--muted) !important;
  padding: 2px 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.admin-action-panel h3 {
  font-size: 18px !important;
  font-weight: 700 !important;
  letter-spacing: -0.01em !important;
  margin: 0 !important;
  color: var(--ink) !important;
}
.admin-action-panel p {
  margin: 0 !important;
  font-size: 13px !important;
  color: var(--muted) !important;
  line-height: 1.5 !important;
  flex-basis: 100%;
}
.admin-action-panel .action-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 16px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

/* Module grid: 3-up on desktop, denser, calmer */
.admin-module-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)) !important;
  gap: 10px !important;
  margin: 0 !important;
}
.admin-module-card {
  display: flex !important;
  align-items: flex-start !important;
  gap: 12px !important;
  padding: 14px !important;
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  background: var(--panel) !important;
  box-shadow: none !important;
  text-align: left !important;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
.admin-module-card:hover {
  border-color: var(--teal) !important;
  box-shadow: var(--soft-shadow) !important;
  transform: translateY(-1px);
}
.admin-module-icon {
  flex: 0 0 36px;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: var(--mint);
  color: var(--teal-dark);
  font-size: 12px; font-weight: 800;
  letter-spacing: 0.02em;
}
.admin-module-card > span:last-child {
  display: flex; flex-direction: column; gap: 3px;
  min-width: 0;
}
.admin-module-card strong {
  font-size: 14px !important;
  font-weight: 600 !important;
  color: var(--ink) !important;
  letter-spacing: -0.005em !important;
  line-height: 1.3 !important;
}
.admin-module-card small {
  font-size: 12.5px !important;
  font-weight: 400 !important;
  color: var(--muted) !important;
  line-height: 1.45 !important;
  letter-spacing: 0 !important;
}

/* Compliance panel: tighter */
#section-admin .panel-secondary {
  padding: 16px 18px;
  margin-bottom: 16px;
}
#section-admin .timeline-actions { margin-top: 8px; }

/* ============================================================
   GLOBAL CONSISTENCY NORMALIZATION — v20260601m
   Implements docs/ui-evaluation-spec.md §1 (layout contract)
   and §10 (known-violations fix list). One source of truth for
   page width, gutter, vertical rhythm, tabs, and cards across
   every tab.
   ============================================================ */

:root {
  --page-max: 1280px;
  --page-gutter: clamp(16px, 3vw, 32px);
  --page-stack: 24px;
}

/* Single source of truth for page width and gutter */
.workspace {
  max-width: var(--page-max) !important;
  padding-left: var(--page-gutter) !important;
  padding-right: var(--page-gutter) !important;
}

/* All page-sections share the same vertical rhythm */
.page-section.is-active {
  gap: var(--page-stack) !important;
}

/* Kill per-page width overrides — every page inherits --page-max */
.resident-detail-page {
  max-width: none !important;
  margin: 0 !important;
}

/* Stop self-centering single odd-cards at 640px — let them flow in the grid */
.resident-module-grid-balanced .resident-module-card:last-child,
.admin-module-grid .admin-module-card:last-child:nth-child(odd) {
  max-width: none !important;
  justify-self: stretch !important;
  width: auto !important;
}

/* Unify resident profile tabs with the admin underline tab style */
.resident-chart-tabs {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 0 !important;
  border-bottom: 1px solid var(--line) !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 0 18px !important;
}
.resident-chart-tab {
  appearance: none !important;
  background: transparent !important;
  border: none !important;
  border-bottom: 2px solid transparent !important;
  border-radius: 0 !important;
  padding: 10px 16px !important;
  margin: 0 !important;
  color: var(--muted) !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  letter-spacing: 0 !important;
  box-shadow: none !important;
  min-height: 40px !important;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}
.resident-chart-tab:hover,
.resident-chart-tab:focus-visible {
  color: var(--ink) !important;
  background: transparent !important;
  border-color: transparent transparent var(--line) transparent !important;
}
.resident-chart-tab.is-active {
  color: var(--teal-dark) !important;
  background: transparent !important;
  border-bottom-color: var(--teal) !important;
}

/* Cards: unified hover (border-color + soft shadow + 1px lift) across the app */
.metric, .platform-card, .resident-module-card, .admin-module-card, .integration-card {
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
.resident-module-card:hover, .integration-card:hover {
  border-color: var(--teal) !important;
  box-shadow: var(--soft-shadow) !important;
  transform: translateY(-1px);
}

/* Resident module grid: match Admin grid density (auto-fill 260px) */
.resident-module-grid,
.resident-module-grid-balanced {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)) !important;
  gap: 10px !important;
}

/* Top bar: lock h1 to spec (22/700, single line) */
.topbar h1 {
  font-size: 22px !important;
  font-weight: 700 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Reduce-motion contract */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }
}

/* ============================================================
   TEMPLATE-FORM RECORDS (v20260602a)
   Draft / Completed save workflow for forms.js templates.
   ============================================================ */
.form-tile-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.form-tile-badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600; line-height: 1;
  padding: 4px 8px; border-radius: 999px;
  letter-spacing: 0.02em;
}
.form-tile-badge-draft { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }
.form-tile-badge-completed { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }

.status-pill {
  display: inline-flex; align-items: center; margin-top: 6px;
  font-size: 11px; font-weight: 600; padding: 4px 10px;
  border-radius: 999px; letter-spacing: 0.02em;
}
.status-pill-draft { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }

.resident-form-completed .completed-form-header strong { font-size: 16px; }
.resident-form-completed .completed-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

/* Populated print-form fields */
.print-field-filled div {
  border-bottom: 1px solid var(--ink);
  min-height: 18px;
  padding: 2px 4px;
  font-weight: 500;
  color: var(--ink);
}
.print-record-status {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.print-record-status[data-record-status="completed"] { color: #065f46; }
.print-record-status[data-record-status="draft"] { color: #9a3412; }

/* ============================================================
   DESIGN-PASS — v20260602b
   Senior SaaS product-design audit fixes:
   - C5/C13 status-pill + acuity-tag discipline (semantic palette)
   - C12 metric tones constrained to spec palette
   - C4 platform-grid hidden (kept as no-op for back-compat)
   - C6 resident-quick-actions hidden (redundant with form tiles)
   - W4 clickable work-queue items
   - C16 facility hero overlap fix
   - C19 form-tile grid: clamp to 4 columns max for visual rhythm
   - Accessibility: keyboard focus-visible ring on all action surfaces
   ============================================================ */

/* C5/C13 — status-pill must stay neutral; acuity uses semantic palette */
.topbar .status-pill {
  background: transparent !important;
  color: var(--muted) !important;
  border-color: var(--line) !important;
  font-weight: 600 !important;
}
.topbar .user-chip {
  background: var(--mint) !important;
  color: var(--teal-dark) !important;
  border-color: var(--mint-border) !important;
}
.tag[data-tone="risk"]    { background: #fdecec; color: var(--rose);     border-color: #f2c7c7; }
.tag[data-tone="warning"] { background: #fcf3e1; color: var(--amber);    border-color: #f0dca6; }
.tag[data-tone="positive"]{ background: #e3f3eb; color: var(--green);    border-color: #c0e1cd; }
.tag[data-tone="steady"]  { background: var(--mint); color: var(--teal-dark); border-color: var(--mint-border); }
.tag[data-tone="clinical"]{ background: var(--mint); color: var(--teal-dark); border-color: var(--mint-border); }

/* C12 — Metric tones: collapse off-palette to spec (blue/green/amber/red/gray) */
.metric[data-tone="finance"] { border-left-color: var(--teal-dark) !important; }
.metric[data-tone="steady"]  { border-left-color: var(--muted) !important; }

/* C4 — Operations platform stack retired from the dashboard */
.platform-grid { display: none !important; }

/* C6 — Resident chart quick-action pills retired (redundant with form tiles) */
.resident-quick-actions { display: none !important; }

/* W4 — Clickable Work Queue items */
.list-item-action {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
.list-item-action:hover,
.list-item-action:focus-visible {
  border-color: var(--teal);
  box-shadow: var(--soft-shadow);
  transform: translateY(-1px);
  outline: none;
}
.list-item-action header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.list-item-action p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

/* C16 — Facility hero: never let Refresh overlap pills */
.facility-hero {
  flex-wrap: wrap;
}
.facility-hero .primary-action {
  margin-left: auto;
  flex: 0 0 auto;
}
@media (max-width: 760px) {
  .facility-hero .primary-action {
    width: 100%;
    margin-left: 0;
  }
}

/* C19 — Form tile grid clamp to keep last-row balance */
.form-tile-grid,
.resident-form-tiles {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)) !important;
}

/* W5 — Resident back nav: subtle text-link rather than primary button */
.link-back {
  appearance: none;
  background: transparent;
  border: none;
  /* Padding sized so the visible hit area is >=32px tall to satisfy WCAG
     2.5.5 (target size) per qa-automation gates. */
  padding: 8px 4px;
  min-height: 32px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0;
}
.link-back:hover,
.link-back:focus-visible {
  color: var(--teal-dark);
  outline: none;
}

/* Accessibility — global focus ring */
:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Typography rhythm — page H2 inside section-heading */
.section-heading h2 {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  margin: 4px 0 0;
}

/* C12 follow-up — recolor metric dots to spec palette (no purple/sun) */
.metric[data-tone="finance"]::before { background: var(--teal-dark) !important; }
.metric[data-tone="steady"]::before  { background: var(--muted) !important; }

/* C10/W6 — Admin Users header + grouped sections (v20260602f) */
.admin-users-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 0 4px;
  border-bottom: 1px solid var(--line);
}
.admin-users-header h3 { font-size: 18px; font-weight: 700; margin: 0; color: var(--ink); }
.admin-users-header p  { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.admin-users-header .primary { white-space: nowrap; }
.admin-users-groups { display: flex; flex-direction: column; gap: 20px; margin-top: 12px; }
.admin-users-group h4 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}

/* ============================================================
   R3/R2 — Modal primitives + R2 copy-prior list (v20260602h)
   Accessible attestation modal and section review panel.
   ============================================================ */
.rc-modal[hidden] { display: none !important; }
.rc-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.rc-modal__scrim {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}
.rc-modal__panel {
  position: relative;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
  width: min(520px, 96vw);
  max-height: min(88vh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.rc-modal__panel--wide { width: min(720px, 96vw); }
.rc-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line, #e5e7eb);
}
.rc-modal__header h2 { margin: 0; font-size: 18px; font-weight: 700; }
.rc-modal__close {
  appearance: none;
  background: transparent;
  border: 0;
  font-size: 24px;
  line-height: 1;
  color: var(--muted, #64748b);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.rc-modal__close:hover { background: rgba(15, 23, 42, 0.06); color: var(--ink, #0f172a); }
.rc-modal__body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.rc-modal__lead { margin: 0; color: var(--muted, #475569); font-size: 14px; line-height: 1.5; }
.rc-modal__check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.45;
  cursor: pointer;
}
.rc-modal__check input { margin-top: 3px; flex: 0 0 auto; }
.rc-modal__field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink, #0f172a); }
.rc-modal__field em { color: var(--muted, #64748b); font-style: normal; font-weight: 400; }
.rc-modal__field input {
  padding: 9px 12px;
  border: 1px solid var(--line, #d1d5db);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
}
.rc-modal__field input:focus {
  outline: none;
  border-color: var(--teal, #0d9488);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.18);
}
.rc-modal__error {
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin: 0;
}
.rc-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line, #e5e7eb);
  background: #f8fafc;
}
.rc-modal__footer .primary-action:disabled,
.rc-modal__footer .primary-action[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.rc-modal__bulk-actions {
  display: flex;
  gap: 12px;
  font-size: 13px;
}
.link-button {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--teal-dark, #0f766e);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}
.link-button:hover { color: var(--ink, #0f172a); }

.rc-copy-prior__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rc-copy-prior__item {
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.rc-copy-prior__item input { margin-top: 3px; flex: 0 0 auto; }
.rc-copy-prior__item-body { flex: 1; min-width: 0; }
.rc-copy-prior__item-title { font-weight: 600; font-size: 14px; color: var(--ink, #0f172a); }
.rc-copy-prior__item-meta { font-size: 12px; color: var(--muted, #64748b); margin-top: 2px; }
.rc-copy-prior__item-preview {
  margin-top: 8px;
  font-size: 12px;
  color: #334155;
  background: #f8fafc;
  border-radius: 6px;
  padding: 8px 10px;
  max-height: 84px;
  overflow: auto;
  white-space: pre-wrap;
}
.rc-copy-prior__item-empty { font-style: italic; color: var(--muted, #94a3b8); }

/* ============================================================
   P1 polish — locked severity color scale (4-stop semantic),
   sign-out affordance, accessible focus rings. v20260602p
   ============================================================ */

/* --- 4-stop severity / priority scale (overrides ad-hoc tones) --- */
.tag[data-tone="critical"],
.chip[data-tone="critical"] {
  color: #7f1d1d;
  background: #fef2f2;
  border-color: #fecaca;
  font-weight: 700;
}
.tag[data-tone="risk"],
.chip[data-tone="risk"] {
  color: #9a3412;
  background: #fff7ed;
  border-color: #fed7aa;
}
.tag[data-tone="warning"],
.chip[data-tone="warning"] {
  color: #854d0e;
  background: #fefce8;
  border-color: #fde68a;
}
.tag[data-tone="positive"],
.chip[data-tone="positive"] {
  color: #166534;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

/* --- Sign-out button in app topbar --- */
.topbar-signout {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted, #64748b);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  margin-left: 8px;
  transition: color 120ms ease, background-color 120ms ease, border-color 120ms ease;
}
.topbar-signout:hover {
  color: var(--ink, #0f172a);
  background: rgba(15, 23, 42, 0.05);
  border-color: var(--line, #e5e7eb);
}
.topbar-signout:focus-visible {
  outline: 2px solid var(--teal, #0d9488);
  outline-offset: 2px;
}

/* --- Login tab keyboard focus ring (a11y) --- */
.login-tab:focus-visible {
  outline: 2px solid var(--teal, #0d9488);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================================================
   PREMIUM SAAS POLISH — v20260602q
   Goal: Linear/Vercel/Stripe-grade restraint and density.
   Strategy: type discipline, tabular numerals, neutral chrome,
   tighter spacing, refined motion, single-source typography.
   This layer is intentionally LAST in the cascade.
   ============================================================ */

:root {
  /* Refined ink palette — cooler, calmer */
  --ink-900: #0b1220;
  --ink-700: #1f2937;
  --ink-500: #475569;
  --ink-400: #64748b;
  --ink-300: #94a3b8;
  --hairline: #e5e7eb;
  --hairline-strong: #d1d5db;
  --surface: #ffffff;
  --surface-sunken: #f8fafc;
  --surface-raised: #ffffff;

  /* Premium shadows (subtle, layered) */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.06), 0 4px 6px -4px rgba(15, 23, 42, 0.04);

  /* Premium radii — 8 not 12 */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;
}

/* --- Body typography: variable Inter, 14px base, tight rhythm --- */
body {
  font-family: "Inter", "Inter Variable", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  font-feature-settings: "cv11", "ss01", "ss03", "cv02" !important;
  font-size: 14px !important;
  line-height: 1.5 !important;
  color: var(--ink-700) !important;
  background: var(--surface-sunken) !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}

/* --- Tabular numerals on every numeric surface --- */
.metric strong,
.metric small,
.chip,
.tag,
.user-chip,
.status-pill,
#taskCount,
#residentCount,
#rosterCount,
.panel-heading span,
[id$="Count"] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "cv11" 1;
}

/* --- Topbar: refined inline header (do NOT make sticky; original
   layout has a top nav strip already). Just polish typography. --- */
.topbar {
  /* UX fix: right-align the action chips (status pill, user chip,
     sign-out button) even when the h1 is empty / replaced by the
     dashboard hero. Without this, the actions float in the upper-
     left dead zone above the page hero, which testers flagged as
     "misplaced". */
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  min-height: 40px !important;
  margin-bottom: 16px !important;
  padding: 4px 0 !important;
}
.topbar h1 {
  font-size: 18px !important;
  font-weight: 600 !important;
  color: var(--ink-900) !important;
  letter-spacing: -0.015em !important;
}
/* Push actions to the trailing edge whether the h1 is shown or empty. */
.topbar-actions {
  margin-left: auto !important;
  gap: 8px !important;
}

/* --- Chips/pills: smaller, neutral, refined.
   Note: tone-specific overrides (.tag[data-tone="risk"|"warning"|"positive"|"critical"])
   must continue to win, so we DO NOT force background/color/border-color here on the
   base .tag selector — only the structural rules. --- */
.chip, .tag, .user-chip, .status-pill {
  height: 24px !important;
  min-height: 24px !important;
  padding: 0 8px !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  border-radius: 6px !important;
  letter-spacing: 0 !important;
}
.chip:not([data-tone]), .tag:not([data-tone]) {
  background: var(--surface) !important;
  color: var(--ink-500) !important;
  border-color: var(--hairline) !important;
}
.user-chip {
  background: transparent !important;
  border-color: transparent !important;
  color: var(--ink-500) !important;
}
.status-pill {
  background: #ecfdf5 !important;
  color: #047857 !important;
  border-color: #a7f3d0 !important;
  font-weight: 600 !important;
}
.status-pill::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  margin-right: 6px;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.18);
}

/* --- Facility hero: refined KPI strip (eyebrow + chips + action) --- */
.facility-hero {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 0 16px !important;
  margin: 0 !important;
  border-bottom: 1px solid var(--hairline) !important;
  border-radius: 0 !important;
  min-height: 0 !important;
  flex-wrap: nowrap !important;
}
.facility-hero .hero-copy { gap: 0 !important; display: block !important; flex: 0 0 auto !important; min-width: 0; }
.facility-hero .hero-copy p {
  font-size: 11px !important;
  font-weight: 600 !important;
  color: var(--ink-400) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.06em !important;
  margin: 0 !important;
}
.facility-hero .hero-copy h2 {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.facility-hero .hero-facts {
  gap: 6px !important;
  margin-left: auto !important;
  flex: 0 1 auto !important;
}
.facility-hero .primary-action {
  margin-left: 8px !important;
  height: 32px;
  padding: 0 12px !important;
  font-size: 13px !important;
}
@media (max-width: 720px) {
  .facility-hero { flex-wrap: wrap !important; }
  .facility-hero .hero-facts { margin-left: 0 !important; width: 100%; }
}

/* --- Section headings: quieter, more confident --- */
.section-heading h2 {
  font-size: 20px !important;
  font-weight: 600 !important;
  letter-spacing: -0.015em !important;
  color: var(--ink-900) !important;
}
.panel h3, .form-title h3 {
  font-size: 14px !important;
  font-weight: 600 !important;
  letter-spacing: -0.005em !important;
  color: var(--ink-900) !important;
}
.eyebrow {
  font-size: 11px !important;
  font-weight: 600 !important;
  letter-spacing: 0.06em !important;
  color: var(--ink-400) !important;
}

/* --- Panels: thinner border, tighter padding, premium shadow --- */
.panel {
  background: var(--surface) !important;
  border: 1px solid var(--hairline) !important;
  border-radius: var(--r-md) !important;
  box-shadow: var(--shadow-xs) !important;
  padding: 18px !important;
}
.panel-heading {
  margin-bottom: 12px !important;
  padding-bottom: 0 !important;
  border-bottom: 0 !important;
}
.panel-heading span {
  font-size: 12px !important;
  font-weight: 500 !important;
  color: var(--ink-400) !important;
}

/* --- Metric cards: dense, numerical, premium --- */
.metric-grid {
  gap: 10px !important;
}
.metric {
  background: var(--surface) !important;
  border: 1px solid var(--hairline) !important;
  border-radius: var(--r-md) !important;
  padding: 14px 16px !important;
  box-shadow: var(--shadow-xs) !important;
  transition: border-color 100ms ease, box-shadow 100ms ease !important;
  transform: none !important;
}
.metric:hover {
  border-color: var(--hairline-strong) !important;
  box-shadow: var(--shadow-sm) !important;
  transform: none !important;
}
.metric small {
  font-size: 11px !important;
  font-weight: 600 !important;
  color: var(--ink-400) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.06em !important;
  margin-bottom: 6px !important;
}
.metric strong {
  font-size: 24px !important;
  font-weight: 600 !important;
  letter-spacing: -0.02em !important;
  color: var(--ink-900) !important;
  line-height: 1.1 !important;
}

/* --- Buttons: refined, restrained, consistent --- */
.primary-action, button.primary-action {
  font-size: 13px !important;
  font-weight: 500 !important;
  letter-spacing: -0.005em !important;
  border-radius: var(--r-sm) !important;
  padding: 7px 14px !important;
  min-height: 32px !important;
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.12) !important;
  transition: background 80ms ease, box-shadow 80ms ease !important;
  transform: none !important;
}
.primary-action:hover { transform: none !important; box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.12) !important; }

.secondary-action, button.secondary-action,
.ghost-button, button.ghost-button {
  font-size: 13px !important;
  font-weight: 500 !important;
  border-radius: var(--r-sm) !important;
  padding: 7px 12px !important;
  min-height: 32px !important;
  background: var(--surface) !important;
  border: 1px solid var(--hairline) !important;
  color: var(--ink-700) !important;
  box-shadow: var(--shadow-xs) !important;
}
.secondary-action:hover, .ghost-button:hover {
  background: var(--surface-sunken) !important;
  border-color: var(--hairline-strong) !important;
}

/* --- Sidebar (horizontal nav strip): cleaner, denser typography --- */
.sidebar {
  background: var(--surface) !important;
  border-bottom: 1px solid var(--hairline) !important;
}
.brand {
  font-size: 13px !important;
  letter-spacing: -0.01em !important;
}
.brand strong { font-weight: 600 !important; font-size: 14px !important; color: var(--ink-900) !important; }

.nav-button {
  font-size: 13px !important;
  font-weight: 500 !important;
  color: var(--ink-500) !important;
  letter-spacing: -0.005em !important;
}
.nav-button:hover {
  color: var(--ink-900) !important;
  background: var(--surface-sunken) !important;
}
.nav-button.is-active {
  color: var(--teal-dark) !important;
  font-weight: 600 !important;
}

/* --- List items / rows: tighter, hover-quiet --- */
.list-item, .resident-card, .resident-strip-card {
  border-radius: var(--r-md) !important;
  border: 1px solid var(--hairline) !important;
  padding: 12px 14px !important;
  background: var(--surface) !important;
  box-shadow: none !important;
  transition: background 80ms ease, border-color 80ms ease !important;
}
.list-item:hover, .resident-card:hover, .resident-strip-card:hover {
  background: var(--surface-sunken) !important;
  border-color: var(--hairline-strong) !important;
  transform: none !important;
}

/* --- Form controls: refined inputs --- */
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="datetime-local"], input[type="search"], input[type="tel"],
select, textarea {
  font-family: inherit !important;
  font-size: 13px !important;
  border-radius: var(--r-sm) !important;
  border: 1px solid var(--hairline-strong) !important;
  padding: 7px 10px !important;
  background: var(--surface) !important;
  color: var(--ink-900) !important;
  box-shadow: var(--shadow-xs) !important;
  transition: border-color 80ms ease, box-shadow 80ms ease !important;
}
input:focus, select:focus, textarea:focus {
  outline: none !important;
  border-color: var(--teal, #0d9488) !important;
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.14) !important;
}

/* --- Toast: subtle slide --- */
.toast {
  font-size: 13px !important;
  border-radius: var(--r-md) !important;
  padding: 10px 14px !important;
  box-shadow: var(--shadow-lg) !important;
  border: 1px solid var(--hairline) !important;
}

/* --- Skeleton shimmer for loading states --- */
@keyframes rc-shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton, [data-loading="true"] {
  background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 800px 100%;
  animation: rc-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
  color: transparent !important;
  user-select: none;
}

/* --- Selection color --- */
::selection {
  background: rgba(13, 148, 136, 0.18);
  color: var(--ink-900);
}

/* --- Scrollbar: thin & neutral --- */
* { scrollbar-width: thin; scrollbar-color: var(--hairline-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--hairline-strong); border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--ink-300); border: 2px solid transparent; background-clip: padding-box; }

/* --- Final motion contract: short, single-direction --- */
* { transition-duration: 80ms; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* --- Empty states: premium SaaS pattern (icon + title + hint + CTA) --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  padding: 32px 20px;
  border: 1px dashed var(--hairline);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  color: var(--ink-500);
  min-height: 160px;
}
.empty-state__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--hairline);
  color: var(--teal-dark, #0f766e);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
  box-shadow: var(--shadow-xs);
}
.empty-state__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-900);
  letter-spacing: -0.005em;
}
.empty-state__hint {
  font-size: 13px;
  color: var(--ink-500);
  max-width: 36ch;
  line-height: 1.5;
}
.empty-state__action {
  margin-top: 8px;
}

/* ============================================================
   P2 polish — topbar separator, sign-out icon alignment,
   nav inactive contrast bump. v20260602s
   ============================================================ */
.topbar-sep {
  display: inline-block;
  width: 1px;
  height: 20px;
  background: var(--line, #e5e7eb);
  margin: 0 4px;
}
.topbar-signout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.topbar-signout-icon {
  flex: 0 0 14px;
  color: currentColor;
}
/* P2-4: darken inactive nav tabs for AA contrast against pale bar */
.nav-button:not(.is-active) {
  color: #475569; /* slate-600, ~ink-700 */
}
.nav-button:not(.is-active):hover {
  color: #0f172a;
}
/* P2-3 ensure dashboard chip row wraps cleanly on narrow */
#metrics, .metric-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ============================================================
   Resident chart tabs — enhanced segmented design w/ icons
   v20260602t   (icons + active pill + scroll-snap + a11y)
   ============================================================ */
.resident-chart-tabs {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 4px !important;
  padding: 6px 6px 8px !important;
  margin: 0 0 20px !important;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%) !important;
  border: 1px solid var(--line, #e5e7eb) !important;
  border-radius: 12px !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
  overflow-x: auto !important;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
  position: relative;
}
.resident-chart-tabs::-webkit-scrollbar { height: 6px; }
.resident-chart-tabs::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.18);
  border-radius: 3px;
}

.resident-chart-tab {
  appearance: none !important;
  flex: 0 0 auto !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 7px !important;
  min-height: 36px !important;
  padding: 8px 14px !important;
  border: 1px solid transparent !important;
  border-radius: 8px !important;
  background: transparent !important;
  color: #475569 !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  white-space: nowrap !important;
  cursor: pointer;
  scroll-snap-align: start;
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
  margin-bottom: 0 !important;
  box-shadow: none !important;
}
.resident-chart-tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: currentColor;
  opacity: 0.85;
  flex: 0 0 16px;
}
.resident-chart-tab-label { line-height: 1; }

.resident-chart-tab:hover,
.resident-chart-tab:focus-visible {
  color: #0f172a !important;
  background: #ffffff !important;
  border-color: var(--line, #e5e7eb) !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06) !important;
  outline: none;
}
.resident-chart-tab:focus-visible {
  border-color: var(--teal, #0d9488) !important;
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.20) !important;
}

.resident-chart-tab.is-active {
  color: var(--teal-dark, #0f766e) !important;
  background: #ffffff !important;
  border-color: var(--teal, #0d9488) !important;
  box-shadow: 0 1px 0 rgba(13, 148, 136, 0.10), 0 4px 12px rgba(13, 148, 136, 0.14) !important;
  border-bottom-color: var(--teal, #0d9488) !important;
}
.resident-chart-tab.is-active .resident-chart-tab-icon { opacity: 1; }

/* Narrow screens — collapse to icon-only chips */
@media (max-width: 720px) {
  .resident-chart-tab { padding: 8px 10px !important; }
  .resident-chart-tab-label { display: none; }
  .resident-chart-tab.is-active .resident-chart-tab-label {
    display: inline; margin-left: 2px; font-size: 12px;
  }
}

/* ============================================================
   Resident chart tabs — wrapping tile grid (v20260602w)
   Replaces the v20260602u horizontal-scroll fix. Tabs now wrap
   onto a second row at narrow widths with even spacing — no
   scrollbar, no mask fade, no clipped labels.
   ============================================================ */
.resident-chart-tabs {
  /* Override the base nowrap + overflow-x:auto so tabs wrap to a
     second row instead of producing a horizontal scrollbar. */
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: stretch !important;
  gap: 6px !important;
  padding: 8px !important;
  overflow: visible !important;
  /* No scroll-snap or mask: the row simply wraps. */
  scroll-snap-type: none !important;
  -webkit-mask-image: none !important;
          mask-image: none !important;
}
.resident-chart-tab {
  /* Each tab is a tile that takes equal share of the row, with a
     sensible minimum so labels never truncate. flex-basis is set
     just under 1/6 so two rows of ~5–6 tiles fit cleanly across
     all viewports without hitting overflow. */
  flex: 1 1 140px !important;
  min-width: 0 !important;
  justify-content: center !important;
  padding: 8px 12px !important;
  font-size: 13px !important;
  gap: 6px !important;
  min-height: 36px !important;
  white-space: nowrap !important;
}
.resident-chart-tab-icon { flex: 0 0 16px; width: 16px; height: 16px; }
.resident-chart-tab-icon svg { width: 16px; height: 16px; }
.resident-chart-tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Hide any leftover scrollbar from the v20260602t base block. */
.resident-chart-tabs::-webkit-scrollbar { height: 0 !important; width: 0 !important; }

/* ============================================================
   Access Control (Admin > Access Control) — v20260602v
   Role permission matrix + user role assignment table.
   ============================================================ */
.rc-access {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}
.rc-access__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.rc-access__header h3 { margin: 0 0 4px; font-size: 16px; font-weight: 700; color: var(--ink, #0f172a); }
.rc-access__header p { margin: 0; font-size: 13px; color: var(--muted, #64748b); }
.rc-access__hint {
  margin: 0;
  padding: 10px 14px;
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 12.5px;
  color: #854d0e;
}
.rc-access-loading {
  padding: 28px 14px;
  text-align: center;
  color: var(--muted, #64748b);
  font-size: 14px;
}

.rc-matrix-wrap, .rc-users-wrap {
  overflow-x: auto;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 8px;
  background: #fff;
}
.rc-matrix, .rc-users {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.rc-matrix th, .rc-matrix td,
.rc-users th, .rc-users td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line, #e5e7eb);
  vertical-align: top;
}
.rc-matrix thead th, .rc-users thead th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--ink, #0f172a);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
}
.rc-matrix tbody th { font-weight: 500; color: var(--ink, #0f172a); }
.rc-matrix tbody th small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--muted, #94a3b8);
  margin-top: 2px;
  font-family: var(--mono, ui-monospace, "SF Mono", Menlo, monospace);
}
.rc-matrix-section th {
  background: #f1f5f9 !important;
  color: var(--ink, #0f172a) !important;
  font-size: 11px !important;
  letter-spacing: 0.08em;
  padding: 6px 10px !important;
}
.rc-matrix-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.rc-matrix-cell input { width: 16px; height: 16px; cursor: pointer; }
.rc-matrix td { text-align: center; }

.rc-users td strong { display: block; color: var(--ink, #0f172a); }
.rc-users td small { color: var(--muted, #64748b); font-size: 12px; }
.rc-user-role {
  padding: 6px 10px;
  border: 1px solid var(--line, #d1d5db);
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  background: #fff;
  cursor: pointer;
  min-width: 200px;
}
.rc-user-role:focus-visible {
  outline: 2px solid var(--teal, #0d9488);
  outline-offset: 2px;
}

/* ============================================================
   Admin chart tabs — wrapping tile grid (v20260602x)
   Mirrors the resident-chart-tabs treatment from v20260602w:
   each top-level admin section becomes an equal-width tile that
   wraps onto a second row at narrow widths. Replaces the
   underline tab strip so Admin and Resident workspaces share
   the same visual language.
   ============================================================ */
.admin-chart-tabs {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: stretch !important;
  gap: 6px !important;
  padding: 8px !important;
  margin: 0 0 18px !important;
  background: #f8fafc !important;
  border: 1px solid var(--line, #e5e7eb) !important;
  border-radius: 10px !important;
  box-shadow: none !important;
  overflow: visible !important;
}
.admin-chart-tabs::-webkit-scrollbar { height: 0 !important; width: 0 !important; }

.admin-chart-tab {
  appearance: none !important;
  flex: 1 1 140px !important;
  min-width: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  padding: 8px 12px !important;
  margin: 0 !important;
  min-height: 36px !important;
  background: transparent !important;
  border: 1px solid transparent !important;
  border-radius: 8px !important;
  color: var(--muted, #64748b) !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  letter-spacing: 0 !important;
  white-space: nowrap !important;
  box-shadow: none !important;
  cursor: pointer;
  transition: color 120ms ease, background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
.admin-chart-tab:hover,
.admin-chart-tab:focus-visible {
  color: var(--ink, #0f172a) !important;
  background: #ffffff !important;
  border-color: var(--line, #e5e7eb) !important;
  outline: none;
}
.admin-chart-tab.is-active {
  color: var(--teal-dark, #0f766e) !important;
  background: #ffffff !important;
  border-color: var(--teal, #0d9488) !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05) !important;
}

/* ============================================================
   Billing workspace — $100M SaaS polish (v20260602y)
   KPI strip, status filter tabs, search, sortable columns,
   pagination, and CSV export. Renders inside section-billing.
   ============================================================ */
.section-heading-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.ghost-action {
  appearance: none;
  background: #ffffff;
  border: 1px solid var(--line, #e5e7eb);
  color: var(--ink, #0f172a);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease;
}
.ghost-action:hover,
.ghost-action:focus-visible {
  border-color: var(--teal, #0d9488);
  color: var(--teal-dark, #0f766e);
  background: #f0fdfa;
  outline: none;
}

.billing-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.billing-kpi {
  background: #ffffff;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  position: relative;
  overflow: hidden;
}
.billing-kpi::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 3px;
  background: var(--line, #e5e7eb);
}
.billing-kpi[data-tone="critical"]::before { background: #ef4444; }
.billing-kpi[data-tone="warning"]::before { background: #f59e0b; }
.billing-kpi[data-tone="positive"]::before { background: #10b981; }
.billing-kpi[data-tone="neutral"]::before { background: var(--teal, #0d9488); }
.billing-kpi-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted, #64748b);
}
.billing-kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink, #0f172a);
  font-variant-numeric: tabular-nums;
}
.billing-kpi-sub {
  font-size: 12px;
  color: var(--muted, #64748b);
}

.billing-panel { padding: 0 !important; }
.billing-panel > .panel-heading {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line, #e5e7eb);
  margin: 0;
}
.billing-panel > .table-wrap { padding: 0; }
.billing-panel .billing-table { margin: 0; }

.billing-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line, #e5e7eb);
  background: #f8fafc;
}
.billing-status-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: #ffffff;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 8px;
}
.billing-status-tab {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted, #64748b);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color 120ms ease, color 120ms ease;
}
.billing-status-tab:hover { color: var(--ink, #0f172a); }
.billing-status-tab.is-active {
  background: var(--teal, #0d9488);
  color: #ffffff;
}
.billing-status-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 0 6px;
  height: 18px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(15, 23, 42, 0.08);
  color: inherit;
  border-radius: 9px;
}
.billing-status-tab.is-active .billing-status-count {
  background: rgba(255, 255, 255, 0.25);
}

.billing-toolbar-controls {
  display: inline-flex;
  gap: 8px;
  margin-left: auto;
  align-items: center;
  /* UX audit: when the toolbar wraps, the search input previously stayed
     at its 280px min so its long placeholder ("…responsible party…") got
     clipped. flex-wrap + 1 1 320px lets it grow to fill any spare row. */
  flex-wrap: wrap;
}
.billing-search {
  appearance: none;
  border: 1px solid var(--line, #d1d5db);
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  min-width: 320px;
  flex: 1 1 320px;
  background: #ffffff;
}
.billing-search:focus {
  outline: none;
  border-color: var(--teal, #0d9488);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.18);
}
.billing-pagesize {
  appearance: none;
  border: 1px solid var(--line, #d1d5db);
  border-radius: 8px;
  padding: 8px 28px 8px 12px;
  font: inherit;
  font-size: 13px;
  background: #ffffff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/></svg>") no-repeat right 10px center;
  cursor: pointer;
}

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

.billing-table th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.billing-table th.sortable:hover { color: var(--teal-dark, #0f766e); }
.billing-table th.sortable .sort-indicator {
  display: inline-block;
  min-width: 10px;
  margin-left: 4px;
  font-size: 10px;
  color: var(--muted, #94a3b8);
}
.billing-table th.is-sorted { color: var(--teal-dark, #0f766e); }
.billing-table th.is-sorted .sort-indicator { color: var(--teal, #0d9488); }
.billing-table th.num, .billing-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.billing-id {
  font-family: var(--mono, ui-monospace, "SF Mono", Menlo, monospace);
  font-size: 12px;
  color: var(--muted, #475569);
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
}
.billing-empty-row {
  text-align: center;
  padding: 32px 16px !important;
  color: var(--muted, #64748b);
  font-style: italic;
}

.billing-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 12px 18px;
  border-top: 1px solid var(--line, #e5e7eb);
  background: #f8fafc;
  flex-wrap: wrap;
}
.billing-page-btn {
  appearance: none;
  background: #ffffff;
  border: 1px solid var(--line, #e5e7eb);
  color: var(--ink, #0f172a);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  min-width: 36px;
  transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease;
}
.billing-page-btn:hover:not(:disabled) {
  border-color: var(--teal, #0d9488);
  color: var(--teal-dark, #0f766e);
}
.billing-page-btn.is-active {
  background: var(--teal, #0d9488);
  border-color: var(--teal, #0d9488);
  color: #ffffff;
}
.billing-page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.billing-page-ellipsis {
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  color: var(--muted, #94a3b8);
}

.tag[data-tone="neutral"],
.chip[data-tone="neutral"] {
  color: #475569;
  background: #f1f5f9;
  border-color: #e2e8f0;
}

/* ============================================================
   Billing v20260602z — date range, row actions, detail modal
   ============================================================ */
.billing-date-range { display: inline-flex; align-items: center; }
.billing-date {
  appearance: none;
  border: 1px solid var(--line, #d1d5db);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
  background: #ffffff;
  color: var(--ink, #0f172a);
  /* UX audit: placeholder "mm/dd/yyyy" needs >=160px on macOS Safari/Chrome
     or the field renders as "mm/dd/y". 168px keeps the picker icon visible. */
  min-width: 168px;
}
.billing-date:focus {
  outline: none;
  border-color: var(--teal, #0d9488);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.18);
}
.billing-date-sep { color: var(--muted, #94a3b8); padding: 0 2px; }
.billing-date-clear { padding: 7px 10px !important; }

.billing-id-link {
  appearance: none;
  background: #f1f5f9;
  border: 0;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--mono, ui-monospace, "SF Mono", Menlo, monospace);
  font-size: 12px;
  color: var(--teal-dark, #0f766e);
  cursor: pointer;
  text-decoration: none;
}
.billing-id-link:hover { background: #e2e8f0; text-decoration: underline; }

.billing-actions-col { width: 48px; }
.billing-actions-cell { text-align: right; padding-right: 12px !important; }
.billing-row-menu { position: relative; display: inline-block; }
.billing-row-menu-toggle {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--muted, #64748b);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.billing-row-menu-toggle:hover,
.billing-row-menu-toggle[aria-expanded="true"] {
  background: #f1f5f9;
  color: var(--ink, #0f172a);
  border-color: var(--line, #e5e7eb);
}
.billing-row-menu-list {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 180px;
  background: #ffffff;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  padding: 4px;
  z-index: 50;
}
.billing-row-menu.is-open .billing-row-menu-list { display: block; }
.billing-row-menu-list button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--ink, #0f172a);
  border-radius: 6px;
  cursor: pointer;
}
.billing-row-menu-list button:hover:not(:disabled) {
  background: #f1f5f9;
  color: var(--teal-dark, #0f766e);
}
.billing-row-menu-list button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Invoice detail modal contents */
.invoice-detail { display: flex; flex-direction: column; gap: 16px; }
.invoice-detail-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  padding: 14px;
  background: #f8fafc;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 10px;
}
.invoice-detail-summary > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.invoice-detail-summary strong {
  font-size: 14px;
  color: var(--ink, #0f172a);
  font-weight: 600;
  word-break: break-word;
}
.invoice-detail-heading {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink, #0f172a);
}
.invoice-detail-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.invoice-detail-table th, .invoice-detail-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line, #e5e7eb);
  text-align: left;
}
.invoice-detail-table thead th {
  background: #f8fafc;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink, #0f172a);
}
.invoice-detail-table th.num, .invoice-detail-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.invoice-detail-table tfoot th {
  background: #f8fafc;
  font-weight: 600;
}
.invoice-detail-table tfoot .invoice-detail-balance th {
  background: #ecfeff;
  color: var(--teal-dark, #0f766e);
  font-weight: 700;
}
.invoice-detail-note {
  margin: 0;
  font-size: 13px;
  color: var(--muted, #64748b);
}
.invoice-detail-note a { color: var(--teal-dark, #0f766e); font-weight: 600; }

/* ============================================================
   Billing v20260603a — responsible party block + detail contacts
   ============================================================ */
.responsible-party-block {
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f8fafc;
}
.responsible-party-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted, #64748b);
}
.responsible-party-block label {
  font-size: 12px;
  color: var(--ink, #0f172a);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.responsible-party-block input,
.responsible-party-block textarea {
  font: inherit;
  font-size: 13px;
  padding: 7px 9px;
  border: 1px solid var(--line, #d1d5db);
  border-radius: 6px;
  background: #fff;
  resize: vertical;
}
.responsible-party-block input:focus,
.responsible-party-block textarea:focus {
  outline: none;
  border-color: var(--teal, #0d9488);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.16);
}

.invoice-detail-summary > div { gap: 4px; }
.invoice-detail-link {
  font-size: 12px;
  color: var(--teal-dark, #0f766e);
  text-decoration: none;
  word-break: break-all;
}
.invoice-detail-link:hover { text-decoration: underline; }
.invoice-detail-address {
  font-size: 12px;
  color: var(--ink, #0f172a);
  white-space: pre-line;
}

/* ============================================================
   Reports + Integrations action rows — v20260603a
   ============================================================ */
.report-actions, .integration-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
}
.report-meta { font-size: 11px; }
.integration-actions .ghost-action { font-size: 12px; padding: 6px 10px; }

.responsible-party-address-grid {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}
.responsible-party-address-grid .rp-addr-row {
  display: grid;
  grid-template-columns: 2fr 0.7fr 0.9fr;
  gap: 8px;
}
.responsible-party-address-grid label {
  font-size: 0.78rem;
  color: var(--muted, #64748b);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meds-calendar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 8px;
}
.meds-calendar-grid .calendar-slot {
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface, #fff);
}
.meds-calendar-grid .calendar-slot strong { display:block; font-size: 0.85rem; color: var(--accent, #2563eb); margin-bottom: 6px; }
.meds-calendar-grid .calendar-slot ul { margin: 0; padding-left: 18px; font-size: 0.85rem; }
.meds-calendar-grid .calendar-slot small { color: var(--muted, #64748b); font-size: 0.8rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 8px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; color: var(--muted, #475569); }
.form-grid label input, .form-grid label select, .form-grid label textarea {
  padding: 6px 8px; border: 1px solid var(--border, #cbd5e1); border-radius: 6px; font-size: 0.9rem;
}
.form-grid .form-grid-full { grid-column: 1 / -1; }
.form-grid .form-grid-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }

/* History range controls (Assessment + MAR sub-panels) */
.history-range-control {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 8px 0 12px;
}
.history-range-control .segmented-control { flex-wrap: wrap; }
.history-custom-input {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem;
  color: var(--text-muted, #64748b);
}
.history-custom-input input {
  padding: 4px 6px; border: 1px solid var(--border, #cbd5e1); border-radius: 6px;
}
.assessment-history-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.assessment-history-row .row-actions { display: flex; gap: 8px; flex-shrink: 0; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border, #e2e8f0); }
.data-table thead th { font-weight: 600; background: var(--surface-alt, #f8fafc); }

/* AI / dropdown / time-chip controls */
.input-with-action { display: flex; gap: 6px; align-items: flex-start; }
.input-with-action > input, .input-with-action > textarea { flex: 1 1 auto; }
.ai-button-stack { display: flex; flex-direction: column; gap: 4px; }
.compact-action { padding: 4px 10px; font-size: 0.8rem; line-height: 1.2; white-space: nowrap; }
.ai-suggest-output { display: block; margin-top: 4px; font-size: 0.75rem; color: #475569; min-height: 1em; }
.time-chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
/* min-width/min-height 32px keeps each chip within WCAG 2.5.5 target-size
   (assert_touch_targets_are_usable in tests/integration/test_website_selenium.py). */
.time-chip { padding: 6px 12px; min-width: 32px; min-height: 32px; border: 1px solid #cbd5e1; border-radius: 999px; background: #f8fafc; cursor: pointer; font-size: 0.85rem; }
.time-chip.is-active { background: #1e40af; color: #fff; border-color: #1e40af; }

/* Work queue filters & groups */
.filter-chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; padding: 0; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--hairline, #e2e8f0); background: #fff; color: var(--ink, #0f172a); font-size: 12.5px; line-height: 1; cursor: pointer; transition: background 120ms ease, border-color 120ms ease; }
.filter-chip:hover { background: #f8fafc; }
.filter-chip.is-active { background: var(--teal-dark, #0e4d49); color: #fff; border-color: var(--teal-dark, #0e4d49); }
.filter-chip[data-tone="risk"] { color: #b3261e; border-color: #f2c7c7; }
.filter-chip[data-tone="risk"].is-active { background: #b3261e; color: #fff; border-color: #b3261e; }
.filter-chip-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 6px; border-radius: 999px; background: rgba(15, 23, 42, 0.08); color: inherit; font-size: 11px; font-weight: 600; }
.filter-chip.is-active .filter-chip-count { background: rgba(255, 255, 255, 0.18); }
.task-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.task-group:last-child { margin-bottom: 0; }
.task-group-heading { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 6px; border-bottom: 1px solid var(--hairline, #e2e8f0); }
.task-group-heading strong { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted, #64748b); }
.task-group-heading span { font-size: 11px; color: var(--muted, #64748b); }

/* Resident roster pagination */
.resident-roster-pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--hairline, #e2e8f0); }
.resident-roster-pagination-info { font-size: 12.5px; color: var(--muted, #64748b); }
.resident-roster-pagination .ghost-action[disabled] { opacity: 0.45; cursor: not-allowed; }

/* Chart header: context chip strip */
.resident-header-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.resident-header-chips .tag { font-size: 12px; }

/* Med-safety status tones + disabled CTA */
.primary-action[disabled], .primary-action[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.med-safety-status[data-tone="warning"] { color: var(--amber, #b45309); }
.med-safety-status[data-tone="info"] { color: var(--muted, #64748b); }

/* ============================================================
   v20260603h — round-2 audit fixes
   ============================================================ */

/* A4: idle-warning session toast (CSP-safe replacement for inline styles) */
.rohacare-idle-title { font-weight: 600; margin-bottom: 6px; }
.rohacare-idle-countdown { margin-bottom: 10px; }
.rohacare-idle-stay {
  background: #22c55e; color: #0b3a16; border: 0; border-radius: 6px;
  padding: 8px 12px; font-weight: 600; cursor: pointer;
}

/* CSP-safe replacement for form-actions inline grid-column override */
.form-actions-full { grid-column: 1 / -1; }
.form-grid-spaced { margin-top: 1rem; }

/* A1: mobile shell — push workspace below the (taller) sidebar on narrow viewports.
   The sidebar is position:fixed top:0 with row layout > 920px, column layout below;
   the prior padding-top:84px was correct only for the row layout. */
@media (max-width: 920px) {
  .workspace {
    padding-top: clamp(132px, 28vw, 168px);
  }
}
@media (max-width: 620px) {
  .workspace {
    padding-top: clamp(140px, 32vw, 180px);
  }
  .nav-list {
    overflow-x: auto;
    /* visible scroll hint */
    scrollbar-color: rgba(14,77,73,0.35) transparent;
  }
  .topbar { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .topbar-actions { width: auto; }
}

/* A5/A8: dashboard header — replaces .facility-hero + redundant h1 */
.dashboard-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 18px;
  padding: 0;
  flex-wrap: wrap; /* UX audit: prevent the actions strip from squeezing the
                     hero title into a narrow column when chips are wide. */
}
.dashboard-header-copy { min-width: 320px; flex: 1 1 320px; }
.dashboard-header-copy h2 {
  margin: 0;
  font-size: clamp(22px, 2vw, 28px);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
  color: var(--ink);
}
.dashboard-header-copy h2 span { color: var(--teal-dark); }
.dashboard-header-sub {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.dashboard-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}
@media (max-width: 720px) {
  .dashboard-header { flex-direction: column; align-items: stretch; }
  .dashboard-header-actions { justify-content: flex-start; }
}

/* A5: hero metric strip — promotes existing #metrics above the fold */
.metric-grid-hero {
  margin: 0 0 18px;
}

/* A11: create-invoice modal */
.rohacare-modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: flex-start; justify-content: center;
  padding: clamp(16px, 4vh, 60px) clamp(12px, 4vw, 32px);
}
.rohacare-modal[hidden] { display: none; }
.rohacare-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 32, 39, 0.55);
  backdrop-filter: blur(2px);
}
.rohacare-modal-panel {
  position: relative;
  width: min(620px, 100%);
  max-height: calc(100vh - 80px);
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(15, 32, 39, 0.28);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.rohacare-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 12px;
  border-bottom: 1px solid var(--line);
}
.rohacare-modal-header h3 {
  margin: 0; font-size: 18px; font-weight: 700;
}
.rohacare-modal-close {
  background: transparent; border: 0; cursor: pointer;
  font-size: 24px; line-height: 1; color: var(--muted);
  width: 32px; height: 32px; border-radius: 8px;
}
.rohacare-modal-close:hover { background: rgba(14,77,73,0.06); color: var(--ink); }
.rohacare-modal-body {
  padding: 18px 22px 22px;
  overflow-y: auto;
}
.form-panel-flush { background: transparent; border: 0; padding: 0; box-shadow: none; }

/* ============================================================
   Round 3 UI/UX fixes — v20260603i
   A6 work-queue collapsible groups
   A7 resident snapshot "view all" CTA
   A9 admin shell IA cleanup
   A12 billing date input widths
   A13 topbar duplication on dashboard
   A15 last-refreshed stamp
   ============================================================ */

/* sr-only helper for headings that exist for a11y but should not paint */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* A6 — collapsible task group headings */
.task-group { margin-bottom: 10px; }
.task-group-heading {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  appearance: none;
  background: rgba(13, 148, 136, 0.06);
  border: 1px solid rgba(13, 148, 136, 0.18);
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit; cursor: pointer;
  color: var(--ink, #0f172a);
  text-align: left;
}
.task-group-heading:hover { background: rgba(13, 148, 136, 0.1); }
.task-group-heading strong { font-size: 13px; font-weight: 700; flex: 1; }
.task-group-count {
  font-size: 12px; font-weight: 600;
  color: var(--muted, #475569);
  background: #fff;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 999px;
  padding: 2px 8px;
}
.task-group-caret {
  font-size: 11px; line-height: 1;
  color: var(--teal-dark, #0f766e);
  width: 12px; display: inline-block;
}
.task-group-body { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.task-group.is-collapsed .task-group-body { display: none; }

/* A7 — resident snapshot "view all" link card */
.resident-strip-more {
  appearance: none;
  background: transparent;
  border: 1px dashed var(--line, #cbd5e1);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--teal-dark, #0f766e);
  font: inherit; font-weight: 600;
  cursor: pointer;
  text-align: left;
  margin-top: 6px;
}
.resident-strip-more:hover {
  background: rgba(13, 148, 136, 0.06);
  border-color: var(--teal, #0d9488);
}

/* A9 — admin shell: remove redundant "Administration" eyebrow inside the
   action panel since the tab and section heading already establish context. */
.admin-action-panel > div:first-child > span {
  display: none !important;
}

/* A12 — billing date inputs need more breathing room so MM/DD/YYYY doesn't clip */
.billing-date { min-width: 168px; }
.billing-date-clear { min-width: 64px; }

/* A13 — hide the "RohaCare" topbar h1 on the dashboard (the dashboard header
   already names the facility). Keep it on other sections as a wayfinder. */
body[data-section="dashboard"] .topbar h1 { display: none; }

/* A15 — last-refreshed stamp lives next to the Refresh button */
.refreshed-stamp {
  font-size: 12px;
  color: var(--muted, #64748b);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ----- Persona 2 family-portal staff modal & related helpers ----- */
.panel-heading-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.invite-family-help {
  margin: 0 0 12px;
  color: var(--muted, #64748b);
  font-size: 0.9rem;
}
.invite-family-result {
  margin-top: 14px;
  padding: 12px;
  background: #eef9f1;
  border-radius: 8px;
  font-size: 0.9rem;
}
.invite-family-result__title {
  margin: 0 0 8px;
  font-weight: 600;
  color: #0f5d27;
}
.invite-family-result__url {
  width: 100%;
  padding: 8px;
  border: 1px solid #c8d1e0;
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.8rem;
  box-sizing: border-box;
}
.invite-family-result__expires {
  margin: 6px 0 0;
  color: #0f5d27;
  font-size: 0.8rem;
}

/* PM-1: Family-notification approval queue (admin panel) */
.notifications-approval-help {
  margin: 0 0 12px;
  font-size: 0.88rem;
}
.notif-approval-card {
  border: 1px solid var(--surface-border, #e3e6ed);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  background: #fff;
}
.notif-approval-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}
.notif-approval-head strong {
  display: block;
  font-size: 0.95rem;
}
.notif-approval-head .small {
  margin: 2px 0 0;
  font-size: 0.78rem;
}
.notif-approval-body {
  background: #f5f7fb;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
  font-family: inherit;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 8px;
  max-height: 220px;
  overflow-y: auto;
}
.notif-approval-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.notif-approval-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tag.tone-warn {
  background: #fdf3d9;
  color: #7a5500;
}
.tag.tone-good {
  background: #e6f6ec;
  color: #0f5d27;
}
.tag.tone-muted {
  background: #eef2f7;
  color: #5b6471;
}
.small {
  font-size: 0.8rem;
}

/* PM-2 (Persona 3): family inbox cross-resident view. */
.nav-badge {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 0.45em;
  margin-left: 0.4em;
  font-size: 0.72rem;
  line-height: 1.4;
  text-align: center;
  border-radius: 999px;
  background: #d97706;
  color: #fff;
  font-weight: 600;
}
.family-inbox-help {
  margin: 0 0 0.75rem 0;
}
.family-inbox-row {
  border-left: 3px solid transparent;
}
.family-inbox-row .tag.tone-warn {
  background: #fef3c7;
  color: #92400e;
}
.family-inbox-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.family-inbox-row-body {
  margin: 0.4rem 0;
}
.family-inbox-row-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.link-button {
  background: none;
  border: none;
  color: #2563eb;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

/* Per-resident Family Messages thread (Family Messages tab). Inbound
   messages from the family portal hug the right, outbound staff
   replies hug the left, mirroring the reading direction in a typical
   chat thread without exceeding 8-bit chrome. */
.family-thread {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.family-thread-row {
  border: 1px solid var(--hairline, rgba(14, 77, 73, 0.12));
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
  max-width: 86%;
}
.family-thread-row--inbound {
  align-self: flex-end;
  border-left: 3px solid var(--teal-dark, #0e4d49);
  background: #f0f8f7;
}
.family-thread-row--outbound {
  align-self: flex-start;
  border-left: 3px solid #2563eb;
}
.family-thread-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.family-thread-subject {
  margin-bottom: 2px;
}
.family-thread-body {
  margin: 0;
  white-space: pre-wrap;
}
.link-button:hover {
  text-decoration: underline;
}

/* PM-3 (Persona 3): trial / seat-limit banner + upgrade modal. */
.billing-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 1rem;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
}
.billing-banner.tone-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}
.billing-banner-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0.15rem;
}
.billing-banner-cta {
  white-space: nowrap;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-backdrop[hidden] {
  display: none;
}
.modal-backdrop .modal {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.25);
}
.modal-backdrop .modal h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.25rem;
}
.modal-backdrop .modal .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}
.billing-upgrade-meta {
  margin: 0.75rem 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 0.75rem;
  font-size: 0.92rem;
}
.billing-upgrade-meta dt {
  font-weight: 600;
  color: #475569;
}
.billing-upgrade-meta dd {
  margin: 0;
}

/* PM-5 (Persona 3): audit log filter/search row. */
.audit-filter-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 0.5rem 0 0.75rem 0;
}
.audit-filter-row .resident-roster-search {
  flex: 1;
  min-width: 220px;
}
.audit-filter-row select {
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #fff;
}

/* PM-7 (Persona 3): Cmd+K resident quick-search palette. */
.quick-search-modal {
  max-width: 560px;
  padding: 0;
  overflow: hidden;
}
.quick-search-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e2e8f0;
}
.quick-search-head h2 {
  margin: 0;
  font-size: 1rem;
}
.quick-search-head kbd {
  background: #f1f5f9;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.75rem;
}
.quick-search-input {
  width: 100%;
  border: none;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border-bottom: 1px solid #e2e8f0;
  outline: none;
}
.quick-search-results {
  max-height: 320px;
  overflow-y: auto;
  padding: 0.25rem 0;
}
.quick-search-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  padding: 0.5rem 1rem;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  border-radius: 0;
}
.quick-search-row:hover,
.quick-search-row.is-active {
  background: #eff6ff;
}
.quick-search-foot {
  padding: 0.5rem 1rem;
  border-top: 1px solid #e2e8f0;
}
.quick-search-foot kbd {
  background: #f1f5f9;
  padding: 0.1rem 0.35rem;
  margin: 0 0.15rem;
  border-radius: 4px;
  font-size: 0.7rem;
}

/* PM-9 (Persona 3): Census & Occupancy report cards. */
.census-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}
.census-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.75rem;
}
.census-card h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  color: #475569;
}
.census-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.census-card li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem;
  padding: 0.2rem 0;
  border-bottom: 1px dashed #e2e8f0;
  align-items: baseline;
}
.census-card li:last-child {
  border-bottom: none;
}
.census-footer {
  margin-top: 0.75rem;
  display: flex;
  justify-content: flex-end;
}

/* PM-10 (Persona 3): mobile-responsive layout fallback for the
   resident roster and primary nav. */
@media (max-width: 768px) {
  .resident-roster-grid,
  .two-column,
  .three-column,
  .stat-grid,
  .stack-grid {
    grid-template-columns: 1fr !important;
  }
  .nav-list {
    flex-wrap: wrap;
  }
  .panel {
    padding: 0.75rem;
  }
  .top-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  table {
    display: block;
    overflow-x: auto;
  }
}

/* Resident safety banner — extracted from inline styles to satisfy CSP. */
.resident-safety-banner {
  background: #fff4ed;
  border-left: 4px solid #d97706;
  padding: 10px 14px;
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.resident-safety-banner__label {
  margin-right: 8px;
  color: #92400e;
}
