:root {
  --bg: #f4efe6;
  --panel: rgba(255, 251, 245, 0.88);
  --panel-strong: #fffdf7;
  --ink: #172121;
  --muted: #5c6768;
  --accent: #b44f2c;
  --accent-dark: #8c3519;
  --accent-soft: #f1cdb7;
  --line: rgba(23, 33, 33, 0.12);
  --ok: #1b7f5f;
  --warn: #bd6f18;
  --danger: #a93434;
  --shadow: 0 20px 60px rgba(63, 36, 18, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Source Sans 3", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(180, 79, 44, 0.22), transparent 26%),
    radial-gradient(circle at bottom right, rgba(27, 127, 95, 0.16), transparent 22%),
    linear-gradient(135deg, #efe5d5 0%, #f8f3eb 45%, #ece4d6 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

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

.form-hint {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
  grid-column: span 2;
}

.context-help {
  margin: 0 0 14px;
  border: 1px solid rgba(180, 79, 44, 0.18);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(241, 205, 183, 0.36), rgba(255, 253, 247, 0.92));
  box-shadow: 0 12px 28px rgba(63, 36, 18, 0.08);
  overflow: hidden;
}

.context-help summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
}

.context-help summary::-webkit-details-marker {
  display: none;
}

.context-help-summary-title {
  font-weight: 700;
  color: var(--ink);
}

.context-help-summary-meta {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}

.context-help-body {
  padding: 0 18px 16px;
  color: var(--ink);
}

.context-help-body p {
  margin: 0 0 10px;
  color: var(--muted);
}

.context-help-body ul {
  margin: 0;
  padding-left: 18px;
}

.context-help-body li {
  margin: 6px 0;
}

@media (max-width: 720px) {
  .context-help summary {
    flex-direction: column;
    align-items: flex-start;
  }

  .context-help-summary-meta {
    white-space: normal;
  }
}

.allocated-staff-picker {
  display: grid;
  gap: 8px;
}

.allocated-staff-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.allocated-staff-controls select {
  flex: 1 1 auto;
}

.allocated-staff-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 36px;
}

.allocated-staff-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.78);
  font-weight: 600;
}

.allocated-staff-remove {
  border: 0;
  border-radius: 999px;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(23, 33, 33, 0.08);
  color: var(--ink);
  font-size: 0.88rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.allocated-staff-remove:hover {
  background: rgba(169, 52, 52, 0.15);
  color: var(--danger);
}

.allocated-staff-empty {
  color: var(--muted);
  font-size: 0.88rem;
}

.admission-form {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(241, 205, 183, 0.28), rgba(255, 255, 255, 0.6));
  margin-bottom: 18px;
}

.admission-form textarea {
  min-height: 64px;
  resize: vertical;
}

.body-map-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 16px;
  margin-bottom: 14px;
}

.body-diagram {
  width: clamp(220px, 34vw, 340px);
  height: auto;
  display: block;
  cursor: pointer;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
}

.body-region {
  fill: rgba(180, 79, 44, 0.15);
  stroke: rgba(180, 79, 44, 0.4);
  stroke-width: 1;
  transition: 0.15s ease;
  cursor: pointer;
}

.body-region:hover {
  fill: rgba(180, 79, 44, 0.35);
  stroke: var(--accent);
  stroke-width: 1.5;
}

.body-region.active {
  fill: rgba(180, 79, 44, 0.6);
  stroke: var(--accent-dark);
  stroke-width: 2;
}

.shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
}

@media (min-width: 901px) {

  /* Lock entire shell to viewport — no full-page scroll */
  body {
    overflow: hidden;
  }

  .shell {
    align-items: start;
    grid-template-columns: 220px minmax(0, 1fr);
    height: 100vh;
    overflow: hidden;
  }

  .sidebar {
    height: 100vh;
    overflow: hidden;
    overscroll-behavior: contain;
  }

  /* Main column fills viewport height */
  .main {
    min-width: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .hero {
    flex-shrink: 0;
    gap: 16px;
    padding: 12px 18px;
  }

  .context-bar {
    flex-shrink: 0;
    margin-top: 10px;
  }

  /* Compact hero title and prevent action buttons wrapping */
  .hero h2 {
    font-size: 1.25rem;
  }

  .hero>.hero-actions,
  .context-bar>.hero-actions {
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
  }

  .hero>.hero-actions button,
  .context-bar>.hero-actions button {
    white-space: nowrap;
    padding: 10px 14px;
    min-height: 38px;
    font-size: 0.88rem;
  }

  /* Description is redundant on the operational view — hide to save vertical space */
  .hero-copy {
    display: none;
  }

  /* Tab content fills remaining height and scrolls internally */
  .tab.active {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 20px;
  }

  .tab.active#tab-overview {
    display: grid;
    align-content: start;
    gap: 10px;
  }

  .stats {
    margin-top: 6px;
  }

  .overview-grid {
    grid-template-columns: minmax(0, 1.2fr) repeat(2, minmax(0, 0.9fr));
    align-items: start;
  }

  .overview-grid>.panel {
    padding: 18px;
  }

  .overview-grid .panel-head {
    margin-bottom: 10px;
  }

  .overview-grid .list {
    gap: 8px;
  }

  .overview-grid .item {
    padding: 12px 14px;
    border-radius: 16px;
  }

  .stat-card {
    padding: 10px 14px;
  }

  .stat-value {
    font-size: 1.55rem;
  }

  .sidebar {
    padding: 24px 14px;
    gap: 18px;
  }

  .sidebar-menu {
    gap: 16px;
  }

  .status-card {
    padding: 14px;
    border-radius: 18px;
  }

  .nav-link {
    padding: 12px 14px;
  }

  .nav-sublink {
    padding: 6px 10px;
  }
}

