:root {
    --bg: #f6f7f3;
    --surface: #ffffff;
    --surface-2: #eef4ef;
    --ink: #16211f;
    --muted: #69736f;
    --line: #dce3dd;
    --brand: #167d72;
    --brand-2: #2b6cb0;
    --accent: #c45b3c;
    --warning: #b7791f;
    --danger: #b83232;
    --ok: #2f855a;
    --shadow: 0 14px 35px rgba(29, 43, 38, .08);
}

[hidden] {
    display: none !important;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}
a { color: inherit; text-decoration: none; }

.no-lucide-icon {
    display: inline-flex;
    width: 1em;
    height: 1em;
    align-items: center;
    justify-content: center;
    font-style: normal;
    font-weight: 900;
    line-height: 1;
}
button, input, select, textarea { font: inherit; }
code {
    background: #edf2f0;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 1px 5px;
}

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: #fbfcf9;
    border-right: 1px solid var(--line);
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 20px;
    padding: 8px 10px;
}
.brand img { width: 32px; height: 32px; }
.nav { display: grid; gap: 4px; overflow-y: auto; padding-right: 3px; }
.nav a, .sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 650;
}
.nav a svg, .sidebar-footer svg, .topbar-actions svg, .button svg, .icon-button svg { width: 18px; height: 18px; flex: 0 0 auto; }
.nav a.active, .nav a.section-active, .nav a:hover, .sidebar-footer a:hover { background: #e6f1ee; color: var(--brand); }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; }

.main {
    min-width: 0;
    padding: 24px;
    padding-bottom: 90px;
}
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}
.topbar h1 {
    margin: 2px 0 0;
    font-size: 28px;
    line-height: 1.15;
}
.eyebrow {
    margin: 0;
    color: var(--brand);
    font-weight: 800;
    text-transform: uppercase;
    font-size: 12px;
}
.topbar-actions, .button-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--muted);
}
.review-mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: -6px 0 18px;
    padding: 8px 12px;
    border: 1px solid var(--brand);
    border-radius: 999px;
    background: #e6f1ee;
    color: var(--brand);
    font-weight: 850;
}
.review-mode-badge svg { width: 16px; height: 16px; }
.review-sidebar-note {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--brand);
    font-weight: 800;
}
.readonly-panel {
    border-color: #b9d9d3;
    background: #f4faf8;
}
.inline-readonly {
    padding: 14px;
    margin-top: 12px;
}
.readonly-note {
    display: inline-flex;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f4faf8;
    color: var(--muted);
    font-weight: 700;
}
.token-panel input[readonly] {
    width: 100%;
    margin: 8px 0 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7faf8;
    color: var(--ink);
}
.button, .icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    border: 1px solid var(--brand);
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    font-weight: 800;
    padding: 9px 14px;
    cursor: pointer;
}
.button-secondary { background: var(--brand-2); border-color: var(--brand-2); }
.button-ghost { background: var(--surface); color: var(--brand); }
.button-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.icon-button { width: 40px; padding: 0; background: var(--surface); color: var(--brand); }
.button:hover, .icon-button:hover { filter: brightness(.96); }

.panel, .metric-card, .algorithm-card, .workspace-hero {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.panel {
    padding: 18px;
    margin-bottom: 18px;
}
.panel h2, .panel h3 { margin: 0 0 10px; }
.panel p { color: var(--muted); line-height: 1.55; }
.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}
.panel-head p { margin: 4px 0 0; }
.patient-hero .data-grid {
    margin-top: 16px;
}
.doctor-route-panel {
    background: #fbfcf9;
}
.route-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}
.route-steps div {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 72px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}
.route-steps strong {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    flex: 0 0 auto;
}
.route-steps span {
    color: var(--ink);
    font-weight: 700;
    line-height: 1.35;
}
.patient-study-list {
    display: grid;
    gap: 14px;
}
.patient-study-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 16px;
}
.patient-study-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}
.patient-study-main h3 {
    margin: 0 0 4px;
}
.patient-study-main p,
.patient-study-summary {
    margin: 0;
    color: var(--muted);
}
.patient-study-summary {
    padding: 10px 0 0;
    border-top: 1px solid var(--line);
}
.patient-study-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}
.patient-study-actions .button {
    min-height: 36px;
    padding: 7px 11px;
}
.workspace-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    margin-bottom: 18px;
    background: #fbfcf9;
}
.workspace-hero h2 { margin: 4px 0; font-size: 25px; }
.workspace-hero p { margin: 0; color: var(--muted); }
.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.metric-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px;
    min-height: 118px;
}
.metric-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #e6f1ee;
    color: var(--brand);
}
.metric-card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
}
.metric-card strong {
    display: block;
    margin-top: 5px;
    font-size: 25px;
    line-height: 1.1;
}
.metric-card small { font-size: 14px; color: var(--muted); }
.metric-card p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }

.workspace-grid {
    display: grid;
    gap: 18px;
}
.workspace-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.workspace-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
.chart-panel { margin-bottom: 0; }
.chart-panel .panel-head {
    align-items: flex-start;
}
.chart-expand {
    flex: 0 0 auto;
}
.chart-reset {
    flex: 0 0 auto;
}
.chart-box {
    position: relative;
    height: 280px;
    min-height: 280px;
}
.chart-box canvas { width: 100% !important; height: 100% !important; }
.chart-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    text-align: center;
    color: var(--muted);
    background: #fbfcf9;
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 18px;
    line-height: 1.45;
}
.chart-modal-open {
    overflow: hidden;
}
.chart-modal {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 1000;
}
.chart-modal.open {
    display: block;
}
.chart-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(12, 20, 20, .58);
}
.chart-modal-dialog {
    position: absolute;
    inset: 32px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .22);
    overflow: hidden;
}
.chart-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}
.chart-modal-head h2 {
    margin: 0;
    font-size: 21px;
}
.chart-modal-body {
    flex: 1;
    min-height: 0;
    padding: 16px;
    overflow: auto;
}
.chart-detail-panel {
    box-shadow: none;
    border: 0;
    padding: 0;
}
.chart-box-detail {
    height: min(68vh, 720px);
    min-height: 520px;
}
@media (max-width: 760px) {
    .chart-modal-dialog {
        inset: 10px;
    }
    .chart-modal-body {
        padding: 10px;
    }
    .chart-box-detail {
        min-height: 430px;
    }
}
.actogram-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0 0 10px;
}
.actogram-controls select {
    width: auto;
    min-width: 190px;
    min-height: 34px;
    padding: 6px 9px;
}
.actogram-toggle {
    display: inline-flex;
    grid-template-columns: none;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 9px;
    background: #fbfcf9;
    color: var(--ink);
    font-size: 12px;
}
.actogram-toggle input {
    width: auto;
    margin: 0;
}
.method-note {
    border-left: 3px solid var(--accent);
    padding-left: 10px;
    color: var(--muted);
    font-size: 14px;
}

