:root {
  color-scheme: light;
  --navy-950: #081726;
  --navy-900: #10263a;
  --navy-800: #18344c;
  --navy-700: #27516f;
  --ink: #14202b;
  --muted: #62717e;
  --line: #dbe3e8;
  --line-soft: #e9eef1;
  --surface: #ffffff;
  --canvas: #f3f6f7;
  --teal: #0c776e;
  --teal-soft: #e0f3f0;
  --blue: #2569a9;
  --blue-soft: #e7f1fb;
  --amber: #9b6100;
  --amber-soft: #fff3d5;
  --red: #a52b2f;
  --red-soft: #fde8e8;
  --purple: #6f4d96;
  --purple-soft: #f0e9f8;
  --shadow: 0 12px 32px rgba(15, 35, 52, 0.08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.demo-banner {
  position: fixed;
  z-index: 20;
  inset: 0 0 auto 0;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 18px;
  color: #fff8e9;
  background: #7b350e;
  font-size: 0.79rem;
  letter-spacing: 0.02em;
}

.demo-banner span { opacity: 0.82; }

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
  padding-top: 34px;
}

.sidebar {
  position: fixed;
  inset: 34px auto 0 0;
  width: 320px;
  display: flex;
  flex-direction: column;
  color: #eaf2f6;
  background: var(--navy-950);
  border-right: 1px solid rgba(255,255,255,0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 88px;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.brand-mark {
  width: 43px;
  height: 43px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 9px;
  background: linear-gradient(145deg, #1e5878, #0c334e);
  font-family: Georgia, serif;
  font-weight: 700;
  letter-spacing: -0.06em;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.brand .eyebrow { color: #91a8b8; }
.brand h1 { margin: 0; font-size: 1rem; font-weight: 650; }

.workspace-switcher { display: grid; gap: 6px; padding: 12px 12px 4px; }
.workspace-button, .admin-section-button {
  width: 100%; padding: 10px 12px; color: #d7e3ea; text-align: left;
  border: 1px solid transparent; border-radius: 8px; background: transparent; cursor: pointer;
}
.workspace-button span, .admin-section-button span { display: block; font-size: .84rem; font-weight: 700; }
.workspace-button small, .admin-section-button small { display: block; margin-top: 3px; color: #8199a9; font-size: .7rem; }
.workspace-button:hover, .admin-section-button:hover { background: #102c42; }
.workspace-button.active, .admin-section-button.active { border-color: #315b73; background: #17384e; }
.admin-section-list { flex: 1; padding: 18px 12px; }

.sidebar-tools { padding: 18px 16px 10px; }
.search-field { position: relative; display: block; }
.search-field svg {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: #7891a2;
  stroke-width: 2;
  transform: translateY(-50%);
}

.search-field input {
  width: 100%;
  height: 42px;
  padding: 0 12px 0 38px;
  color: white;
  border: 1px solid #315067;
  border-radius: 8px;
  outline: none;
  background: #132c41;
}

.search-field input::placeholder { color: #93a6b4; }
.search-field input:focus { border-color: #75b6c2; box-shadow: 0 0 0 3px rgba(117,182,194,.16); }

.cohort-line {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  color: #8ea3b2;
  font-size: 0.77rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.patient-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 4px 10px 16px;
}

.patient-button {
  width: 100%;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 12px;
  margin: 3px 0;
  color: #d7e3ea;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
}

.patient-button:hover { background: #102c42; }
.patient-button.active { border-color: #315b73; background: #17384e; }

.avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #d9f4f0;
  background: #24635f;
  font-weight: 750;
  font-size: 0.86rem;
}

.patient-button:nth-child(2) .avatar { color: #e8e2f6; background: #564574; }
.patient-button:nth-child(3) .avatar { color: #fff0d7; background: #815c2f; }
.patient-list-name { display: block; font-size: 0.92rem; font-weight: 680; }
.patient-list-meta { display: block; margin-top: 3px; color: #8ea3b2; font-size: 0.77rem; }

.organ-dot { width: 8px; height: 8px; border-radius: 50%; background: #61c0af; }
.organ-dot.heart { background: #e78383; }
.organ-dot.liver { background: #d9a354; }

.sidebar-footer { padding: 16px 20px 19px; border-top: 1px solid rgba(255,255,255,0.1); }
.program-stat { display: flex; align-items: baseline; gap: 8px; }
.program-stat strong { font-family: Georgia, serif; font-size: 1.5rem; }
.program-stat span { color: #8ea3b2; font-size: 0.78rem; }
.mix-bar { display: flex; height: 5px; overflow: hidden; margin: 11px 0 8px; border-radius: 999px; background: #30475a; }
.mix-bar .kidney { background: #52aa9d; }
.mix-bar .liver { background: #c99248; }
.mix-bar .heart { background: #d26868; }
.mix-labels { display: flex; justify-content: space-between; color: #7f96a6; font-size: 0.67rem; }

.workspace {
  grid-column: 2;
  min-width: 0;
  padding: 0 32px 50px;
}

.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.topbar h2 { margin: 0; font-family: Georgia, serif; font-size: 1.38rem; font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.data-health {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.8rem;
}
.data-health::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #28a37c; box-shadow: 0 0 0 4px #ddf2ea; }
.data-health.error::before { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }

.secondary-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #aebbc3;
  border-radius: 7px;
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
}
.secondary-button:hover { border-color: var(--navy-700); }

.patient-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 0 20px;
}

.identity { display: flex; gap: 16px; align-items: center; min-width: 0; }
.large-avatar { width: 62px; height: 62px; font-size: 1.03rem; }
.identity h3 { margin: 0 0 7px; font-family: Georgia, serif; font-size: 1.65rem; font-weight: 500; }
.identity-line { display: flex; flex-wrap: wrap; gap: 7px 16px; color: var(--muted); font-size: 0.84rem; }
.identity-line span { position: relative; }
.identity-line span + span::before { content: ""; position: absolute; left: -9px; top: 50%; width: 3px; height: 3px; border-radius: 50%; background: #9eabb4; }

.sync-summary { display: flex; gap: 10px; align-items: center; }
.status-pill, .tag {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
}
.status-pill.synced { color: #075f56; background: var(--teal-soft); }
.status-pill.local { color: #56636d; background: #e8edef; }
.status-pill::before { content: ""; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: currentColor; }

.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tab {
  position: relative;
  flex: 0 0 auto;
  padding: 13px 15px 14px;
  color: var(--muted);
  border: 0;
  background: transparent;
  font-size: 0.84rem;
  font-weight: 650;
  cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--navy-800); }
.tab.active::after { content: ""; position: absolute; inset: auto 10px -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--teal); }

.view { padding-top: 22px; }
.admin-heading { margin-bottom: 18px; }
.admin-heading h3 { margin: 0; font-family: Georgia, serif; font-size: 1.45rem; font-weight: 500; }
.admin-heading p { margin: 6px 0 0; color: var(--muted); font-size: .84rem; }
.service-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.service-card { padding: 16px; }
.service-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.service-card h4 { margin: 0; font-size: .88rem; }
.service-card p { margin: 11px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.4; }
.admin-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.job-status { display: inline-flex; padding: 3px 8px; border-radius: 999px; font-size: .7rem; font-weight: 700; background: #edf1f3; }
.job-status.ready { color: #075f56; background: var(--teal-soft); }
.job-status.failed, .job-status.degraded { color: var(--red); background: var(--red-soft); }
.job-status.running, .job-status.queued, .job-status.partial { color: var(--amber); background: var(--amber-soft); }

.terminology-layout { display: grid; grid-template-columns: minmax(250px, .7fr) minmax(480px, 1.3fr); gap: 16px; align-items: start; }
.terminology-list-card { overflow: hidden; }
.terminology-list { max-height: 720px; overflow-y: auto; padding: 8px; }
.terminology-row { width: 100%; display: grid; gap: 3px; padding: 11px 12px; border: 1px solid transparent; border-radius: 7px; text-align: left; background: transparent; cursor: pointer; }
.terminology-row:hover { background: #f6f9fa; }
.terminology-row.active { border-color: #9ecbc6; background: var(--teal-soft); }
.terminology-row strong { font-size: .82rem; }
.terminology-row span { color: var(--ink); font-size: .74rem; }
.terminology-row small { color: var(--muted); font-size: .68rem; }
.terminology-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.terminology-form label { display: grid; gap: 6px; color: var(--ink); font-size: .77rem; font-weight: 700; }
.terminology-form label > span { color: var(--muted); font-size: .68rem; font-weight: 500; }
.terminology-form input:not([type="checkbox"]), .terminology-form select, .terminology-form textarea { width: 100%; min-height: 40px; padding: 8px 10px; color: var(--ink); border: 1px solid #aebbc3; border-radius: 7px; background: white; }
.terminology-form textarea { resize: vertical; line-height: 1.4; }
.terminology-form input:focus, .terminology-form select:focus, .terminology-form textarea:focus { outline: 2px solid rgba(10, 122, 113, .2); border-color: var(--teal); }
.terminology-wide, .terminology-actions, .terminology-form .inline-error, .terminology-form .inline-success { grid-column: 1 / -1; }
.terminology-check { display: flex !important; grid-template-columns: auto 1fr; align-items: center; justify-content: start; }
.terminology-check input { width: 17px; height: 17px; }
.terminology-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.terminology-audit { margin-top: 16px; }

@media (max-width: 1050px) {
  .service-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .terminology-layout { grid-template-columns: 1fr; }
}
.grid { display: grid; gap: 16px; }
.metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two-column { grid-template-columns: minmax(0, 1.45fr) minmax(300px, .85fr); margin-top: 16px; }

.card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 2px 7px rgba(15,35,52,.025);
}
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 54px; padding: 12px 17px; border-bottom: 1px solid var(--line-soft); }
.card-header h3 { margin: 0; font-size: 0.92rem; }
.card-header p { margin: 3px 0 0; color: var(--muted); font-size: 0.76rem; }
.card-body { padding: 16px 17px; }

.metric { padding: 17px; }
.metric-label { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 0.75rem; font-weight: 680; letter-spacing: .04em; text-transform: uppercase; }
.metric-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 7px; color: var(--teal); background: var(--teal-soft); font-size: .85rem; }
.metric-value { margin: 13px 0 5px; font-family: Georgia, serif; font-size: 1.55rem; }
.metric-detail { color: var(--muted); font-size: 0.78rem; line-height: 1.4; }

.alert-list, .timeline, .record-list { display: grid; gap: 10px; }
.alert {
  position: relative;
  padding: 13px 14px 13px 43px;
  border: 1px solid #f1d3b1;
  border-radius: 8px;
  background: #fffaf0;
}
.alert.high { border-color: #efc8ca; background: #fff7f7; }
.alert-icon { position: absolute; left: 13px; top: 13px; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--amber); font-size: .72rem; font-weight: 800; }
.alert.high .alert-icon { background: var(--red); }
.alert h4 { margin: 0 0 5px; font-size: .85rem; }
.alert p { margin: 0; color: #5e5549; font-size: .8rem; line-height: 1.45; }
.alert-meta { margin-top: 8px; color: var(--muted); font-size: .7rem; }

.fact-list { display: grid; grid-template-columns: auto 1fr; gap: 11px 18px; margin: 0; }
.fact-list dt { color: var(--muted); font-size: .77rem; }
.fact-list dd { margin: 0; text-align: right; font-size: .8rem; font-weight: 650; }

.resource-summary { display: flex; flex-wrap: wrap; gap: 7px; }
.resource-chip { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; color: #475661; background: #fafcfc; font-size: .72rem; }

.table-wrap { overflow-x: auto; }
.clinical-table { width: 100%; border-collapse: collapse; font-size: .81rem; }
.clinical-table th { padding: 10px 13px; color: var(--muted); background: #f8fafb; text-align: left; font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; }
.clinical-table td { padding: 13px; border-top: 1px solid var(--line-soft); vertical-align: top; }
.clinical-table tbody tr:hover { background: #fbfcfd; }
.primary-cell { font-weight: 680; }
.secondary-text { display: block; margin-top: 4px; color: var(--muted); font-size: .73rem; line-height: 1.4; }

.tag.active { color: #07645b; background: var(--teal-soft); }
.tag.stopped { color: #5e6870; background: #e8edef; }
.tag.booked { color: #275d91; background: var(--blue-soft); }
.tag.provisional { color: #7a5300; background: var(--amber-soft); }
.tag.local { color: #5c6670; background: #edf1f3; }
.tag.epic { color: #075f56; background: var(--teal-soft); }

.timeline-item { position: relative; padding: 2px 0 16px 28px; }
.timeline-item::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: -9px; width: 1px; background: var(--line); }
.timeline-item:last-child::before { display: none; }
.timeline-item::after { content: ""; position: absolute; left: 3px; top: 5px; width: 9px; height: 9px; border: 2px solid white; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.timeline-date { color: var(--muted); font-size: .7rem; font-weight: 700; text-transform: uppercase; }
.timeline-item h4 { margin: 4px 0; font-size: .85rem; }
.timeline-item p { margin: 0; color: #52616c; font-size: .8rem; line-height: 1.45; }

.message { padding: 15px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.message-head { display: flex; justify-content: space-between; gap: 15px; margin-bottom: 8px; }
.message-sender { font-size: .8rem; font-weight: 700; }
.message-time { color: var(--muted); font-size: .72rem; }
.message p { margin: 0; font-size: .83rem; line-height: 1.5; }

.observation-value { font-family: Georgia, serif; font-size: 1.8rem; }
.observation-unit { color: var(--muted); font-family: inherit; font-size: .9rem; }

.fhir-toolbar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.fhir-toolbar p { margin: 0; color: var(--muted); font-size: .8rem; }
.fhir-resource { overflow: hidden; }
.fhir-resource summary { display: flex; align-items: center; gap: 10px; padding: 13px 15px; cursor: pointer; list-style: none; }
.fhir-resource summary::-webkit-details-marker { display: none; }
.fhir-resource summary::before { content: "+"; width: 18px; color: var(--muted); font-size: 1rem; }
.fhir-resource[open] summary::before { content: "−"; }
.fhir-resource pre { max-height: 440px; overflow: auto; margin: 0; padding: 16px; color: #d7e5ec; background: #102331; font: 0.75rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.resource-type { font-weight: 750; }
.resource-id { min-width: 0; overflow: hidden; color: var(--muted); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }

.empty-state { padding: 54px 20px; text-align: center; }
.empty-icon { width: 42px; height: 42px; display: grid; place-items: center; margin: 0 auto 12px; border-radius: 50%; color: var(--muted); background: #e9eef1; font-size: 1.5rem; }
.empty-state h3 { margin: 0 0 7px; font-size: .95rem; }
.empty-state p { margin: 0; color: var(--muted); font-size: .8rem; }

.outreach-layout { grid-template-columns: minmax(360px, .9fr) minmax(0, 1.25fr); }
.care-debug-card { grid-column: 1 / -1; }
.care-debug > summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 17px; cursor: pointer; list-style-position: inside; }
.care-debug > summary span:first-child { display: inline-flex; flex-direction: column; gap: 3px; }
.care-debug > summary strong { color: var(--navy-700); font-size: .9rem; }
.care-debug > summary small { color: var(--muted); font-size: .7rem; font-weight: 500; }
.care-debug-body { padding: 0 17px 17px; border-top: 1px solid var(--line); }
.debug-config { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 13px 0; }
.debug-config span { padding: 9px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: #f7f9fa; font-size: .7rem; }
.debug-config strong { display: block; margin-top: 3px; color: var(--ink); font-size: .76rem; }
.debug-awaiting { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; padding: 10px 11px; border-radius: 7px; color: var(--navy-700); background: var(--teal-soft); font-size: .75rem; }
.debug-awaiting code { padding: 2px 5px; border-radius: 4px; background: rgba(255,255,255,.7); font-size: .66rem; }
.debug-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 11px; }
.debug-action { min-width: 0; padding: 11px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.debug-action > div { display: flex; align-items: center; gap: 7px; }
.debug-category { color: var(--muted); font-size: .68rem; font-weight: 750; text-transform: uppercase; }
.debug-action h4 { margin: 8px 0 4px; font-size: .8rem; }
.debug-action p { margin: 3px 0; color: var(--muted); font-size: .7rem; line-height: 1.4; }
.debug-action .debug-next { color: var(--ink); }
.debug-action footer { display: flex; flex-wrap: wrap; gap: 5px 10px; margin-top: 8px; color: var(--muted); font-size: .65rem; }
.debug-notes { margin-top: 11px; padding: 8px 11px; border-left: 3px solid var(--teal); color: var(--muted); background: #f7f9fa; }
.debug-notes p { margin: 3px 0; font-size: .68rem; line-height: 1.4; }
.outreach-state { display: flex; align-items: center; gap: 13px; }
.state-icon { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: var(--muted); background: #e9eef1; font-weight: 800; }
.state-icon.active { color: #075f56; background: var(--teal-soft); }
.state-icon.pending_consent { color: #7a5300; background: var(--amber-soft); }
.state-icon.opted_out { color: var(--red); background: var(--red-soft); }
.outreach-state h3 { margin: 0 0 4px; font-size: .95rem; }
.outreach-state p { margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.4; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.channel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
.channel-card { border: 1px solid var(--line); border-radius: 10px; padding: 11px; display: flex; align-items: center; gap: 9px; cursor: pointer; background: #fff; }
.channel-card.selected { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.channel-card.disabled { opacity: .58; cursor: not-allowed; }
.channel-card > span:nth-child(2) { display: grid; gap: 2px; min-width: 0; flex: 1; }
.channel-card small { color: var(--muted); font-size: .75rem; }
.channel-card .tag { white-space: nowrap; }
.enrollment-select { display: grid; gap: 7px; margin-top: 16px; color: var(--ink); font-size: .78rem; font-weight: 700; }
.enrollment-select select { width: 100%; padding: 10px 11px; color: var(--ink); border: 1px solid #aebbc3; border-radius: 7px; background: white; font: inherit; }
.enrollment-select small { color: var(--muted); font-weight: 400; }
.routing-preview { display: grid; gap: 4px; margin-top: 11px; padding: 11px; border: 1px dashed #aebbc3; border-radius: 7px; color: var(--muted); background: #f7f9fa; font-size: .72rem; line-height: 1.45; }
.routing-preview strong { color: var(--navy-700); }
.date-field { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .75rem; font-weight: 650; }
.date-field input { min-height: 39px; padding: 0 9px; color: var(--ink); border: 1px solid #aebbc3; border-radius: 7px; background: white; }
.primary-button, .danger-button {
  min-height: 39px;
  padding: 0 14px;
  border: 1px solid var(--teal);
  border-radius: 7px;
  color: white;
  background: var(--teal);
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
}
.primary-button:hover { background: #08675f; }
.primary-button:disabled, .secondary-button:disabled { cursor: not-allowed; opacity: .5; }
.danger-button { color: var(--red); border-color: #e5b8bb; background: white; }
.day-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.dose-card { padding: 13px; border: 1px solid var(--line); border-radius: 8px; background: #fafcfc; }
.dose-card h4 { margin: 0 0 8px; font-size: .8rem; text-transform: capitalize; }
.dose-card p { margin: 0 0 10px; color: var(--muted); font-size: .75rem; }
.outreach-notice { margin-top: 14px; padding: 12px; border-radius: 7px; color: #71510d; background: var(--amber-soft); font-size: .76rem; line-height: 1.45; }
.conversation { min-height: 330px; max-height: 560px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 17px; background: #f7f9fa; }
.bubble { max-width: 82%; padding: 10px 12px; border-radius: 13px; font-size: .8rem; line-height: 1.45; box-shadow: 0 1px 2px rgba(15,35,52,.08); }
.bubble.outbound { align-self: flex-end; color: white; border-bottom-right-radius: 4px; background: var(--navy-700); }
.bubble.inbound { align-self: flex-start; border: 1px solid var(--line); border-bottom-left-radius: 4px; background: white; }
.bubble-meta { display: block; margin-top: 5px; opacity: .7; font-size: .65rem; }
.chat-image { display: block; width: min(280px, 100%); max-height: 260px; object-fit: contain; margin-bottom: 8px; border-radius: 8px; background: #e9eef1; }
.conversation-empty { margin: auto; color: var(--muted); text-align: center; font-size: .8rem; }
.agent-thinking { display: none; align-items: center; gap: 9px; padding: 9px 17px; color: var(--navy-700); border-top: 1px solid var(--line); background: #f1f8f7; font-size: .75rem; font-weight: 700; }
.agent-thinking.active { display: flex; }
.thinking-dots { display: inline-flex; gap: 3px; }
.thinking-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--teal); animation: thinking-pulse 1s infinite ease-in-out; }
.thinking-dots i:nth-child(2) { animation-delay: .15s; }
.thinking-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes thinking-pulse { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
.chat-composer { padding: 14px 17px 16px; border-top: 1px solid var(--line); background: white; }
.chat-composer label { display: block; margin-bottom: 7px; color: var(--ink); font-size: .78rem; font-weight: 700; }
.chat-compose-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.chat-compose-row textarea { width: 100%; min-height: 72px; padding: 9px 11px; resize: vertical; color: var(--ink); border: 1px solid #aebbc3; border-radius: 7px; background: white; font: inherit; font-size: .82rem; line-height: 1.4; }
.chat-compose-row textarea:focus { outline: 2px solid rgba(10, 122, 113, .2); border-color: var(--teal); }
.chat-compose-row textarea:disabled { color: var(--muted); background: #f2f5f6; }
.chat-composer p { margin: 8px 0 0; color: var(--muted); font-size: .72rem; line-height: 1.4; }
.chat-media-row { display: flex; align-items: center; gap: 9px; margin-top: 9px; color: var(--muted); font-size: .72rem; }
.chat-media-row input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.media-button, .chat-media-row button { margin: 0; padding: 6px 9px; color: var(--navy-700); border: 1px solid #aebbc3; border-radius: 6px; background: white; font-size: .72rem; font-weight: 700; cursor: pointer; }
.writeback-list { margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: #f7f9fa; }
.writeback-list h4 { margin: 0 0 8px; font-size: .78rem; }
.writeback-row { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 8px; margin-top: 7px; color: var(--muted); font-size: .72rem; line-height: 1.4; }
.inline-error { margin-top: 12px; color: var(--red); font-size: .78rem; }
.inline-success { margin-top: 12px; color: #075f56; font-size: .78rem; }

.auth-admin-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.auth-access-card { max-width: 620px; }
.auth-form { display: grid; gap: 13px; }
.auth-form label { display: grid; gap: 6px; color: var(--ink); font-size: .78rem; font-weight: 700; }
.auth-form input { min-height: 40px; padding: 8px 10px; color: var(--ink); border: 1px solid #aebbc3; border-radius: 7px; background: white; font: inherit; }
.auth-form input:focus { outline: 2px solid rgba(10, 122, 113, .2); border-color: var(--teal); }
.auth-form .primary-button { justify-self: start; }
.auth-help { margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.5; }
.auth-secret { display: grid; gap: 7px; margin-top: 15px; padding: 12px; border: 1px solid #efd18c; border-radius: 7px; background: var(--amber-soft); }
.auth-secret strong { font-size: .76rem; }
.auth-secret code { overflow-wrap: anywhere; font-size: .78rem; }
.auth-secret small { color: var(--muted); font-size: .7rem; }
.auth-enrollment { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 14px; align-items: start; margin-top: 15px; }
.auth-qr { width: 180px; height: 180px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: white; image-rendering: pixelated; }
.auth-enrollment .auth-secret { margin-top: 0; }
.auth-uri-link { display: inline-flex; align-items: center; justify-content: center; justify-self: start; text-decoration: none; }
.auth-confirm-form { grid-column: 1 / -1; grid-template-columns: minmax(180px, 280px) auto; align-items: end; }
.auth-audit-card { grid-column: 1 / -1; }

.load-error { max-width: 720px; margin: 80px auto; padding: 24px; border: 1px solid #efc8ca; border-radius: 10px; background: white; }
.load-error h3 { color: var(--red); }
.load-error code { display: block; padding: 12px; border-radius: 6px; background: #f5f7f8; }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-column { grid-template-columns: 1fr; }
  .outreach-layout { grid-template-columns: 1fr; }
  .debug-config, .debug-actions { grid-template-columns: 1fr 1fr; }
  .auth-admin-layout { grid-template-columns: 1fr; }
  .auth-audit-card { grid-column: auto; }
}

@media (max-width: 560px) {
  .chat-compose-row { grid-template-columns: 1fr; }
  .debug-config, .debug-actions { grid-template-columns: 1fr; }
  .auth-enrollment { grid-template-columns: 1fr; }
  .auth-confirm-form { grid-column: auto; grid-template-columns: 1fr; }
  .terminology-form { grid-template-columns: 1fr; }
  .terminology-wide, .terminology-actions, .terminology-form .inline-error, .terminology-form .inline-success { grid-column: auto; }
}

@media (max-width: 760px) {
  .demo-banner { justify-content: flex-start; }
  .demo-banner span { display: none; }
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; max-height: none; }
  .brand { min-height: 72px; }
  .patient-list { display: flex; overflow-x: auto; padding-bottom: 10px; }
  .patient-button { min-width: 240px; }
  .sidebar-footer { display: none; }
  .workspace { padding: 0 17px 36px; }
  .topbar { min-height: 76px; }
  .topbar .eyebrow, .data-health { display: none; }
  .patient-header { align-items: flex-start; flex-direction: column; }
  .metric-grid { grid-template-columns: 1fr; }
}

@media print {
  .demo-banner { position: static; }
  .sidebar, .topbar-actions, .tabs { display: none; }
  .app-shell { display: block; padding: 0; }
  .workspace { padding: 20px; }
  .view { padding-top: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