.sidebar {
  padding: 20px 12px;
  background: rgba(16, 23, 22, 0.92);
  color: #f7efe5;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-menu {
  display: grid;
  gap: 10px;
}

.sidebar-quick-actions {
  display: grid;
  gap: 8px;
}

.sidebar-action {
  width: 100%;
  justify-content: center;
}

.sidebar-quick-actions .ghost {
  background: rgba(255, 255, 255, 0.12);
  color: #fff7ef;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.sidebar-quick-actions .ghost:hover {
  background: rgba(255, 255, 255, 0.18);
}

.sidebar h1,
.hero h2,
.panel h3 {
  font-family: "Space Grotesk", sans-serif;
  margin: 0;
}

.sidebar-copy,
#sessionMeta {
  color: rgba(247, 239, 229, 0.78);
}

.sidebar-copy {
  display: none;
}

.hero-copy {
  color: var(--muted);
}

.status-card {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  font-size: 0.9rem;
}

.status-label,
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
  font-weight: 700;
}

.eyebrow {
  color: var(--accent);
}

.status-label {
  color: rgba(247, 239, 229, 0.6);
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-submenu {
  display: grid;
  gap: 6px;
  margin: -4px 0 4px;
  padding-left: 18px;
}

.nav-sublink {
  text-align: left;
  border: 0;
  background: transparent;
  color: rgba(247, 239, 229, 0.7);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  transition: 0.2s ease;
}

.nav-sublink:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff7ef;
}

.nav-link {
  text-align: left;
  border: 0;
  background: transparent;
  color: rgba(247, 239, 229, 0.78);
  padding: 14px 16px;
  border-radius: 14px;
  cursor: pointer;
  transition: 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff7ef;
}

.nav-toggle {
  display: none;
  flex: 0 0 auto;
  min-width: 88px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff7ef;
  background: rgba(255, 255, 255, 0.08);
}

.nav-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
}

.main {
  padding: 20px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding: 14px 22px;
  background: linear-gradient(135deg, rgba(255, 252, 247, 0.9), rgba(241, 205, 183, 0.6));
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.hero-content {
  min-width: 0;
  flex: 1 1 auto;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.role-banner {
  margin-top: 18px;
  padding: 14px 18px;
  border-left: 4px solid var(--accent);
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  font-weight: 600;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.context-bar {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.login-panel {
  margin-top: 22px;
}

#loginForm .form-actions {
  grid-column: 2;
}

.tab {
  display: none;
  margin-top: 10px;
}

.tab.active {
  display: block;
}

.stats,
.grid {
  display: grid;
  gap: 18px;
}

.overview-grid {
  margin-top: 12px;
}

.shift-handover-panel {
  grid-column: 1 / -1;
}

.shift-handover-summary {
  display: grid;
  gap: 10px;
}

.shift-handover-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 12px;
}

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

.two-top {
  align-items: start;
  margin-top: 12px;
}

#clientWorkspaceGrid.admission-mode {
  grid-template-columns: minmax(0, 1fr);
}

.client-focus-mode .client-record-section {
  grid-column: 1 / -1;
}

#clientWorkspaceGrid,
#clientWorkspaceGrid>.panel,
.client-record-section,
.client-record-section .panel-head,
.client-record-section .hero-actions {
  min-width: 0;
}

.client-record-section .hero-actions button {
  min-width: 0;
  white-space: normal;
}

.action-menu {
  position: relative;
}

.action-menu-toggle {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.action-menu-toggle::-webkit-details-marker {
  display: none;
}

.action-menu-toggle::after {
  content: "▾";
  font-size: 0.8rem;
}

.action-menu[open] .action-menu-toggle::after {
  content: "▴";
}

.action-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 5;
  min-width: 230px;
  display: grid;
  gap: 6px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.98);
  box-shadow: 0 12px 28px rgba(23, 33, 33, 0.12);
}

.action-menu-list button {
  justify-content: flex-start;
  width: 100%;
}

.client-record-section.no-client-selected> :not(:first-child) {
  display: none;
}

.client-record-section.no-client-selected .panel-head .hero-actions {
  display: none;
}

.stat-card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 12px 16px;
}

.dashboard-metric {
  width: 100%;
  text-align: left;
}

.dashboard-metric.selectable {
  cursor: pointer;
  transition: 0.2s ease;
}

.dashboard-metric.selectable:hover,
.dashboard-metric.selectable:focus-visible {
  border-color: rgba(180, 79, 44, 0.5);
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(180, 79, 44, 0.12);
}

.dashboard-metric.severity-danger,
.item.severity-danger {
  border-color: rgba(169, 52, 52, 0.55);
  box-shadow: 0 0 0 1px rgba(169, 52, 52, 0.18), 0 10px 24px rgba(169, 52, 52, 0.12);
  background: linear-gradient(135deg, rgba(245, 211, 211, 0.88), rgba(255, 255, 255, 0.92));
}