.data-grid, .index-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}
.data-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.data-grid div, .index-grid div {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    min-height: 70px;
}
.data-grid span, .index-grid span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}
.data-grid small, .index-grid small {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}
.data-grid strong, .index-grid strong {
    display: block;
    margin-top: 6px;
    font-size: 19px;
}
.big-number {
    font-size: 52px;
    font-weight: 850;
    color: var(--brand);
}
.big-number small { font-size: 18px; color: var(--muted); }

.table-wrap { overflow-x: auto; }
.intermediate-table table {
    min-width: 640px;
}
.technical-summary {
    display: grid;
    grid-template-columns: minmax(120px, 210px) minmax(0, 1fr);
    gap: 5px 10px;
    margin: 0;
}
.technical-summary dt {
    color: var(--muted);
    font-weight: 850;
}
.technical-summary dd {
    margin: 0;
}
.technical-data {
    margin-top: 8px;
}
.technical-data summary {
    cursor: pointer;
    color: var(--brand-2);
    font-weight: 850;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border: 1px solid var(--brand-2);
    border-radius: 8px;
    background: #f7fbf8;
}
.technical-data pre {
    max-height: 260px;
    overflow: auto;
    margin: 8px 0 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7faf7;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--muted);
}
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}
th, td {
    padding: 11px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}
