.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(32, 42, 53, 0.48);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 18px;
  overflow: auto;
}

.modal {
  width: min(900px, 100%);
  background: #fffdf9;
  border-radius: 8px;
  box-shadow: 0 20px 70px rgba(15, 23, 42, 0.32);
  border: 1px solid var(--line);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: #f7f4ec;
}

.modal-head h3 {
  margin: 0;
}

.modal-body {
  padding: 18px;
}

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

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

.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.notice.inline {
  margin: 10px 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
}

.inline-details {
  display: inline-block;
  margin: 0 6px 6px 0;
}

.inline-details summary {
  list-style: none;
}

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

.inline-unit-form {
  display: grid;
  gap: 8px;
  min-width: 220px;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9;
  box-shadow: var(--shadow);
}

.form-save-bottom .btn {
  min-width: 220px;
  min-height: 46px;
  padding: 12px 20px;
  font-size: 18px;
  line-height: 1.05;
  font-weight: 800;
}

.modal-body form > .form-save-bottom {
  position: sticky;
  bottom: -18px;
  z-index: 8;
  margin: 18px -18px -18px;
  padding: 12px 18px;
  border-top: 1px solid rgba(216, 221, 226, 0.92);
  background: rgba(255, 253, 249, 0.96);
  box-shadow: 0 -10px 24px rgba(32, 42, 53, 0.08);
}

.edit-patient-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  min-width: 76px;
}

.action-column {
  width: 1%;
}

.edit-patient-icon {
  width: 17px;
  height: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.edit-patient-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.user-form {
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: end;
  margin-top: 14px;
}

.admin-create-details { margin: 14px 0; }
.admin-create-details > summary { display: inline-flex; align-items: center; width: fit-content; min-height: 44px; list-style: none; cursor: pointer; }
.admin-create-details > summary::-webkit-details-marker { display: none; }
.admin-create-details > form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.admin-create-details .top-actions { flex-wrap: wrap; }

label {
  display: grid;
  gap: 6px;
  color: #334155;
  font-size: 13px;
  font-weight: 650;
}

.textarea {
  min-height: 120px;
  resize: vertical;
}

.form-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 16px;
}

.form-section:first-child {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.form-section h3 {
  font-size: 15px;
  font-weight: 800;
  margin: 0 0 12px;
  color: #3e5062;
}

.monthly-checklist {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.monthly-checklist h4 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 800;
}

.monthly-checklist div {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.monthly-checklist span,
.monthly-checklist button {
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 750;
  border: 1px solid var(--line);
}

.monthly-checklist button {
  cursor: pointer;
}

.monthly-checklist button:hover,
.monthly-checklist button:focus-visible {
  box-shadow: 0 0 0 3px rgba(166, 111, 47, 0.16);
}

.monthly-checklist .done {
  color: #3f6f4c;
  background: var(--soft-ok);
  border-color: #c9dac4;
}

.monthly-checklist .missing {
  color: #9a4650;
  background: var(--soft-danger);
  border-color: #e8c6c8;
}

.field-attention {
  border-radius: 8px;
  padding: 8px;
  background: var(--soft-warn);
  outline: 1px solid #e1c98f;
}

.summary-text {
  white-space: pre-wrap;
  line-height: 1.55;
}

.summary-editor {
  min-height: 520px;
  font-family: inherit;
  line-height: 1.5;
  white-space: pre-wrap;
}

.summary-snapshots {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.summary-snapshots h3 {
  font-weight: 800;
  margin-bottom: 10px;
}

.summary-snapshot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.summary-snapshot-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fffefb;
}

.summary-snapshot-card h4 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: underline;
}

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

.summary-snapshot-label {
  display: grid;
  gap: 1px;
  font-size: 11px;
  color: var(--muted);
}

.summary-snapshot-label strong {
  color: var(--ink);
}

.summary-snapshot-svg {
  width: 100%;
  height: 38px;
  display: block;
}

.data-notes {
  display: grid;
  gap: 12px;
}

.data-notes div {
  display: grid;
  gap: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.data-notes div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.data-notes span {
  color: var(--muted);
  font-size: 14px;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 120px 120px 100px 120px;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.empty {
  padding: 22px;
  text-align: center;
  color: var(--muted);
}

.demo-banner.live {
  background: #e8f2ee;
  color: #0f766e;
  border-color: rgba(15, 118, 110, 0.22);
}

.banner-short {
  display: none;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(176, 62, 79, 0.08)),
    var(--page);
}

.auth-card {
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-brand {
  margin-bottom: 22px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form h2,
.loading-state h2 {
  margin: 0;
}

.form-error {
  padding: 10px 12px;
  border: 1px solid rgba(176, 62, 79, 0.32);
  background: #f9e7ea;
  color: #8f2737;
  border-radius: 6px;
  font-weight: 700;
}

.code-input {
  max-width: 180px;
  font-size: 24px;
  font-weight: 850;
  letter-spacing: 0;
  text-align: center;
}

.mfa-secret-box {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid rgba(34, 119, 111, 0.24);
  border-radius: 8px;
  background: var(--soft-teal);
}

.mfa-secret-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.mfa-secret-box strong {
  color: #155f59;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 18px;
  overflow-wrap: anywhere;
}

html.tour-scroll-lock,
body.tour-scroll-lock {
  overflow: hidden;
}

body.tour-scroll-lock .modal-backdrop {
  overflow: hidden;
}

.tour-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
}

.tour-dim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(24, 34, 45, 0.58);
  pointer-events: auto;
}

.tour-highlight {
  position: fixed;
  display: none;
  z-index: 2;
  border: 3px solid #d7a443;
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(24, 34, 45, 0.22), 0 14px 40px rgba(15, 23, 42, 0.24);
  background: rgba(255, 253, 249, 0.1);
  pointer-events: none;
  transition: top 140ms ease, left 140ms ease, width 140ms ease, height 140ms ease;
}

.tour-card {
  position: fixed;
  z-index: 3;
  right: 24px;
  bottom: 24px;
  width: min(380px, calc(100vw - 32px));
  background: #fffdf9;
  border: 1px solid #d7d0c3;
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 22px 70px rgba(15, 23, 42, 0.36);
  pointer-events: auto;
}

.tour-card h3 {
  margin: 5px 0 6px;
  font-size: 18px;
}

.tour-card p {
  margin: 0;
  color: #334155;
  font-size: 14px;
  line-height: 1.42;
}

.tour-kicker {
  color: #7a5b1e;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tour-note {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid #e3d7bd;
  border-radius: 8px;
  background: #fbf4e4;
  color: #67512b;
  font-size: 12px;
  font-weight: 700;
}

.tour-controls {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

@media (max-width: 560px) and (orientation: portrait) {
  .tour-card {
    max-height: min(34vh, 250px);
    overflow: auto;
    padding: 10px;
    border-radius: 7px;
  }

  .tour-card h3 {
    margin: 3px 0 4px;
    font-size: 15px;
  }

  .tour-card p {
    font-size: 12px;
    line-height: 1.32;
  }

  .tour-kicker {
    font-size: 10px;
    line-height: 1.18;
    letter-spacing: 0.035em;
  }

  .tour-controls {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    margin-top: 9px;
  }

  .tour-controls .btn {
    min-height: 32px;
    padding: 6px 7px;
    font-size: 11px;
    line-height: 1.08;
  }
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

