:root {
  --ink: #172033;
  --muted: #697386;
  --line: #dce2ea;
  --line-strong: #bdc7d5;
  --surface: #ffffff;
  --canvas: #f3f6fa;
  --brand: #173b57;
  --accent: #e8f1f6;
  --pending-ink: #8a4509;
  --pending-border: #d7973f;
  --pending-surface: #fff4df;
  --pending-accent: #b76519;
  --slot-height: 24px;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at top right, rgba(88, 142, 175, 0.14), transparent 28rem),
    var(--canvas);
}

.auth-navigation {
  width: min(100% - 32px, 1680px);
  min-height: 54px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  color: var(--muted);
  font-size: 0.82rem;
}

.auth-navigation form {
  margin: 0;
}

.auth-navigation__user strong {
  color: var(--ink);
}

.page-shell {
  width: min(100% - 32px, 1680px);
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hero {
  padding: 28px 30px;
  color: #fff;
  background: linear-gradient(125deg, #112d42, #1f5575);
  border-radius: 20px;
  box-shadow: 0 18px 45px rgba(23, 59, 87, 0.18);
}

.hero__title-row,
.plan-summary,
.legend-panel,
.appointment__topline {
  display: flex;
  align-items: center;
}

.hero__title-row {
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  line-height: 1.05;
}

.read-only-badge {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.plan-summary {
  align-items: stretch;
  gap: 18px;
  margin-top: 26px;
}

.plan-summary section {
  min-width: 190px;
  padding: 13px 15px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.09);
}

.summary-label {
  display: block;
  margin-bottom: 5px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.patient-summary {
  flex: 1;
}

.patient-codes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.patient-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 4px 8px;
  border-radius: 7px;
  color: var(--brand);
  background: #fff;
  font-size: 0.76rem;
  font-weight: 850;
}

.legend-panel {
  justify-content: space-between;
  gap: 24px;
  margin: 22px 0 14px;
  padding: 17px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
}

.legend-panel .eyebrow {
  margin: 0;
  color: var(--brand);
}

.legend-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: #3b4657;
  font-size: 0.76rem;
  font-weight: 700;
}

.legend-list li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border: 1px solid var(--event-border);
  border-radius: 4px;
  background: var(--event-bg);
}

.schedule-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 35px rgba(31, 47, 68, 0.08);
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.week-navigation {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}

.week-navigation__export {
  margin-left: auto;
}