.dashboard-metric.severity-warn,
.item.severity-warn {
  border-color: rgba(189, 111, 24, 0.5);
  box-shadow: 0 0 0 1px rgba(189, 111, 24, 0.16), 0 10px 24px rgba(189, 111, 24, 0.1);
  background: linear-gradient(135deg, rgba(253, 231, 200, 0.84), rgba(255, 255, 255, 0.92));
}

.dashboard-metric.severity-danger:hover,
.dashboard-metric.severity-danger:focus-visible,
.dashboard-metric.severity-warn:hover,
.dashboard-metric.severity-warn:focus-visible,
.item.severity-danger:hover,
.item.severity-warn:hover {
  transform: translateY(-1px);
}

.stat-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.stat-action {
  margin: 10px 0 0;
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 0.85rem;
}

.stat-value {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 600;
  color: var(--muted);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fffdf9;
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--ink);
}

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

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  min-height: 46px;
  cursor: pointer;
  background: var(--accent);
  color: #fff8f3;
  font-weight: 700;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  background: #173f3a;
}

button.ghost {
  background: rgba(23, 33, 33, 0.08);
  color: var(--ink);
}

.form-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.split-actions {
  gap: 10px;
  flex-wrap: wrap;
}

.align-end {
  justify-content: flex-end;
}

.top-gap {
  margin-top: 28px;
}

.top-space {
  margin-top: 18px;
}

.compact-grid {
  align-items: end;
}

.check {
  grid-auto-flow: column;
  justify-content: start;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.check input {
  width: auto;
}

.risk-setup-grid {
  grid-column: span 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.risk-flags-title {
  grid-column: span 2;
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.risk-flags {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  display: block;
  font-size: 1.05rem;
  padding: 14px 16px;
  min-height: 56px;
  margin-top: 8px;
  font-size: 0.86rem;
  color: var(--muted);
  margin: 0 0 8px 0;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
}

.span-2 {
  grid-column: span 2;
}

.med-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.list {
  display: grid;
  gap: 12px;
}

.mar-panel {
  margin-top: 18px;
}

.mar-header-head {
  margin-bottom: 10px;
}

.mar-resident-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.mar-resident-card strong {
  font-size: 1.05rem;
  display: block;
}

.mar-resident-card p {
  margin: 5px 0;
  color: var(--muted);
}

.mar-toolbar {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.mar-range-tabs,
.mar-filter-toggles,
.mar-day-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mar-range-btn,
.mar-filter-btn,
.mar-day-btn {
  min-height: 34px;
  padding: 8px 12px;
  font-size: 0.86rem;
}

.mar-day-btn {
  background: rgba(23, 33, 33, 0.08);
  color: var(--ink);
  margin-top: 5px;
}

.mar-range-btn.active,
.mar-filter-btn.active,
.mar-day-btn.active {
  background: #173f3a;
  color: #fff7ef;
}

.mar-custom-range {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.mar-custom-range label {
  min-width: 160px;
}

.mar-day-btn.ok {
  border: 1px solid rgba(27, 127, 95, 0.28);
}

.mar-day-btn.attention {
  border: 1px solid rgba(169, 52, 52, 0.35);
  background: rgba(245, 211, 211, 0.62);
}

.mar-layout {
  margin-top: 14px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 270px;
}

.mar-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
}

.mar-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.mar-table th,
.mar-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(23, 33, 33, 0.1);
}

.mar-table thead th {
  background: rgba(23, 33, 33, 0.06);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.mar-row {
  cursor: pointer;
}

.mar-row:hover {
  background: rgba(180, 79, 44, 0.08);
}

.mar-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  margin-right: 8px;
}

.mar-status-given {
  color: var(--ok);
}

.mar-status-missed {
  color: var(--warn);
}

.mar-status-due {
  color: #6b7280;
}

.mar-status-overdue {
  color: var(--danger);
}

.mar-one-click {
  min-height: 30px;
  padding: 6px 10px;
  font-size: 0.78rem;
}

.mar-sidebar {
  display: grid;
  gap: 10px;
  align-content: start;
  color: var(--ink);
}

.mar-side-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.72);
}

.mar-side-card h4 {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  color: var(--ink);
}

.mar-side-card p {
  margin: 4px 0;
  color: var(--ink);
}

.mar-medication-roster {
  display: grid;
  gap: 8px;
}

.mar-medication-item {
  padding-top: 8px;
  border-top: 1px solid rgba(23, 33, 33, 0.08);
}

.mar-medication-item strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
}

.mar-medication-item p {
  margin: 0;
  color: var(--muted);
}

.mar-alert-item.warn {
  color: var(--warn);
  font-weight: 700;
}

.mar-alert-item.danger {
  color: var(--danger);
  font-weight: 700;
}

.mar-progress {
  margin-top: 8px;
  height: 10px;
  border-radius: 999px;
  background: rgba(23, 33, 33, 0.12);
  overflow: hidden;
}

.mar-progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--ok), #6bbf8d);
}

#marQuickEditDialog {
  width: min(640px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: var(--panel-strong);
}

#marQuickEditDialog::backdrop {
  background: rgba(23, 33, 33, 0.45);
}

.bed-map {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.bed-map-site {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.62);
}

.bed-map-site h4 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.bed-map-ward {
  border: 1px dashed rgba(23, 33, 33, 0.2);
  border-radius: 14px;
  padding: 10px;
  margin-top: 10px;
}

