/* ---- Tokens ----------------------------------------------------------- */
:root {
    --accent: #0B5CAD;
    --ink: #15202B;
    --ink-2: #2A3642;
    --muted: #4A5868;
    --muted-2: #55626F;
    --line: #DDE2E8;
    --line-2: #E6EAEE;
    --line-3: #EEF1F4;
    --field: #C9D1DA;
    --bg: #F4F6F8;
    --soft: #F6F8FA;
    --danger: #B42318;
    --danger-text: #A3290B;
    --ok: #0F6B3F;
    --warn: #7A5B00;
    --sans: 'IBM Plex Sans', system-ui, sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
a:hover { filter: brightness(0.8); }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
h1:focus { outline: none; }
input, select, textarea, button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.pre, .pre dd { white-space: pre-line; }
.stack { display: flex; flex-direction: column; gap: 24px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.row-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.grid-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

/* ---- Layout ----------------------------------------------------------- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.container-wide { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.page { padding-top: 40px; padding-bottom: 64px; }
.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.split-main { flex: 999 1 600px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.split-side { flex: 1 1 300px; display: flex; flex-direction: column; gap: 20px; }

.site-header { background: #fff; border-bottom: 1px solid var(--line); }
.site-header .container { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding-top: 16px; padding-bottom: 16px; }
.logo-placeholder { display: flex; align-items: center; justify-content: center; min-width: 168px; height: 44px; padding: 0 12px; border: 1.5px dashed #AEB8C3; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted-2); letter-spacing: .04em; }
.site-nav { display: flex; flex-wrap: wrap; gap: 24px; font-weight: 500; }
.site-nav a { color: var(--ink-2); text-decoration: none; }
.site-nav a.active { color: var(--accent); border-bottom: 2px solid var(--accent); padding-bottom: 2px; }

.admin-bar { background: var(--ink); color: #fff; }
.admin-bar .container-wide { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding-top: 14px; padding-bottom: 14px; }
.admin-bar a { color: #fff; }
.admin-bar .who { color: #C4CDD6; font-size: 14px; }
.admin-bar .logo-placeholder { min-width: 120px; height: 36px; border-color: #6B7A89; color: #C4CDD6; font-size: 12px; }

/* ---- Type ------------------------------------------------------------- */
.eyebrow { font-family: var(--mono); font-size: 13px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.title-xl { font-size: 40px; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; }
.title-lg { font-size: 32px; font-weight: 700; }
.lede { margin: 0; max-width: 680px; font-size: 17px; line-height: 1.55; color: var(--muted); }
.section-title { font-size: 20px; font-weight: 600; }
.overline { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted-2); }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 8px; font-size: 14px; color: var(--muted); }
.fine { font-size: 13px; color: var(--muted); line-height: 1.5; margin: 0; }

/* ---- Surfaces --------------------------------------------------------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.card-flush { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.panel { background: var(--soft); border-radius: 10px; padding: 18px; }
.divider { border-top: 1px solid var(--line-3); padding-top: 16px; }

/* ---- Form controls ---------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.label .opt { font-weight: 400; color: var(--muted-2); }
.req { color: var(--danger-text); }
.hint { font-size: 13px; color: var(--muted-2); }
.error, .validation-message { font-size: 13px; color: var(--danger-text); }
.input, .select, .textarea { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--field); border-radius: 8px; background: #fff; font-size: 15px; }
.textarea { padding: 10px 12px; line-height: 1.5; resize: vertical; }
.input.mono { font-family: var(--mono); }
.input.invalid, .textarea.invalid, .select.invalid { border-color: var(--danger); }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 16px; top: 16px; }
.search-input { height: 52px; padding-left: 48px; font-size: 16px; border-radius: 10px; }
fieldset { margin: 0; padding: 0; border: 0; }
legend { padding: 0; margin-bottom: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid transparent; font-size: 15px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(0.95); }
.btn-sm { min-height: 40px; padding: 0 12px; font-size: 14px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: #fff; color: var(--ink-2); border-color: var(--field); font-weight: 500; }
.btn-outline { background: #fff; color: var(--accent); border-color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-outline { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn-ghost { background: transparent; color: var(--muted); font-weight: 500; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--line-3); }
.icon-btn.danger { color: var(--danger-text); }

.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--field); background: #fff; color: var(--ink-2); font-weight: 500; cursor: pointer; }
.seg button[aria-pressed="true"] { border: 1.5px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, white); color: var(--ink); font-weight: 600; }
.check-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border: 1px solid var(--field); border-radius: 8px; background: #fff; font-size: 14px; cursor: pointer; }
.check-chip:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, white); }
.check-chip input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

/* ---- Badges & chips --------------------------------------------------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.badge-routine { background: #EEF1F4; color: #334150; }
.badge-stat { background: #FDEDE2; color: #93390A; }
.badge-specialty { background: #EEE9FB; color: #4A2F93; }
.badge-accent { background: color-mix(in srgb, var(--accent) 10%, white); color: var(--ink); }
.badge-neutral { background: #EEF1F4; color: #334150; font-weight: 500; }
.genes { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.gene { font-family: var(--mono); font-size: 13px; font-weight: 500; padding: 2px 8px; border-radius: 6px; background: #F1F3F5; color: var(--ink); cursor: default; }
.gene-table th:last-child, .gene-table td:last-child { text-align: left; white-space: normal; }
.gene-details > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--accent); }
.gene-details[open] > summary { margin-bottom: 10px; }
.match-reason { align-self: flex-start; font-size: 12px; font-weight: 500; color: var(--muted); background: #F1F3F5; border-radius: 6px; padding: 1px 8px; }
.days { display: inline-flex; flex-wrap: wrap; gap: 3px; }
.day { min-width: 32px; padding: 3px 0; text-align: center; border-radius: 6px; font-size: 12px; font-weight: 600; background: #F1F3F5; color: #66727F; text-decoration: line-through; text-decoration-color: #A9B3BD; }
.day.on { background: color-mix(in srgb, var(--accent) 14%, white); color: var(--ink); text-decoration: none; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, white); }
.badge-review { background: #FBF3DC; color: #6B4F00; font-size: 12px; padding: 2px 8px; }
.review-tile { text-align: left; cursor: pointer; border-color: #E9D28A; background: #FFFBEE; font: inherit; }
.review-tile:hover { border-color: var(--accent); }
.review-banner { border: 1px solid #E9D28A; background: #FFFBEE; border-radius: 12px; padding: 20px 24px; display: flex; flex-direction: column; gap: 12px; }
.review-banner ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-published { color: var(--ok); }
.status-draft { color: var(--warn); }
.status-pill { padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.status-pill.status-published { background: #E6F4EC; }
.status-pill.status-draft { background: #FBF3DC; }
.code-chip { display: inline-flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: 13px; padding: 2px 8px; border: 1px solid var(--field); border-radius: 6px; background: #F8FAFC; }
.code-chip.removable { height: 36px; padding: 0 4px 0 12px; font-size: 14px; font-weight: 500; border-radius: 8px; }
.code-chip.removable button { width: 28px; height: 28px; }

/* ---- Directory results ------------------------------------------------ */
.result { border-bottom: 1px solid var(--line-2); }
.result:last-child { border-bottom: 0; }
.result > summary { list-style: none; cursor: pointer; padding: 20px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px; }
.result > summary::-webkit-details-marker { display: none; }
.result > summary:hover { background: #F8FAFC; }
.result-name { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.result-name strong { font-size: 17px; font-weight: 600; line-height: 1.35; }
.result-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.result-col { display: flex; flex-direction: column; gap: 6px; }
.result-cpt { flex: 0 1 200px; }
.result-tat { flex: 0 0 120px; }
.result-level { flex: 0 0 104px; }
.chev { flex: 0 0 20px; transition: transform .15s; }
.result[open] .chev { transform: rotate(180deg); }
.result-body { padding: 4px 24px 28px; display: flex; flex-direction: column; gap: 20px; }
.kv { display: grid; grid-template-columns: 104px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.empty { padding: 56px 24px; text-align: center; }

.def-table { display: grid; grid-template-columns: minmax(140px, 200px) 1fr; border-top: 1px solid var(--line-2); }
.def-table dt, .def-table dd { margin: 0; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.def-table dt { padding-right: 16px; color: var(--muted); font-weight: 500; }
.stab { display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: 10px; background: var(--soft); }
.stab.preferred { background: color-mix(in srgb, var(--accent) 8%, white); border: 1.5px solid var(--accent); }
.stab-value { font-size: 20px; font-weight: 600; margin-top: 4px; }
.stab-value.bad { color: var(--danger-text); }
.glance { display: flex; flex-direction: column; gap: 14px; }
.glance > div { display: flex; justify-content: space-between; gap: 12px; }
.glance > div > span:first-child { color: var(--muted); }
.glance > div > span:last-child { text-align: right; }
.related-card { display: flex; flex-direction: column; gap: 10px; padding: 18px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); text-decoration: none; }
.related-card:hover { border-color: var(--accent); filter: none; }

/* ---- Admin ------------------------------------------------------------ */
.stat-tile { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.stat-tile strong { font-size: 28px; }
.toolbar { padding: 16px 20px; display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; border-bottom: 1px solid var(--line-2); }
.table-scroll { overflow-x: auto; }
.table { width: 100%; min-width: 980px; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; padding: 12px; background: var(--soft); color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.table td { padding: 14px 12px; border-top: 1px solid var(--line-2); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; text-align: right; white-space: nowrap; }
.table tbody tr:hover { background: #F8FAFC; }
.table .name { font-weight: 600; font-size: 15px; }
.table-foot { padding: 14px 20px; border-top: 1px solid var(--line-2); font-size: 14px; color: var(--muted); }

.link-list { border: 1px solid var(--line-2); border-radius: 10px; }
.link-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line-3); }
.link-row .info { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.link-row .select { flex: 0 1 220px; width: auto; min-height: 40px; font-size: 14px; }
.link-context { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.link-context .badge { font-size: 12px; padding: 2px 8px; }
.link-add { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 14px; background: #F8FAFC; border-radius: 0 0 10px 10px; }
.suggest-box { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 10px; border: 1px dashed #AEB8C3; }
.suggest-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 14px; background: #fff; border: 1px solid var(--line-2); border-radius: 8px; }
.suggest-row .info { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(21,32,43,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { width: 100%; max-width: 440px; background: #fff; border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 48px rgba(21,32,43,.3); }
.toast { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); display: flex; align-items: center; gap: 16px; padding: 12px 16px 12px 20px; border-radius: 10px; background: var(--ink); color: #fff; box-shadow: 0 8px 24px rgba(21,32,43,.25); z-index: 40; }
.toast button { min-height: 36px; padding: 0 12px; border: 0; border-radius: 6px; background: var(--ink-2); color: #fff; font-weight: 600; cursor: pointer; }
.alert { padding: 12px 16px; border-radius: 8px; background: #FDECEA; color: #7A1D12; font-size: 14px; }
.saved-note { font-size: 14px; color: var(--ok); font-weight: 500; }

/* ---- Blazor defaults -------------------------------------------------- */
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; padding: 12px 20px; background: #FFF4CE; box-shadow: 0 -1px 2px rgba(0,0,0,.2); z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 12px; top: 10px; }
.blazor-error-boundary { padding: 1rem; background: #b32121; color: #fff; }
.blazor-error-boundary::after { content: "An error has occurred."; }

@media print {
    .site-header, .no-print, #blazor-error-ui { display: none !important; }
    body { background: #fff; }
}

/* ---- Embedded in a lab's website (iframe) ---- */
body:has(.embed-root) { background: transparent; }
.embed-root .container { max-width: none; padding: 0 16px; }
.embed-root .page { padding-top: 16px; padding-bottom: 24px; }
/* ---- Lab logos: one consistent size, proportions kept (wide logos are capped by width, tall ones by height) ---- */
.lab-logo { display: block; width: auto; height: auto; max-height: 48px; max-width: min(260px, 55vw); object-fit: contain; }
@media (max-width: 600px) { .lab-logo { max-height: 40px; } }
.logo-preview { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
/* ---- Lab theme colors (set per lab on Lab details; each falls back to the default look) ----
   --accent    main color: buttons, links, selected menu item, labels, focus outlines
   --secondary header bar behind the logo, hover highlight on results (--header-ink: readable text on it)
   --p1..--p5  accent palette: Routine, STAT and Specialty badges; days performed and preferred temperature;
               match and related-test labels
   Badge text is the palette color darkened, on a light tint of it, so any color stays readable. */
.site-header { background: var(--secondary, #fff); }
.site-header .site-nav a { color: var(--header-ink, var(--ink-2)); }
.site-header .site-nav a.active { color: var(--header-ink, var(--accent)); border-bottom-color: var(--header-ink, var(--accent)); }
.site-header .logo-placeholder { color: var(--header-ink, var(--muted-2)); border-color: color-mix(in srgb, var(--header-ink, #AEB8C3) 55%, transparent); }
.result > summary:hover { background: color-mix(in srgb, var(--secondary, #C9D4E0) 9%, white); }
.badge-routine { background: color-mix(in srgb, var(--p1, #64748B) 14%, white); color: color-mix(in srgb, var(--p1, #64748B) 55%, black); }
.badge-stat { background: color-mix(in srgb, var(--p2, #C2410C) 14%, white); color: color-mix(in srgb, var(--p2, #C2410C) 55%, black); }
.badge-specialty { background: color-mix(in srgb, var(--p3, #6D28D9) 14%, white); color: color-mix(in srgb, var(--p3, #6D28D9) 55%, black); }
.day.on { background: color-mix(in srgb, var(--p4, var(--accent)) 14%, white); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--p4, var(--accent)) 45%, white); }
.stab.preferred { background: color-mix(in srgb, var(--p4, var(--accent)) 8%, white); border-color: var(--p4, var(--accent)); }
.badge-accent { background: color-mix(in srgb, var(--p5, var(--accent)) 12%, white); }
.match-reason { background: color-mix(in srgb, var(--p5, #8A96A3) 12%, white); color: color-mix(in srgb, var(--p5, #4A5868) 60%, black); }