body {
  font-family: -apple-system, Segoe UI, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 24px 32px 64px;
  background: #faf8f6;
  color: #2b2622;
}

header h1 { margin-bottom: 4px; }
.subtitle { color: #8a7f75; margin-top: 0; }

.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.timeline-toggle-btn {
  border: 1px solid #d8cec3;
  border-radius: 8px;
  background: #fff;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.timeline-toggle-btn:hover { border-color: #9d5d50; color: #9d5d50; }

.inputs {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 20px 24px;
  background: #fff;
  border: 1px solid #e6ddd4;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 24px;
}
.inputs label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; flex: 1 1 180px; }
.inputs input, .inputs select {
  padding: 8px 10px;
  border: 1px solid #d8cec3;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}
.rx-type-field { flex: 0 1 160px; }
.label-line { white-space: nowrap; }
.required-mark { color: #c0392b; }

.toggle-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
}
.switch-text { font-size: 13px; font-weight: 600; white-space: nowrap; }

.switch { position: relative; display: inline-flex; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 38px;
  height: 22px;
  background: #d8cec3;
  border-radius: 999px;
  transition: background .15s ease;
  display: inline-block;
}
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(43, 38, 34, .3);
  transition: transform .15s ease;
}
.switch input:checked + .switch-track { background: #9d5d50; }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid #9d5d50; outline-offset: 2px; }

.rx-type-hint {
  font-size: 12px;
  color: #8a7f75;
  margin: -14px 0 20px;
}

.patient-info {
  background: #fff;
  border: 1px solid #e6ddd4;
  border-radius: 8px;
  padding: 12px 20px;
  margin: -12px 0 24px;
  font-size: 13px;
}
.patient-info.hidden { display: none; }
.patient-info-name { font-weight: 700; font-size: 15px; color: #6b4f42; margin-bottom: 4px; }
.patient-info-row { color: #4a423b; }
.patient-info-row + .patient-info-row { margin-top: 2px; }
.patient-info-label { display: inline-block; width: 50px; color: #8a7f75; font-weight: 600; }
.patient-info-loading { color: #8a7f75; font-style: italic; }
.patient-info-error { color: #c0392b; font-weight: 600; }

.fills-table-wrap { margin-top: 10px; }
.fills-title { margin: 0 0 6px; font-size: 11px; color: #8a7f75; }
.fills-empty { margin: 8px 0 0; font-size: 12px; color: #8a7f75; font-style: italic; }
.fills-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.fills-table th, .fills-table td {
  text-align: left;
  padding: 5px 8px;
  border-bottom: 1px solid #f0e9e2;
}
.fills-table th { color: #8a7f75; font-size: 10.5px; text-transform: uppercase; letter-spacing: .03em; }

.fill-type-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  padding: 1px 6px;
}
.fill-type-badge.fill-type-newrx { color: #2f5f9d; background: #eaf1fb; }
.fill-type-badge.fill-type-refill { color: #6b4f9d; background: #f1eafb; }

.group { margin-bottom: 28px; }
.group h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: #8a7f75; margin-bottom: 10px; }

.buttons { display: flex; flex-wrap: wrap; gap: 10px; }

.scenario-btn {
  border: 1px solid #d8cec3;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  position: relative;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.scenario-btn[hidden] { display: none; }
.scenario-btn:disabled { opacity: .45; cursor: not-allowed; }
.scenario-btn:hover:not(:disabled) { border-color: #9d5d50; }
.scenario-btn.color-blue { background: #eaf1fb; }
.scenario-btn.color-lavender { background: #f1eafb; }
.scenario-btn.color-cream { background: #f7efe7; }

.scenario-label { font-weight: 600; }

.badge-row { display: flex; gap: 6px; flex-wrap: wrap; }

.cadence-badge {
  font-size: 10px;
  font-weight: 700;
  color: #6b4f42;
  background: rgba(157, 93, 80, .12);
  border-radius: 4px;
  padding: 2px 6px;
}

.channel-badge {
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  padding: 2px 6px;
}
.channel-badge.channel-email { color: #2f5f9d; background: rgba(47, 95, 157, .12); }
.channel-badge.channel-sms { color: #2f8a4b; background: rgba(47, 138, 75, .12); }
.channel-badge.channel-email-sms { color: #8a5c2f; background: rgba(138, 92, 47, .14); }

/* Scope badges follow the source doc's own color key: Blue = New Rx, Lavender = Refill,
   neutral = shared/both — same convention the button backgrounds (color-blue/lavender/cream)
   already use, just applied to this smaller badge instead. */
.scope-badge {
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  padding: 2px 6px;
  border: 1px solid transparent;
}
.scope-badge.scope-newrx { color: #2f5f9d; background: #eaf1fb; border-color: #cdddf5; }
.scope-badge.scope-refill { color: #6b4f9d; background: #f1eafb; border-color: #ddcdf5; }
.scope-badge.scope-newrx-refill { color: #6b5744; background: #f0ede9; border-color: #ddd3c7; }

.token-badge {
  font-size: 10px;
  color: #8a7f75;
}

.result {
  margin-top: 24px;
  background: #fff;
  border: 1px solid #e6ddd4;
  border-radius: 8px;
  padding: 16px 20px;
}
.result.hidden { display: none; }
.result pre {
  background: #2b2622;
  color: #f7efe7;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
}
.result .status-ok { color: #2f8a4b; font-weight: 700; }
.result .status-fail { color: #c0392b; font-weight: 700; }
.result .warning {
  background: #fff3cd;
  border: 1px solid #e6c76a;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 10px;
  font-size: 13px;
}

.payment-link-box {
  background: #e3f3e6;
  border: 1px solid #b8ddc0;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.payment-link-label { margin: 0 0 6px; font-weight: 700; font-size: 13px; color: #235c33; }
.payment-link {
  display: inline-block;
  word-break: break-all;
  font-size: 14px;
  font-weight: 600;
  color: #2f8a4b;
}
.payment-link-hint { margin: 8px 0 0; font-size: 12px; color: #4d7a58; }

/* --- Timeline sidebar --- */

.timeline-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 38, 34, .35);
  z-index: 40;
}
.timeline-overlay.hidden { display: none; }

.timeline-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(720px, 92vw);
  background: #fff;
  box-shadow: -8px 0 24px rgba(43, 38, 34, .18);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform .2s ease;
}
.timeline-panel.hidden { transform: translateX(100%); pointer-events: none; }

.timeline-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #e6ddd4;
}
.timeline-panel-header h2 { margin: 0; font-size: 18px; }

.timeline-close-btn {
  border: none;
  background: none;
  font-size: 18px;
  cursor: pointer;
  color: #8a7f75;
  padding: 4px 8px;
}
.timeline-close-btn:hover { color: #9d5d50; }

.timeline-panel-body {
  padding: 8px 24px 32px;
  overflow-y: auto;
}
.timeline-panel-body h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #8a7f75;
  margin: 24px 0 10px;
}

.timeline-table-wrap { overflow-x: auto; }

.timeline-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.timeline-table th, .timeline-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #f0e9e2;
  vertical-align: top;
}
.timeline-table th {
  color: #8a7f75;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.timeline-table tbody tr:hover { background: #faf8f6; }

.status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
}
.status-new { background: #e3f3e6; color: #2f8a4b; }
.status-updated { background: #eaf1fb; color: #2f5f9d; }
.status-cadence { background: #fdeedb; color: #a06423; white-space: normal; }
.status-hold { background: #fbe4e4; color: #b13c3c; white-space: normal; }
.status-unchanged { background: #f0ede9; color: #8a7f75; }

.timeline-note {
  font-size: 12px;
  color: #8a7f75;
  font-style: italic;
  margin-top: 20px;
}