.bed-map-ward header {
  font-weight: 700;
  margin-bottom: 8px;
}

.bed-map-rooms {
  display: grid;
  gap: 10px;
}

.bed-room {
  border: 1px solid rgba(23, 33, 33, 0.08);
  border-radius: 12px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.68);
}

.bed-room-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.bed-room-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

/* Two-rows layout: place items vertically into columns, with two rows per column */
.bed-room-grid.two-rows {
  display: grid;
  grid-auto-flow: column;
  grid-template-columns: none !important;
  grid-template-rows: repeat(2, 104px);
  grid-auto-columns: 78px;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.site-shortcuts {
  display: flex;
  gap: 8px;
  margin: 12px 0 8px;
  align-items: center;
}

.site-shortcut {
  background: #ffffff;
  /* solid white for high contrast */
  color: #1f2937;
  /* dark text for readability */
  border: 1px solid rgba(31, 41, 55, 0.08);
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.site-shortcut:hover {
  background: #f6f7f9;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.site-shortcut:focus {
  outline: 3px solid rgba(59, 130, 246, 0.18);
  outline-offset: 2px;
}

.bed-tile .bed-id {
  display: block;
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 1px;
}

.bed-tile .bed-client {
  display: block;
  font-size: 0.68rem;
  color: var(--ink);
  font-weight: 600;
  margin-top: auto;
  line-height: 1.1;
  word-break: break-word;
  overflow: hidden;
  max-height: 38px;
}

.bed-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 100%;
  background: #fffdf8;
  color: var(--ink);
  padding: 8px 4px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 3px;
  width: 100%;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.bed-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.bed-tile strong {
  font-size: 0.88rem;
  color: var(--ink-strong);
  display: block;
}

.bed-tile span {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 500;
}

.bed-tile.available {
  border-color: rgba(27, 127, 95, 0.35);
  background: rgba(216, 239, 231, 0.55);
}

.bed-tile.occupied {
  border-color: rgba(189, 111, 24, 0.4);
  background: rgba(253, 231, 200, 0.52);
}

.bed-tile.selected-client {
  border-color: rgba(169, 52, 52, 0.55);
  box-shadow: 0 0 0 2px rgba(169, 52, 52, 0.2);
}

.item.active {
  border-color: rgba(169, 52, 52, 0.42);
  box-shadow: 0 10px 24px rgba(169, 52, 52, 0.12);
}

.app-dialog {
  width: min(620px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  background: var(--panel-strong);
  color: var(--ink);
}

.app-dialog::backdrop {
  background: rgba(23, 33, 33, 0.45);
  backdrop-filter: blur(2px);
}

.collapsible-toggle {
  margin: 0 0 10px;
  width: fit-content;
}

.item {
  padding: 16px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.item.selectable {
  cursor: pointer;
  transition: 0.2s ease;
}

.item.selectable:hover,
.item.selectable.active {
  border-color: rgba(180, 79, 44, 0.5);
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(180, 79, 44, 0.12);
}

.item.assigned-to-user {
  border-color: rgba(27, 127, 95, 0.35);
}

.item strong {
  display: block;
  margin-bottom: 6px;
}

.item p {
  margin: 4px 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.badge {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: #efe8de;
}

.badge.warn {
  background: #fde7c8;
  color: var(--warn);
}

.badge.danger {
  background: #f5d3d3;
  color: var(--danger);
}

.badge.ok {
  background: #d8efe7;
  color: var(--ok);
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 22px 0;
}

.alert-banner {
  display: none;
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 12px;
  border-left: 4px solid currentColor;
}

.alert-banner.danger {
  background: #f5d3d3;
  color: var(--danger);
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-banner.warn {
  background: #fde7c8;
  color: var(--warn);
  display: flex;
  align-items: center;
  gap: 10px;
}

.split-stack {
  display: grid;
  gap: 22px;
}

/* ── Patient dashboard ─────────────────────────────── */
.pt-dash {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pt-dash-identity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.pt-dash-photo {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--line);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.10);
}

.pt-dash-photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--accent) 18%, rgba(255, 255, 255, 0.6));
  color: var(--accent-dark, #7a2a10);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

.pt-dash-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

.pt-dash-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.pt-stat {
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color 0.15s, background 0.15s;
  font-size: inherit;
  font-family: inherit;
}

.pt-stat:hover {
  border-color: var(--accent);
}

.pt-stat.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.pt-stat.urgent {
  border-color: var(--danger);
  background: rgba(169, 52, 52, 0.06);
}

.pt-stat.warn-border {
  border-color: var(--warn);
  background: rgba(189, 111, 24, 0.06);
}

.pt-stat.ok-border {
  border-color: var(--ok);
  background: rgba(27, 127, 95, 0.07);
}

.pt-stat-num {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
}

.pt-stat-label {
  font-size: 0.75rem;
  color: var(--muted);
}

.pt-stat-sub {
  font-size: 0.72rem;
}

.pt-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.pt-link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 8px;
  font-family: inherit;
  transition: background 0.12s;
}

.pt-link-btn:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.patient-section-tabs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 6px;
  margin: 12px 0;
  padding: 0 4px;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none; /* Hide default scrollbar on Firefox */
}

.patient-section-tabs::-webkit-scrollbar {
  display: none; /* Hide default scrollbar on Chrome, Safari, and Opera */
}

.patient-section-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 8px 10px;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.patient-section-tab.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

/* ── Collapsible detail sections ───────────────────── */
.detail-grid {
  display: block;
  gap: 10px;
  align-items: start;
}

.detail-grid section {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.5);
  overflow: hidden;
}

.detail-grid .compact-head {
  cursor: pointer;
  padding: 8px 12px;
  margin-bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.detail-grid section[data-pt-section="goals"],
.detail-grid section[data-pt-section="bodymap"],
.detail-grid section[data-pt-section="monitoring"] {
  grid-column: 1 / -1;
}

.detail-grid section.pt-tab-hidden {
  display: none;
}

.monitoring-controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.mini-sparkline {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  padding: 2px;
}

.person-summary-card {
  margin-bottom: 12px;
}

.resident-updates-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.resident-tab-btn {
  background: rgba(23, 33, 33, 0.08);
  color: var(--ink);
  border-radius: 999px;
  min-height: 34px;
  padding: 8px 12px;
  font-size: 0.86rem;
}

.resident-tab-btn.active {
  background: #173f3a;
  color: #fff7ef;
}

.detail-grid .compact-head::after {
  content: "›";
  margin-left: auto;
  padding-left: 8px;
  font-size: 1.1rem;
  color: var(--muted);
  transition: transform 0.2s;
}

.detail-grid section.pt-open .compact-head::after {
  transform: rotate(90deg);
}

.detail-grid section:not(.pt-open)>*:not(.panel-head) {
  display: none;
}

.detail-grid section.pt-open>*:not(.panel-head) {
  padding: 0 14px 14px;
}

.detail-empty {
  color: var(--muted);
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
}

.hidden {
  display: none;
}

.compact-head {
  margin-bottom: 10px;
}

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

.summary-card {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
}

.summary-card strong {
  display: block;
  margin-bottom: 4px;
}

.panel-head button,
.hero-actions button,
.form-actions button {
  flex: 0 0 auto;
}

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(23, 33, 33, 0.9);
  color: #fff7ef;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.empty {
  color: var(--muted);
  padding: 12px 0;
}

body.logged-out .sidebar-menu,
body.logged-out .nav-toggle,
body.logged-out .context-bar,
body.logged-out .role-banner,
body.logged-out .tab,
body.logged-out .hero-actions {
  display: none !important;
}

body.logged-out .sidebar {
  justify-content: flex-start;
}

body.logged-out .main {
  padding-top: 28px;
}

body.logged-out .login-panel {
  width: 100%;
}

@media (max-width: 1279px) {
  .shell {
    grid-template-columns: 264px minmax(0, 1fr);
  }

  #clientWorkspaceGrid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 16px 14px;
  }

  .main {
    padding: 22px;
  }

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

  .hero {
    padding: 22px;
  }

  .panel {
    padding: 20px;
  }
}