th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}
.table-link { color: var(--brand-2); font-weight: 800; }
.table-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.inline-form {
    display: inline-flex;
    margin: 0;
}
.danger-link {
    border: 0;
    background: transparent;
    color: var(--danger);
    font: inherit;
    font-weight: 800;
    padding: 0;
    cursor: pointer;
}
.danger-link:hover { text-decoration: underline; }
.empty { color: var(--muted); text-align: center; }
.status {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #edf2f0;
    color: var(--muted);
    font-weight: 800;
    font-size: 12px;
}
.status.analyzed, .status.completed { background: #e6f4ec; color: var(--ok); }
.status.error { background: #fae4e4; color: var(--danger); }
.status.included, .status.main-sleep { background: #e6f4ec; color: var(--ok); }
.status.yes, .status.usable { background: #e6f4ec; color: var(--ok); }
.status.no, .status.limited { background: #fff3d8; color: var(--warning); }
.status.excluded, .status.low-confidence, .status.excluded-off-wrist { background: #fff3d8; color: var(--warning); }
.status.short-rest { background: #edf2f0; color: var(--muted); }

.alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 14px;
    border: 1px solid var(--line);
    background: #eef4f8;
}
.alert svg { width: 18px; height: 18px; flex: 0 0 auto; }
.alert-success { background: #e6f4ec; color: #1f6f46; }
.alert-danger { background: #fae4e4; color: var(--danger); }
.alert-warning { background: #fff3d8; color: var(--warning); }

.disclaimer {
    display: flex;
    gap: 12px;
    background: #fffaf0;
    border-color: #ead7a4;
}
.disclaimer svg { color: var(--warning); flex: 0 0 auto; }
.disclaimer p { margin: 0; color: #5f4a18; }
.clean-list {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
    line-height: 1.6;
}
.feature-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.feature-list span {
    background: #edf2f0;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 10px;
    font-weight: 800;
    font-size: 13px;
}

.form-stack, .form-grid {
    display: grid;
    gap: 12px;
}
.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.form-grid .span-2 { grid-column: span 2; }
label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-weight: 800;
    font-size: 13px;
}
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 10px 11px;
    outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22, 125, 114, .12); }
textarea { resize: vertical; }
.upload-form input[type=file] { padding: 9px; }

.pattern-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.pattern-card {
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand-2);
    border-radius: 8px;
    padding: 14px;
    background: #fbfcf9;
}
.pattern-card.high { border-left-color: var(--danger); }
.pattern-card.moderate { border-left-color: var(--warning); }
.pattern-card.mild { border-left-color: var(--brand); }
.pattern-card.info { border-left-color: var(--brand-2); }
.pattern-card span {
    color: var(--muted);
    text-transform: uppercase;
    font-weight: 850;
    font-size: 11px;
}
.pattern-card h3 { margin: 6px 0 8px; }
.pattern-card p { margin: 7px 0; }
.pattern-card small { color: var(--muted); }
.guidance-details {
    margin-top: 10px;
    border-top: 1px solid var(--line);
    padding-top: 8px;
}
.guidance-details summary {
    cursor: pointer;
    color: var(--brand-2);
    font-weight: 850;
}
.guidance-details .table-wrap {
    margin-top: 8px;
}
.se-explanation {
    margin: 14px 0 0;
}
.se-explanation p {
    margin: 6px 0;
}
.summary-tags, .report-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
.summary-tags span, .report-badges span {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #edf2f0;
    color: var(--ink);
    font-weight: 800;
    font-size: 12px;
}
.compact-details {
    margin-top: 6px;
}
.mini-table {
    min-width: 840px;
    font-size: 12px;
}
.mini-table th, .mini-table td {
    padding: 8px;
}
.inline-panels {
    margin-top: 14px;
}
.inline-panels article {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fbfcf9;
}
.inline-panels h3 {
    margin: 0 0 10px;
    font-size: 16px;
}

.algorithm-list { display: grid; gap: 10px; }
.algorithm-card { overflow: hidden; }
.algorithm-toggle {
    width: 100%;
    border: 0;
    background: #fff;
    color: var(--ink);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 52px;
    padding: 12px 14px;
    cursor: pointer;
    font-weight: 850;
}
.algorithm-body {
    display: none;
    padding: 0 14px 14px;
    color: var(--muted);
}
.algorithm-card.open .algorithm-body { display: block; }
.algorithm-body dl {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 8px 14px;
}
.algorithm-body dt { font-weight: 850; color: var(--ink); }
.algorithm-body dd { margin: 0; }
.raw-channel-cards {
    display: none;
}
.channel-name {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-weight: 850;
    color: var(--ink);
}
.channel-name svg {
    width: 16px;
    height: 16px;
    color: var(--brand);
    flex: 0 0 auto;
}
.raw-channel-cards details {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcf9;
    padding: 10px 12px;
}
.raw-channel-cards details + details {
    margin-top: 8px;
}
.raw-channel-cards summary {
    cursor: pointer;
}
.raw-channel-cards p {
    margin: 8px 0;
}
.tabulator-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 12px 0 10px;
}
.tabulator-toolbar strong {
    margin-right: auto;
}
.tabulator-toolbar input,
.tabulator-toolbar select {
    width: auto;
    min-width: 170px;
    min-height: 36px;
    padding: 7px 9px;
}
.tabulator-export {
    min-height: 36px;
    padding: 7px 10px;
}
.tabulator-source-hidden {
    display: none;
}
.somnoacti-tabulator {
    margin-bottom: 14px;
}
.somnoacti-tabulator .tabulator {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}
.somnoacti-tabulator .tabulator-header {
    background: #eef4ef;
    border-bottom-color: var(--line);
}
.somnoacti-tour-step {
    max-width: 420px;
}
.tippy-box {
    line-height: 1.45;
}
.report-pattern-wrap {
    margin-top: 12px;
}
.report-pattern-table {
    min-width: 820px;
}
.report-pattern-table small {
    color: var(--muted);
}
.index-technical-name {
    color: var(--muted);
    font-weight: 650;
}
.report-pattern-cards {
    display: grid;
    gap: 12px;
    margin-top: 12px;
}
.report-pattern-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcf9;
    padding: 14px;
    break-inside: avoid;
    page-break-inside: avoid;
}
.report-pattern-card div + div {
    margin-top: 8px;
}
.report-pattern-card span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}
.report-pattern-card strong {
    color: var(--brand-2);
}
.report-pattern-card p {
    margin: 2px 0 0;
    font-size: 13px;
    line-height: 1.45;
}
.nav-section-label {
    margin: 14px 12px 6px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 850;
    line-height: 1.25;
    text-transform: uppercase;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 22px;
    background: #eef4ef;
}
.login-card {
    width: min(430px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 28px;
}
.login-logo { width: 52px; height: 52px; }
.login-card h1 { margin: 10px 0 4px; }
.login-card p, .login-card small { color: var(--muted); }

.report-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.report-document {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 30px;
    box-shadow: var(--shadow);
}
.report-header {
    display: flex;
    gap: 16px;
    align-items: center;
    border-bottom: 1px solid var(--line);
    padding-bottom: 16px;
    margin-bottom: 18px;
}
.report-header img { width: 54px; height: 54px; }
.report-document h1 { margin: 0 0 6px; font-size: 26px; }
.report-document h2 { margin: 22px 0 8px; font-size: 18px; }
.report-document p, .report-document li { line-height: 1.55; }
.report-indexes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.report-title-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
.report-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 12px 0;
}
.report-summary-grid div {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7faf8;
    padding: 12px;
}
.report-summary-grid span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
}
.report-summary-grid strong {
    display: block;
    margin-top: 5px;
    font-size: 20px;
}
.report-summary-grid small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}
.report-warning {
    border-left: 3px solid var(--accent);
    background: #fffaf0;
    padding: 10px 12px;
    color: #5f4a18;
}
.short-doctor-report {
    border: 2px solid var(--brand);
    border-radius: 8px;
    background: #f9fcfb;
    padding: 18px;
    margin-bottom: 20px;
}
.short-report-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 10px;
}
.short-report-kicker {
    margin: 0 0 3px;
    color: var(--brand);
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
}
.short-doctor-report h2 {
    margin: 0;
    font-size: 21px;
}
.short-doctor-report h3 {
    margin: 0 0 8px;
    font-size: 14px;
    color: var(--ink);
}
.short-report-status {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 7px 11px;
    border-radius: 999px;
    font-weight: 850;
    white-space: nowrap;
}
.short-report-status.good {
    background: #e6f1ee;
    color: var(--ok);
    border: 1px solid #b9d9d3;
}
.short-report-status.limited {
    background: #fffaf0;
    color: var(--warning);
    border: 1px solid #ead7a4;
}
.short-report-status.bad {
    background: #fef6f6;
    color: var(--danger);
    border: 1px solid #ecc4c4;
}
.short-report-reason {
    margin: 0 0 14px;
    color: var(--ink);
}
.short-report-priority {
    margin: 0 0 14px;
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 13px;
}
.short-report-priority.high {
    background: #fef6f6;
    border: 1px solid #ecc4c4;
    color: #7b2424;
}
.short-report-priority.moderate {
    background: #fffaf0;
    border: 1px solid #ead7a4;
    color: #6a4d12;
}
.short-report-priority.low {
    background: #e6f1ee;
    border: 1px solid #b9d9d3;
    color: var(--ok);
}
.short-report-categories {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}
.short-category-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 12px;
}
.short-category-card > p {
    margin: -3px 0 8px;
    color: var(--muted);
    font-size: 12px;
}
.short-report-list li.high,
.short-report-list li.moderate,
.short-report-list li.mild,
.short-report-list li.good,
.short-report-list li.info {
    padding-left: 4px;
}
.short-report-list li.high { color: var(--danger); }
.short-report-list li.moderate { color: #7a5514; }
.short-report-list li.mild { color: var(--brand); }
.short-report-list li.good { color: var(--ok); }
.short-report-list li.info { color: var(--muted); }
.short-report-list small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
}
.short-report-layout {
    display: grid;
    grid-template-columns: 1.15fr 1fr 1fr;
    gap: 12px;
}
.short-report-layout > div,
.short-report-metrics div {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 12px;
}
.short-report-list {
    margin: 0;
    padding-left: 18px;
}
.short-report-list li {
    margin: 5px 0;
    line-height: 1.42;
}
.short-report-layout.compact {
    grid-template-columns: .95fr 1fr 1fr;
}
.short-report-compare {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcf9;
    padding: 12px;
    margin-top: 12px;
}
.short-report-compare h3 {
    margin: 0 0 4px;
}
.short-report-compare p {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 12px;
}
.short-report-compare div {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.short-report-compare span {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    padding: 5px 8px;
    font-size: 12px;
    font-weight: 750;
}
.context-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    width: 100%;
    max-width: 860px;
}
.context-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 14px;
    min-width: 0;
}
.context-card legend {
    padding: 0 6px;
    color: var(--ink);
    font-weight: 900;
}
.context-card-wide {
    grid-column: auto;
}
.clinical-context-form .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
}
.clinical-context-form .button-row {
    align-items: flex-start;
    max-width: 860px;
}
.clinical-context-panel {
    clear: both;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}
