/* ehds-api viewer · restrained palette · system fonts only */

:root {
    --bg: #f7f7f5;
    --surface: #ffffff;
    --surface-2: #fafaf8;
    --surface-3: #f0efe9;
    --border: #e6e6e0;
    --border-soft: #efefea;
    --text: #1f1f1c;
    --text-muted: #6c6c63;
    --text-faint: #9c9c93;
    --accent: #2a6f6b;
    --accent-2: #1d514e;
    --accent-soft: #d6e9e7;
    --info: #1a5a8c;
    --info-soft: #dbe9f4;
    --warn: #b58348;
    --warn-soft: #f6e8d4;
    --danger: #b54848;
    --danger-soft: #fbeaea;
    --code-bg: #1f1f1c;
    --code-text: #ebebd8;
    --code-key: #9fdbd5;
    --code-string: #f0c373;
    --code-number: #d8a8de;
    --shadow-1: 0 1px 0 rgba(0,0,0,.02), 0 2px 6px rgba(0,0,0,.04);
    --shadow-2: 0 2px 4px rgba(0,0,0,.04), 0 12px 32px rgba(0,0,0,.10);
    --radius: 8px;
    --radius-sm: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

button { font-family: inherit; }
a { color: var(--accent); }
a:hover { color: var(--accent-2); }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace; }

/* ---------- header ---------- */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.brand .title { font-weight: 600; font-size: 15px; }
.brand .subtitle { color: var(--text-muted); font-size: 12px; }
.app-header nav { display: flex; gap: 6px; flex-wrap: wrap; }
.app-header nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
}
.app-header nav a:hover { color: var(--text); background: var(--surface-2); }
.app-header nav a.active { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }
.app-header nav a.ext { color: var(--text-faint); }
.app-header nav a.ext:hover { color: var(--accent); }

/* ---------- main ---------- */
main {
    flex: 1;
    padding: 24px 28px 48px;
    max-width: 1220px;
    width: 100%;
    margin: 0 auto;
}
.loading {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}

/* ---------- page header ---------- */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 18px;
    gap: 12px;
    flex-wrap: wrap;
}
.page-head h1 {
    font-size: 22px;
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.page-head .meta { color: var(--text-muted); font-size: 13px; }

/* ---------- search ---------- */
.search-box {
    display: flex;
    margin-bottom: 16px;
}
.search-box input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
}
.search-box input:focus {
    outline: 2px solid var(--accent-soft);
    outline-offset: -1px;
    border-color: var(--accent);
}

/* ---------- patient grid ---------- */
.patient-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 14px;
}
.patient-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow-1);
    transition: transform .08s ease, border-color .08s ease, box-shadow .08s ease;
    display: block;
}
.patient-card:hover {
    transform: translateY(-1px);
    border-color: var(--accent);
    box-shadow: var(--shadow-2);
}
.patient-card .name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.patient-card .meta {
    color: var(--text-muted);
    font-size: 12px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.patient-card .meta span:not(:last-child)::after {
    content: '·';
    margin-left: 12px;
    color: var(--border);
}
.patient-card .ident {
    margin-top: 8px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
    font-size: 11px;
    color: var(--text-faint);
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
}
.patient-card .ident .id { color: var(--text-muted); }
.country-pill {
    display: inline-block;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 10px;
    letter-spacing: .04em;
}

/* ---------- patient hero ---------- */
.patient-hero {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-1);
}
.patient-hero h1 {
    margin: 0 0 4px 0;
    font-size: 23px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.patient-hero .meta-row {
    color: var(--text-muted);
    font-size: 13px;
}
.patient-hero .hero-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px 22px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-soft);
}
.field-label {
    font-size: 11px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .07em;
    margin-bottom: 2px;
    font-weight: 600;
}
.field-value { font-size: 13px; }
.field-value.mono { font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; }

/* ---------- code chip + URL block ---------- */
.url-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    padding: 4px 8px 4px 10px;
    border-radius: var(--radius-sm);
    font-family: ui-monospace, monospace;
    font-size: 12px;
    color: var(--text);
}
.url-chip .verb {
    color: var(--accent);
    font-weight: 600;
}
.url-chip.with-copy { padding-right: 4px; }
.url-chip .copy-btn {
    background: transparent;
    border: none;
    padding: 2px 6px;
    color: var(--text-faint);
    cursor: pointer;
    font-size: 11px;
    border-radius: 4px;
}
.url-chip .copy-btn:hover { background: var(--surface); color: var(--accent); }