@media (min-width: 901px) and (max-width: 1200px) {
  .shell {
    grid-template-columns: 204px minmax(0, 1fr);
  }

  .sidebar {
    padding: 12px 10px;
  }

  .nav-link {
    padding: 12px 14px;
  }

  .nav-sublink {
    padding: 7px 10px;
  }

  .stat-card {
    padding: 10px 14px;
  }

  .stat-value {
    font-size: 1.6rem;
  }

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

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 22px 18px 16px;
  }

  .main {
    padding: 18px;
  }

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

  .grid.two,
  .summary-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .grid.two-top {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  }

  .mar-layout {
    grid-template-columns: 1fr;
  }

  .mar-table {
    min-width: 640px;
  }

  .panel-head {
    gap: 12px;
  }

  .span-2 {
    grid-column: span 1;
  }
}

/* ============================================================================
   MONITORING & WELLNESS METRICS
   ============================================================================ */

.wellness-card {
  padding: 14px;
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.05), rgba(33, 150, 243, 0.05));
  border-radius: 8px;
  border: 1px solid var(--line);
}

.wellness-card strong {
  font-size: 0.95rem;
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
}

.wellness-score-value {
  font-size: 2.4rem;
  font-weight: 700;
  margin: 12px 0;
  background: linear-gradient(135deg, #4CAF50, #2196F3);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.wellness-detail {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--muted);
  margin: 0;
}

#chartCareActivity,
#chartIncidents,
#chartTaskCompletion {
  min-height: 200px;
  margin-top: 16px;
}

/* RISK ASSESSMENT */

.risk-assessment {
  padding: 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
  grid-column: span 2;
}

/* CARE RECORDS TIMELINE */

