:root {
  color-scheme: light;
  --ink: #1f3337;
  --muted: #546b6f;
  --paper: #f3f5f1;
  --card: #fff;
  --line: #dce5df;
  --brand: #086155;
  --brand-hover: #064b43;
  --brand-light: #e5f4ee;
  --dark: #173439;
  --amber: #805610;
  --amber-light: #f9f0df;
  --danger: #923938;
  --danger-light: #fbeae8;
  --radius: 19px;
  --font: 'Trebuchet MS', system-ui, sans-serif;
  font: 16px/1.55 var(--font);
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }
a { color: var(--brand); }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible, [tabindex='0']:focus-visible { outline: 3px solid #25a692; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.13; }
h1, h2 { letter-spacing: -.038em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1rem; }

.skip-link { position: fixed; top: 8px; left: 8px; z-index: 10; clip-path: inset(50%); border-radius: 8px; padding: 12px; background: var(--card); }
.skip-link:focus-visible { clip-path: none; }
.brand { display: inline-flex; align-items: center; gap: 11px; width: max-content; color: #fff; font-weight: 800; line-height: 1.18; text-decoration: none; letter-spacing: -.02em; }
.brand small { display: block; margin-top: 4px; color: #c1d5d2; font-size: .67rem; letter-spacing: .01em; font-weight: 400; }
.brand-icon { display: inline-block; flex: 0 0 38px; width: 38px; height: 38px; border-radius: 11px; position: relative; background: #b5eccf; }
.brand-icon::before, .brand-icon::after { content: ''; position: absolute; background: #194b42; border-radius: 2px; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.brand-icon::before { width: 18px; height: 5px; }
.brand-icon::after { width: 5px; height: 18px; }
.eyebrow { display: inline-flex; align-items: center; gap: 7px; color: var(--brand); font-size: .69rem; letter-spacing: .12em; font-weight: 800; text-transform: uppercase; }
.dot { display: inline-block; flex: 0 0 7px; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 42px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; font-size: .86rem; font-weight: 800; text-decoration: none; }
.button.primary { background: var(--brand); color: #fff; }
.button.primary:hover { background: var(--brand-hover); }
.button.secondary { background: #fff; border-color: var(--line); color: var(--brand); }
.button.secondary:hover, .button.logout:hover { background: var(--brand-light); }
.button.logout { background: transparent; color: var(--ink); padding-inline: 9px; }
.text-button { padding: 0; background: none; border: 0; color: var(--brand); font-size: .85rem; font-weight: 800; text-align: left; }
.text-button:hover { text-decoration: underline; }
label { display: block; margin-bottom: 7px; color: var(--ink); font-size: .84rem; font-weight: 800; }
input, textarea, select { width: 100%; min-width: 0; color: var(--ink); border: 1px solid #cddbd4; border-radius: 9px; padding: 10px 12px; background: #fff; font-size: .94rem; }
input::placeholder, textarea::placeholder { color: #62747a; }
textarea { resize: vertical; min-height: 118px; display: block; }
.feedback { color: var(--brand); font-size: .87rem; font-weight: 700; }
.feedback:empty { display: none; }
.feedback.error { color: var(--danger); }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.login-screen { min-height: 100vh; display: grid; grid-template-columns: 1.08fr .92fr; }
.login-intro { display: flex; flex-direction: column; position: relative; overflow: hidden; isolation: isolate; min-height: 100vh; justify-content: space-between; gap: 52px; padding: clamp(25px, 5.8vw, 90px); color: #fff; background: radial-gradient(ellipse at 94% 85%, #25554d 0%, transparent 60%), var(--dark); }
.login-intro::before, .login-intro::after { content: ''; position: absolute; z-index: -1; width: 540px; height: 540px; right: -260px; bottom: -280px; border: 1px solid #91baaa50; border-radius: 50%; }
.login-intro::after { width: 610px; height: 610px; right: -284px; bottom: -306px; }
.login-intro .eyebrow { color: #b5eccf; margin-bottom: 16px; }
.login-intro h1 { font-size: clamp(2.8rem, 5.7vw, 6.15rem); line-height: .97; letter-spacing: -.075em; }
.login-intro h1 span { color: #b5eccf; }
.login-intro-copy p { max-width: 360px; margin-top: 24px; color: #d1e2dd; font-size: 1.05rem; }
.login-footer { color: #c2d8d0; font-size: .81rem; }
.login-main { display: grid; align-items: center; justify-items: center; padding: 40px 26px; }
.login-form { width: min(100%, 385px); }
.login-form h2 { font-size: 2.65rem; margin-top: 6px; }
.login-form > p:first-of-type { color: var(--muted); margin: 10px 0 24px; }
.login-form button { justify-content: space-between; width: 100%; margin-top: 16px; }
.login-form .feedback { margin-top: 12px; }
.loading { display: grid; place-content: center; min-height: 100vh; color: var(--muted); text-align: center; }

.workspace { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 16px 18px; color: #e1eeeb; background: var(--dark); }
.sidebar .brand { margin-left: 4px; }
.sidebar-body { margin-top: 50px; }
.sidebar-caption { color: #a7c6bf; margin: 0 0 9px 11px; font-size: .68rem; letter-spacing: .12em; font-weight: 700; text-transform: uppercase; }
.sections { display: grid; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; border: 0; border-radius: 9px; padding: 11px; color: #d5e5e0; background: transparent; font-size: .88rem; text-align: left; white-space: nowrap; }
.nav-item:hover { background: #23474a; }
.nav-item[aria-current='page'] { background: #b5eccf; color: #173d37; font-weight: 800; }
.nav-icon { position: relative; display: inline-block; flex: 0 0 16px; width: 16px; height: 16px; }
.file-icon::before { content: ''; position: absolute; inset: 1px 2px; border: 1.5px solid currentColor; border-radius: 3px; }
.file-icon::after { content: ''; position: absolute; left: 5px; top: 6px; width: 6px; height: 4px; border-block: 1.5px solid currentColor; }
.connection-icon::before, .connection-icon::after { content: ''; display: block; position: absolute; top: 50%; left: 50%; width: 5px; height: 10px; border: 1.5px solid currentColor; border-radius: 7px; }
.connection-icon::before { transform: translate(-75%, -65%) rotate(42deg); }
.connection-icon::after { transform: translate(-35%, -35%) rotate(42deg); }
.metrics-icon::before { content: ''; position: absolute; left: 2px; bottom: 2px; width: 3px; height: 6px; border-radius: 2px; background: currentColor; box-shadow: 5px -3px currentColor, 10px -6px currentColor; }
.sidebar-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 14px 7px 0; border-top: 1px solid #315458; color: #cee1da; font-size: .72rem; }
.sidebar-foot .dot { color: #9addc1; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 65px; padding: 9px clamp(22px, 3vw, 44px); border-bottom: 1px solid var(--line); background: #fafbf8; }
.crumb, .topbar-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: .82rem; }
.crumb { color: var(--muted); }
.crumb strong { color: var(--ink); }
.crumb-divider { color: #879d9c; }
.connection-badge { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #ebdab9; border-radius: 99px; padding: 5px 9px; background: var(--amber-light); color: var(--amber); font-size: .74rem; font-weight: 800; }
.connection-badge.is-on { border-color: #c6e9d9; background: var(--brand-light); color: var(--brand); }
.content { max-width: 1500px; min-width: 0; margin-inline: auto; padding: clamp(21px, 3vw, 42px) clamp(20px, 3vw, 44px) 48px; }
.panel { min-width: 0; padding: clamp(17px, 2.2vw, 27px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: 0 2px 3px #1b353404; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.panel-heading h2 { margin-top: 4px; }
.patient-header { display: flex; align-items: center; gap: clamp(13px, 2vw, 23px); position: relative; min-height: 136px; margin-bottom: 19px; overflow: hidden; background: radial-gradient(ellipse at 100% 0%, #eef7e8, transparent 56%), #fff; }
.patient-avatar { display: grid; place-items: center; flex: 0 0 66px; width: 66px; height: 66px; border-radius: 20px; background: #dcf0e6; color: #125f52; font-size: 1.36rem; font-weight: 800; letter-spacing: -.045em; }
.patient-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 11px; }
.patient-demo { border-radius: 20px; background: var(--amber-light); color: var(--amber); padding: 3px 8px; font-size: .67rem; font-weight: 800; white-space: nowrap; }
.patient-heading h1 { margin: 4px 0 6px; font-size: clamp(1.7rem, 3.4vw, 2.9rem); }
.patient-heading > p { color: var(--muted); font-size: .86rem; }
.clinical-layout { display: grid; gap: 19px; grid-template-columns: minmax(0, 1.58fr) minmax(237px, 1fr); align-items: start; }
.clinical-main, .patient-details { min-width: 0; display: grid; gap: 19px; }
.section-icon { position: relative; display: grid; place-items: center; width: 33px; height: 33px; border-radius: 9px; color: var(--brand); background: var(--brand-light); }
.add-icon { margin-bottom: 11px; }
.add-icon::before, .add-icon::after { content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); border-radius: 2px; background: currentColor; }
.add-icon::before { width: 15px; height: 2px; }
.add-icon::after { width: 2px; height: 15px; }
.section-description { color: var(--muted); font-size: .88rem; margin: 5px 0 0; }
.composer form { display: grid; grid-template-columns: minmax(0, 1fr); margin-top: 18px; }
.composer label:not(:first-child) { margin-top: 13px; }
.optional { margin-left: 4px; color: var(--muted); font-weight: 400; }
.composer-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 8px 0 15px; }
.character-count { color: var(--muted); font-size: .75rem; }
.composer .primary { justify-self: start; }
.composer form .feedback { margin-bottom: 12px; }
.notice { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; border-radius: 10px; padding: 10px 12px; margin: 1px 0 13px; background: var(--amber-light); color: var(--amber); font-size: .82rem; }
.notice .text-button { color: #684402; }
.demographics dl { margin: 10px 0 0; }
.fact { display: grid; grid-template-columns: 1fr 1.15fr; gap: 9px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .82rem; }
.fact dt { color: var(--muted); }
.fact dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.footnote, .help-text { color: var(--muted); font-size: .8rem; }
.footnote { margin-top: 13px; }
.count { display: grid; place-items: center; min-width: 26px; height: 26px; padding-inline: 5px; color: var(--brand); background: var(--brand-light); border-radius: 7px; font-size: .75rem; font-weight: 800; }
.timeline { margin-top: 19px; padding-left: 13px; border-left: 1px solid #cde2d8; }
.timeline-entry { position: relative; padding-bottom: 16px; }
.timeline-entry:last-child { padding-bottom: 2px; }
.timeline-entry::before { content: ''; position: absolute; top: .78rem; left: -17px; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.note-date { color: var(--brand); font-size: .69rem; font-weight: 800; }
.timeline summary { color: var(--ink); cursor: pointer; line-height: 1.2; }
.note-title { font-size: .92rem; font-weight: 800; }
.note-author { color: var(--muted); margin: 4px 0 7px; font-size: .73rem; }
.note-text { color: var(--muted); font-size: .8rem; white-space: pre-line; overflow-wrap: anywhere; }
.history-link { display: block; margin-top: 6px; }

.exchange .eyebrow > span { font-size: .82rem; }
.exchange-meta { margin-top: 16px; }
.exchange-meta select { max-width: 420px; }
.exchange-meta p { overflow-wrap: anywhere; }
.empty-state { display: flex; align-items: center; gap: 9px; margin-top: 15px; border: 1px dashed #c8ded4; border-radius: 12px; padding: 14px; color: var(--muted); background: #f8fbf8; font-size: .85rem; }
.empty-state .section-icon { flex: 0 0 33px; }
.status-tag { display: inline-flex; align-items: center; border-radius: 99px; padding: 5px 9px; color: var(--brand); background: var(--brand-light); font-size: .71rem; font-weight: 800; white-space: nowrap; }
.status-tag.warning { color: var(--amber); background: var(--amber-light); }
.status-tag.error { color: var(--danger); background: var(--danger-light); }
.tab-list { display: flex; gap: 4px; margin: 17px 0 0; border-bottom: 1px solid var(--line); }
.tab { min-height: 40px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; padding: 7px 9px; color: var(--muted); background: transparent; font-size: .82rem; font-weight: 700; }
.tab[aria-selected='true'] { color: var(--brand); border-bottom-color: var(--brand); }
.tab-panel { padding-top: 15px; }
.tab-panel:focus-visible { border-radius: 6px; }
.tab-panel > .button, .tab-panel > .feedback { margin-top: 12px; }
.response-summary { display: grid; gap: 8px; margin: 0 0 10px; padding: 13px; border: 1px solid #cae7db; border-radius: 11px; background: #f2faf6; }
.response-summary.warning { border-color: #eedfc7; background: #fdf8ef; }
.response-summary.error { border-color: #f0cfcc; background: #fff5f4; }
.response-summary p, .normalized p { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.normalized { margin-top: 13px; }
.normalized p { margin-top: 6px; white-space: pre-wrap; }
.finding-list { display: grid; gap: 8px; list-style: none; margin: 10px 0 0; padding: 0; }
.finding { display: grid; gap: 4px; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-size: .85rem; overflow-wrap: anywhere; }
.finding-meta { color: var(--muted); font-size: .77rem; }
.code-section + .code-section { margin-top: 17px; }
.code-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 5px 9px; margin-bottom: 7px; }
.code-heading h3 { font-size: .86rem; }
.code-block { max-height: 425px; width: 100%; margin: 0; overflow: auto; border-radius: 11px; padding: 13px; color: #e5f1ee; background: #1d3437; tab-size: 2; font: .78rem/1.66 ui-monospace, Consolas, monospace; }
.json-key { color: #a3e8d4; }
.json-string { color: #f6d497; }
.json-literal { color: #e4b8f3; }
.json-number { color: #b7dbfa; }

.secondary-page { max-width: 850px; }
.page-heading { margin-bottom: 20px; }
.page-heading h1 { margin: 5px 0 7px; font-size: clamp(2rem, 4vw, 3.1rem); }
.page-heading p { color: var(--muted); }
.settings-card + .settings-card { margin-top: 19px; }
.settings-card form { margin-top: 18px; }
.settings-card input, .settings-card select { max-width: 465px; }
.settings-card .help-text { margin: 6px 0 13px; }
.settings-card .feedback { margin-top: 10px; }
.settings-card > .form-actions { margin-top: 14px; }
.settings-card #token-form .form-actions { margin-top: 12px; }
.advanced-options > summary { cursor: pointer; color: var(--brand); font-weight: 800; }
.advanced-pane { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.advanced-pane h2 { margin-bottom: 9px; }
.integration-mode-option { display: flex; align-items: flex-start; gap: 9px; margin: 0; padding: 11px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.integration-mode-option:has(input:checked) { border-color: var(--brand); background: var(--brand-light); }
.integration-mode-option input { flex: 0 0 auto; width: auto; margin: 3px 0 0; padding: 0; accent-color: var(--brand); }
#webhook-fields { margin-top: 14px; }
#terminology-result .code-section { margin-top: 12px; }
.send-mode { margin: 8px 0; }
.character-count.over-limit { color: var(--danger); }
.endpoint { display: flex; align-items: flex-start; gap: 10px; margin-top: 12px; padding: 12px; border-radius: 10px; background: var(--paper); font-size: .83rem; overflow-wrap: anywhere; }
.endpoint span { color: var(--brand); font-size: .77rem; font-weight: 800; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(107px, 1fr)); gap: 9px; margin: 14px 0 0; }
.metric-value { display: grid; gap: 1px; padding: 11px; background: var(--paper); border-radius: 10px; }
.metric-value dt { font-size: .75rem; color: var(--muted); }
.metric-value dd { grid-row: 1; margin: 0; font-weight: 800; font-size: 1.45rem; letter-spacing: -.035em; overflow-wrap: anywhere; }
.cohort-summary { margin-top: 14px; }
.cohort-details { margin-top: 15px; }
.cohort-details summary { cursor: pointer; color: var(--brand); font-size: .9rem; font-weight: 800; }
.cohort-details .help-text { overflow-wrap: anywhere; }

@media (max-width: 1000px) {
  .workspace { grid-template-columns: 178px minmax(0, 1fr); }
  .sidebar { padding-inline: 11px; }
  .sidebar .brand { gap: 7px; }
  .sidebar .brand small { font-size: .58rem; }
  .sidebar .brand-icon { flex-basis: 32px; width: 32px; height: 32px; border-radius: 8px; }
}
@media (max-width: 815px) {
  .workspace { display: block; }
  .sidebar { position: static; display: flex; flex-direction: row; height: auto; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 20px; }
  .sidebar .brand { margin-left: 0; }
  .sidebar-body { margin: 0; }
  .sidebar-caption, .sidebar-foot { display: none; }
  .sections { display: flex; gap: 3px; }
  .nav-item { padding: 8px 9px; }
  .topbar { min-height: 53px; }
}
@media (max-width: 630px) {
  .clinical-layout { grid-template-columns: minmax(0, 1fr); }
  .login-screen { grid-template-columns: minmax(0, 1fr); }
  .login-intro { min-height: auto; padding: 24px; gap: 28px; }
  .login-intro h1 { font-size: clamp(2.35rem, 11vw, 4rem); }
  .login-intro-copy p { margin-top: 13px; }
  .login-footer { display: none; }
  .login-main { align-items: start; padding-block: 31px; }
}
@media (max-width: 485px) {
  .sidebar { display: grid; padding-inline: 13px; }
  .sections { flex-wrap: wrap; }
  .nav-item { min-height: 38px; padding: 6px 8px; font-size: .77rem; gap: 4px; }
  .topbar { padding-inline: 13px; }
  .topbar-actions { gap: 5px; }
  .crumb > span { display: none; }
  .button.logout { padding: 5px; min-height: 32px; font-size: .75rem; }
  .content { padding: 13px 12px 30px; }
  .patient-avatar { flex-basis: 50px; width: 50px; height: 50px; border-radius: 13px; }
  .patient-header { min-height: 106px; }
}