.clinical-context-panel .panel-head,
.clinical-context-panel .clinical-context-form,
.clinical-context-panel .context-form-grid {
    min-width: 0;
}
.clinical-context-panel .context-summary-table,
.clinical-context-panel .method-note,
.clinical-context-panel > p {
    max-width: 980px;
}
.clinical-context-panel textarea {
    min-height: 120px;
}
.check-item {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 8px 0;
    color: var(--ink);
    font-size: 13px;
    font-weight: 750;
    line-height: 1.35;
}
.check-item input {
    width: 18px;
    height: 18px;
    margin-top: 1px;
    accent-color: var(--brand);
    flex: 0 0 auto;
}
.context-summary-table {
    margin-bottom: 14px;
}
.context-match-block {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcf9;
    padding: 12px;
    margin-top: 12px;
}
.context-match-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}
.context-match-head h3 {
    margin: 0;
}
.context-match-head span {
    border: 1px solid #b9d9d3;
    border-radius: 999px;
    background: #e6f1ee;
    color: var(--ok);
    padding: 5px 8px;
    font-size: 12px;
    font-weight: 850;
    white-space: nowrap;
}
.context-note {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 13px;
}
.context-match-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.context-match-grid > div {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 10px;
}
.context-match-grid h4 {
    margin: 0 0 6px;
    font-size: 13px;
}
.context-match-grid p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}
.tour-fallback-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    display: grid;
    place-items: end center;
    padding: 24px;
    background: rgba(12, 18, 17, .34);
}
.tour-fallback-card {
    position: relative;
    z-index: 10000;
    width: min(520px, calc(100vw - 32px));
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 22px 60px rgba(29, 43, 38, .24);
    padding: 18px;
}
.tour-fallback-card h3 {
    margin: 0 34px 8px 0;
    font-size: 19px;
}
.tour-fallback-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}
.tour-fallback-count {
    margin-bottom: 8px;
    color: var(--brand);
    font-size: 12px;
    font-weight: 900;
}
.tour-fallback-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}
.tour-fallback-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}
.tour-fallback-focus {
    position: relative;
    z-index: 9999;
    outline: 3px solid rgba(22, 125, 114, .55);
    outline-offset: 4px;
}
.short-report-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}
.short-report-metrics span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.3;
}
.short-report-metrics strong {
    display: block;
    margin-top: 5px;
    font-size: 18px;
}
.short-report-glossary {
    margin-top: 12px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: #fbfcf9;
    padding: 10px 12px;
}
.short-report-glossary summary {
    cursor: pointer;
    color: var(--brand);
    font-weight: 850;
}
.short-report-glossary.patient-summary {
    background: #f0f6fb;
}
.short-report-glossary ul {
    margin: 8px 0 0;
    padding-left: 18px;
}
.report-audit {
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 10px 0;
    margin: 8px 0 14px;
    color: var(--muted);
    font-size: 12px;
}
.report-audit h2 {
    margin: 0 0 4px;
    font-size: 13px;
    color: var(--muted);
}
.report-audit p {
    margin: 0;
}
.short-glossary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}
.short-glossary-grid div {
    border-top: 1px solid var(--line);
    padding-top: 8px;
}
.short-glossary-grid strong {
    display: block;
    color: var(--brand);
}
.short-glossary-grid span {
    display: block;
    font-weight: 750;
}
.short-glossary-grid p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.mobile-nav { display: none; }

/* Doctor view: cleaner metric cards */
.doctor-metrics .metric-card {
    min-height: 100px;
    border-left: 3px solid var(--brand);
}
.doctor-metrics .metric-card strong {
    font-size: 22px;
}

/* Doctor view: pattern cards with better readability */
#patterns .pattern-card,
#recommendations .pattern-card {
    padding: 16px;
}
#patterns .pattern-card h3,
#recommendations .pattern-card h3 {
    font-size: 15px;
    line-height: 1.35;
}
.pattern-finding {
    margin: 6px 0;
    font-size: 13px;
    color: var(--ink);
    line-height: 1.45;
}
.pattern-finding strong {
    color: var(--muted);
    font-size: 12px;
}
.pattern-metrics {
    margin: 4px 0;
    font-size: 13px;
    color: var(--brand);
    font-weight: 700;
}
.pattern-interpretation {
    margin: 6px 0;
    font-size: 13px;
    color: var(--muted);
    line-height: 1.45;
    font-style: italic;
}
.pattern-action {
    margin: 8px 0 4px;
    padding: 8px 10px;
    background: #e6f1ee;
    border-radius: 6px;
    font-size: 13px;
    color: var(--brand);
    line-height: 1.45;
}
.pattern-action strong {
    color: var(--brand);
}
.pattern-patient {
    margin: 4px 0;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
    border-top: 1px solid var(--line);
    padding-top: 6px;
}
.pattern-clinical {
    margin: 6px 0;
    font-size: 13px;
    color: var(--brand);
    line-height: 1.45;
    background: #e6f1ee;
    padding: 6px 8px;
    border-radius: 4px;
}
.pattern-clinical strong {
    color: var(--brand);
}
.pattern-limitation {
    display: block;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--line);
    font-size: 11px;
    color: var(--muted);
    line-height: 1.4;
    font-style: italic;
}

/* Doctor view: cleaner summary tags */
.summary-tags span {
    background: var(--surface);
    border: 1px solid var(--brand);
    color: var(--brand);
    font-weight: 700;
}