.tech-block {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 22px;
}
.tech-block h3 {
    margin: 0 0 10px 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .08em;
}
.tech-block .row {
    display: grid;
    grid-template-columns: minmax(170px, 220px) 1fr;
    gap: 12px;
    padding: 4px 0;
    align-items: center;
    border-bottom: 1px dashed var(--border-soft);
}
.tech-block .row:last-child { border-bottom: none; }
.tech-block .row .lbl {
    color: var(--text-muted);
    font-size: 12px;
}

/* ---------- doc cards on patient detail ---------- */
section.section-title {
    margin: 26px 0 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .08em;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}
.doc-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 8px;
}
.doc-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--shadow-1);
    transition: border-color .08s, transform .08s;
}
.doc-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.doc-card .label { font-weight: 600; font-size: 14px; }
.doc-card .sub { font-size: 11px; color: var(--text-faint); font-family: ui-monospace, monospace; }
.doc-card .open { font-size: 11px; color: var(--accent); margin-top: 2px; }

/* ---------- resource buckets ---------- */
.resource-bucket {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    overflow: hidden;
}
.resource-bucket summary {
    padding: 12px 18px;
    cursor: pointer;
    user-select: none;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-2);
    font-weight: 600;
    border-bottom: 1px solid transparent;
    transition: border-bottom-color .08s;
}
.resource-bucket summary::-webkit-details-marker { display: none; }
.resource-bucket summary:hover { background: var(--surface-3); }
.resource-bucket[open] summary { border-bottom-color: var(--border); }
.resource-bucket summary .count {
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    padding: 2px 10px;
    border-radius: 10px;
    font-weight: 600;
}
.resource-bucket .resource-list { padding: 0; }
.resource-row {
    padding: 9px 18px;
    border-bottom: 1px solid var(--border-soft);
    display: grid;
    grid-template-columns: minmax(140px, 220px) 1fr auto;
    gap: 16px;
    align-items: center;
    font-size: 13px;
}
.resource-row:last-child { border-bottom: none; }
.resource-row { cursor: pointer; }
.resource-row:hover { background: var(--surface-2); }
.resource-row:hover .rid { color: var(--accent); }
.resource-row .rid {
    font-family: ui-monospace, monospace;
    font-size: 11px;
    color: var(--text-muted);
    border-bottom: 1px dashed transparent;
}
.resource-row .display { color: var(--text); }
.resource-row .ts {
    font-size: 11px;
    color: var(--text-faint);
    font-family: ui-monospace, monospace;
}

/* ---------- breadcrumbs ---------- */
.crumbs {
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}
.crumbs a { color: var(--accent); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .sep { color: var(--text-faint); }

/* ---------- document viewer ---------- */
.doc-header {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-1);
}
.doc-header h1 {
    margin: 0 0 8px 0;
    font-size: 21px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.doc-header .summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px 22px;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-soft);
}
.doc-header .summary div .lbl {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-faint);
    font-weight: 600;
    margin-bottom: 2px;
}
.doc-header .summary div .val { color: var(--text); }
.doc-header .summary div .val.mono { font-family: ui-monospace, monospace; font-size: 11px; word-break: break-all; }

.entry-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 18px;
}
.entry-bar .chip {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 3px 10px;
    font-size: 11px;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.entry-bar .chip .n { font-weight: 600; color: var(--text); }

.section-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}
.section-block h3 {
    margin: 0;
    padding: 12px 18px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.section-block h3 .meta-right {
    display: flex;
    gap: 8px;
    align-items: center;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 12px;
}
.section-block h3 .loinc-pill {
    background: var(--info-soft);
    color: var(--info);
    font-family: ui-monospace, monospace;
    padding: 1px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
.section-block h3 .loinc-pill::after { content: '↗'; font-size: 10px; opacity: 0.7; }
.section-block h3 .loinc-pill:hover { text-decoration: underline; }

.section-block .entries .entry-row {
    padding: 9px 18px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-soft);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
}
.section-block .entries .entry-row:last-child { border-bottom: none; }
.section-block .entries .entry-row .left { min-width: 0; }
.section-block .entries .entry-row .ref {
    font-family: ui-monospace, monospace;
    font-size: 11px;
    color: var(--text-faint);
    margin-bottom: 2px;
    cursor: pointer;
}
.section-block .entries .entry-row .ref:hover { color: var(--accent); text-decoration: underline; }
.section-block .entries .entry-row .display { color: var(--text); }
.section-block .entries .entry-row .right {
    font-size: 11px;
    color: var(--text-faint);
    text-align: right;
}
.section-block .entries .entry-row .code-chip {
    display: inline-block;
    font-family: ui-monospace, monospace;
    background: var(--surface-2);
    padding: 1px 6px;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 10px;
    margin-left: 6px;
}

/* ---------- buttons ---------- */
.btn,
.btn-primary,
.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    text-decoration: none;
}
.btn:hover, .btn-ghost:hover { background: var(--surface-2); border-color: var(--accent); color: var(--accent); }
.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* ---------- json modal ---------- */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(20, 20, 18, 0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    padding: 24px;
}
.modal-overlay[hidden] { display: none; }
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-2);
    width: min(960px, 100%);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.modal-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.modal-title #modal-title-text { font-weight: 600; font-size: 14px; }