.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline-item {
  position: relative;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.timeline-item:last-child {
  border-bottom: none;
}

.timeline-marker {
  position: absolute;
  left: -28px;
  top: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: white;
}

.timeline-marker.complete {
  background: var(--ok);
  border-color: var(--ok);
}

.timeline-marker.incomplete {
  background: var(--warn);
  border-color: var(--warn);
}

.timeline-content {
  font-size: 0.9rem;
}

@media (max-width: 860px) {
  .sidebar {
    gap: 16px;
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-menu {
    display: none;
  }

  .sidebar.menu-open .sidebar-menu {
    display: grid;
  }

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

  .nav-link {
    width: 100%;
  }

  .hero h2 {
    font-size: 1.7rem;
  }

  .hero-copy,
  .sidebar-copy,
  #sessionMeta,
  .item p,
  .summary-card p {
    font-size: 0.98rem;
  }

  label.check {
    grid-auto-flow: row;
    justify-content: stretch;
    align-items: start;
  }

  label.check input {
    margin-top: 2px;
  }
}

@media (max-width: 720px) {
  .main {
    padding: 14px;
  }

  .hero {
    padding: 18px;
    flex-direction: column;
  }

  .hero-content,
  .hero-actions,
  .context-bar>div {
    width: 100%;
  }

  .context-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats,
  .grid.two,
  .grid.two-top,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .mar-custom-range {
    flex-direction: column;
    align-items: stretch;
  }

  .mar-custom-range label,
  .mar-custom-range button {
    width: 100%;
  }

  .panel,
  .status-card,
  .stat-card,
  .summary-card,
  .item {
    border-radius: 18px;
  }

  .panel,
  .status-card {
    padding: 18px;
  }

  .hero-actions,
  .form-actions,
  .split-actions,
  .med-flags {
    width: 100%;
  }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-actions>button,
  .form-actions>button,
  .split-actions>button,
  .panel-head>button {
    width: 100%;
  }

  .check {
    gap: 8px;

    .risk-setup-grid,
    .risk-flags-items {
      grid-template-columns: 1fr;
    }
  }

  .risk-setup-grid,
  .risk-flags {
    grid-template-columns: 1fr;
  }

  .toast {
    left: 14px;
    right: 14px;
    bottom: 14px;
  }
}

@media (max-width: 480px) {
  .sidebar {
    padding: 18px 14px 14px;
  }

  .main {
    padding: 12px;
  }

  .hero,
  .panel,
  .status-card {
    padding: 16px;
  }

  .hero h2 {
    font-size: 1.45rem;
  }

  .stat-value {
    font-size: 1.7rem;
  }

  button,
  input,
  textarea,
  select {
    font-size: 16px;
  }
}

/* ── Risk Banner ─────────────────────────── */
.risk-banner {
  padding: 12px 16px;
  margin: 8px 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(169, 52, 52, 0.1) 0%, rgba(189, 111, 24, 0.05) 100%);
  border-left: 4px solid var(--danger);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.risk-banner.hidden {
  display: none;
}

.risk-banner-inner {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.risk-item {
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.risk-item.risk-critical {
  background: rgba(169, 52, 52, 0.15);
  color: #8c2e2e;
  border-left: 3px solid #a93434;
}

.risk-item.risk-high {
  background: rgba(189, 111, 24, 0.15);
  color: #8c5f14;
  border-left: 3px solid #bd6f18;
}

.risk-item.risk-medium {
  background: rgba(27, 127, 95, 0.08);
  color: #1b7f5f;
  border-left: 3px solid #1b7f5f;
}

/* ── Mood Tracker ────────────────────────── */
.mood-tracker {
  padding: 12px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 10px;
  border: 1px solid var(--line);
}

.mood-entry-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mood-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mood-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.mood-btn {
  border: none;
  background: transparent;
  font-size: 2rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s ease;
  opacity: 0.6;
}

.mood-btn:hover {
  opacity: 1;
  transform: scale(1.15);
  background: rgba(180, 79, 44, 0.1);
}

.mood-btn.mood-selected {
  animation: mood-selected-pulse 0.3s ease;
}

@keyframes mood-selected-pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.25);
  }

  100% {
    transform: scale(1);
  }
}

/* ──────────────────────────────────────────────────────────
   👑 PREMIUM NURSE DASHBOARD STYLES (Priority Zones, Banner, Trends)
   ────────────────────────────────────────────────────────── */

.shift-snapshot-banner {
  background: linear-gradient(135deg, rgba(180, 79, 44, 0.08) 0%, rgba(27, 127, 95, 0.08) 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
}

.shift-snapshot-content h2 {
  margin: 0 0 6px 0;
  font-size: 1.6rem;
  color: var(--ink);
  font-weight: 700;
}

.shift-snapshot-content p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 500;
}

.shift-health-metric {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--panel-strong);
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.health-score-ring {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: inset 0 0 0 4px rgba(0, 0, 0, 0.04);
}

.health-score-ring.excellent {
  background: rgba(27, 127, 95, 0.1);
  color: var(--ok);
  border: 3px solid var(--ok);
}

.health-score-ring.fair {
  background: rgba(189, 111, 24, 0.1);
  color: var(--warn);
  border: 3px solid var(--warn);
}

.health-score-ring.action {
  background: rgba(169, 52, 52, 0.1);
  color: var(--danger);
  border: 3px solid var(--danger);
}

.health-score-details {
  display: flex;
  flex-direction: column;
}

.health-score-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.5px;
}

.health-score-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
}

/* Priority Zones Layout */
.priority-zone {
  margin-top: 32px;
  padding: 20px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px dashed var(--line);
}

.priority-zone.critical-zone {
  background: rgba(169, 52, 52, 0.015);
  border-color: rgba(169, 52, 52, 0.15);
}

.priority-zone.attention-zone {
  background: rgba(189, 111, 24, 0.01);
  border-color: rgba(189, 111, 24, 0.12);
}

.priority-zone.routine-zone {
  background: rgba(27, 127, 95, 0.015);
  border-color: rgba(27, 127, 95, 0.15);
}