/* Doctor view: recommendation severity colors */
.pattern-card.high { border-left: 4px solid var(--danger); background: #fef6f6; }
.pattern-card.moderate { border-left: 4px solid var(--warning); background: #fffbf0; }
.pattern-card.mild { border-left: 4px solid var(--brand); background: #f4faf8; }
.pattern-card.info { border-left: 4px solid var(--brand-2); background: #f0f6fb; }

/* Doctor view: cleaner explanation grid */
.explain-grid div {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}
.explain-grid span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    text-transform: uppercase;
}
.explain-grid strong {
    display: block;
    margin-top: 4px;
    font-size: 20px;
}

/* Doctor view: prominent conclusion section */
#conclusion {
    border: 2px solid var(--brand);
    background: #f9fcfb;
}
#conclusion h2 {
    color: var(--brand);
}

/* Doctor view: cleaner data-grid cells */
.data-grid div {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

/* Doctor view: role badge in hero */
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}
.role-badge.analyst {
    background: #e6f1ee;
    color: var(--brand);
    border: 1px solid var(--brand);
}
.role-badge.doctor {
    background: #f0f6fb;
    color: var(--brand-2);
    border: 1px solid var(--brand-2);
}

/* Enhanced pattern cards — workspace */
.pattern-clinical {
    background: #f0f7f5;
    border: 1px solid #c4ddd8;
    border-radius: 6px;
    padding: 8px 10px;
    margin: 8px 0;
}
.pattern-action {
    background: #f0f6fb;
    border: 1px solid #b8d4e8;
    border-radius: 6px;
    padding: 8px 10px;
    margin: 8px 0;
}
.pattern-patient {
    background: #fdf6f0;
    border: 1px solid #e8d4b8;
    border-radius: 6px;
    padding: 8px 10px;
    margin: 8px 0;
}
.pattern-confidence {
    color: var(--muted);
    font-size: 12px;
    margin-top: 6px;
}

/* Report pattern cards — shared */
.report-pattern-cards {
    display: grid;
    gap: 14px;
    margin-top: 14px;
}
.report-pattern-card {
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand-2);
    border-radius: 8px;
    padding: 16px;
    background: #fbfcf9;
}
.report-pattern-card.high { border-left-color: var(--danger); background: #fef6f6; }
.report-pattern-card.moderate { border-left-color: var(--warning); background: #fffbf0; }
.report-pattern-card.mild { border-left-color: var(--brand); background: #f4faf8; }
.report-pattern-card.info { border-left-color: var(--brand-2); background: #f0f6fb; }
.report-pattern-header {
    margin-bottom: 10px;
}
.report-pattern-level {
    display: inline-block;
    color: var(--muted);
    text-transform: uppercase;
    font-weight: 850;
    font-size: 11px;
    margin-bottom: 4px;
}
.report-pattern-header h3 {
    margin: 0;
    font-size: 15px;
    line-height: 1.35;
}
.report-pattern-field {
    margin: 8px 0;
}
.report-pattern-field span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 2px;
}
.report-pattern-field p {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
}
.report-pattern-confidence {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}
.metric-explain-notes {
    margin-top: 10px;
    padding: 8px 10px 0;
    border-top: 1px dashed var(--line);
    color: var(--muted);
}
.metric-explain-notes.compact {
    margin-top: 6px;
    padding: 6px 8px 0;
}
.metric-explain-notes > span {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 850;
    text-transform: uppercase;
}
.metric-explain-notes small {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    line-height: 1.4;
}
.clinical-nights-panel {
    border-color: #c4ddd8;
}
.clinical-night-shortcut {
    border-color: var(--brand) !important;
    background: #eef7f4 !important;
}
.clinical-night-shortcut .button {
    margin-top: 8px;
    width: 100%;
    justify-content: center;
}
.clinical-night-table td {
    vertical-align: top;
}
.clinical-night-list {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}
.clinical-night-row {
    display: grid;
    grid-template-columns: minmax(210px, 0.9fr) minmax(240px, 1.05fr) minmax(280px, 1.65fr) max-content;
    gap: 12px;
    align-items: center;
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand-2);
    border-radius: 8px;
    background: #fff;
    padding: 12px;
}
.clinical-night-row.good { border-left-color: var(--ok); }
.clinical-night-row.warn { border-left-color: var(--warning); }
.clinical-night-row.bad { border-left-color: var(--danger); }
.clinical-night-row-main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    min-width: 0;
}
.clinical-night-row-main > div {
    min-width: 0;
}
.clinical-night-row-main strong {
    display: block;
    font-size: 15px;
    line-height: 1.25;
    overflow-wrap: normal;
    word-break: normal;
}
.clinical-night-row-main span:not(.night-pill) {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
}
.clinical-night-row-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.clinical-night-row-metrics span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 26px;
    padding: 4px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}
