:root {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  color: #0f2c24;
  background: #f5f8f6;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

a {
  color: #0b5a4c;
  text-underline-offset: 4px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: #03261e;
  border-bottom: 1px solid rgba(201, 162, 63, 0.35);
  padding: 18px max(20px, calc((100% - 1120px) / 2));
  color: #f8f6f0;
}

header a {
  color: #f8f6f0;
}

header p {
  margin: 5px 0 0;
  font-size: 12px;
  color: #c1d9cf;
}

.header-links {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.header-links a {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.wordmark {
  font-weight: 750;
  letter-spacing: 1.5px;
  text-decoration: none;
  font-size: 14px;
}

.wordmark span {
  color: #e2c782;
}

main {
  max-width: 1160px;
  margin: auto;
  padding: 24px 20px;
}

h1 {
  font-size: clamp(26px, 4vw, 40px);
  letter-spacing: -0.02em;
  margin: 8px 0 10px;
  font-weight: 700;
  color: #09241d;
}

h2 {
  font-size: 22px;
  margin: 22px 0 14px;
  color: #09241d;
}

h3 {
  font-size: 16px;
  margin: 0 0 10px;
  color: #0c2c23;
}

p {
  line-height: 1.65;
  color: #3f5c52;
}

li {
  line-height: 1.85;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

.notice {
  border: 1px solid #d4bf84;
  background: #faf5e6;
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 13px;
  color: #4f4120;
}

.notice strong {
  white-space: nowrap;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 26px 0 22px;
}

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: #0a5241;
  margin: 0;
}

nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid #d4dfd9;
  padding-bottom: 16px;
}

button,
input,
select {
  font: inherit;
  border-radius: 8px;
  min-height: 44px;
}

button {
  border: 1px solid #085042;
  background: #085042;
  color: #ffffff;
  padding: 10px 15px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background-color 160ms ease, border-color 160ms ease;
}

button:hover {
  background: #04362c;
}

button.secondary,
nav button {
  background: #ffffff;
  color: #17493c;
  border-color: #c2d1ca;
}

nav button[aria-current] {
  background: #04362c;
  color: #ffffff;
  border-color: #04362c;
}

button.secondary:hover,
nav button:hover {
  border-color: #085042;
  background: #eef5f1;
}

nav button[aria-current]:hover {
  background: #04362c;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

:focus-visible {
  outline: 3px solid #b58d31;
  outline-offset: 3px;
}

input,
select {
  padding: 10px 12px;
  background: #ffffff;
  color: #0f2c24;
  border: 1px solid #8aa498;
  width: 100%;
  margin: 6px 0 12px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #163b31;
}

.metrics,
.columns,
.form-grid {
  display: grid;
  gap: 18px;
}

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

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

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

.card {
  background: #ffffff;
  border: 1px solid #d4dfd9;
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 18px;
}

.metrics p {
  font-size: 12px;
  margin: 0;
}

.metrics strong {
  font-size: 36px;
  display: block;
  margin-top: 10px;
  font-weight: 700;
  color: #063f35;
  font-variant-numeric: tabular-nums;
}

.record {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.record p {
  margin: 0 0 8px;
  font-size: 13px;
}

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

.actions button {
  font-size: 12px;
}

.badge {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: #edf2ef;
  color: #20453a;
}

.checked_in {
  background: #e2f2e8;
  color: #154e34;
}

.cancelled {
  background: #f5e9e5;
  color: #703d27;
}

.completed {
  background: #e4edf3;
  color: #21455e;
}

.small {
  font-size: 12px;
  color: #4f6b60;
}

.answer {
  padding: 15px;
  background: #f4f7f5;
  border: 1px solid #dce5e0;
  border-radius: 8px;
  min-height: 65px;
}

.task-list label {
  padding: 11px 0;
  line-height: 1.6;
  border-bottom: 1px solid #ecf1ee;
}

.task-list label:last-child {
  border-bottom: 0;
}

.task-list input {
  width: 20px;
  min-height: 20px;
  margin: 0 12px 0 0;
  vertical-align: middle;
  accent-color: #085042;
}

#status {
  min-height: 22px;
  font-size: 13px;
  font-weight: 500;
  color: #0b5a4c;
  margin: 16px 0;
}

#form-error {
  color: #98380d;
  font-size: 13px;
  font-weight: 600;
}

/* Operational analytics & progress bars */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 16px;
}

.metric-row {
  margin-bottom: 10px;
}

.metric-row-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 5px;
  color: #173b32;
}

.bar-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e6eee9;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: #0a5c48;
  transition: width 180ms ease;
}

.bar-fill-gold {
  background: #b58d31;
}

/* Role matrix & supplier grids */
.supplier-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: 14px;
}

.supplier-results .card {
  margin: 0;
}

.supplier-results p {
  overflow-wrap: anywhere;
}

.role-list {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 13px;
  color: #2f4e44;
}

.consent-timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.step-chip {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid #cdd9d2;
  color: #4a665c;
  background: #f5f8f6;
}

.step-chip.active {
  background: #04362c;
  border-color: #04362c;
  color: #ffffff;
}