.zone-header {
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.zone-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.zone-indicator.critical {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

.zone-indicator.attention {
  background: var(--warn);
  box-shadow: 0 0 8px var(--warn);
}

.zone-indicator.routine {
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

/* Quick Action Buttons on Cards */
.card-action-bar {
  display: flex;
  justify-content: flex-end;
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  gap: 8px;
}

.card-action-btn {
  border: none;
  background: var(--accent);
  color: white;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.card-action-btn:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.card-action-btn.secondary-btn {
  background: rgba(23, 33, 33, 0.06);
  color: var(--ink);
}

.card-action-btn.secondary-btn:hover {
  background: rgba(23, 33, 33, 0.12);
}

#statsGrid {
  position: relative;
  z-index: 10;
}

/* Hover Previews */
.stat-card {
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease !important;
  z-index: 1;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06) !important;
  z-index: 99999 !important;
  /* Forces the active stat card above any sibling layout structures */
}

.hover-preview-container {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 280px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  z-index: 999999 !important;
  /* Elevated overlay */
  pointer-events: none;
  animation: fadeIn 0.15s ease-out;
}

.stat-card:hover .hover-preview-container {
  display: block;
}

.hover-preview-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.hover-preview-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hover-preview-item {
  font-size: 0.82rem;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hover-preview-badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}

/* Handover Refinements */
.handover-header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.handover-completeness {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.handover-completeness.success {
  background: rgba(27, 127, 95, 0.12);
  color: var(--ok);
}

.handover-completeness.pending {
  background: rgba(189, 111, 24, 0.12);
  color: var(--warn);
}

.handover-filters-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.3);
  padding: 10px 14px;
  margin-bottom: 16px;
}

.handover-filters-summary {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

.handover-risk-preview {
  margin: 16px 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.handover-risk-bucket {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.handover-risk-bucket.critical {
  border-left: 4px solid var(--danger);
}

.handover-risk-bucket.warning {
  border-left: 4px solid var(--warn);
}

.handover-risk-bucket.routine {
  border-left: 4px solid var(--ok);
}

.handover-risk-bucket-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.handover-risk-bucket-count {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink);
}

.handover-risk-bucket-residents {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Trends indicators */
.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-left: 6px;
}

.stat-trend.up {
  color: var(--danger);
}

.stat-trend.down {
  color: var(--ok);
}

.stat-trend.stable {
  color: var(--muted);
}

/* Animation fade in */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ──────────────────────────────────────────────────────────
   👑 CLIENT PAGE & HEADER ENHANCEMENTS
   ────────────────────────────────────────────────────────── */

/* Sticky Top App Header */
.app-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-logo-icon {
  font-size: 1.4rem;
}

.header-logo-text {
  font-weight: 700;
  font-family: "Outfit", sans-serif;
  color: var(--ink);
  font-size: 1.1rem;
}

/* Header Session Widget & Dropdown */
.header-session-widget {
  position: relative;
}

.session-dropdown {
  position: relative;
}

.session-dropdown-toggle {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--ink);
  transition: all 0.2s ease;
}

.session-dropdown-toggle:hover {
  background: var(--bg);
  border-color: var(--accent);
}

.role-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.5px;
}

.role-badge.admin {
  background: rgba(169, 52, 52, 0.12);
  color: var(--danger);
}

.role-badge.nurse {
  background: rgba(180, 79, 44, 0.12);
  color: var(--accent);
}

.role-badge.carer {
  background: rgba(27, 127, 95, 0.12);
  color: var(--ok);
}

.role-badge.guest {
  background: rgba(23, 33, 33, 0.08);
  color: var(--muted);
}

.username-label {
  font-size: 0.88rem;
}

.dropdown-arrow {
  font-size: 0.6rem;
  opacity: 0.5;
}

.session-dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  min-width: 180px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  z-index: 1000;
  animation: fadeIn 0.15s ease-out;
}

.session-dropdown-menu.active {
  display: block;
}

.dropdown-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropdown-item:hover {
  background: var(--bg);
  color: var(--accent);
}

.dropdown-item.danger:hover {
  background: rgba(169, 52, 52, 0.08);
  color: var(--danger);
}

.dropdown-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 6px 0;
}

/* Breadcrumb Context Trail */
.breadcrumb-container {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(23, 33, 33, 0.06);
}

.breadcrumb-item {
  cursor: pointer;
  transition: color 0.2s ease;
}

.breadcrumb-item:hover {
  color: var(--accent);
}

.breadcrumb-separator {
  opacity: 0.4;
}

.breadcrumb-current {
  color: var(--ink);
  font-weight: 700;
}

/* Client Ward pastel stripe */
.client-ward-header-strip {
  height: 6px;
  border-radius: 99px;
  margin-bottom: 16px;
  width: 100%;
}