.clinical-night-row-metrics b {
    color: var(--muted);
    font-size: 11px;
}
.clinical-night-row p {
    margin: 0;
    color: var(--ink);
    font-size: 13px;
    line-height: 1.35;
    min-width: 0;
    overflow-wrap: break-word;
}
.clinical-night-row .button {
    min-height: 34px;
    padding: 7px 10px;
    white-space: nowrap;
}
.clinical-night-row .button svg {
    width: 16px;
    height: 16px;
}
.night-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0;
}
.night-filter-bar .button {
    min-height: 34px;
    padding: 7px 11px;
}
.night-filter-bar .button.active {
    background: var(--brand);
    color: #fff;
}
.night-sort-control {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    color: var(--muted);
    font-weight: 800;
    flex-wrap: wrap;
}
.night-sort-control select {
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-weight: 700;
    padding: 0 12px;
}
.night-sort-control .button {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
}
.clinical-night-row-main .night-pill {
    justify-self: start;
    max-width: 100%;
    white-space: normal;
    text-align: left;
    border-radius: 12px;
}
.night-glossary {
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcf9;
    padding: 10px 12px;
}
.night-glossary summary {
    cursor: pointer;
    color: var(--brand);
    font-weight: 850;
}
.night-glossary div {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 16px;
    margin-top: 10px;
}
.night-glossary p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}
.night-glossary strong {
    color: var(--ink);
}
.night-pill,
.night-metric {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 850;
    white-space: nowrap;
}
.night-pill.good,
.night-metric.good {
    background: #e6f1ee;
    color: var(--ok);
    border: 1px solid #b9d9d3;
}
.night-pill.warn,
.night-metric.warn {
    background: #fff6dc;
    color: #7a5514;
    border: 1px solid #ead7a4;
}
.night-pill.bad,
.night-metric.bad {
    background: #fbe8e8;
    color: var(--danger);
    border: 1px solid #efc5c5;
}
.night-metric.muted {
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--line);
}
.night-detail-list {
    display: none;
    gap: 10px;
    margin-top: 16px;
}
.night-detail-card {
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand-2);
    border-radius: 8px;
    background: var(--surface);
    overflow: hidden;
}
.night-detail-card.good { border-left-color: var(--ok); }
.night-detail-card.warn { border-left-color: var(--warning); }
.night-detail-card.bad { border-left-color: var(--danger); }
.night-detail-card > summary {
    display: grid;
    grid-template-columns: 150px 190px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 12px 14px;
    cursor: pointer;
    list-style: none;
}
.night-detail-card > summary::-webkit-details-marker {
    display: none;
}
.night-detail-card > summary span {
    font-weight: 900;
    color: var(--ink);
}
.night-detail-card > summary strong {
    color: var(--brand);
    font-size: 12px;
    text-transform: uppercase;
}
.night-detail-card > summary em {
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
    line-height: 1.35;
}
.night-detail-card[open] > summary {
    border-bottom: 1px solid var(--line);
    background: #fbfcf9;
}
.night-mini-bar {
    display: flex;
    height: 14px;
    margin: 14px 14px 6px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-2);
    overflow: hidden;
}
.night-mini-bar span {
    display: block;
    min-width: 2px;
}
.night-mini-bar .sleep { background: #167d72; }
.night-mini-bar .wake { background: #c45b3c; }
.night-mini-bar .rest { background: #b7791f; }
.night-mini-bar .off { background: #69736f; }
.night-mini-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 14px 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
}
.night-mini-legend span::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 5px;
    border-radius: 50%;
}
.night-mini-legend .sleep::before { background: #167d72; }
.night-mini-legend .wake::before { background: #c45b3c; }
.night-mini-legend .rest::before { background: #b7791f; }
.night-mini-legend .off::before { background: #69736f; }
.night-detail-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    padding: 14px;
}
.night-detail-grid > div {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-2);
    padding: 10px;
    min-width: 0;
}
.night-detail-grid span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 850;
    text-transform: uppercase;
    line-height: 1.25;
}
.night-detail-grid strong {
    display: block;
    margin-top: 5px;
    font-size: 17px;
    line-height: 1.2;
}
.night-detail-grid small {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
}
.night-clinical-reading,
.night-exclusion {
    margin: 0 14px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcf9;
    padding: 12px;
}
.night-clinical-reading strong,
.night-exclusion strong {
    display: block;
    margin-bottom: 5px;
    color: var(--brand);
}
.night-clinical-reading p,
.night-exclusion p {
    margin: 0 0 8px;
    color: var(--ink);
    line-height: 1.45;
}

/* Doctor report view */
.doctor-report .report-patient-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
    margin-bottom: 18px;
}
.doctor-report .report-patient-info h2 {
    margin: 0 0 6px;
    font-size: 14px;
    color: var(--muted);
    text-transform: uppercase;
}
.doctor-report .report-metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 18px;
}
.doctor-report .report-metric {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}
.doctor-report .report-metric span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.doctor-report .report-metric strong {
    display: block;
    font-size: 22px;
    line-height: 1.1;
}
.doctor-report .report-note {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 10px;
}
.doctor-report .report-limitations {
    background: #fffaf0;
    border: 1px solid #ead7a4;
    border-radius: 8px;
    padding: 14px;
}

/* PDF export mode: html2pdf captures screen CSS, so force a stable A4 layout. */
body.pdf-exporting {
    background: #fff !important;
}
body.pdf-exporting .report-actions,
body.pdf-exporting .no-print,
body.pdf-exporting .sidebar,
body.pdf-exporting .topbar,
body.pdf-exporting .mobile-nav,
body.pdf-exporting .review-mode-badge,
body.pdf-exporting button {
    display: none !important;
}
body.pdf-exporting .app-shell,
body.pdf-exporting .main {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #fff !important;
}
body.pdf-exporting .report-document {
    width: 186mm !important;
    max-width: 186mm !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 8mm !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
    color: #111 !important;
    font-size: 11px !important;
    line-height: 1.38 !important;
    overflow: visible !important;
    box-sizing: border-box !important;
}
body.pdf-exporting .report-document * {
    box-sizing: border-box !important;
}
body.pdf-exporting .report-header {
    border-bottom: 1.5px solid #111 !important;
    padding-bottom: 8px !important;
    margin-bottom: 10px !important;
}
body.pdf-exporting .report-header img {
    width: 42px !important;
    height: 42px !important;
}
body.pdf-exporting .report-document h1 {
    font-size: 19px !important;
    margin: 0 0 3px !important;
}
body.pdf-exporting .report-document h2 {
    font-size: 14px !important;
    margin: 14px 0 6px !important;
}
body.pdf-exporting .report-document h3 {
    font-size: 12px !important;
}
body.pdf-exporting .report-document p,
body.pdf-exporting .report-document li {
    line-height: 1.38 !important;
    overflow-wrap: anywhere !important;
}
body.pdf-exporting .short-doctor-report,
body.pdf-exporting .short-category-card,
body.pdf-exporting .short-report-layout > div,
body.pdf-exporting .short-report-metrics div,
body.pdf-exporting .short-report-glossary,
body.pdf-exporting .short-report-compare,
body.pdf-exporting .context-match-block,
body.pdf-exporting .context-match-grid > div,
body.pdf-exporting .report-pattern-card,
body.pdf-exporting .report-summary-grid div,
body.pdf-exporting .index-grid div {
    background: #fff !important;
    color: #111 !important;
    border-color: #999 !important;
    box-shadow: none !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
}
body.pdf-exporting .short-doctor-report {
    padding: 10px !important;
    border-width: 1px !important;
}
body.pdf-exporting .short-report-head,
body.pdf-exporting .context-match-head {
    display: block !important;
}
body.pdf-exporting .short-report-status,
body.pdf-exporting .context-match-head span {
    display: inline-block !important;
    margin-top: 5px !important;
    white-space: normal !important;
    border-color: #999 !important;
    background: #fff !important;
    color: #111 !important;
}
body.pdf-exporting .short-report-categories,
body.pdf-exporting .short-report-layout,
body.pdf-exporting .short-report-layout.compact,
body.pdf-exporting .context-match-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 6px !important;
}
body.pdf-exporting .short-report-metrics,
body.pdf-exporting .short-glossary-grid,
body.pdf-exporting .report-summary-grid,
body.pdf-exporting .report-title-grid,
body.pdf-exporting .report-indexes,
body.pdf-exporting .index-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
}
body.pdf-exporting .report-pattern-cards {
    display: grid !important;
    gap: 8px !important;
}
body.pdf-exporting .report-pattern-card {
    padding: 10px !important;
    border-left-width: 3px !important;
}
body.pdf-exporting .table-wrap {
    overflow: visible !important;
}
body.pdf-exporting table {
    width: 100% !important;
    min-width: 0 !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    font-size: 9.5px !important;
}
body.pdf-exporting th,
body.pdf-exporting td {
    padding: 4px 5px !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
}
body.pdf-exporting a {
    color: #111 !important;
    text-decoration: none !important;
}