.patient-plan-selection {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin: 18px 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.patient-plan-selection p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.patient-plan-selection__form {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto;
  align-items: end;
  gap: 10px;
  min-width: min(100%, 560px);
}

.patient-plan-notice {
  margin: 18px 0;
  padding: 14px 18px;
  color: #38475a;
  border: 1px solid #b9ccda;
  border-radius: 10px;
  background: #f2f7fa;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.45;
}

.patient-plan-toolbar-label {
  margin: 0;
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 800;
}

.form-panel > .week-navigation:first-child {
  margin-top: 0;
}

.zoom-controls {
  display: flex;
  gap: 6px;
}

.calendar-create-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.calendar-create-actions form {
  display: flex;
}

.calendar-reset-action {
  margin-left: 10rem;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.primary-button {
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
}

.primary-button:hover {
  background: #245d80;
}

.secondary-button {
  color: var(--brand);
  border-color: var(--line-strong);
  background: #fff;
}

.danger-button {
  color: #9f1d24;
  border-color: #dfb2b5;
  background: #fff6f6;
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.danger-button:focus-visible {
  outline: 3px solid #6ba4c5;
  outline-offset: 2px;
}

.zoom-button {
  min-height: 30px;
  padding: 4px 11px;
  color: var(--brand);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
}

.zoom-button:hover:not(:disabled) {
  background: var(--accent);
}

.zoom-button:focus-visible {
  outline: 3px solid #6ba4c5;
  outline-offset: 1px;
}

.zoom-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.schedule-hint {
  display: none;
  padding: 9px 14px;
  color: var(--muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  font-size: 0.72rem;
}

.schedule-scroll {
  display: block;
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
}

.schedule-scroll:focus-visible {
  outline: 3px solid #6ba4c5;
  outline-offset: -3px;
}

.week-board {
  width: 100%;
  min-width: 0;
}

.week-layout {
  display: grid;
  grid-template-columns: 64px repeat(7, minmax(0, 1fr));
}

.week-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line-strong);
  background: #f8fafc;
}

.time-header,
.day-header {
  min-width: 0;
  border-right: 1px solid var(--line-strong);
}

.time-header {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.day-header:last-child {
  border-right: 0;
}

.day-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 13px 10px;
}

.day-heading strong {
  color: var(--brand);
  font-size: 0.92rem;
}

.day-heading span {
  color: var(--muted);
  font-size: 0.72rem;
}

.day-header--weekend {
  background: #f1f4f8;
}

.day-header--inactive {
  color: #758195;
  background: #edf0f4;
}

.day-header--inactive .day-heading strong,
.day-header--inactive .day-heading span {
  color: #758195;
}

.day-inactive-label {
  display: block;
  padding: 0 13px 8px;
  color: #758195;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.week-body {
  align-items: start;
}

.time-axis,
.day-grid {
  height: calc(var(--slot-height) * 48);
}

.time-axis {
  position: relative;
  border-right: 1px solid var(--line-strong);
  background: #fbfcfe;
}

.time-tick {
  position: absolute;
  top: calc(var(--slot-index) * var(--slot-height));
  right: 10px;
  transform: translateY(-50%);
  color: #707b8c;
  font-size: 0.65rem;
  font-variant-numeric: tabular-nums;
}

.time-tick:first-child {
  transform: none;
}

.time-tick--end {
  transform: translateY(-100%);
}

.day-grid {
  display: grid;
  isolation: isolate;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: repeat(var(--total-slots), var(--slot-height));
  min-width: 0;
  border-right: 1px solid var(--line-strong);
  background: #fff;
}

.day-grid:last-child {
  border-right: 0;
  background: #fbfcfd;
}

.day-grid.day-grid--inactive {
  background: #f2f4f7;
}

.day-grid--inactive .lane {
  opacity: 0.58;
}

.lane {
  z-index: 0;
  grid-column: 1;
  grid-row: 1 / -1;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(123, 137, 155, 0.22) 0,
      rgba(123, 137, 155, 0.22) 1px,
      transparent 1px,
      transparent var(--slot-height)
    );
}

.appointment {
  z-index: 2;
  min-width: 0;
  margin: 2px 3px;
  padding: 5px 6px;
  overflow: hidden;
  border: 1px solid var(--event-border);
  border-left-width: 4px;
  border-radius: 7px;
  color: #1b2638;
  background: var(--event-bg);
  box-shadow: 0 2px 6px rgba(28, 42, 58, 0.12);
  grid-row: var(--start-line) / span var(--duration-slots);
}

.appointment--single {
  grid-column: 1 / -1;
  justify-self: start;
  width: calc(var(--column-width) - 6px);
  margin-left: calc(var(--column-offset) + 3px);
}

.appointment--editable {
  padding: 0;
}

.appointment__edit-link {
  display: block;
  height: 100%;
  min-height: 100%;
  padding: 5px 6px;
  color: inherit;
  text-decoration: none;
}

.appointment--editable:hover {
  filter: brightness(0.96);
  box-shadow: 0 3px 9px rgba(28, 42, 58, 0.22);
}

.appointment--editable:focus-within {
  outline: 3px solid #2b6f99;
  outline-offset: 1px;
}

@media (hover: hover) and (pointer: fine) {
  .appointment--draggable,
  .appointment--draggable .appointment__edit-link {
    cursor: grab;
  }
}

.appointment--dragging {
  opacity: 0.3;
}

.appointment--move-pending {
  opacity: 0.55;
  pointer-events: none;
}

.appointment-drag-active {
  cursor: grabbing;
  user-select: none;
}

.appointment-drag-ghost {
  position: fixed;
  z-index: 1000;
  box-sizing: border-box;
  margin: 0;
  opacity: 0.92;
  pointer-events: none;
  transform: rotate(0.5deg);
  box-shadow: 0 10px 24px rgba(28, 42, 58, 0.28);
}

.appointment-drag-preview {
  z-index: 5;
  grid-column: 1 / -1;
  margin: 2px 3px;
  padding: 5px 7px;
  overflow: hidden;
  border: 2px dashed #225f84;
  border-radius: 7px;
  color: #123b56;
  background: rgba(210, 235, 249, 0.92);
  font-size: 0.68rem;
  font-weight: 850;
  line-height: 1.2;
  pointer-events: none;
}

.appointment-drag-status {
  margin: 8px 0;
  padding: 9px 12px;
  border: 1px solid #7b899b;
  border-radius: 8px;
  color: #243449;
  background: #f3f6f8;
  font-size: 0.82rem;
  font-weight: 700;
}

.appointment-drag-status[data-state="dragging"],
.appointment-drag-status[data-state="pending"] {
  border-color: #2b6f99;
  color: #164d70;
  background: #e5f3fb;
}

.appointment-drag-status[data-state="success"] {
  border-color: #2f7b45;
  color: #245f36;
  background: #e5f4e9;
}

.appointment-drag-status[data-state="error"] {
  border-color: #a44343;
  color: #7b2929;
  background: #fbe8e8;
}

.appointment--full {
  grid-column: 1 / -1;
}

.appointment__topline {
  justify-content: space-between;
  gap: 5px;
}

.appointment__markers {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 3px;
}

.appointment strong {
  min-width: 0;
  overflow: hidden;
  font-size: 0.7rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.appointment time,
.appointment__detail,
.appointment__location {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: rgba(23, 32, 51, 0.72);
  font-size: 0.61rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.appointment__location {
  color: rgba(23, 32, 51, 0.9);
  font-weight: 750;
}

.patient-marker {
  flex: 0 0 auto;
  padding: 1px 5px;
  border: 1px solid rgba(23, 32, 51, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.55rem;
  font-weight: 900;
}

.participant-marker {
  max-width: 180px;
  overflow: hidden;
  padding: 1px 5px;
  border: 1px solid rgba(23, 32, 51, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  font-size: 0.52rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.color-physiotherapy {
  --event-bg: #dff2e3;
  --event-border: #3b9652;
}

.color-ergotherapy {
  --event-bg: #ffe7ca;
  --event-border: #dd8223;
}

.color-psychotherapy {
  --event-bg: #fff3b9;
  --event-border: #d0a921;
}

.color-medicine {
  --event-bg: #dcecff;
  --event-border: #3c7fc3;
}

.color-care {
  --event-bg: #f7dcef;
  --event-border: #b85491;
}

.color-neutral {
  --event-bg: #e8ebef;
  --event-border: #77818e;
}

.form-shell {
  width: min(100% - 32px, 760px);
  margin: 0 auto;
  padding: 48px 0;
}

.form-shell--wide {
  width: min(100% - 32px, 980px);
}

.form-shell--login {
  width: min(100% - 32px, 480px);
  padding-top: 12vh;
}

.login-page {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  background-color: #071524;
  background-image:
    linear-gradient(
      90deg,
      rgba(3, 13, 24, 0.14) 0%,
      rgba(3, 13, 24, 0.04) 46%,
      rgba(3, 13, 24, 0) 68%
    ),
    url("images/masterraster-login.webp");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.login-page .form-shell--login {
  width: min(calc(100% - 3rem), 21rem);
  margin-right: auto;
  margin-left: clamp(1.5rem, 6vw, 6.5rem);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  transform: translateY(-9rem);
}

.login-page .form-panel {
  padding: 0.65rem 1.25rem 1.25rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.login-page .appointment-form {
  gap: 0.8rem;
}

.login-page .form-field {
  gap: 0.4rem;
  color: rgba(218, 230, 238, 0.78);
  font-size: 0.76rem;
  font-weight: 650;
}

.login-page .form-field input {
  min-height: 42px;
  padding: 0.6rem 0.7rem;
  color: #f5f8fa;
  border-color: rgba(204, 225, 239, 0.24);
  background: rgba(1, 11, 20, 0.48);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.login-page .form-field input:hover,
.login-page .form-field input:focus {
  outline: none;
  border-color: rgba(204, 225, 239, 0.36);
  background: rgba(5, 23, 38, 0.62);
}

.login-page .form-actions .primary-button {
  width: 100%;
  min-height: 42px;
  color: rgba(218, 230, 238, 0.78);
  border-color: rgba(204, 225, 239, 0.24);
  background: rgba(1, 11, 20, 0.48);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  font-size: 0.8rem;
  font-weight: 650;
}

.login-page .form-actions .primary-button:hover {
  color: rgba(230, 239, 244, 0.9);
  border-color: rgba(204, 225, 239, 0.36);
  background: rgba(5, 23, 38, 0.62);
}

.login-page .form-actions .primary-button:focus-visible {
  color: rgba(230, 239, 244, 0.9);
  outline: none;
  border-color: rgba(204, 225, 239, 0.36);
  background: rgba(5, 23, 38, 0.62);
}

.login-page .validation-errors {
  margin: 0 0 0.8rem;
  padding: 0.7rem 0.8rem;
  color: #ffe1e3;
  border-color: rgba(243, 165, 172, 0.42);
  background: rgba(100, 30, 39, 0.48);
  font-size: 0.78rem;
}

.login-page .validation-errors p {
  margin: 0;
}

.login-page .validation-errors p + p {
  margin-top: 0.4rem;
}

.form-header {
  padding: 26px 28px;
  color: #fff;
  border-radius: 18px 18px 0 0;
  background: linear-gradient(125deg, #112d42, #1f5575);
}

.form-header p:last-child {
  margin: 12px 0 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
}

.form-panel {
  padding: 28px;
  border: 1px solid var(--line-strong);
  border-top: 0;
  border-radius: 0 0 18px 18px;
  background: #fff;
  box-shadow: 0 14px 36px rgba(31, 47, 68, 0.1);
}

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

.form-field {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 0.82rem;
  font-weight: 750;
}

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

.participant-fieldset {
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
}

.participant-fieldset legend {
  padding: 0 5px;
  color: #344054;
  font-size: 0.82rem;
  font-weight: 750;
}

.participant-fieldset p {
  margin: 0 0 12px;
  color: #667085;
  font-size: 0.78rem;
}

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

.participant-choice {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
}

.participant-choice input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--brand);
}

.participant-choice:has(input:checked) {
  border-color: #397a9f;
  background: #edf6fb;
}

.form-field input,
.form-field select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-weight: 500;
}

.form-field input:focus,
.form-field select:focus {
  outline: 3px solid rgba(107, 164, 197, 0.45);
  border-color: #397a9f;
}

.form-field input[readonly] {
  color: #566274;
  background: #f2f5f8;
  cursor: default;
}

.form-actions {
  display: flex;
  gap: 10px;
  padding-top: 4px;
}

.validation-errors {
  margin: 18px 0;
  padding: 16px 18px;
  color: #7d2026;
  border: 1px solid #dfb2b5;
  border-radius: 10px;
  background: #fff6f6;
  font-size: 0.86rem;
  line-height: 1.45;
}

.validation-errors ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.success-messages {
  margin: 18px 0;
  padding: 14px 18px;
  color: #245f3c;
  border: 1px solid #add2ba;
  border-radius: 10px;
  background: #f2faf5;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.45;
}

.success-messages p {
  margin: 0;
}

.success-messages p + p {
  margin-top: 6px;
}

.delete-form {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.form-panel h2 {
  margin: 0 0 16px;
  color: var(--brand);
  font-size: 1rem;
}

.form-panel h2:not(:first-child) {
  margin-top: 30px;
}

.location-list {
  display: grid;
  gap: 16px;
}

.location-entry {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
}

.catalog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.catalog-heading h2 {
  margin: 0;
}

.stay-list {
  display: grid;
  gap: 0.75rem;
}

.stay-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22rem;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #f8fafc;
}

.stay-row-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 0.5rem;
  width: 22rem;
}

.stay-row-actions > .secondary-button {
  width: 100%;
  min-width: 0;
  text-align: center;
}

.stay-row-actions .allocation-toggle {
  align-self: center;
  min-width: 0;
}

.stay-row-actions .allocation-toggle label {
  justify-content: center;
}

.stay-status-action {
  grid-column: 2;
}

.stay-new-id-action {
  grid-column: 3;
}

.stay-overview {
  display: grid;
  gap: 0.7rem;
  min-width: 0;
}

.stay-weekday-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 0.75rem;
  min-width: 0;
}

.stay-weekday-submit {
  justify-self: start;
}

.stay-weekday-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.stay-weekday-status {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
  font-size: 0.75rem;
  font-weight: 800;
}

.stay-weekday-status--saved {
  color: #245f3c;
  border-color: #8fc5a1;
  background: #e9f7ee;
}

.stay-weekday-status--pending,
.stay-weekday-status--dirty {
  color: var(--pending-ink);
  border-color: var(--pending-border);
  background: var(--pending-surface);
}

.stay-identity {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.stay-id {
  color: #344054;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.stay-days {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(4rem, 1fr));
  gap: 0.6rem;
  max-width: 34rem;
}

.stay-day {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 4rem;
  min-height: 4rem;
  padding: 0.45rem;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  color: var(--muted);
  background: #fff;
  font-size: 0.85rem;
  font-weight: 750;
}

.stay-day-state {
  font-size: 1.5rem;
  line-height: 1;
}

.stay-day--editable {
  cursor: pointer;
  user-select: none;
}

.stay-day--editable:hover,
.stay-day--editable:focus-within {
  border-color: var(--line-strong);
  background: #f4f8fa;
}

.stay-day--editable:has(.stay-day-checkbox:checked) {
  border-color: rgba(31, 90, 122, 0.28);
  color: var(--brand);
  background: #edf6fa;
}

.stay-day--editable.stay-day--saved {
  border-color: #79b58a;
  color: #245f3c;
  background: #e9f7ee;
}

.stay-day--saved .stay-day-checkbox {
  accent-color: #2f7d4a;
}

.stay-weekday-form[data-weekdays-confirmed="false"]
  .stay-day--editable:has(.stay-day-checkbox:checked),
.stay-weekday-form--dirty
  .stay-day--editable:has(.stay-day-checkbox:checked),
.stay-day--editable.stay-day--changed {
  border-color: var(--pending-border);
  color: var(--pending-ink);
  background: var(--pending-surface);
}

.stay-weekday-form[data-weekdays-confirmed="false"] .stay-day-checkbox,
.stay-weekday-form--dirty .stay-day-checkbox {
  accent-color: var(--pending-accent);
}

.stay-day-checkbox {
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  accent-color: var(--brand);
}

.stay-day-checkbox:focus-visible {
  outline: 3px solid #6ba4c5;
  outline-offset: 2px;
}

.stay-weekday-submit {
  white-space: nowrap;
}

.stay-day--active {
  border-color: rgba(31, 90, 122, 0.28);
  color: var(--brand);
  background: #edf6fa;
}

.allocation-toggle label {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
}

.allocation-toggle input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--brand);
}

.button-disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.assignment-preview {
  display: grid;
  gap: 0.65rem;
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
}

.assignment-preview li {
  display: grid;
  gap: 0.2rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: #f8fafc;
}

.assignment-preview span {
  color: var(--muted);
  font-size: 0.84rem;
}

.location-form {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 140px 90px auto;
  align-items: end;
  gap: 12px;
  padding: 13px;
}

.location-form--new {
  grid-template-columns: minmax(240px, 1fr) 140px auto;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
}

.location-availability {
  padding: 13px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.location-availability__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.location-availability__heading h3,
.location-availability__heading p {
  margin: 0;
}

.location-availability__heading h3 {
  color: var(--brand);
  font-size: 0.94rem;
}

.location-availability__heading p {
  color: var(--muted);
  font-size: 0.82rem;
}

.location-availability__list {
  display: grid;
  gap: 8px;
}

.availability-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
}

.availability-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 130px 130px auto;
  align-items: end;
  gap: 10px;
}

.availability-form--new {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.availability-delete-form {
  display: flex;
  align-items: flex-end;
}

.active-choice {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  color: #344054;
  font-size: 0.82rem;
  font-weight: 750;
}

.active-choice input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--brand);
}

@media (max-width: 900px) {
  .page-shell {
    width: min(100% - 20px, 1680px);
    padding-top: 18px;
  }

  .hero {
    padding: 22px 20px;
  }

  .plan-summary,
  .legend-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .plan-summary section {
    min-width: 0;
  }

  .legend-list {
    justify-content: flex-start;
  }

  .calendar-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .patient-plan-selection {
    align-items: stretch;
    flex-direction: column;
  }

  .patient-plan-selection__form {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .calendar-create-actions {
    align-self: flex-start;
  }

  .calendar-reset-action {
    margin-left: 0;
  }

  .zoom-controls {
    justify-content: flex-end;
  }

  .form-shell {
    width: min(100% - 20px, 760px);
    padding-top: 20px;
  }

  .form-header,
  .form-panel {
    padding: 22px 20px;
  }

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

  .form-field--wide {
    grid-column: auto;
  }

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

  .location-form,
  .location-form--new,
  .availability-form,
  .availability-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .location-availability__heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .stay-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .stay-row-actions {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .stay-status-action,
  .stay-new-id-action {
    grid-column: 1;
  }

  .schedule-hint {
    display: block;
  }
}

@media (max-width: 640px) {
  .login-page {
    align-items: flex-start;
    background-position: 62% center;
  }

  .login-page .form-shell--login {
    width: min(calc(100% - 2rem), 21rem);
    margin-top: max(1rem, 5vh);
    margin-right: auto;
    margin-bottom: max(1rem, 5vh);
    margin-left: auto;
    transform: none;
  }
}

@media (max-height: 600px) {
  .login-page {
    align-items: flex-start;
  }

  .login-page .form-shell--login {
    margin-top: 1rem;
    margin-bottom: 1rem;
    padding: 0;
    transform: none;
  }

  .login-page .form-panel {
    padding-bottom: 1rem;
  }

  .login-page .appointment-form {
    gap: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