.step-chip.revoked {
  background: #7c2d12;
  border-color: #7c2d12;
  color: #ffffff;
}

.task-row {
  padding: 12px 0;
  border-bottom: 1px solid #e4ece8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.task-row:last-child {
  border-bottom: 0;
}

/* Interactive 18-slot clinic dayboard */
.dayboard-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 12px;
}

.dayboard-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: #4f6b60;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

.legend-dot.open {
  background: #c8d8d0;
}

.legend-dot.booked {
  background: #b58d31;
}

.legend-dot.checked_in {
  background: #0a5c48;
}

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

.slot-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 3px;
  padding: 10px 11px;
  min-height: 62px;
  border-radius: 10px;
  border: 1px solid #d4dfd9;
  background: #f8fbf9;
  color: #12362c;
  text-align: left;
  font-size: 12px;
  line-height: 1.3;
  transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease;
}

.slot-tile:hover {
  border-color: #085042;
  background: #eef6f2;
}

.slot-tile strong {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: #072c22;
}

.slot-tile span {
  font-size: 11px;
  color: #4a665c;
  font-weight: 500;
}

.slot-tile.booked {
  background: #faf5e6;
  border-color: #d4bf84;
}

.slot-tile.booked strong {
  color: #5c4514;
}

.slot-tile.booked span {
  color: #6b531b;
}

.slot-tile.checked_in {
  background: #e4f3ea;
  border-color: #0a5c48;
}

.slot-tile.checked_in strong,
.slot-tile.checked_in span {
  color: #063f35;
}

.slot-tile.selected {
  outline: 2px solid #04362c;
  outline-offset: 1px;
}

/* Deterministic receptionist safety router */
.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 14px;
}

.prompt-chip {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  background: #f4f7f5;
  color: #17493c;
  border: 1px solid #c2d1ca;
}

.prompt-chip:hover {
  background: #e8f2ec;
  border-color: #085042;
}

.prompt-chip.safety {
  background: #faf5e6;
  color: #6b4e16;
  border-color: #d4bf84;
}

.prompt-chip.safety:hover {
  background: #f5ebd0;
  border-color: #b58d31;
}

.answer.safety-boundary {
  background: #fdf4ef;
  border-color: #d9825b;
  color: #6b240c;
}

/* Visual 4-stage episode stepper & policy matrix */
.stage-stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0 14px;
}

.stage-step {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid #dce5e0;
  background: #f7faf8;
  font-size: 11px;
  color: #4f6b60;
}

.stage-step.done {
  background: #eaf4ee;
  border-color: #82b59d;
  color: #0d4a3a;
}

.stage-step.current {
  background: #04362c;
  border-color: #04362c;
  color: #ffffff;
}

.stage-step-num {
  font-weight: 700;
  font-size: 12px;
}

.stage-step-label {
  line-height: 1.3;
  font-weight: 600;
}

.policy-matrix {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.policy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f7faf8;
  border: 1px solid #dce5e0;
}

.policy-row strong {
  font-size: 13px;
  color: #0c2c23;
  display: block;
}

.policy-row p {
  margin: 2px 0 0;
}

.policy-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 6px;
}

.policy-badge.allow {
  background: #dff2e7;
  color: #0b4f3a;
  border: 1px solid #8bc4a7;
}

.policy-badge.deny {
  background: #fbeae5;
  color: #7c2d12;
  border: 1px solid #e2a592;
}

.card-divider {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #e4ece8;
}

.card-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}

.card-heading-row h3 {
  margin: 0;
}

.handover-dl {
  margin: 12px 0 16px;
}

.handover-dl dd {
  margin: 4px 0 12px;
  color: #2f4e44;
  font-size: 14px;
}

.handover-dl dd:last-child {
  margin-bottom: 0;
}

footer {
  border-top: 1px solid #d4dfd9;
  padding: 20px 0;
  font-size: 12px;
  color: #4f6b60;
}

[hidden] {
  display: none !important;
}

.skip {
  position: absolute;
  top: -100px;
  left: 15px;
  background: #ffffff;
  color: #04362c;
  padding: 12px;
  font-weight: 600;
}

.skip:focus {
  top: 10px;
}

@media (max-width: 640px) {
  header {
    padding: 16px;
    flex-wrap: wrap;
  }
  .notice {
    display: block;
  }
  .notice strong {
    display: block;
    margin-bottom: 6px;
  }
  .heading {
    display: block;
  }
  .metrics {
    gap: 9px;
  }
  .metrics .card {
    padding: 14px;
  }
  .metrics strong {
    font-size: 28px;
  }
  .metrics p {
    min-height: 36px;
  }
  .columns,
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid {
    gap: 0;
  }
  .record,
  .task-row {
    align-items: flex-start;
    flex-direction: column;
  }
  .card {
    padding: 18px;
  }
  .wordmark {
    font-size: 12px;
  }
  .header-links a {
    font-size: 12px;
  }
  nav button {
    flex: 1 1 auto;
  }
  .stage-stepper {
    grid-template-columns: repeat(2, 1fr);
  }
  .dayboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}