/* Compact medical PDF: keep only the clinically useful report sections. */
body.pdf-exporting .report-document > section:not(.pdf-keep),
body.pdf-exporting .no-pdf,
body.pdf-exporting .short-report-glossary,
body.pdf-exporting .short-report-compare,
body.pdf-exporting .context-match-block,
body.pdf-exporting .metric-explain-notes,
body.pdf-exporting .report-audit,
body.pdf-exporting .technical-data,
body.pdf-exporting details {
    display: none !important;
}
body.pdf-exporting .report-document {
    width: 170mm !important;
    max-width: 170mm !important;
    padding: 0 !important;
    font-size: 10.4px !important;
    line-height: 1.28 !important;
}
body.pdf-exporting .pdf-capture-root,
body.pdf-exporting .pdf-capture-root * {
    transform: none !important;
}
body.pdf-exporting .pdf-capture-root .report-document {
    width: 170mm !important;
    max-width: 170mm !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    position: static !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    overflow: visible !important;
}
body.pdf-exporting .report-header {
    gap: 8px !important;
    padding-bottom: 6px !important;
    margin-bottom: 7px !important;
}
body.pdf-exporting .report-header img {
    width: 34px !important;
    height: 34px !important;
}
body.pdf-exporting .report-document h1 {
    font-size: 16px !important;
}
body.pdf-exporting .report-document h2 {
    font-size: 12.5px !important;
    margin: 8px 0 5px !important;
    padding-bottom: 3px !important;
    border-bottom: 1px solid #d4d8d6 !important;
}
body.pdf-exporting .report-document h3 {
    font-size: 10.8px !important;
    margin: 0 0 4px !important;
}
body.pdf-exporting .report-document p,
body.pdf-exporting .report-document li,
body.pdf-exporting .report-document td,
body.pdf-exporting .report-document th {
    line-height: 1.28 !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    hyphens: none !important;
}
body.pdf-exporting .pdf-keep {
    margin: 0 0 7px !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
}
body.pdf-exporting .short-doctor-report,
body.pdf-exporting .report-warning,
body.pdf-exporting .report-pattern-card,
body.pdf-exporting .report-summary-grid > div,
body.pdf-exporting .report-title-grid > div {
    border: 1px solid #b8bfba !important;
    border-radius: 5px !important;
    background: #fff !important;
    box-shadow: none !important;
}
body.pdf-exporting .short-doctor-report {
    padding: 7px !important;
}
body.pdf-exporting .short-report-head {
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    gap: 8px !important;
}
body.pdf-exporting .short-report-head h2,
body.pdf-exporting .short-report-kicker,
body.pdf-exporting .short-report-reason,
body.pdf-exporting .short-report-priority {
    margin-top: 0 !important;
    margin-bottom: 5px !important;
}
body.pdf-exporting .short-report-status,
body.pdf-exporting .short-report-priority {
    padding: 4px 6px !important;
    border-radius: 5px !important;
    white-space: normal !important;
}
body.pdf-exporting .short-report-categories {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 5px !important;
}
body.pdf-exporting .short-report-layout,
body.pdf-exporting .short-report-layout.compact {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 5px !important;
}
body.pdf-exporting .short-report-list {
    margin: 0 !important;
    padding-left: 14px !important;
}
body.pdf-exporting .short-category-card,
body.pdf-exporting .short-report-layout > div {
    padding: 6px !important;
    border: 1px solid #ccd2ce !important;
    border-radius: 5px !important;
}
body.pdf-exporting .short-report-metrics,
body.pdf-exporting .report-summary-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 5px !important;
}
body.pdf-exporting .report-title-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 5px !important;
}
body.pdf-exporting .report-pattern-cards {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 5px !important;
}
body.pdf-exporting .report-pattern-card {
    padding: 7px !important;
    border-left-width: 3px !important;
}
body.pdf-exporting .report-pattern-card:nth-of-type(n+7) {
    display: block !important;
}
body.pdf-exporting .report-pattern-field {
    margin-top: 4px !important;
}
body.pdf-exporting .report-pattern-field span,
body.pdf-exporting .report-pattern-level {
    font-size: 8.5px !important;
    letter-spacing: 0 !important;
}
body.pdf-exporting .report-pattern-field p {
    margin: 1px 0 0 !important;
}
body.pdf-exporting .pdf-note {
    display: block !important;
    color: #444 !important;
    font-size: 9px !important;
    margin-top: 4px !important;
}

/* Analyst report view */
.analyst-report .report-pattern-card {
    padding: 14px;
}

@media (max-width: 900px) {
    .report-title-grid,
    .report-summary-grid,
    .report-indexes {
        grid-template-columns: 1fr;
    }
    .short-report-head {
        display: grid;
    }
    .short-report-status {
        justify-content: center;
        white-space: normal;
        text-align: center;
    }
    .short-report-layout,
    .short-report-metrics,
    .short-glossary-grid,
    .short-report-categories,
    .short-report-layout.compact,
    .context-form-grid,
    .context-match-grid {
        grid-template-columns: 1fr;
    }
    .context-card-wide {
        grid-column: span 1;
    }
    .context-match-head {
        display: grid;
    }
    .raw-channel-table {
        display: none;
    }
    .raw-channel-cards {
        display: block;
    }
    .doctor-report .report-patient-info {
        grid-template-columns: 1fr;
    }
    .doctor-report .report-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .night-detail-card > summary,
    .night-detail-grid {
        grid-template-columns: 1fr;
    }
    .night-detail-card > summary {
        gap: 4px;
    }
    .night-pill,
    .night-metric {
        white-space: normal;
    }
}


