:root {
  color-scheme: light;
  --navy-950: #071827;
  --navy-900: #0c2236;
  --navy-850: #102c45;
  --navy-800: #153a59;
  --blue-700: #1f5f91;
  --blue-600: #2874ad;
  --blue-500: #3c8ac3;
  --blue-100: #e7f2fa;
  --blue-050: #f3f8fc;
  --gold-500: #e7b221;
  --ink-900: #15283a;
  --ink-700: #41566a;
  --ink-500: #6a7c8e;
  --surface: #ffffff;
  --surface-alt: #f6f9fc;
  --canvas: #edf3f8;
  --line: #d8e2eb;
  --line-strong: #bfd0de;
  --danger: #a33c35;
  --danger-bg: #fff1ef;
  --warning: #875c00;
  --warning-bg: #fff8df;
  --success: #236044;
  --success-bg: #eaf6ef;
  --shadow-sm: 0 1px 2px rgba(11, 34, 53, .06), 0 5px 18px rgba(11, 34, 53, .05);
  --shadow-lg: 0 18px 50px rgba(7, 24, 39, .16);
  --radius: 11px;
  --topbar-height: 74px;
  --sidebar-width: 252px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { min-height: 100vh; margin: 0; padding-bottom: 50px; color: var(--ink-900); background: var(--canvas); font-size: 14px; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
a { color: var(--blue-700); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
svg { fill: currentColor; }
code { padding: 2px 6px; border-radius: 5px; background: #eaf0f5; color: #253d52; font-family: Consolas, "Courier New", monospace; font-size: .92em; }

.icon { width: 17px; height: 17px; flex: 0 0 17px; }

.topbar {
  position: fixed;
  z-index: 60;
  inset: 0 0 auto 0;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 24px 8px 16px;
  border-bottom: 1px solid rgba(7, 24, 39, .14);
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 2px 12px rgba(7, 24, 39, .07);
}

.brand { display: inline-flex; align-items: center; width: 216px; height: 56px; }
.brand img { width: auto; height: 54px; object-fit: contain; }
.topbar-spacer { flex: 1; }
.session-summary { display: flex; align-items: center; gap: 14px; color: var(--ink-700); }
.welcome-text { white-space: nowrap; }
.secure-session {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid #c5d8e7;
  border-radius: 999px;
  background: var(--blue-050);
  color: #285878;
  font-size: 12px;
  font-weight: 700;
}
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink-900);
  cursor: pointer;
}
.mobile-menu-button { display: none; }

.app-shell { min-height: 100vh; padding-top: var(--topbar-height); }
.sidebar {
  position: fixed;
  z-index: 50;
  top: var(--topbar-height);
  bottom: 0;
  left: 0;
  width: var(--sidebar-width);
  overflow-y: auto;
  padding: 14px 12px 22px;
  background: linear-gradient(180deg, var(--navy-800), var(--navy-950));
  box-shadow: 4px 0 18px rgba(7, 24, 39, .12);
  scrollbar-color: #54718a transparent;
  scrollbar-width: thin;
}
.main-nav { display: flex; flex-direction: column; gap: 6px; }
.nav-group { margin: 0; border-radius: 11px; }
.nav-group[open] {
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, .045);
  background: rgba(3, 17, 30, .16);
}
.nav-group-title,
.nav-item {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #edf5fb;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease, color .12s ease;
}
.nav-group-title { list-style: none; }
.nav-group-title::-webkit-details-marker { display: none; }
.nav-group-title:hover,
.nav-item:hover {
  border-color: rgba(255, 255, 255, .06);
  background: rgba(255, 255, 255, .075);
  color: #fff;
  text-decoration: none;
}
.nav-group-title.active,
.nav-item.active,
.nav-group:has(.subnav a.active) > .nav-group-title {
  border-color: rgba(255, 255, 255, .07);
  background: rgba(255, 255, 255, .07);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--gold-500);
}
.nav-icon { width: 18px; height: 18px; flex: 0 0 18px; color: #adc4d7; }
.nav-group-title:hover .nav-icon,
.nav-item:hover .nav-icon,
.nav-group-title.active .nav-icon,
.nav-item.active .nav-icon,
.nav-group:has(.subnav a.active) > .nav-group-title .nav-icon { color: #fff; }
.nav-chevron { width: 14px; height: 14px; margin-left: auto; color: #829fb7; transition: transform .15s ease; }
.nav-group:not([open]) .nav-chevron { transform: rotate(-90deg); }
.subnav {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 4px 0 7px;
  padding: 3px 8px 4px 39px;
}
.subnav::before {
  content: "";
  position: absolute;
  top: 3px;
  bottom: 4px;
  left: 22px;
  width: 1px;
  background: rgba(183, 205, 222, .18);
}
.subnav a {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #c9d9e7;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.15;
  text-decoration: none;
  transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease, color .12s ease, transform .12s ease;
}
.subnav a:hover {
  border-color: rgba(255, 255, 255, .06);
  background: rgba(255, 255, 255, .06);
  color: #fff;
  text-decoration: none;
}
.subnav a.active {
  border-color: #d6e4ef;
  background: linear-gradient(90deg, #eaf4fb 0%, #ffffff 100%);
  color: #16334d;
  font-weight: 800;
  box-shadow: 0 5px 14px rgba(2, 16, 29, .16);
}
.subnav-dot { width: 5px; height: 5px; flex: 0 0 5px; border-radius: 50%; background: #7595af; }
.subnav a.active .subnav-dot { background: var(--gold-500); box-shadow: 0 0 0 3px rgba(231, 178, 33, .16); }
.manage-subnav { padding-bottom: 7px; }
.logout-form { margin: 8px 0 0; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, .1); }
.nav-button { text-align: left; }

.content {
  min-height: calc(100vh - var(--topbar-height));
  margin-left: var(--sidebar-width);
  padding: 26px clamp(18px, 2.6vw, 42px) 44px;
}
/* Authenticated pages use all space available to the right of the navigation.
   Individual pages should not introduce arbitrary desktop max-width wrappers. */
.content > :not(.state-card):not(.app-modal) {
  width: 100%;
  max-width: none;
}
.sidebar-scrim { display: none; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin: 0 0 20px;
}
.page-header h1 { margin: 0; color: var(--ink-900); font-size: clamp(25px, 2vw, 32px); line-height: 1.15; letter-spacing: -.025em; }
.page-header p { max-width: 850px; margin: 7px 0 0; color: var(--ink-500); font-size: 14px; }

.panel,
.notice-panel,
.report-card,
.metric-card,
.state-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.panel { padding: 20px; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel-header h2,
.foundation-notice h2,
.report-card h2 { margin: 0; color: var(--ink-900); font-size: 17px; }
.panel-header p,
.foundation-notice p,
.report-card p { margin: 5px 0 0; color: var(--ink-500); }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card { min-width: 0; display: flex; align-items: center; gap: 14px; padding: 17px; }
.metric-icon { width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: var(--blue-100); color: var(--blue-700); }
.metric-icon .icon { width: 21px; height: 21px; }
.metric-card > div { min-width: 0; display: flex; flex-direction: column; }
.metric-label { color: var(--ink-500); font-size: 12px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.metric-card strong { margin-top: 2px; color: var(--ink-900); font-size: 26px; line-height: 1; }
.two-column-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 18px; }
.foundation-list { display: grid; gap: 9px; }
.foundation-list > div { display: flex; align-items: flex-start; gap: 10px; padding: 9px 11px; border: 1px solid #e4ebf1; border-radius: 8px; background: var(--surface-alt); }
.foundation-list .icon { margin-top: 1px; color: var(--blue-600); }
.numbered-steps { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.numbered-steps li { display: flex; gap: 11px; padding: 10px 0; border-bottom: 1px solid #e7edf2; }
.numbered-steps li:last-child { border-bottom: 0; }
.numbered-steps li > span { width: 28px; height: 28px; flex: 0 0 28px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--navy-850); color: #fff; font-weight: 800; }
.numbered-steps strong { display: block; }
.numbered-steps p { margin: 3px 0 0; color: var(--ink-500); }

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.button:hover { text-decoration: none; }
.button.primary { background: linear-gradient(135deg, #1769a5, #2386bd); border-color: #1769a5; color: #fff; box-shadow: 0 4px 12px rgba(31, 95, 145, .22); }
.button.primary:hover { background: linear-gradient(135deg, #125782, #1769a5); border-color: #125782; }
.button.secondary { background: #e8f3fb; border-color: #9fc4dc; color: #174f78; }
.button.secondary:hover { background: #d8ebf8; border-color: #6ea6ca; }
.button.ghost { background: transparent; border-color: var(--line); color: var(--ink-700); }
.button.ghost:hover { background: var(--surface-alt); }
.button.full-width { width: 100%; }
.button.disabled { pointer-events: none; opacity: .45; }

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}
.status-badge.ready,
.status-badge.active { background: var(--success-bg); color: var(--success); }
.status-badge.inactive { background: #edf0f3; color: #596979; }
.status-badge.locked { margin-left: 4px; background: var(--danger-bg); color: var(--danger); }
.status-badge.planned { background: var(--warning-bg); color: var(--warning); }
.status-badge.neutral { background: var(--blue-100); color: #285878; }

.table-panel { padding: 0; overflow: hidden; }
.table-panel > .panel-header { margin: 0; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.filter-toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-alt);
}
.search-control { min-width: 240px; max-width: 600px; flex: 1; display: flex; align-items: center; gap: 9px; height: 39px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; }
.search-control .icon { color: var(--ink-500); }
.search-control input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink-900); }
.toolbar-count { margin-left: auto; color: var(--ink-500); font-size: 12px; font-weight: 700; white-space: nowrap; }
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { padding: 11px 13px; border-bottom: 1px solid var(--line-strong); background: #eef4f8; color: #3d566b; text-align: left; font-size: 11px; font-weight: 800; letter-spacing: .035em; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 12px 13px; border-bottom: 1px solid #e7edf2; color: #2b4053; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #f8fbfd; }
.cell-subtext { display: block; margin-top: 2px; color: var(--ink-500); font-size: 11px; }
.empty-cell { padding: 30px !important; color: var(--ink-500) !important; text-align: center; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface-alt); color: var(--ink-500); }

.foundation-notice { max-width: 900px; }
.foundation-notice .status-badge { margin-bottom: 10px; }
.foundation-notice .button { margin-top: 12px; }
.notice-panel { padding: 14px 16px; margin-bottom: 18px; border-left: 4px solid var(--blue-600); }
.notice-panel p { margin: 4px 0 0; color: var(--ink-500); }
.warning-notice { border-left-color: var(--gold-500); background: #fffdf6; }

.report-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.report-card { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 14px; padding: 17px; }
.report-card > .icon { width: 24px; height: 24px; justify-self: center; color: var(--blue-700); }

.agreement-panel { max-width: 950px; }
.agreement-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.agreement-summary > div { display: flex; flex-direction: column; gap: 4px; padding: 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-alt); }
.agreement-summary span { color: var(--ink-500); font-size: 11px; font-weight: 800; text-transform: uppercase; }

.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { color: #2f485d; font-weight: 750; }
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-900);
  outline: 0;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus,
.search-control:focus-within { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(60, 138, 195, .14); }
.form-field input.input-validation-error,
.form-field select.input-validation-error,
.form-field textarea.input-validation-error {
  border-color: #c9655d;
  background: #fffafa;
  box-shadow: 0 0 0 3px rgba(163, 60, 53, .08);
}
.form-field input.input-validation-error:focus,
.form-field select.input-validation-error:focus,
.form-field textarea.input-validation-error:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(163, 60, 53, .13);
}
.field-validation { min-height: 17px; color: var(--danger); font-size: 12px; }
.field-validation-error { display: block; font-weight: 650; }
.field-validation-valid:empty { color: transparent; }
.validation-summary { margin-bottom: 12px; padding: 10px 12px; border: 1px solid #e5b7b3; border-radius: 8px; background: var(--danger-bg); color: var(--danger); }
.validation-summary:empty { display: none; }
.validation-summary ul { margin: 0; padding-left: 18px; }
.checkbox-row { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-700); cursor: pointer; }
.checkbox-row input { width: 16px; height: 16px; }
.password-field { position: relative; }
.password-field input { padding-right: 62px; }
.password-toggle { position: absolute; top: 5px; right: 5px; min-height: 32px; padding: 0 9px; border: 0; border-radius: 6px; background: var(--blue-050); color: var(--blue-700); font-weight: 750; cursor: pointer; }

.state-picker { position: relative; width: 100%; }
.state-picker-value { display: none !important; }
.state-picker-options:not([hidden]) {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(12, 36, 56, .18);
}
.state-picker-option {
  display: block;
  width: 100%;
  min-height: 34px;
  padding: 7px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-900);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.state-picker-option:hover,
.state-picker-option[aria-selected="true"] { background: var(--blue-050); color: var(--blue-700); }


/* Facility management */
.facility-toolbar { flex-wrap: wrap; }
.toolbar-select { display: flex; align-items: center; gap: 7px; min-height: 39px; }
.toolbar-select label { color: var(--ink-500); font-size: 11px; font-weight: 800; letter-spacing: .025em; text-transform: uppercase; white-space: nowrap; }
.toolbar-select select { min-width: 126px; height: 39px; padding: 0 30px 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; color: var(--ink-900); outline: 0; }
.toolbar-select select:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(60, 138, 195, .14); }
.sort-link { display: inline-flex; align-items: center; gap: 5px; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; text-decoration: none; }
.sort-link:hover { color: var(--blue-700); text-decoration: none; }
.sort-link span { min-width: 10px; color: var(--blue-700); }
.table-primary-link { color: var(--ink-900); font-weight: 800; text-decoration: none; }
.table-primary-link:hover { color: var(--blue-700); text-decoration: underline; }
.action-column { width: 1%; text-align: right !important; white-space: nowrap; }
.compact-button { min-height: 31px; padding: 5px 10px; font-size: 12px; }
.loc-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.loc-badges span { padding: 3px 7px; border: 1px solid #cfdfeb; border-radius: 999px; background: var(--blue-050); color: #335d7b; font-size: 10px; font-weight: 800; white-space: nowrap; }
.cell-subtext-inline { display: inline; margin: 0; }

.form-panel { padding: 0; overflow: visible; }
.facility-form {
  width: 100%;
  max-width: none;
  display: grid;
  gap: 14px;
  padding: 14px;
  border-color: #cad9e5;
  background: linear-gradient(180deg, #edf5fb 0%, #f6f9fc 100%);
}

.facility-form .form-field label,
.facility-form .field-label { color: #24445e; font-size: 12.5px; font-weight: 800; }
.facility-form .form-field input,
.facility-form .form-field select,
.facility-form .form-field textarea {
  min-height: 43px;
  border-color: #c7d6e3;
  background: #fbfdff;
  box-shadow: inset 0 1px 2px rgba(7, 24, 39, .035);
  transition: border-color .12s ease, background-color .12s ease, box-shadow .12s ease;
}
.facility-form .form-field input:hover,
.facility-form .form-field select:hover,
.facility-form .form-field textarea:hover { border-color: #9fb9ce; background: #fff; }
.facility-form .form-field input:focus,
.facility-form .form-field select:focus,
.facility-form .form-field textarea:focus {
  border-color: var(--blue-500);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(60, 138, 195, .14), inset 0 1px 2px rgba(7, 24, 39, .025);
}
.form-panel > .validation-summary { margin: 0; }
.form-section {
  overflow: hidden;
  padding: 0 20px 20px;
  border: 1px solid #d5e1eb;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(11, 34, 53, .045);
}
.form-section-last { border-bottom: 1px solid #d5e1eb; }
.form-section-heading {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 0 -20px 18px;
  padding: 13px 20px 12px;
  border-bottom: 1px solid #dbe6ee;
  background: linear-gradient(90deg, #e9f3fb 0%, #f7fbfe 66%, #ffffff 100%);
}
.form-section-heading h2 { margin: 0; color: #183851; font-size: 16px; letter-spacing: -.01em; }
.form-section-heading p { margin: 3px 0 0; color: #5a7185; font-size: 12.5px; }
.form-grid { display: grid; gap: 15px 18px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.facility-header-grid { grid-template-columns: minmax(360px, 2fr) minmax(220px, .8fr) minmax(270px, 1fr); }
.form-span-2 { grid-column: span 2; }
.status-field { justify-content: flex-start; }
.switch-row {
  min-height: 48px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid #cbd9e4;
  border-radius: 9px;
  background: #f8fbfd;
  color: var(--ink-700);
  cursor: pointer;
  transition: border-color .12s ease, background-color .12s ease, box-shadow .12s ease;
}
.switch-row:hover { border-color: #9fbdd3; background: #f2f8fc; }
.switch-row:has(input:checked) {
  border-color: #8db6d5;
  background: #edf6fd;
  box-shadow: inset 3px 0 0 var(--blue-600);
}
.switch-row input { width: 17px; height: 17px; flex: 0 0 17px; margin-top: 2px; accent-color: var(--blue-600); }
.switch-row span { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.switch-row strong { color: var(--ink-900); font-size: 13px; }
.switch-row small { color: var(--ink-500); font-size: 11px; line-height: 1.35; }
.choice-grid { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 10px; }
.choice-card {
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #c9d8e4;
  border-radius: 9px;
  background: #fbfdff;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(11, 34, 53, .025);
  transition: border-color .12s ease, background-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.choice-card:hover {
  border-color: #91b4cf;
  background: #f2f8fc;
  box-shadow: 0 4px 10px rgba(11, 34, 53, .07);
}
.choice-card:has(input:checked) {
  border-color: #174f7b;
  background: linear-gradient(135deg, var(--blue-700), var(--navy-800));
  box-shadow: 0 5px 14px rgba(21, 58, 89, .18);
}
.choice-card input { width: 17px; height: 17px; flex: 0 0 17px; accent-color: var(--gold-500); }
.choice-card span { display: flex; min-width: 0; flex-direction: column; }
.choice-card strong { color: var(--ink-900); font-size: 13px; }
.choice-card small { color: var(--ink-500); font-size: 10px; font-weight: 750; letter-spacing: .02em; }
.choice-card:has(input:checked) strong { color: #fff; }
.choice-card:has(input:checked) small { color: #d6e6f2; }
.choice-card-inactive { border-style: dashed; background: #f8fafb; opacity: .8; }
.inline-notice { padding: 12px 14px; border: 1px dashed var(--line-strong); border-radius: 8px; background: var(--surface-alt); color: var(--ink-500); }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 16px;
  border: 1px solid #d5e1eb;
  border-radius: 10px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 2px 10px rgba(11, 34, 53, .04);
}
.text-uppercase { text-transform: uppercase; }
.success-notice { border-left-color: var(--success); background: var(--success-bg); }
.record-meta-bar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: -4px 0 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--line); box-shadow: var(--shadow-sm); }
.record-meta-bar > div { min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; background: var(--surface); }
.record-meta-bar span { color: var(--ink-500); font-size: 10px; font-weight: 800; letter-spacing: .035em; text-transform: uppercase; }
.record-meta-bar strong { overflow: hidden; color: var(--ink-900); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.auth-body { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 0%, #244f70 0, transparent 42%), linear-gradient(135deg, var(--navy-950), var(--navy-800)); }
.auth-shell { width: min(100%, 470px); }
.login-card { padding: 28px; border: 1px solid rgba(255, 255, 255, .18); border-radius: 15px; background: rgba(255, 255, 255, .98); box-shadow: var(--shadow-lg); }
.login-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.login-brand img { width: 138px; height: auto; }
.login-brand h1 { margin: 0; font-size: 24px; }
.login-brand p { margin: 4px 0 0; color: var(--ink-500); }
.login-form { display: grid; gap: 14px; }
.login-forgot-link { align-self: flex-end; margin-top: -3px; font-size: 13px; font-weight: 700; }
.login-footnote { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--ink-500); font-size: 12px; }

.state-card { max-width: 680px; margin: 40px auto; padding: 28px; text-align: center; }
.compact-state h1 { margin: 12px 0 5px; }
.compact-state p { margin: 0 auto 18px; color: var(--ink-500); }
.state-icon { min-width: 58px; height: 58px; display: inline-flex; align-items: center; justify-content: center; padding: 0 8px; border-radius: 50%; background: var(--blue-100); color: var(--blue-700); font-weight: 900; }
.state-icon.danger { background: var(--danger-bg); color: var(--danger); }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-column-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  :root { --topbar-height: 66px; }
  .topbar { padding: 7px 12px; }
  .mobile-menu-button { display: inline-flex; }
  .brand { width: auto; height: 48px; }
  .brand img { height: 46px; }
  .welcome-text { display: none; }
  .secure-session { padding: 6px 9px; }
  .sidebar { top: var(--topbar-height); width: min(86vw, var(--sidebar-width)); transform: translateX(-105%); transition: transform .18s ease; }
  .mobile-nav-open .sidebar { transform: translateX(0); }
  .sidebar-scrim { position: fixed; z-index: 45; inset: var(--topbar-height) 0 0 0; display: block; background: rgba(4, 17, 28, .55); }
  .sidebar-scrim[hidden] { display: none; }
  .mobile-nav-open { overflow: hidden; }
  .content { margin-left: 0; padding: 20px 16px 36px; }
  .page-header { align-items: stretch; flex-direction: column; }
  .page-header .button { align-self: flex-start; }
  .report-grid { grid-template-columns: 1fr; }
  .agreement-summary { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .metric-grid { grid-template-columns: 1fr; }
  .filter-toolbar { align-items: stretch; flex-wrap: wrap; }
  .search-control { min-width: 100%; max-width: none; flex-basis: 100%; }
  .toolbar-count { width: 100%; margin-left: 0; }
  .report-card { grid-template-columns: 36px 1fr; }
  .report-card .status-badge { grid-column: 2; justify-self: start; }
  .login-card { padding: 22px 18px; }
  .login-brand { align-items: flex-start; flex-direction: column; }
  .login-brand img { width: 155px; }
  .pagination { align-items: stretch; flex-direction: column; text-align: center; }
}

@media (max-width: 1100px) {
  .facility-header-grid { grid-template-columns: minmax(280px, 1.5fr) minmax(220px, 1fr); }
  .facility-header-grid .facility-client-field { grid-column: 1 / -1; }
  .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choice-grid { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
  .record-meta-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .facility-form { gap: 10px; padding: 10px; }
  .form-section { padding: 0 14px 16px; }
  .form-section-heading { margin: 0 -14px 15px; padding: 12px 14px 11px; }
  .form-grid-3,
  .form-grid-4,
  .facility-header-grid { grid-template-columns: 1fr; }
  .facility-header-grid .facility-client-field { grid-column: auto; }
  .form-span-2 { grid-column: span 1; }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-actions { justify-content: stretch; }
  .form-actions .button { flex: 1; }
  .record-meta-bar { grid-template-columns: 1fr; }
  .toolbar-select { flex: 1 1 160px; }
  .toolbar-select select { width: 100%; }
}

@media (max-width: 460px) {
  .choice-grid { grid-template-columns: 1fr; }
}

/* Facility identity row alignment: text and boolean controls share one control baseline. */
.facility-header-grid .form-field > label:not(.switch-row),
.facility-header-grid .form-field > .field-label {
  min-height: 18px;
  display: flex;
  align-items: center;
  line-height: 18px;
}
.facility-header-grid .switch-row {
  height: 43px;
  min-height: 43px;
  align-items: center;
  padding: 0 12px;
}
.facility-header-grid .switch-row input {
  margin-top: 0;
}
.facility-header-grid .switch-row span {
  display: flex;
  justify-content: center;
}
.facility-header-grid .switch-row small {
  display: none;
}

/* Facility form workspace: compact two-column layout with a reusable accent header. */
.page-header-accent {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 78px;
  margin-bottom: 14px;
  padding: 14px 18px;
  overflow: hidden;
  border: 1px solid #1f557f;
  border-radius: 11px;
  background: linear-gradient(105deg, var(--navy-900) 0%, #164f79 58%, #2376aa 100%);
  box-shadow: 0 6px 18px rgba(8, 35, 57, .14);
}
.page-header-accent::after {
  content: "";
  position: absolute;
  inset: auto -70px -82px auto;
  width: 220px;
  height: 160px;
  border: 24px solid rgba(255, 255, 255, .055);
  border-radius: 50%;
  pointer-events: none;
}
.page-header-accent-icon {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 10px;
  background: rgba(255, 255, 255, .11);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .04);
}
.page-header-accent-icon .icon { width: 23px; height: 23px; }
.page-header-accent-copy { min-width: 0; }
.page-header-accent h1 { color: #fff; font-size: clamp(24px, 1.8vw, 30px); }
.page-header-accent p { max-width: none; margin-top: 4px; color: #dceaf4; font-size: 13px; }
.page-header-accent .page-header-button {
  position: relative;
  z-index: 1;
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, .45);
  background: rgba(255, 255, 255, .12);
  color: #fff;
}
.page-header-accent .page-header-button:hover {
  border-color: rgba(255, 255, 255, .72);
  background: rgba(255, 255, 255, .2);
}

.facility-form {
  gap: 12px;
  padding: 12px;
}
.facility-form-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
  align-items: stretch;
  gap: 12px;
}
.facility-form-main,
.facility-form-side {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 12px;
}
.facility-form .form-section {
  padding: 0 16px 15px;
}
.facility-form .form-section-heading {
  margin: 0 -16px 13px;
  padding: 10px 16px 9px;
}
.facility-form .form-section-heading h2 { font-size: 14px; }
.facility-form .form-section-heading p { margin-top: 2px; font-size: 11.5px; }
.facility-form .form-grid { gap: 9px 12px; }
.form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.facility-form .form-field { gap: 4px; }
.facility-form .form-field label,
.facility-form .field-label { font-size: 11.5px; }
.facility-form .form-field input,
.facility-form .form-field select {
  min-height: 37px;
  padding: 7px 10px;
  border-radius: 7px;
}
.facility-form .form-field textarea {
  min-height: 78px;
  padding: 8px 10px;
  border-radius: 7px;
}
.facility-form .field-validation { min-height: 0; font-size: 11px; }
.facility-form .field-validation-valid:empty { display: none; }

.facility-settings-list {
  display: grid;
  gap: 8px;
}
.facility-settings-section .switch-row {
  min-height: 58px;
  align-items: center;
  padding: 9px 10px;
}
.facility-settings-section .switch-row input { margin-top: 0; }
.facility-settings-section .switch-row strong { font-size: 12.5px; }
.facility-settings-section .switch-row small { font-size: 10.5px; line-height: 1.25; }
.facility-loc-grid {
  display: grid;
  gap: 10px;
}
.facility-loc-row {
  display: grid;
  grid-template-columns: minmax(100px, .7fr) minmax(140px, 1.3fr);
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.facility-loc-row:last-child { border-bottom: 0; }
.facility-loc-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  cursor: pointer;
}
.facility-loc-toggle strong { font-size: 12px; }
.facility-loc-toggle input { width: 15px; height: 15px; flex: 0 0 15px; }
.facility-loc-toggle small {
  display: block;
  color: var(--ink-500);
  font-size: 10px;
}
.facility-loc-location {
  min-width: 0;
}
.facility-loc-location input {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-900);
  font: inherit;
  font-size: 12px;
}
.facility-loc-location input:disabled {
  background: #f1f4f7;
  color: var(--ink-500);
  cursor: not-allowed;
}
.facility-loc-row-inactive {
  opacity: .72;
}
.facility-form .form-actions { padding: 11px 13px; }

@media (min-width: 981px) {
  .facility-form-side {
    height: 100%;
    grid-template-rows: auto minmax(0, 1fr);
    align-content: stretch;
  }
  .facility-form-side .facility-loc-section {
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
  }
  .facility-form-side .facility-loc-grid {
    align-content: start;
  }
}

@media (max-width: 1250px) {
  .facility-form-layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .facility-form-main .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .facility-form-layout { grid-template-columns: 1fr; }
  .facility-form-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .page-header-accent {
    grid-template-columns: auto minmax(0, 1fr);
    min-height: 0;
    padding: 13px 14px;
  }
  .page-header-accent .page-header-button { grid-column: 1 / -1; justify-self: start; }
  .facility-form-side,
  .form-grid-2 { grid-template-columns: 1fr; }
  .facility-form-main .form-grid-4 { grid-template-columns: 1fr; }
  .facility-form-main .form-span-2 { grid-column: span 1; }
}

@media (max-width: 460px) {
  .facility-loc-row { grid-template-columns: 1fr; gap: 7px; }
}

/* Facility list Add/Edit modal: large workspace with colored header and sticky actions. */
.app-modal {
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
}
.app-modal::backdrop {
  background: rgba(5, 20, 34, .64);
  backdrop-filter: blur(2px);
}
.facility-modal {
  /* Modals are intentionally narrower than normal full-width application pages.
     Keep a consistent visible gutter around the dialog itself. */
  width: min(90vw, 1800px);
  height: 80dvh;
  max-width: min(90vw, 1800px);
  max-height: calc(100dvh - 48px);
  overflow: hidden;
  border: 1px solid rgba(18, 73, 111, .45);
  border-radius: 16px;
  background: var(--surface-alt);
  box-shadow: 0 28px 72px rgba(4, 22, 37, .34);
}
.facility-modal-shell {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--surface-alt);
}
.facility-modal-header {
  position: relative;
  z-index: 2;
  min-height: 76px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  padding: 13px 20px;
  overflow: hidden;
  background: linear-gradient(105deg, var(--navy-900) 0%, #16547f 60%, #2581b9 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(5, 31, 50, .18);
}
.facility-modal-header::after {
  content: "";
  position: absolute;
  right: 58px;
  bottom: -92px;
  width: 250px;
  height: 175px;
  border: 26px solid rgba(255, 255, 255, .055);
  border-radius: 50%;
  pointer-events: none;
}
.facility-modal-header-icon {
  position: relative;
  z-index: 1;
  width: 43px;
  height: 43px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, .26);
  border-radius: 10px;
  background: rgba(255, 255, 255, .12);
}
.facility-modal-header-icon .icon { width: 23px; height: 23px; }
.facility-modal-heading { position: relative; z-index: 1; min-width: 0; }
.facility-modal-heading h2 {
  margin: 0;
  color: #fff;
  font-size: 23px;
  line-height: 1.1;
}
.facility-modal-heading p {
  margin: 4px 0 0;
  color: #dcecf6;
  font-size: 12.5px;
}
.facility-modal-close {
  position: relative;
  z-index: 2;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ef9da4;
  border-radius: 9px;
  background: #fff;
  color: #c62836;
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.facility-modal-close span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  line-height: 1;
  transform: translateY(-1px);
}
.facility-modal-close:hover {
  border-color: #c62836;
  background: #fff0f1;
  color: #a91422;
}
.facility-modal-form {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: var(--surface-alt);
}
.facility-modal-body {
  min-height: 0;
  overflow: auto;
  padding: 20px 22px 22px;
  background: #edf4f9;
  scrollbar-gutter: stable;
}
.facility-modal .validation-summary:not(:empty) { margin-bottom: 10px; }
.facility-modal .facility-form-layout {
  min-height: 100%;
  gap: 16px;
}
.facility-modal .facility-form-main,
.facility-modal .facility-form-side {
  gap: 16px;
}
.facility-modal .form-section {
  overflow: hidden;
  border-radius: 10px;
}
.facility-modal .form-section-heading h3 {
  margin: 0;
  color: var(--navy-900);
  font-size: 14px;
  line-height: 1.2;
}
.facility-modal-footer {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 -6px 18px rgba(12, 45, 68, .07);
}
.facility-modal-footer-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
  color: var(--ink-700);
}
.facility-modal-footer-copy span { font-size: 12px; font-weight: 800; }
.facility-modal-footer-copy small { color: var(--ink-500); font-size: 10.5px; }
.facility-modal-actions { display: flex; align-items: center; gap: 8px; }
.facility-modal-actions .button { min-width: 112px; }
.facility-modal-loading {
  position: absolute;
  z-index: 6;
  inset: 0 0 66px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(239, 246, 251, .86);
  color: var(--navy-900);
  backdrop-filter: blur(1px);
}
.facility-modal-loading[hidden] { display: none; }
.loading-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(18, 82, 124, .2);
  border-top-color: var(--blue-700);
  border-radius: 50%;
  animation: app-spin .75s linear infinite;
}
@keyframes app-spin { to { transform: rotate(360deg); } }
body:has(.facility-modal[open]) { overflow: hidden; }

@media (max-width: 980px) {
  .facility-modal {
    width: 90vw;
    height: 84dvh;
    max-width: 90vw;
    max-height: calc(100dvh - 32px);
  }
  .facility-modal-body { padding: 16px; }
}

@media (max-width: 700px) {
  .facility-modal {
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
  }
  .facility-modal-header { min-height: 70px; padding: 11px 12px; }
  .facility-modal-heading h2 { font-size: 20px; }
  .facility-modal-heading p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .facility-modal-body { padding: 10px; }
  .facility-modal-footer { align-items: stretch; flex-direction: column; gap: 8px; }
  .facility-modal-footer-copy { display: none; }
  .facility-modal-actions { width: 100%; }
  .facility-modal-actions .button { flex: 1; }
  .facility-modal-loading { bottom: 64px; }
}

/* ZIP lookup feedback is intentionally compact so it does not distort form rows. */
.zip-lookup-status {
  display: block;
  margin-top: 4px;
  color: var(--ink-500);
  font-size: 10.5px;
  line-height: 1.25;
}
.zip-lookup-status[hidden] { display: none; }
.zip-lookup-status.is-loading { color: var(--blue-700); }
.zip-lookup-status.is-success { color: var(--blue-700); font-weight: 650; }
.zip-lookup-status.is-warning { color: #8b5a14; }

/* Patient management: familiar patient + DOA workflow with separate treatment episodes. */
.is-hidden { display: none !important; }
.patient-toolbar { flex-wrap: wrap; }
.patient-toolbar .search-control { min-width: min(520px, 100%); flex: 1 1 360px; }
.patient-table th,
.patient-table td { vertical-align: middle; }
.patient-inline-badge { display: inline-flex; margin-left: 5px; vertical-align: middle; }

.patient-form-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 360px);
  align-items: stretch;
  gap: 14px;
}
.patient-form-main,
.patient-form-side {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 12px;
}
.patient-form-side { grid-template-rows: auto minmax(0, 1fr); }
.patient-form .patient-identity-grid {
  grid-template-columns: minmax(150px, 1.2fr) minmax(150px, 1.2fr) minmax(135px, .9fr) minmax(70px, .45fr) minmax(105px, .65fr) minmax(150px, 1fr);
  align-items: start;
}
.patient-age-field input {
  text-align: center;
  font-weight: 800;
  background: #edf4f9 !important;
  color: var(--navy-900);
}
.sensitive-field-help {
  display: block;
  margin-top: 3px;
  color: var(--ink-500);
  font-size: 10px;
  line-height: 1.25;
}
.patient-case-fields { display: grid; gap: 8px; }
.patient-case-section .form-field textarea { min-height: 86px; }

.patient-match-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 11px 12px;
  border: 1px solid #b8d2e5;
  border-left: 4px solid var(--blue-600);
  border-radius: 9px;
  background: linear-gradient(90deg, #eaf5fc, #f8fbfe);
  color: var(--ink-700);
}
.patient-match-panel[hidden] { display: none; }
.patient-match-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #d8ebf8;
  color: var(--blue-700);
}
.patient-match-icon .icon { width: 19px; height: 19px; }
.patient-match-copy { min-width: 0; display: grid; gap: 2px; }
.patient-match-copy strong { color: var(--navy-900); font-size: 12.5px; }
.patient-match-copy span { font-size: 11.5px; }
.patient-match-copy small { color: var(--ink-500); font-size: 10.5px; }
.patient-match-actions { display: flex; align-items: center; gap: 7px; }

.patient-history-section {
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.patient-history-heading { align-items: center; }
.patient-history-heading .button { flex: 0 0 auto; }
.patient-history-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 6px;
}
.patient-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 9px;
  border: 1px solid #d8e3eb;
  border-radius: 7px;
  background: #fbfdff;
}
.patient-history-item.is-current {
  border-color: #a8c8de;
  background: #eef7fd;
  box-shadow: inset 3px 0 0 var(--blue-600);
}
.patient-history-item > div { min-width: 0; display: grid; gap: 1px; }
.patient-history-item strong {
  overflow: hidden;
  color: var(--ink-900);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.patient-history-item span:not(.status-badge) {
  overflow: hidden;
  color: var(--ink-500);
  font-size: 9.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.patient-history-item .status-badge { flex: 0 0 auto; }

.patient-modal .patient-form-layout { min-height: 100%; gap: 16px; }
.patient-modal .patient-form-main,
.patient-modal .patient-form-side { gap: 16px; }
.patient-modal .patient-form-side { grid-template-rows: auto minmax(0, 1fr); }
.patient-modal .patient-history-section { height: 100%; }
.patient-modal .patient-modal-body { padding: 18px 20px 20px; }

@media (max-width: 1380px) {
  .patient-form .patient-identity-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .patient-age-field { max-width: 110px; }
}

@media (max-width: 1180px) {
  .patient-form-layout { grid-template-columns: minmax(0, 1fr) 310px; }
  .patient-form .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .patient-form-layout { grid-template-columns: 1fr; }
  .patient-form-side { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto; }
  .patient-modal .patient-form-side { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto; }
  .patient-match-panel { grid-template-columns: auto minmax(0, 1fr); }
  .patient-match-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

@media (max-width: 700px) {
  .patient-form .patient-identity-grid,
  .patient-form .form-grid-4,
  .patient-form-side,
  .patient-modal .patient-form-side { grid-template-columns: 1fr; }
  .patient-age-field { max-width: none; }
  .patient-form .form-span-2 { grid-column: span 1; }
  .patient-match-panel { grid-template-columns: 1fr; }
  .patient-match-icon { display: none; }
  .patient-match-actions { justify-content: stretch; }
  .patient-match-actions .button { flex: 1; }
}

/* Patient standalone form: stretch both columns to use the available form height,
   matching the completed Facility form treatment while leaving the modal unchanged. */
@media (min-width: 981px) {
  .patient-form[data-patient-standalone-form] .patient-form-main {
    grid-template-rows: auto minmax(0, 1fr);
    align-content: stretch;
  }

  .patient-form[data-patient-standalone-form] .patient-form-main > .form-section:last-child {
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .patient-form[data-patient-standalone-form] .patient-form-side {
    height: 100%;
    grid-template-rows: minmax(0, 1fr);
    align-content: stretch;
  }

  .patient-form[data-patient-standalone-form] .patient-case-section {
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .patient-form[data-patient-standalone-form] .patient-case-fields {
    align-content: start;
  }
}


.required-indicator {
  color: #c62828;
  font-weight: 700;
  margin-left: 0.15rem;
}


.notification-menu {
  position: relative;
}

.topbar-notification-link {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 36px;
  padding: .5rem .7rem;
  border: 0;
  border-radius: .55rem;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.topbar-notification-link:hover,
.topbar-notification-link[aria-expanded="true"] {
  background: #f0f5f9;
}

.topbar-notification-link .icon {
  width: 1rem;
  height: 1rem;
}

.topbar-notification-count {
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 .35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #c62828;
  color: #fff;
  font-size: .72rem;
  line-height: 1;
}

.notification-dropdown {
  position: absolute;
  z-index: 120;
  top: calc(100% + 10px);
  right: 0;
  width: min(430px, calc(100vw - 24px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(7, 24, 39, .20);
}

.notification-dropdown[hidden] {
  display: none;
}

.notification-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  background: #f7fafc;
}

.notification-dropdown-header > div {
  display: grid;
  gap: 1px;
}

.notification-dropdown-header strong {
  color: var(--navy-900);
  font-size: 14px;
}

.notification-dropdown-header span {
  color: var(--ink-500);
  font-size: 11px;
}

.notification-pending-label {
  padding: 3px 8px;
  border-radius: 999px;
  background: #fff2ef;
  color: var(--danger) !important;
  font-weight: 750;
}

.notification-dropdown-list {
  max-height: 430px;
  overflow-y: auto;
}

.notification-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid #e7edf2;
}

.notification-item:last-child {
  border-bottom: 0;
}

.notification-item:hover {
  background: #f9fbfd;
}

.notification-item-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #e9f3fa;
  color: var(--blue-700);
}

.notification-item-icon .icon {
  width: 16px;
  height: 16px;
}

.notification-item-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
  color: var(--ink-700);
  font-size: 12px;
}

.notification-item-copy strong {
  color: var(--navy-900);
  font-size: 12.5px;
}

.notification-item-copy b {
  color: var(--navy-900);
}

.notification-item-copy small {
  color: var(--ink-500);
  font-size: 10.5px;
}

.notification-item-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.notification-item-actions form {
  margin: 0;
}

.notification-item-actions .button {
  min-width: auto;
}

.notification-empty {
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 28px 18px;
  color: var(--ink-500);
  text-align: center;
}

.notification-empty .icon {
  width: 22px;
  height: 22px;
  color: var(--blue-700);
}

.notification-empty strong {
  color: var(--navy-900);
}

@media (max-width: 700px) {
  .topbar-notification-link > span:not(.topbar-notification-count) {
    display: none;
  }

  .notification-dropdown {
    position: fixed;
    top: calc(var(--topbar-height) + 8px);
    right: 358px;
    left: auto;
    width: auto;
  }

  .notification-item {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .notification-item-actions {
    grid-column: 2;
    justify-content: flex-start;
  }
}

.patient-checkout-cell {
  min-width: 132px;
}

.checkout-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7fafc;
  color: var(--ink-700);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.checkout-state-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: currentColor;
}

.checkout-state.available {
  border-color: #cfe4d7;
  background: #f1f8f4;
  color: var(--success);
}

.checkout-state.mine {
  border-color: #bdd7e8;
  background: #eef6fb;
  color: var(--blue-700);
}

.checkout-state.busy {
  border-color: #ead79f;
  background: #fff9e8;
  color: #7a5a00;
}

.checkout-time,
.checkout-owner {
  margin-top: 3px;
  white-space: nowrap;
}

.patient-checkout-actions {
  min-width: 310px;
}

.patient-action-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.patient-action-group .inline-form {
  display: inline-flex;
  margin: 0;
}

.patient-action-group .button {
  min-width: auto;
}

.patient-checkin-button {
  color: var(--ink-700);
  background: #f8fafc;
  border-color: var(--line-strong);
}

.patient-checkin-button:hover {
  color: var(--navy-900);
  background: #eef3f7;
}

@media (max-width: 1320px) {
  .patient-checkout-actions { min-width: 260px; }
  .patient-action-group { flex-wrap: wrap; }
}


/* Global internal messaging - right-aligned utility dock */
.chat-dock {
  position: fixed;
  z-index: 180;
  inset: auto 0 0;
  height: 50px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0 18px;
  border-top: 1px solid #c7d4df;
  background: linear-gradient(180deg, #f3f6f8, #e5ebf0);
  box-shadow: 0 -3px 12px rgba(7, 24, 39, .08);
}
.chat-contact-panel {
  position: absolute;
  z-index: 2;
  right: 18px;
  bottom: 0;
  width: 340px;
  height: min(500px, calc(100vh - var(--topbar-height) - 20px));
  min-height: min(500px, calc(100vh - var(--topbar-height) - 20px));
  display: grid;
  grid-template-rows: 48px auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid #bfcfdb;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: #fff;
  box-shadow: 0 10px 32px rgba(7, 24, 39, .24);
  transition: height .18s ease, min-height .18s ease;
}
.chat-contact-panel.collapsed {
  height: 48px;
  min-height: 48px;
}
.chat-contact-panel.collapsed .chat-contact-search-wrap,
.chat-contact-panel.collapsed .chat-contact-list {
  display: none;
}
.chat-contact-header {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  border: 0;
  background: linear-gradient(105deg, var(--navy-900), #195b87);
  color: #fff;
  text-align: left;
  cursor: pointer;
}
.chat-contact-header > div:first-child { display: grid; gap: 1px; }
.chat-contact-header strong { font-size: 14px; }
.chat-contact-header span { color: #dbe9f2; font-size: 10px; }
.chat-contact-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.chat-contact-total-unread {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #c62828;
  color: #fff !important;
  font-size: 10px !important;
  font-weight: 800;
}
.chat-contact-chevron {
  color: #fff !important;
  font-size: 16px !important;
  transform: rotate(180deg);
  transition: transform .18s ease;
}
.chat-contact-panel.collapsed .chat-contact-chevron {
  transform: rotate(0deg);
}
.chat-contact-panel.has-unread-attention.collapsed .chat-contact-header {
  animation: chatRosterAttention .7s ease-in-out infinite alternate;
}
@keyframes chatRosterAttention {
  from { background: linear-gradient(105deg, var(--navy-900), #195b87); }
  to { background: linear-gradient(105deg, #8b1d1d, #d03636); }
}
.chat-contact-search-wrap {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: #f7fafc;
}
.chat-contact-search-wrap input {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 5px 8px;
  background: #fff;
  color: var(--ink-900);
  font-size: 11px;
}
.chat-contact-list {
  min-height: 0;
  overflow-y: auto;
}
.chat-contact {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0,1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid #edf1f4;
  background: #fff;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.chat-contact:hover { background: #f1f6fa; }
.chat-contact-avatar {
  position: relative;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #dcecf7;
  color: var(--navy-900);
  font-size: 11px;
  font-weight: 800;
}
.chat-contact-presence {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #aeb9c2;
}
.chat-contact-presence.online {
  background: #36a766;
}
.chat-contact-presence-label {
  font-weight: 700;
}
.chat-contact-presence-label.online {
  color: #237a49;
}
.chat-contact-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}
.chat-contact-copy strong {
  overflow: hidden;
  color: var(--navy-900);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-contact-copy small {
  overflow: hidden;
  color: var(--ink-500);
  font-size: 9.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-contact-unread {
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #c62828;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
}
.chat-contact-empty {
  padding: 24px 12px;
  color: var(--ink-500);
  font-size: 11px;
  text-align: center;
}

.chat-window-stack {
  position: absolute;
  z-index: 1;
  right: 368px;
  bottom: 0;
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}
.chat-window {
  width: 340px;
  height: 390px;
  display: grid;
  grid-template-rows: 42px minmax(0,1fr);
  overflow: hidden;
  border: 1px solid #b8cad7;
  border-bottom: 0;
  border-radius: 9px 9px 0 0;
  background: #fff;
  box-shadow: 0 8px 28px rgba(7, 24, 39, .24);
  pointer-events: auto;
}
.chat-window.minimized {
  height: 42px;
}
.chat-window-header {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0,1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 10px;
  background: var(--navy-900);
  color: #fff;
}
.chat-window-title {
  min-width: 0;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.chat-window-title strong {
  overflow: hidden;
  font-size: 12px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-window-person {
  min-width: 0;
  display: grid;
  gap: 0;
}
.chat-window-person small {
  color: #bdd0dd;
  font-size: 8.5px;
  line-height: 1.1;
}
.chat-presence-dot.offline {
  background: #9aa8b2;
  box-shadow: 0 0 0 2px rgba(154,168,178,.16);
}
.chat-presence-dot.online {
  background: #55c987;
  box-shadow: 0 0 0 2px rgba(85,201,135,.18);
}
.chat-window-unread {
  flex: 0 0 auto;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #d32f2f;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
}
.chat-presence-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6cc58c;
  box-shadow: 0 0 0 2px rgba(108,197,140,.18);
}
.chat-window-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.chat-header-button {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #dceaf4;
  font: inherit;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.chat-header-button:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}
.chat-close {
  font-size: 19px;
}
.chat-window-body {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0,1fr) auto;
  background: #f4f7f9;
}
.chat-thread {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
}
.chat-thread-empty {
  margin: auto;
  color: var(--ink-500);
  font-size: 11px;
  text-align: center;
}
.chat-line { display: flex; }
.chat-line.mine { justify-content: flex-end; }
.chat-line.theirs { justify-content: flex-start; }
.chat-line-bubble {
  max-width: 82%;
  padding: 6px 8px;
  border: 1px solid #d6e1e8;
  border-radius: 10px;
  background: #fff;
  color: var(--ink-900);
}
.chat-line.mine .chat-line-bubble {
  border-color: #bdd8ea;
  background: #e7f3fb;
}
.chat-line-body {
  font-size: 11px;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat-line-bubble small {
  display: block;
  margin-top: 3px;
  color: var(--ink-500);
  font-size: 8.5px;
  text-align: right;
}
.chat-send-form {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.chat-send-form input {
  min-width: 0;
  min-height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 11px;
}
.chat-send-form button {
  min-width: 54px;
  border: 0;
  border-radius: 7px;
  background: var(--blue-700);
  color: #fff;
  font-size: 10.5px;
  font-weight: 750;
  cursor: pointer;
}
.chat-window.has-new-message .chat-window-header {
  background: #1f75ad;
}
.chat-window.minimized.has-new-message {
  box-shadow: 0 0 0 2px rgba(31,117,173,.20), 0 8px 28px rgba(7,24,39,.24);
}
.chat-window-header.chat-flash {
  animation: chatAttention .7s ease-in-out infinite alternate;
}
@keyframes chatAttention {
  from { background: var(--navy-900); }
  to { background: #2d91cf; }
}

@media (max-width: 980px) {
  .chat-dock { padding: 0 8px; }
  .chat-window-stack {
    right: 8px;
    left: 8px;
  }
  .chat-window {
    width: min(340px, calc(100vw - 16px));
  }
  .chat-window-stack .chat-window:nth-child(n+2) { display: none; }
  .chat-contact-panel {
    right: 8px;
    width: min(340px, calc(100vw - 16px));
    height: min(500px, calc(100vh - var(--topbar-height) - 8px));
    min-height: min(500px, calc(100vh - var(--topbar-height) - 8px));
  }
  .chat-contact-panel.collapsed {
    height: 48px;
    min-height: 48px;
  }
}
@media (max-width: 700px) {
  .chat-window {
    width: calc(100vw - 16px);
    height: min(480px, calc(100vh - var(--topbar-height) - 16px));
  }
}

/* Data retention */
.retention-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.retention-summary-card {
  display: grid;
  gap: 3px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.retention-summary-card span {
  color: var(--ink-500);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.retention-summary-card strong {
  color: var(--navy-900);
  font-size: 20px;
}
.retention-summary-card small {
  color: var(--ink-500);
  font-size: 10.5px;
  line-height: 1.25;
}
.retention-hold-form {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}
.retention-hold-form input {
  width: 190px;
  min-height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 5px 7px;
  font-size: 11px;
}

@media (max-width: 1050px) {
  .retention-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .topbar-message-link > span:not(.topbar-message-count) { display: none; }
  .message-drawer {
    top: var(--topbar-height);
    width: 100vw;
  }
  .retention-summary-grid { grid-template-columns: 1fr; }
  .retention-hold-form { flex-direction: column; }
  .retention-hold-form input { width: 100%; }
}


/* Data retention workspace */
.retention-page-header {
  margin-bottom: 12px;
}
.retention-mode-badge {
  margin-left: auto;
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 999px;
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  white-space: nowrap;
}
.retention-mode-badge.enabled {
  background: rgba(49, 154, 94, .22);
}
.retention-mode-badge.validation {
  background: rgba(255, 187, 61, .18);
}
.retention-overview {
  display: grid;
  grid-template-columns: minmax(300px, 1.6fr) repeat(3, minmax(120px, .55fr));
  align-items: stretch;
  gap: 1px;
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid #d0dce5;
  border-radius: 10px;
  background: #d0dce5;
  box-shadow: 0 2px 8px rgba(10, 36, 56, .06);
}
.retention-overview-copy,
.retention-stat {
  background: #fff;
}
.retention-overview-copy {
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 13px 15px;
}
.retention-eyebrow {
  color: var(--blue-700);
  font-size: 9.5px;
  font-weight: 850;
  letter-spacing: .055em;
  text-transform: uppercase;
}
.retention-overview-copy strong {
  color: var(--navy-900);
  font-size: 14px;
}
.retention-overview-copy small {
  max-width: 680px;
  color: var(--ink-500);
  font-size: 10.5px;
  line-height: 1.35;
}
.retention-stat {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 1px;
  padding: 10px;
  text-align: center;
}
.retention-stat span {
  color: var(--ink-500);
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
}
.retention-stat strong {
  color: var(--navy-900);
  font-size: 20px;
}
.retention-stat small {
  color: var(--ink-500);
  font-size: 9.5px;
}
.retention-section {
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid #d0dce5;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(10, 36, 56, .06);
}
.retention-section-header {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 14px;
  border-bottom: 1px solid #dde6ec;
  background: #f8fbfd;
}
.retention-section-header > div {
  display: grid;
  gap: 2px;
}
.retention-section-header h2 {
  margin: 0;
  color: var(--navy-900);
  font-size: 15px;
}
.retention-section-header p {
  margin: 0;
  color: var(--ink-500);
  font-size: 10.5px;
}
.retention-section-count {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid #d0dde6;
  border-radius: 999px;
  background: #fff;
  color: var(--ink-600);
  font-size: 9.5px;
  font-weight: 800;
}
.retention-empty-state {
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 22px;
  color: var(--ink-500);
}
.retention-empty-state.compact {
  min-height: 96px;
}
.retention-empty-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: #eaf4fa;
  color: var(--blue-700);
}
.retention-empty-icon .icon {
  width: 18px;
  height: 18px;
}
.retention-empty-state > div {
  display: grid;
  gap: 2px;
}
.retention-empty-state strong {
  color: var(--navy-900);
  font-size: 12px;
}
.retention-empty-state p {
  margin: 0;
  font-size: 10.5px;
}
.retention-table-wrap {
  border: 0;
}
.retention-table {
  margin: 0;
}
.retention-table thead th {
  background: #eef4f8;
}
.retention-hold-form {
  align-items: center;
}

@media (max-width: 1000px) {
  .retention-overview {
    grid-template-columns: 1fr repeat(3, minmax(100px, .45fr));
  }
}
@media (max-width: 760px) {
  .retention-mode-badge {
    display: none;
  }
  .retention-overview {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .retention-overview-copy {
    grid-column: 1 / -1;
  }
  .retention-section-header {
    align-items: flex-start;
  }
}


/* Dashboard */
.dashboard-header { align-items: center; }
.dashboard-metric-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.dashboard-metric-today { border-color: #c8dceb; }
.dashboard-metric-upcoming { border-color: #d7dfbf; }
.dashboard-metric-overdue { border-color: #e9c6c1; }
.dashboard-metric-overdue .metric-icon { background: var(--danger-bg); color: var(--danger); }
.dashboard-metric-today .metric-icon { background: var(--blue-100); color: var(--blue-700); }
.dashboard-metric-upcoming .metric-icon { background: var(--warning-bg); color: var(--warning); }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, .7fr);
  gap: 18px;
  align-items: start;
}
.dashboard-side { display: grid; gap: 18px; }
.dashboard-review-panel .panel-header { align-items: center; }
.dashboard-review-table td { vertical-align: middle; }

.dashboard-due-badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.dashboard-due-badge.overdue { background: var(--danger-bg); color: var(--danger); }
.dashboard-due-badge.today { background: var(--warning-bg); color: var(--warning); }
.dashboard-due-badge.upcoming { background: var(--blue-100); color: var(--blue-700); }

.dashboard-operations-panel,
.dashboard-quick-links { padding: 0; overflow: hidden; }
.dashboard-operations-panel .panel-header,
.dashboard-quick-links .panel-header {
  margin: 0;
  padding: 17px 18px;
  border-bottom: 1px solid var(--line);
}

.dashboard-stat-list { display: grid; }
.dashboard-stat-list > div {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 17px;
  border-bottom: 1px solid #e8eef3;
}
.dashboard-stat-list > div:last-child { border-bottom: 0; }
.dashboard-stat-icon {
  width: 35px;
  height: 35px;
  flex: 0 0 35px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--blue-050);
  color: var(--blue-700);
}
.dashboard-stat-list > div > div { display: flex; flex-direction: column; }
.dashboard-stat-list strong { color: var(--ink-900); font-size: 20px; line-height: 1; }
.dashboard-stat-list span:not(.dashboard-stat-icon) { margin-top: 3px; color: var(--ink-500); font-size: 12px; }

.dashboard-action-list { display: grid; padding: 8px; }
.dashboard-action-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--ink-700);
  font-weight: 700;
}
.dashboard-action-list a:hover {
  background: var(--blue-050);
  color: var(--blue-700);
  text-decoration: none;
}
.dashboard-action-list .icon { color: var(--blue-600); }

@media (max-width: 1180px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .dashboard-header { align-items: flex-start; flex-direction: column; }
  .dashboard-side { grid-template-columns: 1fr; }
}

/* Desktop compact density: keep familiar workflows visible with less
   scrolling while preserving comfortable controls on small screens. */
@media (min-width: 901px) {
  :root {
    --topbar-height: 64px;
    --sidebar-width: 210px;
    --radius: 9px;
  }

  body.app-body { font-size: 13px; line-height: 1.42; }
  .topbar { padding: 6px 20px 6px 14px; }
  .brand { width: 190px; height: 48px; }
  .brand img { height: 46px; }
  .sidebar { padding: 10px 10px 16px; }
  .sidebar-toolbar { display: flex; justify-content: flex-end; margin: 0 0 5px; }
  .sidebar-collapse-toggle {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 5px 8px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 7px;
    background: rgba(255, 255, 255, .06);
    color: #dce9f3;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
  }
  .sidebar-collapse-toggle:hover,
  .sidebar-collapse-toggle:focus-visible { background: rgba(255, 255, 255, .14); color: #fff; }
  .sidebar-collapse-toggle .icon { width: 15px; height: 15px; flex: 0 0 15px; }
  .main-nav { gap: 4px; }
  .nav-group-title,
  .nav-item { min-height: 40px; gap: 9px; padding: 7px 9px; }
  .subnav a { min-height: 30px; gap: 7px; padding: 5px 8px; font-size: 12px; }

  .content { padding: 18px clamp(14px, 2vw, 30px) 30px; }
  .page-header { gap: 16px; margin-bottom: 15px; }
  .page-header h1 { font-size: clamp(22px, 1.8vw, 28px); }
  .page-header p { margin-top: 5px; font-size: 13px; }
  .page-header-accent { min-height: 66px; gap: 11px; padding: 10px 14px; }
  .page-header-accent-icon { width: 40px; height: 40px; }
  .page-header-accent h1 { font-size: clamp(22px, 1.7vw, 27px); }
  .page-header-accent p { font-size: 12px; }

  .panel { padding: 16px; }
  .panel-header { gap: 12px; margin-bottom: 12px; }
  .button { min-height: 35px; gap: 6px; padding: 7px 11px; }
  .table-panel > .panel-header { padding: 14px 16px; }
  .filter-toolbar { gap: 7px; padding: 10px 12px; }
  .search-control { height: 36px; }
  .toolbar-select { min-height: 36px; }
  .toolbar-select select { height: 36px; }
  .data-table th { padding: 8px 10px; }
  .data-table td { padding: 9px 10px; }
  .pagination { gap: 9px; padding: 9px 12px; }

  .form-section { padding: 0 14px 12px; }
  .form-section-heading { margin: 0 -14px 10px; padding: 9px 14px 8px; }
  .form-section-heading h2 { font-size: 14px; }
  .form-section-heading p { font-size: 11.5px; }
  .form-grid { gap: 11px 14px; }
  .form-field { gap: 4px; }
  .form-field label { font-size: 12px; }
  .form-field input,
  .form-field select,
  .form-field textarea { min-height: 38px; padding: 7px 10px; }
  .field-validation { min-height: 14px; font-size: 11px; }
  .facility-form .form-section { padding: 0 14px 12px; }
  .facility-form .form-section-heading { margin: 0 -14px 10px; padding: 8px 14px; }
  .facility-form .form-field input,
  .facility-form .form-field select { min-height: 36px; padding: 6px 9px; }
  .choice-card { min-height: 54px; gap: 8px; padding: 8px 10px; }

  .facility-modal-header { min-height: 66px; gap: 14px; padding: 10px 16px; }
  .facility-modal-heading h2 { font-size: 20px; }
  .facility-modal-body { padding: 16px 18px 18px; }
  .facility-modal-footer { min-height: 60px; gap: 12px; padding: 9px 14px; }
}

html.sidebar-collapsed { --sidebar-width: 64px; }

@media (min-width: 901px) {
  html.sidebar-collapsed .sidebar { padding: 10px 7px 16px; }
  html.sidebar-collapsed .sidebar-toolbar { justify-content: center; }
  html.sidebar-collapsed .sidebar-collapse-toggle { width: 40px; padding: 5px; }
  html.sidebar-collapsed .sidebar-collapse-toggle > span,
  html.sidebar-collapsed .nav-group-title > span,
  html.sidebar-collapsed .nav-item > span { display: none; }
  html.sidebar-collapsed .nav-group[open] {
    padding: 0;
    border-color: transparent;
    background: transparent;
  }
  html.sidebar-collapsed .nav-group-title,
  html.sidebar-collapsed .nav-item { justify-content: center; gap: 0; padding: 7px 0; }
  html.sidebar-collapsed .nav-chevron,
  html.sidebar-collapsed .subnav { display: none; }
  html.sidebar-collapsed .nav-group-title[data-tooltip],
  html.sidebar-collapsed .nav-item[data-tooltip],
  html.sidebar-collapsed .sidebar-collapse-toggle[data-tooltip] { position: relative; }
  html.sidebar-collapsed .nav-group-title[data-tooltip]::after,
  html.sidebar-collapsed .nav-item[data-tooltip]::after,
  html.sidebar-collapsed .sidebar-collapse-toggle[data-tooltip]::after {
    content: attr(data-tooltip);
    position: fixed;
    z-index: 100;
    top: var(--nav-tooltip-y, 80px);
    left: calc(var(--sidebar-width) + 12px);
    transform: translateY(-50%);
    width: max-content;
    max-width: 240px;
    padding: 6px 9px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 6px;
    background: var(--navy-950);
    color: #fff;
    box-shadow: 0 6px 18px rgba(7, 24, 39, .24);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
  html.sidebar-collapsed .nav-group-title[data-tooltip]:hover::after,
  html.sidebar-collapsed .nav-group-title[data-tooltip]:focus-visible::after,
  html.sidebar-collapsed .nav-item[data-tooltip]:hover::after,
  html.sidebar-collapsed .nav-item[data-tooltip]:focus-visible::after,
  html.sidebar-collapsed .sidebar-collapse-toggle[data-tooltip]:hover::after,
  html.sidebar-collapsed .sidebar-collapse-toggle[data-tooltip]:focus-visible::after {
    opacity: 1;
    visibility: visible;
  }
}

@media (max-width: 900px) {
  html.sidebar-collapsed { --sidebar-width: 252px; }
  .sidebar-collapse-toggle { display: none; }
}

/* Shared one-line form controls use a single height across application pages. */
input:is([type="text"], [type="email"], [type="password"], [type="search"], [type="tel"], [type="url"], [type="number"], [type="date"], [type="datetime-local"], [type="month"], [type="week"], [type="time"]),
input:not([type]),
select {
  box-sizing: border-box;
  height: 38px;
  min-height: 38px;
}
