:root {
  --brand-blue: #044c92;
  --brand-green: #77c249;
  --navy: #082f4f;
  --navy-hover: #0d426c;
  --primary: #075297;
  --primary-hover: #043d72;
  --canvas: #f5f7fa;
  --surface: #ffffff;
  --ink: #172b4d;
  --muted: #5e6c84;
  --line: #d8e1ea;
  --success: #287d5a;
  --success-bg: #d8f7e8;
  --warning: #9a6700;
  --warning-bg: #fff1c7;
  --danger: #b42318;
  --danger-bg: #fee4e2;
  --focus: #2e90fa;
  --sidebar-text: #a8c0cf;
  --shadow: 0 1px 2px rgba(16, 42, 67, 0.08);
}

/* Reading history: Figma Version 3, scoped to preserve the existing shell. */
.readings-page { max-width: 960px; margin: 0 auto; }
.readings-page .page-header { margin-bottom: 24px; }
.readings-page .page-header h1 { font-size: 26px; line-height: 1.25; }
.readings-page .page-header p { margin-top: 4px; }
.readings-page #export-readings { min-height: 28px; padding: 4px 10px; font-size: 13px; border-radius: 4px; }
.readings-page #export-readings svg { width: 14px; height: 14px; }
.readings-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.readings-page .reading-summary { padding: 16px; box-shadow: none; }
.reading-summary p { margin: 0 0 4px; color: var(--muted); font-size: 13px; }
.reading-summary strong { display: block; font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.reading-summary small { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.readings-page .readings-card { padding: 0; box-shadow: none; overflow: hidden; }
.readings-filters { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.readings-filter-fields { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.readings-custom-dates:not([hidden]) { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.readings-custom-dates label { display: grid; gap: 4px; flex: 0 1 200px; min-width: 0; font-size: 14px; }
.readings-custom-dates input { width: 100%; min-width: 0; min-height: 44px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--ink); font: inherit; }
.readings-custom-dates input[aria-invalid='true'] { border-color: #B42318; }
.readings-date-error { color: #B42318; font-size: 14px; }
.readings-filter-fields label { display: grid; gap: 4px; width: 176px; font-size: 13px; font-weight: 500; }
.readings-filter-fields label.readings-search { flex: 1; min-width: 224px; }
.readings-filter-fields label.readings-clinician-filter { width: 192px; }
.readings-filter-fields input, .readings-filter-fields select { width: 100%; min-height: 36px; height: 36px; padding: 6px 12px; font-size: 14px; font-weight: 400; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: var(--surface); }
.readings-search-input { position: relative; display: block; width: min(100%, 256px); }
.readings-search-input input { padding-left: 32px; }
.readings-search-input input::placeholder { color: var(--muted); }
.readings-search-input svg { position: absolute; width: 14px; height: 14px; left: 10px; top: 11px; fill: none; stroke: var(--muted); stroke-width: 1.75; pointer-events: none; }
.readings-filter-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.readings-filter-status p { margin: 0; }
.readings-filter-status strong { color: var(--ink); }
.readings-filter-status .text-button { border: 0; background: transparent; border-radius: 4px; padding: 4px 10px; color: var(--muted); font-size: 13px; cursor: pointer; }
.readings-filter-status .text-button:hover { color: var(--ink); background: var(--canvas); }
.readings-table-scroll { overflow-x: auto; }
.readings-page table { width: 100%; font-size: 14px; }
.readings-page th, .readings-page td { padding: 12px 20px; }
.readings-page th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; background: var(--surface); }
.readings-page td { color: var(--muted); }
.readings-page td.reading-resident, .readings-page td strong { color: var(--ink); font-weight: 500; }
.reading-timestamp { font-size: 13px; font-variant-numeric: tabular-nums; }
.reading-author { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 13px; color: var(--ink); }
.reading-author-avatar { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%; background: var(--line); color: var(--muted); font-size: 10px; font-weight: 600; }
.reading-you { border-radius: 4px; background: #f3f4f6; color: #374151; font-size: 11px; font-weight: 500; line-height: 20px; padding: 2px 8px; }
.reading-unattributed { color: var(--muted); font-size: 13px; }
.readings-empty-icon { display: flex; align-items: center; justify-content: center; margin: 0 auto 8px; width: 36px; height: 36px; border-radius: 50%; background: #f3f4f6; }
.readings-empty-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.75; }
.readings-page td.empty-state { padding: 48px 20px; text-align: center; }
.readings-page .empty-state p { margin: 4px 0 0; font-size: 13px; }
@media (max-width: 1024px) {
  .readings-page #export-readings, .readings-page #clear-readings-filters, .readings-filter-fields input, .readings-filter-fields select { min-height: 44px; height: auto; }
  .readings-search-input svg { top: 15px; }
}
@media (max-width: 600px) {
  .readings-summary-grid { grid-template-columns: 1fr; gap: 10px; }
  .readings-filter-fields label, .readings-filter-fields label.readings-clinician-filter, .readings-filter-fields label.readings-search, .readings-search-input { width: 100%; min-width: 0; flex-basis: 100%; }
  .readings-page .page-header { flex-wrap: wrap; gap: 12px; }
  .readings-filter-status { flex-wrap: wrap; }
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, "Segoe UI Variable Text", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; }
button, a, select, input { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--focus) 50%, transparent); outline-offset: 2px; }
.skip-link { position: fixed; z-index: 100; top: -60px; left: 12px; padding: 10px 14px; color: #fff; background: var(--navy); }
.skip-link:focus { top: 12px; }

.app-shell { --sidebar-width: 240px; min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar {
  position: sticky;
  z-index: 20;
  top: 0;
  height: 100vh;
  height: 100dvh;
  width: var(--sidebar-width);
  overflow-y: auto;
  padding: 18px 12px 14px;
  display: flex;
  flex-direction: column;
  color: #fff;
  background: var(--navy);
}
.brand { min-height: 86px; padding: 0 4px 13px; display: grid; gap: 8px; }
.sidebar > * { flex-shrink: 0; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; }
.brand-home { display: flex; align-items: center; min-width: 0; min-height: 44px; border-radius: 4px; }
.brand-home:hover { background: rgba(255, 255, 255, .06); }
.sidebar-collapse { flex: 0 0 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 5px; color: #fff; background: transparent; cursor: pointer; }
.sidebar-collapse:hover { background: rgba(255, 255, 255, .1); }
.sidebar-collapse svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.sidebar-resize { position: fixed; z-index: 21; top: 0; bottom: 0; left: calc(var(--sidebar-width) - 5px); width: 10px; cursor: col-resize; touch-action: none; }
.sidebar-resize::after { content: ''; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px; background: rgba(168, 192, 207, .35); }
.sidebar-resize:hover::after, .sidebar-resize:focus-visible::after { width: 4px; left: 3px; background: var(--focus); }
body.sidebar-resizing, body.sidebar-resizing * { cursor: col-resize !important; user-select: none !important; }
.sidebar-restore { display: none; padding: 12px 25px 0; }
@media (min-width: 761px) {
  .sidebar-motion { transition: grid-template-columns 300ms ease; }
  .sidebar-motion .sidebar { transition: transform 300ms ease, visibility 0s; }
  .app-shell.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
  .sidebar-collapsed .sidebar { transform: translateX(-100%); visibility: hidden; }
  .sidebar-motion.sidebar-collapsed .sidebar { transition: transform 300ms ease, visibility 0s 300ms; }
  .sidebar-collapsed .sidebar-resize { display: none; }
  .sidebar-collapsed .sidebar-restore { display: block; }
}
.brand-logo-surface { position: relative; display: block; width: fit-content; max-width: 100%; align-self: center; background: transparent; }
.brand-logo { width: auto; height: 34px; max-width: 100%; display: block; }
/* Reuse the original transparent logo; whiten only its lettering, after the symbol/gap. */
.brand-logo-wordmark { position: absolute; inset: 0; width: 100%; height: 100%; filter: brightness(0) invert(1); clip-path: inset(0 0 0 28%); pointer-events: none; }
.brand-copy { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 7px; }
.brand-copy strong { color: #fff; font-size: 12px; line-height: 1.15; letter-spacing: -0.005em; }
.brand-copy small {
  padding: 2px 5px;
  border-radius: 3px;
  color: #ffe39b;
  background: #645414;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.home-context { margin: 0 -4px 12px; padding: 8px 8px 6px; border: 1px solid rgba(255, 255, 255, .1); border-radius: 6px; background: rgba(255, 255, 255, .035); }
.home-selector-label { display: block; margin-bottom: 2px; color: #7fa3ba; font-size: 9px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.home-selector {
  width: 100%;
  min-height: 30px;
  margin: 0;
  padding: 4px 24px 4px 0;
  border: 0;
  border-radius: 4px;
  color: #d7e5ed;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
}
.home-selector:hover { background: rgba(255, 255, 255, .06); }
.home-selector option { color: var(--ink); background: #fff; }
.navigation { display: grid; gap: 3px; }
.nav-item {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 4px;
  color: var(--sidebar-text);
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  font-weight: 560;
}
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.nav-item > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.nav-item.active, .nav-item[aria-current="page"] { color: #fff; background: var(--brand-blue); }
.nav-icon { width: 16px; display: inline-grid; place-items: center; flex: 0 0 auto; font-size: 12px; }
.nav-icon svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.admin-navigation { margin-top: 18px; }
.admin-navigation > p {
  margin: 0 10px 7px;
  color: #728fa0;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.sidebar-footer { margin-top: auto; padding-top: 10px; border-top: 1px solid rgba(216, 225, 234, .16); }
.support-button { margin-bottom: 6px; }
.support-button .nav-icon svg { width: 15px; height: 15px; }
.account-wrap { position: relative; }
.account-control {
  width: 100%;
  min-height: 54px;
  padding: 7px 8px;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 5px;
  color: #fff;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.account-control:hover, .account-control[aria-expanded="true"] { background: rgba(255, 255, 255, .08); }
.account-avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #17879c;
  font-size: 10px;
  font-weight: 750;
}
.account-copy { min-width: 0; display: grid; }
.account-copy strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.account-copy small { color: #a8c0cf; font-size: 10px; overflow-wrap: anywhere; }
.account-chevron { color: #8ba6b7; font-size: 12px; }
.account-menu {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 62px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  color: #fff;
  background: #1d3a52;
  box-shadow: 0 12px 34px rgba(16, 42, 67, .22);
}
.account-menu-header { padding: 9px 10px 8px; display: grid; border-bottom: 1px solid rgba(255, 255, 255, .12); }
.account-menu-header strong { font-size: 12px; }
.account-menu-header span { color: var(--sidebar-text); font-size: 10px; }
.account-menu button, .sign-out-link {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 4px;
  color: var(--sidebar-text);
  background: transparent;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  font-size: 12px;
}
.account-menu button:hover, .sign-out-link:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.sign-out-link { color: #fca5a5; }
.menu-divider { height: 1px; margin: 5px 3px; background: rgba(255, 255, 255, .12); }
.menu-icon { width: 15px; height: 15px; display: inline-grid; place-items: center; flex: 0 0 auto; }
.menu-icon svg, .account-chevron svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.account-chevron { width: 15px; height: 15px; display: inline-grid; place-items: center; }

.main-content { min-width: 0; min-height: 100vh; background: var(--canvas); }
.mobile-menu, .mobile-nav-close, .mobile-nav-scrim { display: none; }
.page { width: 100%; max-width: 1180px; margin: 0 auto; padding: 36px 38px 64px; }
.page:focus { outline: none; }
.page-header { margin-bottom: 24px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.page-header h1 { margin: 0; font-size: 28px; font-weight: 650; letter-spacing: -.025em; }
.page-header p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.breadcrumb { margin: 0 0 3px !important; color: var(--muted); font-size: 12px !important; }
.page-actions { display: flex; align-items: center; gap: 8px; }
h2, h3, p { margin-top: 0; }
h2 { font-size: 22px; letter-spacing: -.018em; }
h3 { font-size: 15px; }

.button {
  min-height: 36px;
  padding: 7px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { border-color: #aebdcc; background: #fafbfd; }
.button.primary { border-color: var(--primary); color: #fff; background: var(--primary); }
.button.primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); }
.button.danger { border-color: #f3b7b2; color: var(--danger); }
.button.tertiary { border-color: transparent; color: var(--primary); background: transparent; }
.button:disabled { opacity: .52; cursor: not-allowed; }
.button svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }

.card, .table-card, .form-card, .round-banner, .resident-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.metric-grid { margin-bottom: 20px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.metric-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-card { min-height: 94px; padding: 17px; }
.metric-card span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; color: #092f55; font-size: 25px; font-weight: 620; }
.metric-card small { color: var(--muted); font-size: 11px; }
.metric-card .success-number { color: var(--success); }
.metric-card .warning-number { color: var(--warning); }
.round-overview { margin-bottom: 14px; padding: 17px; display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 13px; }
.overview-top { margin-bottom: 14px; display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.overview-top .round-overview { margin-bottom: 0; }
.round-overview-icon, .device-symbol {
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--primary);
  background: #e7f2f4;
}
.round-overview-icon { width: 42px; height: 42px; }
.round-overview-icon svg, .device-symbol svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.round-overview h2 { margin: 0 0 2px; font-size: 15px; }
.round-overview p { margin: 0; color: var(--muted); font-size: 12px; }

.section-card { margin-top: 20px; }
.section-heading { min-height: 50px; padding: 12px 17px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.section-heading h2 { margin: 0; font-size: 14px; }
.text-action { border: 0; color: var(--primary); background: transparent; font-size: 12px; cursor: pointer; }
.text-action:hover { text-decoration: underline; }
.table-card { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 17px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th.numeric, td.numeric { text-align: right; }
th { color: var(--muted); background: #fff; font-size: 10px; font-weight: 700; letter-spacing: .045em; text-transform: uppercase; }
td { font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: #f9fbfc; }
.person-cell { display: flex; align-items: center; gap: 9px; font-weight: 620; }
.person-avatar {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #4a6075;
  background: #e4ebf2;
  font-size: 9px;
  font-weight: 700;
}
.identifier-cell { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: 11px; }
.sparkline { width: 64px; height: 24px; display: block; overflow: visible; }
.sparkline polyline { fill: none; stroke: var(--primary); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.sparkline circle { fill: var(--primary); }
.sparkline-empty { color: var(--muted); }
.table-footer { padding: 11px 17px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.pagination { display: flex; align-items: center; gap: 7px; }
.pagination button { min-width: 28px; min-height: 28px; border: 0; color: var(--muted); background: transparent; cursor: pointer; }

.status {
  padding: 4px 7px;
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  color: #335269;
  background: #edf1f5;
  font-size: 10px;
  font-weight: 650;
}
.status.available, .status.active, .status.success { color: #12613e; background: var(--success-bg); }
.status.in-use, .status.pending, .status.warning { color: #805300; background: var(--warning-bg); }
.status.setup-required { color: #084c7e; background: #dceeff; }
.status.offline, .status.inactive { color: #667085; background: #f0f2f5; }
.status.error, .status.suspended { color: var(--danger); background: var(--danger-bg); }
.cell-detail { display: block; margin-top: 5px; color: var(--muted); white-space: nowrap; }
.table-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-width: 230px; }
.table-actions .button { min-height: 30px; padding: 5px 8px; font-size: 10px; }

.search-bar { width: 280px; margin-bottom: 14px; position: relative; }
.search-bar span { position: absolute; top: 50%; left: 11px; color: var(--muted); transform: translateY(-50%); }
input, select, textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  background: #fff;
}
.search-bar input { padding-left: 31px; }
input::placeholder, textarea::placeholder { color: #8b99aa; }
textarea { min-height: 92px; resize: vertical; }
label { display: grid; gap: 6px; color: #34465a; font-size: 12px; font-weight: 620; }
.checkbox-field { align-self: end; min-height: 38px; padding: 8px 10px; display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.checkbox-field input { width: 16px; min-height: 16px; margin: 0; accent-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.weight-field { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) 76px; gap: 8px; align-content: start; }
.weight-field input, .weight-field select { width: 100%; min-width: 0; }
.weight-field small { grid-column: 1 / -1; color: var(--muted); }
.role-fieldset { margin: 0; padding: 0; border: 0; }
.role-fieldset legend { margin-bottom: 8px; color: var(--ink); font-size: 13px; font-weight: 600; }
.role-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.role-choice { display: flex; align-items: flex-start; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }
.role-choice:has(input:checked) { border-color: var(--primary); background: #f0f8fa; }
.role-choice input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--primary); }
.role-choice span { display: grid; gap: 2px; }
.role-choice strong { font-size: 13px; }
.role-choice small { color: var(--muted); font-size: 11px; line-height: 1.35; font-weight: 400; }
.form-card { padding: 20px; }
.form-card h2 { margin-bottom: 16px; font-size: 18px; }
.form-actions { margin-top: 18px; display: flex; justify-content: flex-end; gap: 8px; }
.form-help { margin: 7px 0 0; color: var(--muted); font-size: 11px; font-weight: 400; }
.compliance-notice { margin-bottom: 16px; padding: 13px 15px; border: 1px solid #b8cee1; border-left: 4px solid var(--primary); border-radius: 6px; background: #f3f8fc; color: #26445d; }
.compliance-notice strong { display: block; margin-bottom: 3px; color: #0b3558; font-size: 13px; }
.compliance-notice p { margin: 0; font-size: 12px; }
.page-compliance { margin-top: -7px; }
.privacy-metrics { max-width: 760px; }
.split-actions { align-items: center; }
.split-actions > span { flex: 1; }
.inline-notice { margin: 14px 0 0; padding: 11px 13px; border-radius: 5px; color: #1f6047; background: #e5f5ed; font-size: 12px; }
.inline-notice.error { color: var(--danger); background: var(--danger-bg); }

.device-list, .resident-choice-list { display: grid; gap: 10px; }
.device-row, .resident-choice {
  width: 100%;
  min-height: 66px;
  padding: 12px 14px;
  display: grid;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  text-align: left;
}
.device-row { grid-template-columns: 40px 1fr auto auto auto; }
.resident-choice { grid-template-columns: 38px 1fr auto; }
.device-symbol { width: 38px; height: 38px; }
.device-symbol.available { color: var(--success); background: #dff8ea; }
.device-symbol.in-use { color: var(--warning); background: #fff1c7; }
.device-symbol.setup-required { color: var(--brand-blue); background: #dceeff; }
.device-symbol.offline { color: #64748b; background: #f0f2f5; }
.device-integration-note { margin: 10px 2px 0; color: var(--muted); font-size: 11px; }
.device-copy, .resident-choice-copy { min-width: 0; }
.device-copy strong, .resident-choice-copy strong { display: block; margin-bottom: 1px; font-size: 12px; }
.device-copy span, .resident-choice-copy span { color: var(--muted); font-size: 11px; }
.device-meta { color: var(--muted); font-size: 11px; }

.round-banner {
  margin: -8px 0 25px;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-color: #b7d8df;
  background: #edf7f8;
}
.round-banner-copy { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 11px; }
.round-banner-copy strong { font-size: 12px; }
.round-separator { color: #8da5b3; }
.measurement-card { max-width: 680px; margin: 0 auto; padding: 32px; text-align: center; }
.measurement-resident { margin-bottom: 24px; }
.measurement-resident .person-avatar { width: 42px; height: 42px; margin: 0 auto 10px; }
.measurement-resident h1 { margin: 0 0 3px; font-size: 24px; }
.measurement-resident p { color: var(--muted); }
.measurement-visual { width: 74px; height: 74px; margin: 0 auto 17px; display: grid; place-items: center; border-radius: 50%; color: var(--primary); background: #e7f2f4; }
.measurement-visual svg { width: 34px; height: 34px; stroke: currentColor; fill: none; stroke-width: 1.5; }
.measurement-card h2 { margin-bottom: 7px; font-size: 18px; }
.measurement-card > p { max-width: 500px; margin: 0 auto 18px; color: var(--muted); }
.measurement-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.vital-grid { margin: 20px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.vital { padding: 18px; border: 1px solid #b7d8df; border-radius: 7px; background: #f4fbfc; }
.vital span { display: block; color: var(--muted); font-size: 11px; }
.vital strong { display: inline-block; margin: 4px 3px 0 0; color: #092f55; font-size: 36px; font-weight: 620; }
.vital small { color: var(--muted); }
.saved-confirmation { margin-bottom: 18px; color: var(--success); font-size: 12px; }
.measurement-waiting { margin: 0 auto 18px; padding: 10px 12px; border: 1px solid #b8cee1; border-radius: 6px; color: #26445d; background: #f3f8fc; font-size: 12px; }

.overview-trend-card { margin-bottom: 16px; padding: 18px 20px 12px; }
.chart-card-heading { margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.chart-card-heading h2 { margin: 0; font-size: 14px; }
.chart-card-heading p { margin: 0; color: var(--muted); font-size: 10px; text-align: right; }
.overview-chart { width: 100%; height: 150px; display: block; overflow: visible; }
.overview-bar { fill: var(--primary); opacity: .75; }
.overview-average-line { stroke: var(--success); stroke-width: 2; }
.overview-average-dot { fill: var(--success); stroke: #fff; stroke-width: 1.5; }

.back-link { margin: 0 0 14px; padding: 0; display: inline-flex; align-items: center; border: 0; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; }
.back-link:hover { color: var(--ink); }
.resident-header { margin-bottom: 20px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.resident-identity { min-width: 0; display: flex; align-items: center; gap: 12px; }
.resident-identity > div { min-width: 0; overflow-wrap: anywhere; }
.resident-header .page-actions { flex-shrink: 0; }
.resident-avatar { width: 48px; height: 48px; font-size: 14px; }
.resident-title-row { display: flex; align-items: center; gap: 9px; }
.resident-title-row h1 { margin: 0; font-size: 26px; font-weight: 650; letter-spacing: -.025em; }
.resident-identity p { margin: 2px 0 0; color: var(--muted); }
.resident-summary-grid { margin-bottom: 16px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.resident-summary-grid.with-weight { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.weight-summary .button { margin-top: 12px; }
.weight-history h2 { margin: 0; font-size: 14px; }
.weight-table-scroll { overflow-x: auto; }
.weight-table-scroll table { min-width: 620px; }
.weight-note { max-width: 300px; white-space: normal; overflow-wrap: anywhere; }
.manual-badge { display: inline-block; font-size: 12px; color: var(--muted); background: var(--canvas); border-radius: 4px; padding: 2px 5px; }
.weight-resident-identity { display: flex; gap: 12px; align-items: center; border: 1px solid var(--line); background: var(--canvas); padding: 12px; border-radius: 6px; margin-bottom: 16px; }
.weight-resident-identity small { display:block; color:var(--muted); overflow-wrap:anywhere; }
.modal.weight-entry-modal { width: min(448px, 100%); }
.weight-entry-modal .modal-header { padding: 12px 20px; align-items: center; }
.weight-entry-modal .modal-header h2 { font-size: 16px; font-weight: 600; }
.weight-entry-modal .modal-body { padding: 16px 20px 0; }
.weight-entry-modal .weight-resident-identity { margin-bottom: 18px; padding: 12px; gap: 10px; }
.weight-entry-modal .weight-resident-identity > div { min-width: 0; }
.weight-entry-modal .weight-resident-identity strong { font-size: 14px; }
.weight-entry-modal .weight-resident-identity small { font-size: 12px; }
.weight-entry-modal .person-avatar { width: 36px; height: 36px; flex: 0 0 36px; }
.weight-entry-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; }
.weight-entry-grid > .weight-field, .weight-entry-grid > .full { grid-column: 1 / -1; }
.weight-entry-grid .weight-field { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 12px; }
.weight-entry-grid label { min-width: 0; gap: 6px; font-size: 13px; font-weight: 500; }
.weight-entry-grid input, .weight-entry-grid select { min-width: 0; width: 100%; height: 36px; min-height: 36px; padding: 6px 10px; font-size: 13px; }
.weight-entry-grid input::placeholder { font-weight: 400; }
.weight-entry-modal .weight-accessible-help { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.weight-entry-attribution { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; padding: 12px 0 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.weight-entry-attribution svg { width: 14px; height: 14px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.weight-entry-attribution strong { margin: 0 4px; color: var(--ink); font-weight: 500; }
.weight-entry-modal .form-actions { display: flex; margin: 0 -20px; padding: 16px 20px; border-top: 1px solid var(--line); }
.weight-entry-modal .form-actions .button { width: auto; min-height: 36px; padding: 6px 12px; font-size: 13px; }
.weight-entry-modal .button.primary { background: #126e82; border-color: #126e82; }
.weight-entry-modal .button.primary:hover { background: #0e5969; border-color: #0e5969; }
@media(max-width:600px) {
  .weight-entry-modal .modal-body { padding-bottom: env(safe-area-inset-bottom); }
  .weight-entry-modal .weight-entry-grid input, .weight-entry-modal .weight-entry-grid select, .weight-entry-modal .form-actions .button { min-height: 44px; }
}
#weight-error { color: #b42318; }
#weight-chart-frame { position: relative; min-width: 0; }
.weight-chart { display: block; width:100%; height:180px; }
.weight-chart-tooltip { position:absolute; top:5px; width: min(240px,100%); padding:10px; background:white; border:1px solid var(--line); border-radius:6px; box-shadow:0 2px 8px #172b4d22; pointer-events:none; font-size:12px; overflow-wrap:anywhere; }
.weight-chart circle:focus { outline: 2px solid #2e90fa; }
.measurement-tabs { display:flex; gap:12px; padding:0 16px; border-bottom:1px solid var(--line); }
.measurement-tabs button { background:none; border:0; border-bottom:2px solid transparent; color:var(--muted); padding:12px 4px; min-height:44px; cursor:pointer; }
.measurement-tabs button[aria-selected=true] { border-bottom-color:#126e82; color:#126e82; }
@media(max-width:1200px) { .resident-summary-grid.with-weight {grid-template-columns:repeat(2,minmax(0,1fr));} }
@media(max-width:600px) { .resident-summary-grid.with-weight {grid-template-columns:1fr;} .weight-history .trend-card-header {flex-wrap:wrap;} }
.resident-metric, .identifier-card { min-width: 0; min-height: 126px; padding: 16px; overflow-wrap: anywhere; }
.resident-summary-grid > article { position: relative; }
.resident-summary-grid > article > span:not(.resident-card-icon) { padding-right: 36px; min-height: 20px; }
.resident-summary-grid .resident-card-icon { position: absolute; top: 12px; right: 12px; width: 28px; height: 28px; margin: 0; display: grid; place-items: center; border-radius: 6px; background: #dbeafe; color: #126e82; pointer-events: none; }
.resident-card-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.resident-metric > span, .identifier-card > span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.identifier-card > span { margin-bottom: 8px; font-size: 10px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.resident-metric strong { display: block; color: var(--ink); font-size: 30px; font-weight: 650; font-variant-numeric: tabular-nums; }
.resident-metric small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }
.identifier-card dl { margin: 0; display: grid; gap: 4px; }
.identifier-card dl div { min-width: 0; display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 12px; font-size: 11px; }
.identifier-card dt { color: var(--muted); }
.identifier-card dd { min-width: 0; margin: 0; color: var(--ink); text-align: right; white-space: normal; overflow-wrap: anywhere; }
.identifier-card dl div:first-child dd { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; }

.trend-card { margin-bottom: 16px; overflow: hidden; }
.trend-card-header { min-height: 52px; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.trend-card-title { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.trend-card-title h2 { margin: 0; font-size: 14px; }
.trend-card-body { padding: 14px 16px 13px; }
.segmented-control { padding: 2px; display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 5px; }
.segmented-control button { min-height: 26px; padding: 4px 9px; border: 0; border-radius: 3px; color: var(--muted); background: transparent; cursor: pointer; font-size: 11px; font-weight: 620; }
.segmented-control button:hover { color: var(--ink); }
.segmented-control button.active, .segmented-control button[aria-pressed="true"] { color: var(--ink); background: var(--canvas); }
.trend-chart { width: 100%; height: 180px; display: block; overflow: visible; }
.trend-chart-frame { position: relative; }
.chart-grid-line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-area { stroke: none; pointer-events: none; }
.chart-axis-label { fill: #5e6c84; font-size: 11px; }
.chart-x-axis { stroke: #d8e1ea; stroke-width: 1; }
.spo2-line, .pulse-line { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.spo2-line { stroke: #126e82; stroke-width: 2; }
.pulse-line { stroke: #9a6700; stroke-width: 1.5; stroke-dasharray: 5 3; }
.chart-reveal-rect { transform-box: view-box; transform-origin: 38px 0; animation: chart-series-reveal 1500ms ease forwards; }
.weight-chart .chart-reveal-rect { transform-origin: 51px 0; }
.weight-chart.chart-settled .chart-reveal-rect { animation: none; transform: scaleX(1); }
.weight-chart.chart-settled .chart-point { animation: none; opacity: 1; }
.reference-line { stroke: #287d5a; stroke-width: 1; stroke-dasharray: 4 3; }
.reference-label { fill: #287d5a; font-size: 10px; }
.chart-point { opacity: 0; animation: chart-point-in 250ms ease 1050ms forwards; }
.spo2-point circle { fill: #126e82; stroke: none; }
.pulse-point circle { fill: #9a6700; stroke: none; }
.chart-hover-layer { pointer-events: none; }
.chart-hover-line { stroke: #7c8ea3; stroke-width: 1; stroke-dasharray: 3 3; }
.chart-hover-spo2 { fill: #126e82; stroke: #fff; stroke-width: 2; }
.chart-hover-pulse { fill: #9a6700; stroke: #fff; stroke-width: 2; }
.trend-tooltip {
  position: absolute;
  z-index: 2;
  top: 17px;
  width: 206px;
  padding: 11px 12px 9px;
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 8px 22px rgba(16, 42, 67, .15);
  pointer-events: none;
  font-size: 11px;
}
.trend-tooltip > strong { margin-bottom: 1px; font-size: 12px; }
.trend-tooltip > span { display: grid; grid-template-columns: 8px 42px 1fr; align-items: center; gap: 5px; }
.trend-tooltip b { font-variant-numeric: tabular-nums; }
.tooltip-dot { width: 6px; height: 6px; display: block; border-radius: 50%; }
.spo2-dot { background: #126e82; }
.pulse-dot { background: #9a6700; }
.trend-tooltip small { margin: 3px -12px -9px; padding: 7px 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; }
.chart-point:focus { outline: none; }
.chart-point:focus circle, .overview-average-dot:focus, g:focus .overview-bar { stroke: var(--focus); stroke-width: 3; }
.chart-legend { padding-top: 8px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 18px; color: #5e6c84; font-size: 12px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 24px; height: 0; display: inline-block; border-top: 2px solid; }
.chart-legend .legend-spo2 { border-color: #126e82; }
.chart-legend .legend-pulse { border-color: #9a6700; border-top-style: dashed; }
.resident-chart-legend { gap: 12px; font-size: 11px; }
.resident-chart-legend .legend-pulse-label { color: #9a6700; }
.resident-chart-legend .legend-spo2-label { color: #126e82; }
.resident-chart-legend i { position: relative; width: 12px; border-top-width: 1.5px; }
.resident-chart-legend i::after { content: ''; position: absolute; left: 4px; top: -3px; width: 4px; height: 4px; border: 1px solid currentColor; border-radius: 50%; background: var(--surface); }
.resident-chart-note .note-line-sample { display: inline-block; width: 30px; margin-right: 3px; vertical-align: middle; border-top: 1px dashed currentColor; }
.chart-note { margin: 8px 0 0; color: var(--muted); font-size: 10px; }
.chart-empty { min-height: 180px; display: grid; place-items: center; color: var(--muted); }
.trend-table-wrap { margin: -14px -16px -13px; overflow: auto; }
.resident-reading-history { margin-top: 0; margin-bottom: 16px; }
.resident-reading-history td, .weight-table-scroll td { color: var(--ink); }
.resident-reading-history .history-timestamp, .weight-table-scroll .history-timestamp { color: var(--muted); font-variant-numeric: tabular-nums; }

@keyframes chart-series-reveal { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes chart-point-in { to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .sidebar-motion, .sidebar-motion .sidebar, .sidebar-motion .sidebar * { transition: none !important; }
  .chart-reveal-rect { animation: none; transform: scaleX(1); }
  .chart-point { animation: none; opacity: 1; }
}

.two-column { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr); gap: 16px; }
.list-card { padding: 0; }
.round-record { padding: 15px 17px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.round-record:last-child { border-bottom: 0; }
.round-record strong { display: block; font-size: 12px; }
.round-record span, .round-record small { color: var(--muted); font-size: 11px; }
.checklist { padding: 17px; }
.checklist h2 { margin-bottom: 12px; font-size: 14px; }
.checklist ul { margin: 0; padding: 0; display: grid; gap: 9px; list-style: none; }
.checklist li { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.checklist li::before { content: "✓"; width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; color: var(--success); background: var(--success-bg); font-size: 10px; font-weight: 800; }

.upload-card { max-width: 760px; padding: 24px; }
.drop-zone { padding: 46px 24px; border: 1px dashed #aebdcc; border-radius: 7px; text-align: center; background: #fafbfd; }
.drop-zone input { max-width: 360px; margin: 14px auto 0; }
.drop-zone strong { display: block; margin-bottom: 5px; font-size: 13px; }
.drop-zone p { margin: 0; color: var(--muted); font-size: 11px; }
.empty-state { padding: 52px 24px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--ink); }
.error-card { max-width: 680px; padding: 22px; border-left: 4px solid var(--danger); }
.error-card h2 { font-size: 17px; }
.error-card p { color: var(--muted); }

.modal-backdrop { position: fixed; z-index: 80; inset: 0; padding: 24px; display: grid; place-items: center; background: rgba(8, 25, 40, .45); }
.modal { width: min(620px, 100%); max-height: calc(100vh - 48px); overflow: auto; border-radius: 8px; background: #fff; box-shadow: 0 24px 70px rgba(8, 25, 40, .32); }
.modal-header { padding: 18px 20px; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 18px; }
.modal-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.modal-close { width: 32px; height: 32px; border: 0; border-radius: 4px; background: transparent; cursor: pointer; font-size: 20px; }
.modal-close:hover { background: var(--canvas); }
.modal-body { padding: 20px; }

.toast-region { position: fixed; z-index: 100; right: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast { min-width: 260px; max-width: 380px; padding: 12px 14px; border: 1px solid #b8ddca; border-radius: 6px; color: #18593e; background: #f0faf5; box-shadow: 0 12px 32px rgba(16, 42, 67, .16); font-size: 12px; }
.toast.error { border-color: #f3b7b2; color: var(--danger); background: #fff5f4; }
.loading-screen { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 13px; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid #d8e1ea; border-top-color: var(--primary); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-page { background: #f4f6f9; }
.login-main { min-height: 100vh; padding: 24px; display: grid; place-items: center; }
.login-card { width: min(390px, 100%); padding: 34px 38px 28px; border: 1px solid var(--line); border-radius: 9px; background: #fff; box-shadow: 0 2px 5px rgba(16, 42, 67, .12); text-align: center; }
.login-brand { width: 100%; margin-bottom: 21px; display: grid; justify-items: center; gap: 10px; text-align: center; }
.login-logo { width: min(230px, 82%); height: auto; display: block; }
.login-brand > span:last-child { display: grid; }
.login-brand strong { color: var(--brand-blue); font-size: 15px; }
.login-brand small { color: var(--muted); font-size: 10px; }
.environment-badge { padding: 3px 7px; display: inline-block; border: 1px solid #efc76a; border-radius: 3px; color: #8a5b00; background: #fffaf0; font-size: 9px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.login-card h1 { margin: 20px 0 6px; color: #092f55; font-size: 22px; }
.login-card > p { color: var(--muted); font-size: 12px; }
.microsoft-button { min-height: 42px; margin-top: 20px; display: flex; align-items: center; justify-content: center; gap: 9px; border: 1px solid #b9c7d4; border-radius: 4px; color: #092f55; text-decoration: none; font-size: 12px; font-weight: 620; }
.microsoft-button:hover { border-color: var(--primary); background: #f8fbfc; }
.microsoft-button.primary-login { background: var(--primary); border-color: var(--primary); color: #fff; }
.microsoft-button.primary-login:hover { filter: brightness(1.08); background: var(--primary); }
.microsoft-mark { width: 14px; height: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 1px; }
.microsoft-mark i:nth-child(1) { background: #f25022; }
.microsoft-mark i:nth-child(2) { background: #7fba00; }
.microsoft-mark i:nth-child(3) { background: #00a4ef; }
.microsoft-mark i:nth-child(4) { background: #ffb900; }
.support-copy { margin: 17px 0 !important; }
.support-copy a, .login-card footer a { color: var(--primary); text-decoration: none; }
.login-card footer { padding-top: 17px; display: flex; justify-content: center; gap: 9px; border-top: 1px solid var(--line); font-size: 10px; }

@media (max-width: 980px) {
  .metric-grid.four { grid-template-columns: 1fr 1fr; }
  .two-column { grid-template-columns: 1fr; }
  .overview-top { grid-template-columns: 1fr; }
  .page { padding: 28px 25px 50px; }
}

@media (max-width: 760px) {
  .sidebar-collapse, .sidebar-resize, .sidebar-restore { display: none; }
  body.mobile-nav-open { overflow: hidden; }
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 30; left: 0; width: min(296px, calc(100vw - 48px)); padding-top: 58px; transform: translateX(-105%); visibility: hidden; transition: transform .2s ease, visibility .2s; box-shadow: 8px 0 30px rgba(16, 42, 67, .24); }
  .sidebar.open { left: 0; visibility: visible; transform: translateX(0); transition: transform .2s ease; }
  .mobile-menu { position: fixed; z-index: 25; top: max(12px, env(safe-area-inset-top)); left: 12px; width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; color: var(--navy); background: #fff; box-shadow: var(--shadow); cursor: pointer; font-size: 21px; }
  .mobile-nav-close { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 10px; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 6px; color: #fff; background: rgba(255, 255, 255, .08); cursor: pointer; font-size: 26px; line-height: 1; }
  .mobile-nav-scrim { position: fixed; z-index: 29; inset: 0; width: 100%; height: 100%; display: block; border: 0; background: rgba(8, 25, 40, .5); }
  .mobile-nav-scrim[hidden] { display: none; }
  .page { padding: calc(68px + env(safe-area-inset-top)) 16px calc(40px + env(safe-area-inset-bottom)); }
  .page-header { flex-direction: column; }
  .page-actions { width: 100%; flex-wrap: wrap; }
  .metric-grid, .metric-grid.four, .form-grid, .vital-grid, .role-options { grid-template-columns: 1fr; }
  .resident-summary-grid { grid-template-columns: 1fr; }
  .trend-card-header, .chart-card-heading { align-items: flex-start; flex-direction: column; }
  .chart-card-heading p { text-align: left; }
  .trend-card-title { align-items: flex-start; flex-direction: column; }
  .trend-chart { min-width: 0; height: auto; aspect-ratio: 940 / 180; }
  .trend-card-body { overflow: visible; }
  .round-overview { grid-template-columns: 42px 1fr; }
  .round-overview .button { grid-column: 1 / -1; }
  .device-row { grid-template-columns: 40px 1fr auto; }
  .device-row .device-meta { display: none; }
  .device-row .status { grid-column: 3; }
  .resident-choice { grid-template-columns: 36px 1fr; }
  .resident-choice .button { grid-column: 1 / -1; }
  .round-banner { align-items: flex-start; flex-direction: column; }
  .search-bar { width: 100%; }
  .form-grid .full { grid-column: auto; }
  .table-card { border-radius: 6px; }
  th, td { padding-left: 12px; padding-right: 12px; }
}

@media (max-width: 520px) {
  .page-header { margin-bottom: 18px; gap: 14px; }
  .page-header h1 { font-size: 24px; }
  .page-header p { font-size: 13px; }
  .page-actions .button { min-height: 44px; flex: 1 1 auto; }
  .button, .text-action, .segmented-control button { min-height: 44px; }
  .metric-card { min-height: 84px; padding: 14px; }
  .metric-card strong { font-size: 23px; }
  .round-overview { grid-template-columns: 38px 1fr; padding: 14px; }
  .round-overview .button { width: 100%; grid-column: 1 / -1; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .table-card { max-width: 100%; }
  .table-card > table { min-width: 660px; }
  .table-footer { align-items: flex-start; flex-direction: column; }
  .table-actions { min-width: 0; }
  .search-bar { width: 100%; }
  .resident-header { align-items: flex-start; flex-direction: column; gap: 14px; }
  .resident-identity { align-items: flex-start; }
  .resident-title-row { align-items: flex-start; flex-wrap: wrap; }
  .resident-title-row h1 { font-size: 23px; }
  .resident-header > div:last-child, .resident-header > .button { width: 100%; }
  .resident-header .button { min-height: 44px; flex: 1; }
  .resident-metric, .identifier-card { min-height: 108px; padding: 14px; }
  .trend-card-header { gap: 10px; }
  .trend-card-title, .trend-card-header > .segmented-control { width: 100%; }
  .segmented-control { width: 100%; }
  .segmented-control button { flex: 1; }
  .trend-card-body { padding: 12px 8px; }
  .trend-chart-frame { margin: 0 -2px; }
  .trend-tooltip { top: 8px; width: min(206px, calc(100% - 12px)); }
  .chart-legend { gap: 10px; font-size: 10px; }
  .chart-note { padding: 0 4px; line-height: 1.45; }
  .trend-table-wrap { margin: -12px -8px; }
  .round-banner { position: sticky; z-index: 10; top: 8px; margin-top: 0; }
  .round-banner .button { width: 100%; min-height: 44px; }
  .device-row { grid-template-columns: 38px minmax(0, 1fr) auto; padding: 11px; }
  .device-row .button, .resident-choice .button { min-height: 44px; }
  .resident-choice { padding: 11px; }
  .measurement-card { padding: 22px 14px; }
  .measurement-actions { display: grid; }
  .measurement-actions .button { width: 100%; min-height: 44px; }
  .vital strong { font-size: 32px; }
  .form-card, .upload-card { padding: 16px; }
  .drop-zone { padding: 28px 14px; }
  .form-actions { display: grid; grid-template-columns: 1fr; }
  .form-actions .button { width: 100%; min-height: 44px; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { width: 100%; max-height: calc(100dvh - env(safe-area-inset-top)); border-radius: 12px 12px 0 0; }
  .modal-header { padding: 16px; }
  .modal-body { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  .modal-close { width: 44px; height: 44px; }
  .toast-region { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); left: 12px; }
  .toast { min-width: 0; max-width: none; }
  .login-main { padding: 16px; }
  .login-card { padding: 28px 22px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
}
.reading-time-warning {
  display: block;
  max-width: 22rem;
  margin-top: 4px;
  white-space: normal;
  color: #9A6700;
}
.live-update-status { padding:12px 16px; margin:12px 0; color:#805b19; background:#f7efd9; border-radius:8px; font-size:14px; line-height:1.5; }
.live-update-status[hidden] { display:none; }