.sleep-day-map-panel .panel-head{align-items:flex-start}
.sleep-day-map-summary{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin:14px 0}
.sleep-day-map-summary span{display:grid;gap:4px;min-height:64px;padding:12px;border:1px solid var(--line);border-radius:8px;background:var(--surface-2);color:var(--ink);font-size:24px;font-weight:900}
.sleep-day-map-summary strong{color:var(--muted);font-size:12px;font-weight:850;text-transform:uppercase}
.sleep-day-map{display:grid;gap:14px;margin-top:14px}
.sleep-day-card{border:1px solid var(--line);border-left:4px solid var(--brand);border-radius:8px;background:#fff;overflow:hidden}
.sleep-day-card-head{display:grid;grid-template-columns:minmax(170px,.5fr) minmax(0,1fr);gap:16px;align-items:center;padding:14px 16px;border-bottom:1px solid var(--line);background:#fbfcf9}
.sleep-day-card-head span{color:var(--muted);font-size:12px;font-weight:850;text-transform:uppercase}
.sleep-day-card-head h3{margin:2px 0 0;font-size:22px;line-height:1.15}
.sleep-day-card-stats{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px}
.sleep-day-card-stats span{min-height:28px;padding:5px 9px;border:1px solid #c4ddd8;border-radius:999px;background:#eef7f4;color:var(--brand);text-transform:none}
.sleep-day-section{padding:14px 16px;border-top:1px solid #edf2ef}
.sleep-day-section:first-of-type{border-top:0}
.sleep-day-section.main{background:#fbfffd}
.sleep-day-section.short{background:#fff}
.sleep-day-section.uncertain{background:#fff8f8}
.sleep-day-section-title{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:10px}
.sleep-day-section-title strong{font-size:18px}
.sleep-day-section-title span,.sleep-day-section-title b{padding:5px 9px;border:1px solid #d6e2de;border-radius:999px;background:#eef4ef;color:var(--ink);font-size:13px;font-weight:850}
.sleep-day-facts{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:10px}
.sleep-day-facts span{padding:5px 9px;border-radius:999px;border:1px solid #d6e2de;background:#fff;font-weight:750;color:var(--muted)}
.sleep-day-reason,.sleep-day-empty{margin:8px 0;color:var(--muted);line-height:1.45}
.sleep-day-evidence{margin-top:10px;padding:12px;border:1px solid #cfe5df;border-radius:8px;background:#f4fbf8}
.sleep-day-evidence strong{display:block;margin-bottom:6px;color:var(--brand)}
.sleep-day-evidence ul,.sleep-short-list ul,.sleep-uncertain-list{margin:0;padding-left:18px}
.sleep-short-list{display:grid;gap:10px;margin:0;padding-left:22px}
.sleep-short-list>li{padding:10px;border:1px solid var(--line);border-radius:8px;background:#fff}
.sleep-short-list div{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:6px}
.sleep-short-list div span{color:var(--muted);font-weight:750}
.sleep-uncertain-list{display:grid;gap:8px;padding-left:0;list-style:none}
.sleep-uncertain-list li{display:flex;gap:10px;justify-content:space-between;align-items:center;padding:10px;border:1px solid #f0c7c7;border-radius:8px;background:#fff}
.sleep-uncertain-list span{color:var(--muted)}


.sleep-day-map-panel .panel-head{align-items:flex-start}
.sleep-day-map-summary{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin:14px 0}
.sleep-day-map-summary span{display:grid;gap:4px;min-height:64px;padding:12px;border:1px solid var(--line);border-radius:8px;background:var(--surface-2);color:var(--ink);font-size:24px;font-weight:900}
.sleep-day-map-summary strong{color:var(--muted);font-size:12px;font-weight:850;text-transform:uppercase}
.sleep-day-map{display:grid;gap:14px;margin-top:14px}
.sleep-day-card{border:1px solid var(--line);border-left:4px solid var(--brand);border-radius:8px;background:#fff;overflow:hidden}
.sleep-day-card-head{display:grid;grid-template-columns:minmax(170px,.5fr) minmax(0,1fr);gap:16px;align-items:center;padding:14px 16px;border-bottom:1px solid var(--line);background:#fbfcf9}
.sleep-day-card-head span{color:var(--muted);font-size:12px;font-weight:850;text-transform:uppercase}
.sleep-day-card-head h3{margin:2px 0 0;font-size:22px;line-height:1.15}
.sleep-day-card-stats{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px}
.sleep-day-card-stats span{min-height:28px;padding:5px 9px;border:1px solid #c4ddd8;border-radius:999px;background:#eef7f4;color:var(--brand);text-transform:none}
.sleep-day-section{padding:14px 16px;border-top:1px solid #edf2ef}
.sleep-day-section:first-of-type{border-top:0}
.sleep-day-section.main{background:#fbfffd}
.sleep-day-section.short{background:#fff}
.sleep-day-section.uncertain{background:#fff8f8}
.sleep-day-section-title{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:10px}
.sleep-day-section-title strong{font-size:18px}
.sleep-day-section-title span,.sleep-day-section-title b{padding:5px 9px;border:1px solid #d6e2de;border-radius:999px;background:#eef4ef;color:var(--ink);font-size:13px;font-weight:850}
.sleep-day-facts{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:10px}
.sleep-day-facts span{padding:5px 9px;border-radius:999px;border:1px solid #d6e2de;background:#fff;font-weight:750;color:var(--muted)}
.sleep-day-reason,.sleep-day-empty{margin:8px 0;color:var(--muted);line-height:1.45}
.sleep-day-evidence{margin-top:10px;padding:12px;border:1px solid #cfe5df;border-radius:8px;background:#f4fbf8}
.sleep-day-evidence strong{display:block;margin-bottom:6px;color:var(--brand)}
.sleep-day-evidence ul,.sleep-short-list ul,.sleep-uncertain-list{margin:0;padding-left:18px}
.sleep-short-list{display:grid;gap:10px;margin:0;padding-left:22px}
.sleep-short-list>li{padding:10px;border:1px solid var(--line);border-radius:8px;background:#fff}
.sleep-short-list div{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:6px}
.sleep-short-list div span{color:var(--muted);font-weight:750}
.sleep-uncertain-list{display:grid;gap:8px;padding-left:0;list-style:none}
.sleep-uncertain-list li{display:flex;gap:10px;justify-content:space-between;align-items:center;padding:10px;border:1px solid #f0c7c7;border-radius:8px;background:#fff}
.sleep-uncertain-list span{color:var(--muted)}
/* somnoacti-sleep-day-accordion */
.sleep-day-card[open]{box-shadow:0 12px 28px rgba(25,50,45,.07)}
.sleep-day-card-head{grid-template-columns:minmax(150px,.45fr) minmax(230px,1fr) auto auto;border-bottom:0;cursor:pointer;list-style:none}
.sleep-day-card[open]>.sleep-day-card-head{border-bottom:1px solid var(--line)}
.sleep-day-card-head::-webkit-details-marker{display:none}
.sleep-day-card-main{display:grid;gap:3px}
.sleep-day-card-main strong{font-size:18px;line-height:1.25}
.sleep-day-card-main span{color:var(--muted);font-size:14px;font-weight:750;text-transform:none}
.sleep-day-open{display:inline-flex;min-height:34px;align-items:center;justify-content:center;padding:0 12px;border:1px solid var(--brand);border-radius:8px;color:var(--brand)!important;font-size:13px!important;font-weight:850!important;text-transform:none!important;white-space:nowrap}
.sleep-day-open:before{content:"+";margin-right:6px;font-weight:900}
.sleep-day-card[open] .sleep-day-open:before{content:"-"}
.sleep-day-card[open] .sleep-day-open{background:var(--brand);color:#fff!important}