.modal-title .muted { color: var(--text-muted); font-size: 11px; font-family: ui-monospace, monospace; word-break: break-all; }
.modal-actions { display: flex; gap: 6px; }
.modal-actions .btn-ghost {
    padding: 5px 10px;
    font-size: 12px;
}
.modal #modal-body {
    flex: 1;
    overflow: auto;
    margin: 0;
    padding: 16px 18px;
    background: var(--code-bg);
    color: var(--code-text);
    font-size: 12px;
    line-height: 1.55;
    border-radius: 0;
    white-space: pre;
}

.json-dump {
    background: var(--code-bg);
    color: var(--code-text);
    border-radius: var(--radius);
    padding: 14px 18px;
    overflow-x: auto;
    font-size: 12px;
    line-height: 1.55;
    font-family: ui-monospace, monospace;
    margin-top: 12px;
    white-space: pre;
    max-height: 540px;
    overflow-y: auto;
}
/* basic JSON token coloring (decorated client-side) */
.json-key { color: var(--code-key); }
.json-string { color: var(--code-string); }
.json-number { color: var(--code-number); }
.json-boolean { color: #f08585; }
.json-null { color: #888; font-style: italic; }

/* ---------- toast ---------- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--surface);
    padding: 8px 16px;
    border-radius: 18px;
    font-size: 12px;
    box-shadow: var(--shadow-2);
    z-index: 1100;
}
.toast[hidden] { display: none; }

/* ---------- server page ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
}
.stat-card .label {
    font-size: 11px;
    color: var(--text-faint);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: .07em;
    font-weight: 600;
}
.stat-card .value { font-size: 22px; font-weight: 600; line-height: 1.1; }
.stat-card .sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.endpoints-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 16px;
}
.endpoints-table th, .endpoints-table td {
    text-align: left;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 13px;
    vertical-align: top;
}
.endpoints-table th {
    background: var(--surface-2);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .07em;
}
.endpoints-table tr:last-child td { border-bottom: none; }
.endpoints-table code {
    background: var(--surface-3);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: ui-monospace, monospace;
}

/* ---------- endpoints page ---------- */
.endpoint-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 10px;
}
.endpoint-card .head {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
}
.endpoint-card .label { font-weight: 600; font-size: 14px; }
.endpoint-card .method-badge {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-family: ui-monospace, monospace;
}
.endpoint-card .method-badge.post { background: var(--info-soft); color: var(--info); }
.endpoint-card .auth-badge {
    background: var(--warn-soft);
    color: var(--warn);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.endpoint-card .auth-badge.none { background: var(--surface-3); color: var(--text-muted); }
.endpoint-card .path {
    font-family: ui-monospace, monospace;
    color: var(--text);
    font-size: 13px;
}
.endpoint-card pre {
    background: var(--code-bg);
    color: var(--code-text);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-family: ui-monospace, monospace;
    font-size: 12px;
    line-height: 1.55;
    margin: 10px 0 0 0;
    overflow-x: auto;
    white-space: pre;
    position: relative;
}
.endpoint-card .copy-row {
    display: flex;
    justify-content: flex-end;
    margin-top: -4px;
}

.token-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 18px;
}
.token-card .head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.token-card .head h2 { margin: 0; font-size: 15px; }
.token-card .token-display {
    background: var(--code-bg);
    color: var(--code-text);
    font-family: ui-monospace, monospace;
    font-size: 11px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    word-break: break-all;
    line-height: 1.45;
    max-height: 100px;
    overflow-y: auto;
    margin-top: 8px;
}
.token-card .meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ---------- footer ---------- */
footer {
    padding: 14px 28px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.footer-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.footer-tags .pill {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 10px;
    font-family: ui-monospace, monospace;
    font-size: 11px;
}

/* ---------- empty / error ---------- */
.empty {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.error {
    padding: 16px;
    background: var(--danger-soft);
    border: 1px solid #fbcaca;
    color: var(--danger);
    border-radius: var(--radius);
}

@media (max-width: 720px) {
    .app-header { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
    main { padding: 14px 16px 36px; }
    .resource-row { grid-template-columns: 1fr; gap: 4px; }
    .tech-block .row { grid-template-columns: 1fr; gap: 2px; }
    .doc-header .summary { grid-template-columns: 1fr; }
    .modal-overlay { padding: 12px; }
    .capability-grid { grid-template-columns: 1fr; }
    .qr-grid { grid-template-columns: 1fr 1fr; }
    .patients-table { font-size: 12px; }
}

/* ---------- clickable URL chips ---------- */
.url-chip.linkable {
    text-decoration: none;
}
.url-chip.linkable:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-2);
}

/* ---------- home page ---------- */
.hero-home {
    padding: 28px 0 22px;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 22px;
}
.hero-home h1 {
    font-size: 26px;
    margin: 0 0 8px;
    letter-spacing: -0.01em;
}
.hero-home .tagline {
    color: var(--text-muted);
    font-size: 14.5px;
    line-height: 1.6;
    max-width: 820px;
    margin: 0 0 18px;
}
.hero-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    max-width: 820px;
}
.capability-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}
.cap-card {
    display: block;
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    transition: border-color .15s ease, box-shadow .15s ease, transform .05s ease;
}
.cap-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-1);
}
.cap-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.cap-icon { font-size: 20px; }
.cap-title { font-weight: 600; font-size: 14.5px; }
.cap-desc {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 10px;
}
.cap-go {
    font-size: 12px;
    color: var(--accent);
    font-weight: 500;
}
.note-block {
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 20px;
}
.note-block h3 { margin: 0 0 6px; font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.note-block p { margin: 0; color: var(--text); font-size: 13.5px; }

/* ---------- capability narrative pages ---------- */
.doc-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 18px;
}
.doc-block h3 {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.doc-block p { margin: 0 0 10px; font-size: 13.5px; color: var(--text); }
.doc-block code { background: var(--surface-3); padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.flow-list { padding-left: 20px; margin: 0; }
.flow-list li { margin-bottom: 8px; font-size: 13.5px; line-height: 1.6; }
.flow-list li code { font-size: 11.5px; }
.code-snippet {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    overflow-x: auto;
    margin: 8px 0 0;
}

/* ---------- demo (end-to-end walkthrough) ---------- */
.demo-steps { display: flex; flex-direction: column; gap: 12px; }
.demo-step {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
}
.demo-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.demo-head h3 { margin: 0; font-size: 15px; flex: 1; }
.demo-n {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
}
.demo-narrative { color: var(--text-muted); font-size: 13px; line-height: 1.55; margin-bottom: 8px; }
.demo-url {
    display: inline-block;
    background: var(--surface-3);
    color: var(--text-muted);
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 4px;
    margin-bottom: 10px;
}
.demo-out:empty { display: none; }
.demo-result-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 8px;
    font-size: 12px;
}
.demo-actions { padding-top: 8px; }

/* ---------- QR ---------- */
.qr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}
.qr-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.qr-title { font-weight: 600; font-size: 13px; text-align: center; }
.qr-img {
    width: 100%;
    max-width: 180px;
    height: auto;
    background: white;
    padding: 8px;
    border-radius: var(--radius-sm);
}
.qr-url {
    font-size: 10.5px;
    color: var(--text-muted);
    word-break: break-all;
    text-align: center;
}
.qr-url a { color: var(--text-muted); }

/* ---------- patient list extras ---------- */
.list-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.list-controls .search-box { flex: 1; min-width: 200px; margin: 0; }
.view-toggle { display: flex; gap: 4px; }
.view-toggle .btn-ghost.active {
    background: var(--accent-soft);
    color: var(--accent-2);
    border-color: var(--accent-soft);
}
.doc-badges {
    display: inline-flex;
    gap: 4px;
    margin-left: auto;
}
.doc-badge {
    text-decoration: none;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-3);
    border-radius: 4px;
    font-size: 13px;
    transition: background-color .12s ease;
}
.doc-badge:hover { background: var(--accent-soft); }

.patients-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 13px;
}
.patients-table th {
    text-align: left;
    background: var(--surface-2);
    padding: 9px 12px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
}
.patients-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}
.patients-table tr:last-child td { border-bottom: none; }
.patients-table tr:hover td { background: var(--surface-2); }
.patients-table a { text-decoration: none; }
.patients-table .doc-badges { margin-left: 0; }