.ward-strip-north {
  background: linear-gradient(90deg, #a7f3d0, #34d399);
}

.ward-strip-south {
  background: linear-gradient(90deg, #fecdd3, #fb7185);
}

.ward-strip-east {
  background: linear-gradient(90deg, #bfdbfe, #60a5fa);
}

.ward-strip-west {
  background: linear-gradient(90deg, #fde68a, #fbbf24);
}

.ward-strip-default {
  background: linear-gradient(90deg, var(--line), var(--muted));
}

/* Pinned residents and switcher select */
/* Searchable Quick Switch Combobox & Recent Views Combo */
.searchable-quick-switch-container {
  position: relative;
  width: 260px;
}

.quick-switch-search-input {
  width: 100%;
  padding: 6px 12px 6px 32px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--panel-strong) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="%2378716c" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>') no-repeat 10px center;
  background-size: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.quick-switch-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(186, 112, 79, 0.15);
  background-color: var(--background);
}

.quick-switch-dropdown-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  max-height: 280px;
  overflow-y: auto;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  z-index: 999;
  padding: 6px 0;
}

.qs-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 12px 4px 12px;
  border-top: 1px solid var(--line);
}

.qs-section-title:first-of-type {
  border-top: none;
}

.qs-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.qs-item:hover {
  background: rgba(186, 112, 79, 0.08);
  color: var(--accent);
}

.qs-selected {
  background: rgba(186, 112, 79, 0.12);
  color: var(--accent);
  font-weight: 600;
}

.qs-item-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent);
}

.qs-item-name {
  flex-grow: 1;
}

.qs-empty {
  padding: 12px;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

.client-header-inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.client-header-btn {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  color: var(--accent-dark, #7a2a10);
  transition: all 0.2s ease;
}

.client-header-btn:hover {
  background: var(--panel-strong, #fbf7ee);
  border-color: var(--accent);
  color: var(--accent);
}

/* Sidebar recent / pin lists */
.sidebar-recent-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.5px;
  margin: 12px 0 6px 12px;
}

.sidebar-recent-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 12px;
  margin-bottom: 12px;
}

.sidebar-recent-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s ease;
}

.sidebar-recent-link:hover {
  color: var(--accent);
}

.sidebar-recent-link::before {
  content: "👤";
  font-size: 0.75rem;
}

/* Pinned resident button on details */
.pin-client-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
  transition: transform 0.2s ease;
}

.pin-client-btn:hover {
  transform: scale(1.2);
}

/* Smooth client transition fade classes */
.client-fade-transition {
  animation: clientFade 0.25s ease-out;
}

@keyframes clientFade {
  from {
    opacity: 0;
    transform: translateY(3px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Premium Modal Styles */
.modal-dialog {
  border: 1px solid var(--line);
  background: var(--panel-strong, #fffdf8);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  padding: 0;
  max-width: 580px;
  width: calc(100% - 32px);
  color: var(--ink);
  overflow: hidden;
}

.modal-dialog::backdrop {
  background: rgba(43, 34, 25, 0.4);
  backdrop-filter: blur(8px);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--surface, #fcfaf3);
  border-bottom: 1px solid var(--line);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--ink-strong);
}

.modal-header .close-btn {
  background: none;
  border: none;
  font-size: 1.75rem;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-header .close-btn:hover {
  color: var(--danger);
}

.modal-dialog form {
  padding: 24px;
  gap: 16px;
}

.readonly-input {
  background: var(--surface, #fcfaf3) !important;
  color: var(--ink) !important;
  cursor: not-allowed;
  border: 1px solid var(--line);
  font-weight: 600;
}

.required {
  color: var(--danger);
  font-weight: 700;
  margin-left: 2px;
}

/* Premium Care Plan Layout Styles */
.care-plan-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 24px;
  background: var(--panel-strong, #fffdf8);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  flex-wrap: wrap;
}

.care-plan-header-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

.care-plan-photo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
  box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}

.care-plan-badges {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.care-plan-badges span {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 9999px;
  letter-spacing: 0.05em;
}

.badge-falls {
  background: #fdf2f2;
  color: #c53030;
  border: 1px solid #feb2b2;
}

.badge-nutrition {
  background: #fffaf0;
  color: #dd6b20;
  border: 1px solid #fbd38d;
}

.badge-dnar {
  background: #f7fafc;
  color: #4a5568;
  border: 1px solid #e2e8f0;
}

.badge-dols {
  background: #ebf8ff;
  color: #2b6cb0;
  border: 1px solid #bee3f8;
}

.care-plan-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.care-plan-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.button-compact {
  padding: 6px 12px !important;
  font-size: 0.82rem !important;
  min-height: auto !important;
  border-radius: 6px !important;
}

/* Care Plan Overview List */
.care-plan-overview-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 24px;
}

.overview-row {
  display: flex;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.overview-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.overview-label {
  font-weight: 700;
  color: var(--ink-strong);
  width: 180px;
  flex-shrink: 0;
}

.overview-value {
  color: var(--ink);
}

/* Goal Progress Badges */
.progress-badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 9999px;
  text-transform: uppercase;
}

.progress-in-progress {
  background: #fffaf0;
  color: #dd6b20;
  border: 1px solid #fbd38d;
}

.progress-on-track {
  background: #f0fff4;
  color: #38a169;
  border: 1px solid #c6f6d5;
}

.progress-needs-review {
  background: #fff5f5;
  color: #e53e3e;
  border: 1px solid #fed7d7;
}

/* Monitoring Trends widgets */
.monitoring-trends-widgets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  padding: 16px;
}

.trend-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-radius: 10px;
  background: var(--surface, #fcfaf3);
  border: 1px solid var(--line);
}

.trend-card-left h4 {
  margin: 0 0 4px 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.trend-card-left .trend-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink-strong);
  margin: 0;
}

.trend-arrow {
  font-size: 1.8rem;
  font-weight: 700;
}

.trend-up {
  color: #38a169;
}

.trend-down {
  color: #e53e3e;
}

.trend-stable {
  color: #4a5568;
}