/* =========================================================
   Bệnh án chuyên khoa – bộ màu và khung giao diện
   Màu chủ đạo: xanh teal. Mọi màu lấy từ biến, không viết cứng trong trang.
   ========================================================= */
:root {
    --c-bg: #f3f6f6;
    --c-surface: #ffffff;
    --c-surface-2: #eaf1f1;
    --c-ink: #0f2628;
    --c-ink-2: #44585a;
    --c-muted: #6b7f81;
    --c-line: #d3dfdf;
    --c-accent: #0e7c86;
    --c-accent-600: #0a636c;
    --c-accent-50: #e3f5f4;
    --c-accent-ink: #083f45;
    --c-ok: #1f7a4d;
    --c-ok-bg: #e3f4ea;
    --c-warn: #9a5b00;
    --c-warn-bg: #fdf1dc;
    --c-bad: #b3261e;
    --c-bad-bg: #fbe5e3;
    --c-control-border: #7f9799;

    /* Màu nhóm lớn của form nhập (Lâm sàng / Cận lâm sàng / Điều trị…), theo thứ tự xuất hiện. */
    --c-tone-0: #0e7c86;
    --c-tone-0-bg: #e3f5f4;
    --c-tone-1: #3b5bab;
    --c-tone-1-bg: #e7ecf8;
    --c-tone-2: #7a4c9e;
    --c-tone-2-bg: #f1e9f7;
    --c-tone-3: #8a5a12;
    --c-tone-3-bg: #f8eedd;

    --sidebar-w: 52px;
    --sidebar-w-open: 208px;
    --topbar-h: 52px;

    --bs-body-bg: var(--c-bg);
    --bs-body-color: var(--c-ink);
    --bs-body-font-family: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
    --bs-body-font-size: 0.9375rem;
    --bs-link-color: var(--c-accent);
    --bs-link-color-rgb: 14, 124, 134;
    --bs-link-hover-color: var(--c-accent-600);
    --bs-link-hover-color-rgb: 10, 99, 108;
    --bs-border-color: var(--c-line);
    --bs-primary: var(--c-accent);
    --bs-primary-rgb: 14, 124, 134;
}

html, body {
    height: 100%;
}

.skip-link {
    position: absolute;
    z-index: 100;
    background: var(--c-surface);
    padding: 8px 12px;
}

/* ---------- Khung ứng dụng ---------- */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100%;
}

.sidebar-open .app-shell {
    grid-template-columns: var(--sidebar-w-open) minmax(0, 1fr);
}

.app-sidebar {
    background: var(--c-surface);
    border-right: 1px solid var(--c-line);
    padding: 6px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden auto;
}

.sidebar-toggle,
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 17px;
    white-space: nowrap;
    color: var(--c-ink-2);
    text-decoration: none;
    font-size: 0.875rem;
    border: 0;
    background: transparent;
}

.sidebar-toggle {
    color: var(--c-accent);
    font-weight: 700;
    cursor: pointer;
}

.app-sidebar svg {
    width: 18px;
    height: 18px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-label {
    display: none;
}

.sidebar-open .sidebar-label {
    display: inline;
}

a.sidebar-item:hover {
    background: var(--c-surface-2);
    color: var(--c-accent-ink);
}

.sidebar-item.active {
    background: var(--c-accent-50);
    color: var(--c-accent-ink);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--c-accent);
}

.sidebar-item.disabled {
    opacity: 0.45;
    cursor: default;
}

.sidebar-separator {
    border-top: 1px solid var(--c-line);
    margin: 6px 10px;
}

/* Menu theo nhóm (Navigation/MainMenu.cs): mỗi nhóm một màu, icon y tế Healthicons trong ô màu nhạt; mục đang mở tô đậm. */
.app-sidebar .g-clinical { --menu-c: var(--c-tone-0); --menu-bg: var(--c-tone-0-bg); }
.app-sidebar .g-analysis { --menu-c: var(--c-tone-1); --menu-bg: var(--c-tone-1-bg); }
.app-sidebar .g-config { --menu-c: var(--c-tone-2); --menu-bg: var(--c-tone-2-bg); }
.app-sidebar .g-admin { --menu-c: var(--c-tone-3); --menu-bg: var(--c-tone-3-bg); }
.app-footer { margin-top: auto; padding: 10px 20px 14px; text-align: center; font-size: .75rem; color: var(--c-muted); border-top: 1px solid var(--c-line); }
.auth-shell { align-content: center; }
.auth-shell .app-footer { border-top: 0; margin-top: 12px; }
@media print { .app-footer { display: none; } }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 8px 10px 6px; color: var(--c-accent-ink); text-decoration: none; white-space: nowrap; font-size: .95rem; }
.sidebar-brand .menu-icon { --menu-c: var(--c-surface); --menu-bg: var(--c-accent); }
.sidebar-brand b { color: var(--c-accent); }
.menu-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 32px; height: 32px; border-radius: 9px;
    background: var(--menu-bg, var(--c-surface-2)); color: var(--menu-c, var(--c-ink-2)); }
.app-sidebar .menu-icon svg { width: 20px; height: 20px; fill: currentColor; stroke: none; }
.app-sidebar .sidebar-item { padding: 5px 10px; gap: 10px; }
.sidebar-item.active { box-shadow: inset 3px 0 0 var(--menu-c, var(--c-accent)); }
.sidebar-item.active .menu-icon { background: var(--menu-c); color: var(--c-surface); }
a.sidebar-item:hover .menu-icon { box-shadow: inset 0 0 0 1.5px var(--menu-c); }
.sidebar-group { margin: 8px 10px 2px; border-top: 1px solid var(--c-line); }
.sidebar-group .sidebar-label { display: none; }
.sidebar-open .sidebar-group { border-top: 0; margin: 10px 12px 2px; }
.sidebar-open .sidebar-group .sidebar-label { display: block; font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--menu-c); }

.sidebar-toggle:focus-visible,
.sidebar-item:focus-visible,
.quick-search input:focus-visible {
    outline: 2px solid var(--c-accent);
    outline-offset: -2px;
}

.app-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: var(--topbar-h);
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-line);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    flex-wrap: wrap;
}

.quick-search {
    flex: 1 1 220px;
    max-width: 560px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--c-line);
    border-radius: 6px;
    background: var(--c-bg);
    padding: 0 10px;
    margin: 0;
}

.quick-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    padding: 6px 0;
    font-size: 0.875rem;
    color: var(--c-ink);
}

kbd {
    font-size: 0.6875rem;
    background: var(--c-surface);
    color: var(--c-ink-2);
    border: 1px solid var(--c-line);
    border-radius: 3px;
    padding: 0 5px;
    white-space: nowrap;
}

.topbar-chip {
    border: 1px solid var(--c-accent);
    color: var(--c-accent-ink);
    background: var(--c-accent-50);
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
}

.topbar-user {
    font-size: 0.8125rem;
    color: var(--c-ink-2);
    white-space: nowrap;
}

.app-content {
    padding: 16px;
    flex: 1;
}

/* ---------- Thành phần dùng chung ---------- */
.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 12px;
}

.panel {
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: 6px;
    margin-bottom: 12px;
}

.panel-header {
    padding: 8px 14px;
    border-bottom: 1px solid var(--c-line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-weight: 600;
    font-size: 0.875rem;
}

.panel-body {
    padding: 12px 14px;
}

.status-pill {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 1px 9px;
    border-radius: 99px;
    white-space: nowrap;
}

.status-ok { background: var(--c-ok-bg); color: var(--c-ok); }
.status-warn { background: var(--c-warn-bg); color: var(--c-warn); }
.status-bad { background: var(--c-bad-bg); color: var(--c-bad); }

.kv {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 6px 16px;
    margin: 0;
    font-size: 0.875rem;
}

.kv dt { color: var(--c-ink-2); font-weight: 500; }
.kv dd { margin: 0; }

.btn-primary {
    --bs-btn-bg: var(--c-accent);
    --bs-btn-border-color: var(--c-accent-600);
    --bs-btn-hover-bg: var(--c-accent-600);
    --bs-btn-hover-border-color: var(--c-accent-600);
    --bs-btn-active-bg: var(--c-accent-600);
    --bs-btn-active-border-color: var(--c-accent-600);
}

/* ---------- Thanh trên: người dùng ---------- */
a.topbar-chip { text-decoration: none; }
a.topbar-chip:hover { background: var(--c-accent); color: #fff; }

button.topbar-user {
    border: 0;
    background: transparent;
    padding: 4px 6px;
    border-radius: 6px;
}

button.topbar-user:hover { background: var(--c-surface-2); }

/* ---------- Trang đăng nhập ---------- */
.auth-shell {
    min-height: 100%;
    display: grid;
    place-items: center;
    padding: 24px 16px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: 10px;
    padding: 28px;
}

.auth-brand {
    color: var(--c-accent);
    font-weight: 700;
    font-size: 0.8125rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.auth-title { font-size: 1.375rem; font-weight: 700; margin: 0 0 16px; }
.auth-hint { font-size: 0.8125rem; color: var(--c-muted); margin: 16px 0 0; text-align: center; }

.auth-divider {
    text-align: center;
    font-size: 0.8125rem;
    color: var(--c-muted);
    margin: 14px 0;
}

.code-input { font-size: 1.25rem; letter-spacing: 0.3em; text-align: center; }

.qr-box {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
    border: 1px solid var(--c-line);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 16px;
    background: #fff;
    color: #111;
}

.setup-key { font-size: 0.9375rem; word-break: break-all; color: #111; }

.choice-list { display: grid; gap: 8px; }

.choice {
    text-align: left;
    border: 1px solid var(--c-line);
    border-radius: 8px;
    background: var(--c-bg);
    padding: 10px 14px;
    display: grid;
    gap: 2px;
    color: var(--c-ink);
}

.choice span { font-size: 0.8125rem; color: var(--c-ink-2); }
.choice:hover, .choice.active { border-color: var(--c-accent); background: var(--c-accent-50); }

/* ---------- Bảng và form quản trị ---------- */
.page-tabs { margin-bottom: 12px; }
.page-tabs .nav-link { color: var(--c-ink-2); font-size: 0.875rem; }
.page-tabs .nav-link.active { color: var(--c-accent-ink); font-weight: 600; border-top: 2px solid var(--c-accent); }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .form-control, .toolbar .form-select { width: auto; min-width: 180px; }
.input-code { max-width: 140px; min-width: 100px !important; }
.input-scope { min-width: 150px !important; }

.data-table { margin: 0; font-size: 0.875rem; }
.data-table th { background: var(--c-surface-2); color: var(--c-ink-2); font-size: 0.8125rem; font-weight: 600; white-space: nowrap; }
.data-table td, .data-table th { padding: 7px 12px; vertical-align: middle; }
.data-table.matrix th:not(:first-child), .data-table.matrix td:not(:first-child) { text-align: center; }
.data-table .group-row th { background: var(--c-surface); color: var(--c-accent); font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; }
.th-note { font-weight: 400; font-size: 0.6875rem; color: var(--c-muted); }
.row-denied td { background: var(--c-bad-bg); }

.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.form-actions-left { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.temp-password { font-size: 1.125rem; user-select: all; }
.pager { display: flex; gap: 16px; align-items: center; font-size: 0.875rem; }

/* ---------- Ô nhập liệu: phải nhìn ra ngay là bấm được, gõ được ---------- */
.form-control,
.form-select {
    background-color: var(--c-surface);
    border-color: var(--c-control-border);
    color: var(--c-ink);
}

.form-control:hover:not(:disabled):not([readonly]),
.form-select:hover:not(:disabled) {
    border-color: var(--c-accent);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--c-surface);
    border-color: var(--c-accent);
    box-shadow: 0 0 0 0.2rem rgba(14, 124, 134, 0.2);
}

/* Ô chỉ đọc hoặc bị khoá mới có nền xám. */
.form-control[readonly],
.form-control:disabled,
.form-select:disabled {
    background-color: var(--c-surface-2);
    border-color: var(--c-line);
    color: var(--c-ink-2);
}

.form-check-input {
    width: 1.2em;
    height: 1.2em;
    margin-top: 0.15em;
    background-color: var(--c-surface);
    border: 2px solid var(--c-control-border);
    cursor: pointer;
}

.form-check-input:hover:not(:disabled) {
    border-color: var(--c-accent);
    box-shadow: 0 0 0 3px var(--c-accent-50);
}

.form-check-input:focus {
    border-color: var(--c-accent);
    box-shadow: 0 0 0 0.2rem rgba(14, 124, 134, 0.25);
}

.form-check-input:checked {
    background-color: var(--c-accent);
    border-color: var(--c-accent);
}

.form-check-input:disabled {
    background-color: var(--c-surface-2);
    border-color: var(--c-line);
    cursor: not-allowed;
}

.form-check-label { cursor: pointer; }

/* Bảng ma trận: cả ô là vùng bấm, rê chuột vào thì sáng lên. */
.data-table.matrix td.cell-toggle { cursor: pointer; }
.data-table.matrix td.cell-toggle:hover { background: var(--c-accent-50); }
.data-table.matrix td.cell-toggle.is-checked { background: var(--c-accent-50); }
.data-table.matrix tbody tr:hover td:first-child { color: var(--c-accent-ink); font-weight: 600; }
.btn-outline-primary {
    --bs-btn-color: var(--c-accent);
    --bs-btn-border-color: var(--c-accent);
    --bs-btn-hover-bg: var(--c-accent);
    --bs-btn-hover-border-color: var(--c-accent);
    --bs-btn-active-bg: var(--c-accent-600);
    --bs-btn-active-border-color: var(--c-accent-600);
}

@media (max-width: 720px) {
    .app-shell,
    .sidebar-open .app-shell {
        grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    }

    .sidebar-open .sidebar-label,
    .sidebar-open .sidebar-group .sidebar-label { display: none; }
    .sidebar-open .sidebar-group { border-top: 1px solid var(--c-line); margin: 8px 10px 2px; }
    .kv { grid-template-columns: 1fr; }
}

/* ---------- Danh mục ---------- */
.row-inactive td { color: var(--c-muted); }
.unit { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.8125rem; white-space: nowrap; }
.input-num { max-width: 110px; min-width: 80px !important; }
.pre-line { white-space: pre-line; }

/* Mã (chỉ số, tên đăng nhập) dùng màu chủ đạo thay cho màu hồng mặc định của Bootstrap. */
code { color: var(--c-accent-ink); }

/* ---------- Bệnh nhân ---------- */
.req { color: var(--c-bad); }
.search-wide { min-width: 300px !important; }
.row-link { color: var(--c-ink); text-decoration: none; font-weight: 500; }
.row-link:hover { color: var(--c-accent); text-decoration: underline; }
.stack { display: grid; gap: 8px; }

.hidden-match {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 8px 14px;
    background: var(--c-warn-bg);
    color: var(--c-warn);
    border-bottom: 1px solid var(--c-line);
    font-size: 0.875rem;
}

.patient-bar {
    display: flex;
    gap: 6px 16px;
    align-items: center;
    flex-wrap: wrap;
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: 6px;
    padding: 9px 14px;
    margin-bottom: 12px;
    font-size: 0.875rem;
    color: var(--c-ink-2);
}

.patient-bar strong { font-size: 1.0625rem; color: var(--c-ink); }

.panel-danger { border-color: var(--c-bad); }
.panel-danger > .panel-header { color: var(--c-bad); }

.request-card {
    display: grid;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--c-line);
    font-size: 0.875rem;
}

.request-card:last-child { border-bottom: 0; }
.request-reason { margin-top: 2px; color: var(--c-ink-2); }

/* ---------- Ô tìm nhanh ---------- */
.quick-search-wrap { position: relative; flex: 1 1 220px; max-width: 560px; }
.quick-search-wrap .quick-search { max-width: none; }
.topbar-spacer { flex: 1 1 220px; }
.quick-search:focus-within { border-color: var(--c-accent); background: var(--c-surface); }
.quick-search input:focus-visible { outline: none; }

.quick-results {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(15, 38, 40, 0.14);
    max-height: 420px;
    overflow-y: auto;
    z-index: 30;
}

.quick-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 2px 10px;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--c-ink);
    border-bottom: 1px solid var(--c-line);
    font-size: 0.875rem;
}

.quick-item:last-child { border-bottom: 0; }
.quick-item small { grid-column: 2; color: var(--c-ink-2); }
.quick-item.active, .quick-item:hover { background: var(--c-accent-50); }
.quick-item.locked { background: var(--c-warn-bg); color: var(--c-warn); }
.quick-empty { padding: 10px 12px; font-size: 0.875rem; color: var(--c-muted); }

.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 0.875rem; }

/* ---------- Số điện thoại nhiều dòng ---------- */
.phone-rows { display: grid; gap: 6px; }

.phone-row {
    display: grid;
    grid-template-columns: minmax(150px, 200px) minmax(150px, 190px) minmax(0, 1fr);
    gap: 8px;
}

.status-neutral { background: var(--c-surface-2); color: var(--c-ink-2); }

/* ---------- Ô chọn có tìm kiếm ---------- */
.combo { position: relative; }

.combo-list {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 2px);
    background: var(--c-surface);
    border: 1px solid var(--c-control-border);
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(15, 38, 40, 0.14);
    max-height: 260px;
    overflow-y: auto;
    z-index: 20;
    font-size: 0.875rem;
}

.combo-option { padding: 6px 10px; cursor: pointer; }
.combo-option.active, .combo-option:hover { background: var(--c-accent-50); color: var(--c-accent-ink); }
.combo-empty { padding: 8px 10px; color: var(--c-muted); }
.combo.is-chosen input[role=combobox] { border-color: var(--c-ok); }

@media (max-width: 720px) {
    .phone-row { grid-template-columns: 1fr; }
}

/* ---------- Form theo mẫu bệnh án ---------- */
.encounter-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 1rem; align-items: start; }
.section-nav { position: sticky; top: 4.5rem; display: flex; flex-direction: column; gap: .125rem; font-size: .875rem; }
.section-nav a { padding: .35rem .6rem; border-radius: .375rem; color: var(--c-ink-2); text-decoration: none; border-left: 3px solid transparent; }
.section-nav a:hover { background: var(--c-accent-50); color: var(--c-accent-600); border-left-color: var(--c-accent); }
@media (max-width: 991.98px) {
    .encounter-layout { grid-template-columns: minmax(0, 1fr); }
    .section-nav { position: static; flex-direction: row; flex-wrap: wrap; }
}
.encounter-head { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: flex-end; }
.encounter-head > div:first-child { min-width: 180px; }
.save-state { margin-left: auto; font-size: .85rem; color: var(--c-muted); }
.save-state.is-dirty { color: var(--c-warn); }
.save-state.is-saving { color: var(--c-accent); }
.save-state.is-saved { color: var(--c-ok); }
.save-state.is-error { color: var(--c-bad); font-weight: 600; }
.form-section { scroll-margin-top: 4.5rem; }
.form-item .form-label { font-weight: 500; margin-bottom: .25rem; }
.field-error { color: var(--c-bad); font-size: .8rem; }
.field-error:empty { display: none; }
.field-previous { font-size: .78rem; color: var(--c-muted); margin-top: .15rem; }
.flag { font-size: .75rem; font-weight: 600; margin-left: .25rem; white-space: nowrap; }
.flag-none { display: none; }
.flag-abnormal { color: var(--c-warn); }
.flag-critical { color: var(--c-bad); }
.yes-no .btn { min-width: 3.5rem; }
.choice-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.choice-chips .btn { border-radius: 999px; }
.input-group .unit-select { flex: 0 0 auto; width: auto; max-width: 9rem; }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
.calc-value { display: flex; align-items: baseline; gap: .35rem; min-height: 31px; padding: .25rem .5rem; border: 1px dashed var(--c-line); border-radius: .375rem; background: var(--c-surface-2); }
.calc-value output { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 2.5rem; }
.calc-unit, .calc-note { font-size: .8rem; color: var(--c-muted); }
.calc-note { margin-left: auto; font-style: italic; }
.form-matrix th, .form-matrix td, .form-group-table th, .form-group-table td { vertical-align: top; }
.form-matrix tbody th { font-weight: 500; white-space: nowrap; }
.form-matrix input { min-width: 5rem; }
.form-group-table .row-no { width: 2.5rem; color: var(--c-muted); }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; background: var(--c-bg); padding: .75rem 0; border-top: 1px solid var(--c-line); }
.form-readonly dd .table { width: auto; }
.new-encounter { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-end; }
.encounter-list .key-value { display: inline-block; margin-right: .75rem; font-size: .85rem; }
.back-link { text-decoration: none; font-size: 1.1rem; }

/* Trình soạn mẫu */
.designer-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }
.designer-toolbar input[type=search] { max-width: 22rem; }
.designer-section { border: 1px solid var(--c-line); border-radius: .5rem; margin-bottom: .6rem; background: var(--c-surface); }
.designer-section[open] { border-color: var(--c-accent); margin-bottom: 1rem; }
.designer-section > summary, .designer-item-box > summary { list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; }
.designer-section > summary::-webkit-details-marker, .designer-item-box > summary::-webkit-details-marker { display: none; }
.designer-section-head { padding: .6rem .75rem; background: var(--c-surface-2); border-radius: .5rem; }
.designer-section[open] > .designer-section-head { border-bottom: 1px solid var(--c-line); border-radius: .5rem .5rem 0 0; }
.designer-section-title { font-weight: 600; font-size: 1rem; }
.designer-caret::before { content: "▸"; display: inline-block; width: 1em; color: var(--c-muted); transition: transform .15s; }
details[open] > summary > .designer-caret::before { transform: rotate(90deg); }
.designer-chip { display: inline-block; font-size: .72rem; line-height: 1.4; padding: 0 .45rem; border-radius: 1rem; border: 1px solid var(--c-line); color: var(--c-ink-2); background: var(--c-surface); white-space: nowrap; }
.designer-chip.chip-muted { color: var(--c-muted); }
.designer-chip.chip-strong { border-color: var(--c-accent); color: var(--c-accent); }
.designer-chip.chip-bad { border-color: var(--c-bad); color: var(--c-bad); }
.designer-section-settings { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; padding: .75rem; border-bottom: 1px solid var(--c-line); }
.designer-section-settings .form-label { font-size: .75rem; margin-bottom: .1rem; color: var(--c-ink-2); }
.designer-items { padding: .5rem .75rem 0; }
.designer-item-box { border: 1px solid var(--c-line); border-radius: .4rem; margin-bottom: .4rem; }
.designer-item-box[open] { border-color: var(--c-accent); }
.designer-item-head { padding: .35rem .6rem; font-size: .875rem; }
.designer-item-box[open] > .designer-item-head { background: var(--c-surface-2); border-bottom: 1px solid var(--c-line); border-radius: .4rem .4rem 0 0; }
.designer-item-no { color: var(--c-muted); font-variant-numeric: tabular-nums; min-width: 1.5rem; }
.designer-item-name { font-weight: 500; }
.designer-item-width { margin-left: auto; color: var(--c-muted); font-size: .75rem; }
.designer-item-box.is-filtered-out, .designer-section.is-filtered-out { display: none; }
.designer-item-box.is-match > summary { background: var(--c-accent-50); }
.designer-item { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: .5rem; padding: .6rem .75rem; }
.designer-item .span-2 { grid-column: span 2; }
.designer-item .span-3 { grid-column: span 3; }
.designer-item .span-4 { grid-column: span 4; }
.designer-item .span-6 { grid-column: span 6; }
.designer-item .span-12 { grid-column: span 12; }
.designer-item .form-label { font-size: .75rem; margin-bottom: .1rem; color: var(--c-ink-2); }
.designer-flags { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: center; }
.designer-tools { display: flex; gap: .25rem; justify-content: flex-end; align-items: flex-end; }
@media (max-width: 991.98px) {
    .designer-item .span-2, .designer-item .span-3, .designer-item .span-4 { grid-column: span 6; }
    .designer-item .span-6 { grid-column: span 12; }
}
.json-editor { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .8rem; min-height: 28rem; }
/* Trình soạn: chỉ hiện các ô hợp với loại mục */
.designer-item .when-indicator, .designer-item .when-rows, .designer-item .when-matrix, .designer-item .when-group, .designer-item .when-calc { display: none; }
.designer-item[data-type="Field"] .when-indicator, .designer-item[data-type="Calculated"] .when-indicator,
.designer-item[data-type="Matrix"] .when-rows, .designer-item[data-type="Group"] .when-rows,
.designer-item[data-type="Matrix"] .when-matrix, .designer-item[data-type="Group"] .when-group,
.designer-item[data-type="Calculated"] .when-calc { display: block; }

/* Có / Không: hai lựa chọn tách bạch, lựa chọn đang chọn tô đậm, có dấu ✓ */
.seg { display: inline-flex; border: 1px solid var(--c-control-border); border-radius: .5rem; overflow: hidden; background: var(--c-surface); }
.seg-opt { position: relative; margin: 0; cursor: pointer; }
.seg-opt + .seg-opt { border-left: 1px solid var(--c-control-border); }
.seg-opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg-opt span { display: block; padding: .3rem .95rem; font-size: .9rem; color: var(--c-ink-2); user-select: none; }
.seg-opt:hover span { background: var(--c-accent-50); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--c-accent); outline-offset: -2px; }
.seg-yes input:checked + span { background: var(--c-accent); color: #fff; font-weight: 600; }
.seg-no input:checked + span { background: var(--c-ink-2); color: #fff; font-weight: 600; }
.seg-yes input:checked + span::before, .seg-no input:checked + span::before { content: "✓ "; }
.seg-clear span { color: var(--c-muted); font-size: .8rem; padding: .35rem .7rem; }
.seg-clear input:checked + span { background: var(--c-surface-2); color: var(--c-ink-2); }

/* Chọn nhiều: lưới ô đánh dấu, ô đã chọn tô nền */
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .35rem .5rem; }
.check-opt { display: flex; align-items: flex-start; gap: .5rem; margin: 0; padding: .35rem .6rem; border: 1px solid var(--c-line); border-radius: .4rem; cursor: pointer; background: var(--c-surface); font-size: .9rem; }
.check-opt:hover { border-color: var(--c-accent); }
.check-opt .form-check-input { margin-top: .15rem; flex: 0 0 auto; }
.check-opt:has(input:checked) { background: var(--c-accent-50); border-color: var(--c-accent); color: var(--c-accent-ink); font-weight: 500; }
.check-opt.is-none { font-style: italic; }

/* Ô chọn có tìm kiếm, cho thêm mới */
.tag-combo { position: relative; }
.tag-box { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; min-height: 31px; padding: .2rem .35rem; border: 1px solid var(--c-control-border); border-radius: .375rem; background: var(--c-surface); cursor: text; }
.tag-box:focus-within { border-color: var(--c-accent); box-shadow: 0 0 0 .2rem var(--c-accent-50); }
.tag { display: inline-flex; align-items: center; gap: .25rem; padding: .1rem .2rem .1rem .55rem; border-radius: 999px; background: var(--c-accent-50); color: var(--c-accent-ink); font-size: .85rem; border: 1px solid var(--c-accent); }
.tag.is-new { background: var(--c-warn-bg); border-color: var(--c-warn); color: var(--c-warn); }
.tag-x { border: 0; background: transparent; color: inherit; font-size: 1rem; line-height: 1; padding: 0 .3rem; cursor: pointer; }
.tag-input { flex: 1 1 8rem; min-width: 8rem; border: 0; outline: 0; background: transparent; font-size: .875rem; padding: .15rem; }
.tag-combo .combo-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; max-height: 16rem; overflow-y: auto; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: .375rem; box-shadow: 0 6px 18px rgba(0, 0, 0, .12); }
.tag-combo .combo-option { padding: .4rem .65rem; cursor: pointer; font-size: .9rem; }
.tag-combo .combo-option.active, .tag-combo .combo-option:hover { background: var(--c-accent-50); }
.tag-combo .combo-option.is-new { color: var(--c-accent-600); font-weight: 600; border-top: 1px dashed var(--c-line); }
.tag-combo .combo-empty { padding: .4rem .65rem; color: var(--c-muted); font-size: .85rem; }

/* Chi tiết trong cửa sổ bật lên */
.detail-dialog { width: min(560px, calc(100vw - 32px)); border: 0; border-radius: .6rem; padding: 1rem 1.1rem; box-shadow: 0 12px 40px rgba(0, 0, 0, .25); color: var(--c-ink); background: var(--c-surface); }
.detail-dialog::backdrop { background: rgba(15, 38, 40, .35); }
.dlg-head { font-weight: 600; margin-bottom: .75rem; }
.dlg-actions { display: flex; justify-content: flex-end; margin-top: 1rem; }
.popup-summary { margin-top: .35rem; font-size: .85rem; padding: .3rem .5rem; border-left: 3px solid var(--c-accent); background: var(--c-accent-50); border-radius: 0 .3rem .3rem 0; }
.popup-summary.is-empty { color: var(--c-muted); font-style: italic; border-left-color: var(--c-warn); background: var(--c-warn-bg); }

/* Bảng theo dõi */
.followup-table th, .followup-table td { white-space: nowrap; font-size: .85rem; }
.followup-table thead th { position: sticky; top: 0; background: var(--c-surface-2); z-index: 1; }
.followup-table .fu-label { position: sticky; left: 0; background: var(--c-surface); z-index: 1; white-space: normal; min-width: 200px; }
.followup-table .fu-group td { background: var(--c-surface-2); font-weight: 600; color: var(--c-ink-2); }
.followup-table .trend { font-size: .75rem; margin-left: .15rem; color: var(--c-muted); }
.followup-scroll { max-height: 70vh; overflow: auto; }

.form-item > .form-label { display: block; }

/* ---------- Màn hình theo dõi (thiết kế đã duyệt, màn hình 4) ---------- */
:root { --c-series-1: #7a4fb0; --c-series-2: #c2410c; --c-series-3: #2563eb; --c-series-4: #15803d; --c-series-5: #a16207; }
.dx-line { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin: 0 0 .6rem; font-size: .9rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; margin-bottom: .6rem; }
.kpi { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: .4rem; padding: .5rem .65rem; min-width: 0; }
.kpi small { display: block; font-size: .68rem; color: var(--c-muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: .72rem; }
.kpi.alert { border-color: var(--c-bad); background: var(--c-bad-bg); }
.kpi.alert small, .kpi.alert strong { color: var(--c-bad); }
.flagrow { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin: 0 0 .75rem; }
.pill { display: inline-block; font-size: .72rem; font-weight: 600; padding: .05rem .55rem; border-radius: 99px; white-space: nowrap; }
.p-ok { background: var(--c-ok-bg); color: var(--c-ok); }
.p-warn { background: var(--c-warn-bg); color: var(--c-warn); }
.p-bad { background: var(--c-bad-bg); color: var(--c-bad); }
.p-info { background: var(--c-accent-50); color: var(--c-accent-ink); }
.p-mute { background: var(--c-surface-2); color: var(--c-ink-2); border: 1px solid var(--c-line); }
.pending { display: inline-block; border: 1px dashed var(--c-warn); background: var(--c-warn-bg); color: var(--c-warn); font-size: .72rem; padding: .05rem .5rem; border-radius: .25rem; white-space: nowrap; }
.box { background: var(--c-surface); border: 1px solid var(--c-line); border-top: 3px solid var(--c-accent); border-radius: .3rem; margin-bottom: .75rem; min-width: 0; }
.box-h { padding: .5rem .75rem; border-bottom: 1px solid var(--c-line); display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.box-h h5 { margin: 0; font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; }
.box-b { padding: .6rem .75rem; }
.fu-split { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: .75rem; }
@media (max-width: 1099.98px) { .fu-split { grid-template-columns: minmax(0, 1fr); } }
.legend { display: flex; flex-wrap: wrap; gap: .25rem .75rem; font-size: .75rem; }
.legend .lg.s0 { color: var(--c-accent); } .legend .lg.s1 { color: var(--c-series-1); } .legend .lg.s2 { color: var(--c-series-2); }
.legend .lg.s3 { color: var(--c-series-3); } .legend .lg.s4 { color: var(--c-series-4); } .legend .lg.s5 { color: var(--c-series-5); }
.chart-wrap { overflow-x: auto; }
.trend { min-width: 420px; display: block; }
.trend .grid { stroke: var(--c-line); stroke-width: 1; }
.trend .axis { fill: var(--c-muted); font-size: 11px; }
.trend .limit { stroke: var(--c-bad); stroke-width: 1.2; stroke-dasharray: 5 4; }
.trend .limit-text { fill: var(--c-bad); font-size: 10.5px; }
.trend .line { fill: none; stroke-width: 2.5; }
.trend .dot { fill: var(--c-surface); stroke-width: 2; }
.trend .val { font-size: 11px; font-weight: 600; }
.trend .s0 { stroke: var(--c-accent); } .trend .val.s0, .trend .dot.last.s0 { fill: var(--c-accent); }
.trend .s1 { stroke: var(--c-series-1); } .trend .val.s1, .trend .dot.last.s1 { fill: var(--c-series-1); }
.trend .s2 { stroke: var(--c-series-2); } .trend .val.s2, .trend .dot.last.s2 { fill: var(--c-series-2); }
.trend .s3 { stroke: var(--c-series-3); } .trend .val.s3, .trend .dot.last.s3 { fill: var(--c-series-3); }
.trend .s4 { stroke: var(--c-series-4); } .trend .val.s4, .trend .dot.last.s4 { fill: var(--c-series-4); }
.trend .s5 { stroke: var(--c-series-5); } .trend .val.s5, .trend .dot.last.s5 { fill: var(--c-series-5); }
.trend .val { stroke: none; }
.trend .band { stroke: none; opacity: .12; }
.trend .band.s0 { fill: var(--c-accent); } .trend .band.s1 { fill: var(--c-series-1); } .trend .band.s2 { fill: var(--c-series-2); }
.trend .band.s3 { fill: var(--c-series-3); } .trend .band.s4 { fill: var(--c-series-4); } .trend .band.s5 { fill: var(--c-series-5); }
.trend .tick { stroke: var(--c-line); stroke-width: 1; }
.trend .event { stroke: var(--c-ink-2); stroke-width: 1; stroke-dasharray: 2 3; }
.trend .event-no { fill: var(--c-ink-2); font-size: 10px; font-weight: 600; }
.trend .dot.alert { stroke: var(--c-bad); stroke-width: 3; }
.trend-events { margin: .25rem 0 0; padding-left: 1.4rem; font-size: .78rem; color: var(--c-ink-2); }
.kpi .spark { margin-top: .2rem; }
.stage-strip { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-top: .6rem; font-size: .8rem; }
.stage-strip .stage-title { color: var(--c-muted); margin-right: .25rem; }
.stage-strip .stage { border-radius: .25rem; padding: .1rem .4rem; border: 1px solid var(--c-line); white-space: nowrap; }
.stage-strip .stage-1 { background: var(--c-chart-o1); color: var(--c-ink); border-color: var(--c-chart-o1); }
.stage-strip .stage-2 { background: var(--c-chart-o2); color: var(--c-surface); border-color: var(--c-chart-o2); }
.stage-strip .stage-3 { background: var(--c-chart-o3); color: var(--c-surface); border-color: var(--c-chart-o3); }
.stage-strip .stage-none { color: var(--c-muted); }
.chart-pick summary { cursor: pointer; font-size: .8rem; color: var(--c-accent-600); margin-top: .35rem; }
.tl { list-style: none; padding: 0; margin: 0; }
.tl li { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: .6rem; padding: .5rem 0; border-bottom: 1px dashed var(--c-line); }
.tl li:last-child { border-bottom: 0; }
.tl .d { font-size: .78rem; color: var(--c-ink-2); font-variant-numeric: tabular-nums; }
.tl .t { font-size: .85rem; }
.tl .tags { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; margin-top: .25rem; }
.delta { font-size: .72rem; color: var(--c-ink-2); margin-left: .1rem; }
.hl-bad { color: var(--c-bad); font-weight: 600; }
.followup-table td.num, .followup-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Tab hồ sơ: biểu tượng + phím tắt gợi ý */
.record-tabs .nav-link { display: inline-flex; align-items: center; gap: .4rem; }
.tab-icon, .back-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.tab-kbd { font-family: ui-monospace, Consolas, monospace; font-size: .62rem; padding: .05rem .3rem; border-radius: .25rem; border: 1px solid var(--c-line); background: var(--c-surface-2); color: var(--c-muted); box-shadow: none; }
.record-tabs .nav-link.active .tab-kbd { border-color: var(--c-accent); color: var(--c-accent-600); }
@media (max-width: 767.98px) { .tab-kbd { display: none; } }

/* Nút quay về hồ sơ ở trang khám */
.back-btn { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; }

/* Chẩn đoán: "Chẩn đoán chính: Mã - Tên (ghi chú)" mỗi loại một dòng */
.dx-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .2rem .6rem; margin: 0; }
.dx-list dt { font-weight: 500; color: var(--c-ink-2); }
.dx-list dd { margin: 0; font-weight: 600; }
.dx-box { background: var(--c-surface); border: 1px solid var(--c-line); border-left: 4px solid var(--c-accent); border-radius: .4rem; padding: .5rem .75rem; margin-bottom: .6rem; }

/* Vùng thao tác nguy hiểm (xoá lượt khám) */
.danger-zone { margin-top: 1rem; border: 1px solid var(--c-bad); border-radius: .4rem; padding: .5rem .75rem; background: var(--c-surface); }
.danger-zone summary { cursor: pointer; color: var(--c-bad); font-weight: 600; font-size: .9rem; }

/* Kê toa */
.rx-item { border: 1px solid var(--c-line); border-radius: .5rem; padding: .6rem .75rem; margin-bottom: .6rem; background: var(--c-surface); }
.rx-head { display: flex; gap: .5rem; align-items: center; }
.rx-no { font-weight: 700; color: var(--c-accent); min-width: 1.6rem; }
.rx-search { position: relative; flex: 1 1 auto; }
.rx-search .combo-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; max-height: 18rem; overflow-y: auto; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: .375rem; box-shadow: 0 6px 18px rgba(0, 0, 0, .12); }
.rx-search .combo-option { padding: .4rem .65rem; cursor: pointer; font-size: .88rem; border-bottom: 1px dashed var(--c-line); }
.rx-search .combo-option:hover { background: var(--c-accent-50); }
.rx-search .combo-option.is-new { color: var(--c-accent-600); font-weight: 600; }
.rx-preview { margin-top: .4rem; font-style: italic; color: var(--c-ink-2); min-height: 1.2em; }
.rx-item .form-label.small { font-size: .75rem; margin-bottom: .1rem; color: var(--c-ink-2); }

/* Cột bên của lượt khám: Tự tính, Gợi ý, Còn thiếu */
.insights { display: flex; flex-direction: column; gap: .75rem; font-size: .875rem; }
.ins-box { border: 1px solid var(--c-line); border-radius: .5rem; background: var(--c-surface); padding: .6rem .75rem; }
.ins-box h6 { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--c-muted); margin: 0 0 .4rem; }
.ins-box ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.ins-box li { padding: .3rem .5rem; border-radius: .375rem; font-weight: 600; }
.ins-box li small { display: block; font-weight: 400; color: var(--c-ink-2); }
.ins-box li.sg-bad { background: var(--c-bad-bg); color: var(--c-bad); }
.ins-box li.sg-warn { background: var(--c-warn-bg); color: var(--c-warn); }
.ins-box li.sg-info { background: var(--c-accent-50); color: var(--c-accent-600); }
.ins-box li.ins-missing { background: var(--c-surface-2); font-weight: 500; }
.ins-note { margin: .4rem 0 0; font-size: .75rem; color: var(--c-muted); }
.ins-calc { border-bottom: 1px dashed var(--c-line); }
.ins-calc:last-child { border-bottom: 0; }
.ins-calc summary { display: flex; justify-content: space-between; gap: .5rem; padding: .3rem 0; cursor: pointer; list-style: none; }
.ins-calc summary::-webkit-details-marker { display: none; }
.ins-calc summary b { white-space: nowrap; }
.ins-calc summary b.ins-abnormal { color: var(--c-warn); }
.ins-calc summary b.ins-critical { color: var(--c-bad); }
.ins-detail { font-size: .78rem; color: var(--c-ink-2); padding: 0 0 .4rem; }
.ins-source { margin-top: .2rem; color: var(--c-accent-ink); }
@media (min-width: 1200px) {
    .encounter-layout { grid-template-columns: 190px minmax(0, 1fr) 250px; }
    .insights { position: sticky; top: 4.5rem; max-height: calc(100vh - 6rem); overflow-y: auto; }
}
@media (max-width: 1199.98px) {
    .insights { order: -1; }
    .encounter-layout > .section-nav { order: -2; }
}

/* Sửa quy tắc gợi ý */
.rule-criterion { border: 1px solid var(--c-line); border-radius: .5rem; padding: .5rem .75rem .6rem; margin-bottom: .6rem; }
.rule-criterion legend { float: none; width: auto; font-size: .95rem; font-weight: 600; padding: 0 .3rem; margin: 0; }
.rule-condition { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .2rem 0; }
.rule-condition .rule-value { width: 6rem; }

/* Đọc file cận lâm sàng: tải file, màn hình đối chiếu */
.upload-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.upload-row .form-control { flex: 1 1 18rem; }
.steps { list-style: none; display: flex; gap: .5rem; padding: 0; margin: 0 0 .75rem; font-size: .85rem; }
.steps li { padding: .25rem .75rem; border-radius: 999px; background: var(--c-surface-2); color: var(--c-muted); }
.steps li.done { background: var(--c-ok-bg); color: var(--c-ok); }
.steps li.done::before { content: "✓ "; }
.steps li.current { background: var(--c-accent); color: var(--c-surface); font-weight: 600; }
.review-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 1rem; align-items: start; }
@media (max-width: 1199.98px) { .review-layout { grid-template-columns: minmax(0, 1fr); } }
.review-source { position: sticky; top: 4.5rem; }
@media (max-width: 1199.98px) { .review-source { position: static; } }
.source-text { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .8rem; line-height: 1.5; tab-size: 4;
    max-height: 70vh; overflow: auto; border: 1px solid var(--c-line); border-radius: .375rem; padding: .5rem .6rem; background: var(--c-bg); }
.source-text > div { padding: 0 .25rem; border-radius: .2rem; white-space: pre-wrap; min-height: 1.5em; }
.src-matched { background: var(--c-warn-bg); }
.src-unmatched { background: var(--c-bad-bg); }
.src-key { padding: 0 .35rem; border-radius: .2rem; }
.review-lines th { font-size: .78rem; white-space: nowrap; }
.review-lines td { vertical-align: top; }
.review-lines .rv-check { width: 2.5rem; text-align: center; }
.review-lines tr.rv-unmatched td { background: var(--c-bad-bg); }
.review-lines tr.rv-suggested td { background: var(--c-warn-bg); }
.review-lines tr.rv-blank td { background: var(--c-surface-2); }
.rv-value { display: flex; gap: .25rem; min-width: 9.5rem; }
.rv-value .rv-unit { width: 5rem; flex: 0 0 5rem; }
.rv-remember { display: inline-flex; gap: .3rem; align-items: center; font-size: .78rem; margin-top: .2rem; color: var(--c-ink-2); }
.review-checks { border-top: 1px solid var(--c-line); }
.check-list { list-style: none; padding: 0; margin: .75rem 0 0; display: flex; flex-direction: column; gap: .25rem; font-size: .875rem; }
.check-list li::before { display: inline-block; width: 1.2rem; font-weight: 700; }
.check-list li.ok::before { content: "✓"; color: var(--c-ok); }
.check-list li.warn::before { content: "!"; color: var(--c-warn); }
.check-list li.bad { color: var(--c-bad); font-weight: 600; }
.check-list li.bad::before { content: "✗"; }

/* Hội chẩn */
.invite-list { display: flex; flex-direction: column; gap: .6rem; }
.invite-card { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap;
    border: 1px solid var(--c-line); border-left: 4px solid var(--c-accent); border-radius: .5rem; padding: .6rem .85rem; background: var(--c-surface); }
.invite-card.is-urgent { border-left-color: var(--c-bad); background: var(--c-bad-bg); }
.invitee-table td:last-child { width: 12rem; }
.session-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
@media (max-width: 1099.98px) { .session-layout { grid-template-columns: minmax(0, 1fr); } }
.session-side { display: flex; flex-direction: column; gap: .75rem; position: sticky; top: 4.5rem; }
@media (max-width: 1099.98px) { .session-side { position: static; order: -1; } }
.session-side summary { cursor: pointer; font-weight: 600; }
.session-side .check-opt { font-size: .875rem; }
.opinions { margin-top: 1rem; }
.opinions h6 { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--c-muted); }
.opinion { border-left: 3px solid var(--c-accent); padding: .3rem .7rem; margin-bottom: .5rem; background: var(--c-accent-50); border-radius: 0 .375rem .375rem 0; }
.opinion-h { font-size: .8rem; }
.opinion-b, .pre-line { white-space: pre-line; }

/* Chuông thông báo */
.topbar-bell { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 2.1rem; height: 2.1rem; border-radius: 50%; color: var(--c-ink-2); }
.topbar-bell:hover { background: var(--c-surface-2); color: var(--c-accent-600); }
.topbar-bell svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.topbar-bell.has-unread { color: var(--c-accent-600); }
.bell-count { position: absolute; top: -.1rem; right: -.2rem; min-width: 1.1rem; height: 1.1rem; padding: 0 .25rem; border-radius: 999px;
    background: var(--c-bad); color: var(--c-surface); font-size: .68rem; font-weight: 700; line-height: 1.1rem; text-align: center; }
.notice-list { list-style: none; margin: 0; padding: 0; }
.notice-list li { border-bottom: 1px solid var(--c-line); }
.notice-list li:last-child { border-bottom: 0; }
.notice-list li.is-unread { background: var(--c-accent-50); }
.notice-open { display: flex; flex-direction: column; gap: .15rem; width: 100%; text-align: left; border: 0; background: transparent; padding: .6rem .9rem; color: inherit; }
.notice-open:hover { background: var(--c-surface-2); }
.notice-open small { color: var(--c-muted); }

/* Dải cảnh báo khi đang làm việc dưới góc nhìn người dùng khác */
.acting-bar { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap;
    background: var(--c-bad); color: var(--c-surface); padding: .45rem 1rem; font-size: .875rem; position: sticky; top: 0; z-index: 30; }
.acting-bar form { margin: 0; }

/* Nhập hộ: dải "Đang nhập thay BS …" luôn hiện với người nhập hộ (vàng: khác dải đỏ của "góc nhìn người dùng khác") */
.onbehalf-bar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; padding: .4rem 1rem; font-size: .875rem;
    background: var(--c-warn-bg); color: var(--c-ink); border-bottom: 2px solid var(--c-warn); position: sticky; top: 0; z-index: 29; }
.onbehalf-bar > svg { width: 1.1rem; height: 1.1rem; flex: none; fill: none; stroke: var(--c-warn); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.onbehalf-bar b { font-weight: 700; }
.onbehalf-bar small { color: var(--c-ink-2); margin-left: .35rem; }
.onbehalf-bar.is-missing { background: var(--c-bad-bg); border-bottom-color: var(--c-bad); }
.onbehalf-bar.is-missing > svg { stroke: var(--c-bad); }
.onbehalf-menu form { margin: 0; }
.onbehalf-menu .dropdown-item small { display: block; color: var(--c-muted); font-size: .78rem; }
.onbehalf-menu .dropdown-item.active small { color: inherit; }
.onbehalf-list { list-style: none; margin: 0; padding: 0; }
.onbehalf-list li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .5rem 0; border-bottom: 1px dashed var(--c-line); }
.onbehalf-list li:last-child { border-bottom: 0; }
.onbehalf-list li.is-current b { color: var(--c-accent-ink); }
.onbehalf-list small { display: block; color: var(--c-ink-2); }
.onbehalf-list form { margin: 0; }
.onbehalf-modal-head { background: var(--c-warn-bg); border-bottom: 2px solid var(--c-warn); }
.onbehalf-doctor { font-size: 1.35rem; font-weight: 700; color: var(--c-ink); margin-bottom: .35rem; }
.onbehalf-change { margin-top: .9rem; padding-top: .75rem; border-top: 1px dashed var(--c-line); }
.doctor-of b { color: var(--c-ink); }
.desk-card.is-sign { border-color: var(--c-warn); background: var(--c-warn-bg); }
.desk-card.is-sign strong { color: var(--c-warn); }

/* Cấu hình hệ thống */
.setting-list { list-style: none; margin: 0; padding: 0; }
.setting-list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: .8rem 1rem; border-bottom: 1px solid var(--c-line); }
.setting-list li:last-child { border-bottom: 0; }
.setting-list p { margin: .2rem 0; color: var(--c-ink-2); max-width: 70ch; }
.setting-list small { color: var(--c-muted); }
.setting-list form { display: flex; gap: .5rem; align-items: center; margin: 0; flex: none; }
@media (max-width: 640px) { .setting-list li { flex-direction: column; } }

/* Bàn làm việc */
.desk-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.desk-card { display: flex; flex-direction: column; gap: .15rem; padding: .7rem .9rem; border: 1px solid var(--c-line); border-radius: .5rem;
    background: var(--c-surface); color: var(--c-ink); text-decoration: none; }
.desk-card:hover { border-color: var(--c-accent); background: var(--c-accent-50); }
.desk-card small { color: var(--c-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
.desk-card strong { font-size: 1.6rem; line-height: 1.1; }
.desk-card.is-alert { border-color: var(--c-bad); background: var(--c-bad-bg); }
.desk-card.is-alert strong { color: var(--c-bad); }
.desk-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.desk-grid > .panel { margin-bottom: 0; }
@media (max-width: 991.98px) { .desk-grid { grid-template-columns: minmax(0, 1fr); } }
.desk-list { list-style: none; margin: 0; padding: 0; }
.desk-list li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .4rem 0; border-bottom: 1px dashed var(--c-line); }
.desk-list li:last-child { border-bottom: 0; }
.desk-list small { display: block; color: var(--c-ink-2); }
.desk-list li > span:first-child { min-width: 0; }
.desk-list .status-pill { white-space: normal; max-width: 100%; }

/* Việc cần làm trên hồ sơ */
.task-list { list-style: none; margin: 0; padding: 0; }
.task-list li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .5rem .9rem; border-bottom: 1px solid var(--c-line); }
.task-list small { display: block; color: var(--c-ink-2); }
.task-list li.is-done b { text-decoration: line-through; color: var(--c-muted); font-weight: 500; }
.task-list li.is-overdue { background: var(--c-bad-bg); }
.task-list form { margin: 0; }
.task-add { display: flex; gap: .5rem; flex-wrap: wrap; }
.task-add input[name="title"] { flex: 1 1 16rem; }
.task-add input[type="date"] { flex: 0 0 10rem; }

/* Báo cáo */
.report-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 991.98px) { .report-grid { grid-template-columns: minmax(0, 1fr); } }
.report-grid > .panel { margin-bottom: 0; }
.bar-row { display: grid; grid-template-columns: minmax(8rem, 14rem) minmax(0, 1fr) 3rem; gap: .5rem; align-items: center; padding: .2rem 0; font-size: .9rem; }
.bar-svg { width: 100%; height: .7rem; display: block; }
.bar-svg .bar-bg { fill: var(--c-surface-2); }
.bar-svg .bar-fg { fill: var(--c-accent); }
.bar-row .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Biểu đồ dùng chung (Clinic.Web/Charts) ---------- */
/* Màu theo thứ tự s0…s5 dùng chung với .trend; t-* là màu có nghĩa; t-o1…o3 là nhóm có thứ tự (nhạt → đậm, ví dụ GAP I–III). */
:root { --c-chart-o1: #9fd3cf; --c-chart-o2: #3f9ea6; --c-chart-o3: #0a4f56; }
.chart .s0 { fill: var(--c-accent); stroke: var(--c-accent); }
.chart .s1 { fill: var(--c-series-1); stroke: var(--c-series-1); }
.chart .s2 { fill: var(--c-series-2); stroke: var(--c-series-2); }
.chart .s3 { fill: var(--c-series-3); stroke: var(--c-series-3); }
.chart .s4 { fill: var(--c-series-4); stroke: var(--c-series-4); }
.chart .s5 { fill: var(--c-series-5); stroke: var(--c-series-5); }
.chart .t-bad { fill: var(--c-bad); background: var(--c-bad); }
.chart .t-warn { fill: var(--c-warn); background: var(--c-warn); }
.chart .t-ok { fill: var(--c-ok); background: var(--c-ok); }
.chart .t-muted { fill: var(--c-control-border); background: var(--c-control-border); }
.chart .t-accent { fill: var(--c-accent); background: var(--c-accent); }
.chart .t-o1 { fill: var(--c-chart-o1); background: var(--c-chart-o1); }
.chart .t-o2 { fill: var(--c-chart-o2); background: var(--c-chart-o2); }
.chart .t-o3 { fill: var(--c-chart-o3); background: var(--c-chart-o3); }
.chart .pct { color: var(--c-muted); font-size: .8em; }
.chart-empty { padding: .25rem 0; }

.chart-hbar .hbar-row { display: grid; grid-template-columns: minmax(8rem, min(26rem, 45%)) minmax(0, 1fr) 4.5rem; gap: .5rem; align-items: center; padding: .2rem 0; font-size: .9rem; }
.chart-hbar .hbar-svg { width: 100%; height: .7rem; display: block; }
.chart-hbar .hbar-bg { fill: var(--c-surface-2); stroke: none; }
.chart-hbar .hbar-fg { stroke: none; }
.chart-hbar .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.chart-cols { display: block; min-width: 360px; }
.chart-cols .grid { stroke: var(--c-line); stroke-width: 1; fill: none; }
.chart-cols .axis { fill: var(--c-muted); stroke: none; font-size: 11px; }
.chart-cols .val { fill: var(--c-ink-2); stroke: none; font-size: 10.5px; font-weight: 600; }
.chart-cols .col { stroke: none; }
.chart-cols .line { fill: none; stroke-width: 2; }
.chart-cols .dot { fill: var(--c-surface); stroke-width: 2; }
.chart-cols .marker { stroke: var(--c-bad); stroke-width: 1.4; stroke-dasharray: 5 4; fill: none; }
.chart-cols .marker-text { fill: var(--c-bad); stroke: none; font-size: 10.5px; }

.chart-stack .stack-svg, .chart-compliance .stack-svg { width: 100%; height: .9rem; display: block; border-radius: .2rem; }
.chart-stack .seg, .chart-compliance .seg { stroke: none; }
.chart-compliance { display: grid; grid-template-columns: minmax(0, 1fr) 6.5rem; gap: .5rem; align-items: center; }
.chart-compliance .bg { fill: var(--c-surface-2); stroke: none; }
.chart-compliance .target { stroke: var(--c-ink); stroke-width: 2; }
.chart-compliance .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .9rem; }
.chart-legend { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem 1rem; padding: 0; margin: .4rem 0 0; font-size: .85rem; }
.chart-legend .sw { display: inline-block; width: .7rem; height: .7rem; border-radius: .15rem; margin-right: .3rem; vertical-align: -.05rem; }

.spark { width: 120px; height: 28px; display: block; }
.spark-line { fill: none; stroke: var(--c-accent); stroke-width: 1.5; }
.spark-dot { fill: var(--c-accent); }

.stats-filter { display: flex; flex-wrap: wrap; align-items: end; gap: .5rem 1rem; margin: .75rem 0 .5rem; font-size: .85rem; }
.stats-filter label { display: grid; gap: .15rem; color: var(--c-ink-2); }
.stats-quick { display: flex; gap: .75rem; margin-left: auto; }
.stats-compare th a { color: inherit; }
.km .km-line { fill: none; stroke-width: 2.2; }
.km-risk { font-size: .8rem; margin-top: .4rem; }
.km-risk th.num, .km-risk td.num { text-align: right; font-variant-numeric: tabular-nums; }
.km-risk .lg.s0 { color: var(--c-accent); } .km-risk .lg.s1 { color: var(--c-series-1); } .km-risk .lg.s2 { color: var(--c-series-2); }
.stats-compare th.num, .stats-compare td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.report-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.report-kpis a.kpi { color: inherit; text-decoration: none; }
.report-kpis a.kpi:hover { border-color: var(--c-accent); }
.report-kpis .kpi strong { font-size: 1.4rem; }
.report-sub { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--c-muted); margin: .9rem 0 .4rem; }
.report-compliance { display: grid; gap: .2rem; padding: .3rem 0; font-size: .9rem; }
.report-list > summary { padding: .5rem 1rem; cursor: pointer; color: var(--c-ink-2); font-size: .9rem; }
.report-list[open] > summary { border-bottom: 1px solid var(--c-line); }
.desk-meter { display: grid; gap: .2rem; }
.desk-meter .chart-legend { display: none; }
.desk-meter-text { font-size: .75rem; color: var(--c-ink-2); }
.chart-table { margin-top: .4rem; font-size: .85rem; }
.chart-table > summary { color: var(--c-muted); cursor: pointer; }
@media print { .chart-table { display: none; } }

/* Kết quả cận lâm sàng: bảng theo thời gian và màn hình nhập tay */
.lab-table .lab-group th { background: var(--c-surface-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; }
.lab-table th.num, .lab-table td.num { text-align: right; white-space: nowrap; }
.lab-entry { display: grid; grid-template-columns: repeat(auto-fill, minmax(21rem, 1fr)); gap: .5rem 1.5rem; }
.lab-entry-row { display: grid; grid-template-columns: minmax(0, 1fr) 6rem 6.75rem; gap: .4rem; align-items: center; }
.lab-entry-row label { font-size: .875rem; }
.lab-entry-row small { grid-column: 1 / -1; color: var(--c-ink-2); font-size: .75rem; margin-top: -.25rem; }
.lab-entry-row .lab-unit { font-size: .8rem; color: var(--c-ink-2); }

/* ---------- Form nhập gọn: tiêu đề phần, mục phụ, cận lâm sàng (docs/KHAM-GON-VA-TRINH-CHIEU.md) ---------- */
.form-group-heading { display: flex; align-items: center; gap: .6rem; margin: 1.1rem 0 .5rem; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--tone); }
.form-group-heading::after { content: ""; flex: 1; height: 2px; background: var(--tone-bg); }
.tone-0 { --tone: var(--c-tone-0); --tone-bg: var(--c-tone-0-bg); }
.tone-1 { --tone: var(--c-tone-1); --tone-bg: var(--c-tone-1-bg); }
.tone-2 { --tone: var(--c-tone-2); --tone-bg: var(--c-tone-2-bg); }
.tone-3 { --tone: var(--c-tone-3); --tone-bg: var(--c-tone-3-bg); }
.form-section { border-left: 4px solid var(--tone, var(--c-accent)); }
.form-section.is-revealed { box-shadow: 0 0 0 2px var(--tone-bg, var(--c-accent-50)); }
.section-head { position: sticky; top: var(--topbar-h); z-index: 4; background: var(--tone-bg, var(--c-accent-50)); border-radius: 0 5px 0 0; padding: .55rem .9rem; }
.sec-title { display: inline-flex; align-items: center; gap: .55rem; }
.sec-no { display: inline-flex; align-items: center; justify-content: center; min-width: 1.7rem; height: 1.7rem; padding: 0 .35rem; border-radius: 99px; background: var(--tone, var(--c-accent)); color: var(--c-surface); font-size: .8rem; font-weight: 700; }
.sec-name { font-size: 1.02rem; font-weight: 700; color: var(--c-ink); }
.sec-meta { display: inline-flex; align-items: center; flex-wrap: wrap; gap: .4rem; font-weight: 500; }
.sec-chip { font-size: .75rem; padding: 1px 8px; border-radius: 99px; background: var(--c-surface); color: var(--c-ink-2); border: 1px solid var(--c-line); white-space: nowrap; }
.sec-chip.chip-bad { background: var(--c-bad-bg); color: var(--c-bad); border-color: transparent; font-weight: 600; }
.sec-chip.chip-warn { background: var(--c-warn-bg); color: var(--c-warn); border-color: transparent; font-weight: 600; }
.layout-btn { font-size: .78rem; padding: 0 .25rem; color: var(--c-ink-2); }
.layout-btn:disabled { color: var(--c-ok); opacity: 1; }
.form-item { position: relative; }
.item-hide { position: absolute; top: -1.05rem; right: .5rem; z-index: 1; opacity: 0; padding: 0 .3rem; font-size: .72rem; line-height: 1rem; background: var(--c-surface); transition: opacity .12s; }
.form-item:hover > .item-hide, .form-item:focus-within > .item-hide, .item-hide:focus-visible, .item-hide:disabled { opacity: 1; }
.empty-sections .panel-body { padding: .5rem .9rem; }
.default-tag { margin-left: .3rem; font-size: .68rem; font-weight: 600; padding: 0 .35rem; border-radius: 99px; background: var(--c-surface-2); color: var(--c-ink-2); white-space: nowrap; }
.defaults-dialog { width: min(620px, calc(100vw - 32px)); }
.defaults-list { display: grid; gap: .3rem; max-height: min(55vh, 460px); overflow-y: auto; }
.defaults-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .6rem; padding: .4rem .6rem; border: 1px solid var(--c-line); border-radius: .4rem; cursor: pointer; }
.defaults-row:has(input:not(:checked)) { color: var(--c-muted); text-decoration: line-through; }
.defaults-value { color: var(--c-accent-ink); }

.section-nav a { display: flex; align-items: center; gap: .4rem; }
.section-nav .nav-no { flex: none; min-width: 1.35rem; font-size: .75rem; font-weight: 700; color: var(--c-muted); text-align: right; }
.section-nav .nav-name { flex: 1; min-width: 0; }
.section-nav .nav-mark { flex: none; width: .55rem; height: .55rem; border-radius: 99px; }
.section-nav a.is-done .nav-mark { background: var(--c-ok); }
.section-nav a.is-partial .nav-mark { background: var(--c-accent); opacity: .5; }
.section-nav a.is-missing .nav-mark { background: var(--c-bad); }
.section-nav a.is-optional { color: var(--c-muted); font-style: italic; }
.section-nav a.is-optional .nav-mark { width: auto; height: auto; background: none; }
.section-nav a.is-optional .nav-mark::before { content: "+"; font-style: normal; font-weight: 700; color: var(--c-accent); }
.section-nav .nav-config { margin-top: .5rem; font-size: .8rem; color: var(--c-accent); border-top: 1px solid var(--c-line); border-radius: 0; }

.add-section-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; margin-bottom: .75rem; }
.add-dialog { width: min(640px, calc(100vw - 32px)); }
.add-list { display: grid; gap: .25rem; max-height: min(60vh, 520px); overflow-y: auto; }
.add-option { display: flex; align-items: baseline; gap: .5rem; width: 100%; text-align: left; border: 1px solid var(--c-line); border-radius: .4rem; background: var(--c-surface); color: var(--c-ink); padding: .4rem .6rem; }
.add-option:hover, .add-option:focus-visible { background: var(--c-accent-50); border-color: var(--c-accent); }
.add-kind { flex: none; font-size: .7rem; font-weight: 700; text-transform: uppercase; color: var(--c-accent-600); min-width: 2.4rem; }
.add-detail { margin-left: auto; font-size: .8rem; color: var(--c-muted); }
.more-dialog { width: min(820px, calc(100vw - 32px)); }
/* Phần phụ: nhập trong cửa sổ bật lên; trên form chỉ còn thẻ tóm tắt khi đã có dữ liệu. */
.section-dialog { width: min(1100px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; background: var(--c-bg); }
.section-dialog > .form-section { margin: 0; border-radius: .6rem .6rem 0 0; }
.section-dialog .section-head { top: 0; }
.section-dialog-actions { position: sticky; bottom: 0; margin: 0; padding: .6rem 1rem; background: var(--c-surface); border-top: 1px solid var(--c-line); }
.section-card { border-left: 4px solid var(--tone, var(--c-accent)); }
.section-card-head { display: flex; align-items: center; gap: .55rem; padding: .45rem .9rem; flex-wrap: wrap; }
.section-card-head .sec-name { font-weight: 700; }
.section-card-text { flex: 1 1 18rem; min-width: 0; font-size: .85rem; color: var(--c-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.more-entry { padding: .5rem 0; border-bottom: 1px solid var(--c-line); }
.more-entry > .row > .form-item { flex: 0 0 100%; max-width: 100%; }
.more-entry.is-target { background: var(--c-accent-50); border-radius: .3rem; padding: .5rem; }
.more-summary { margin-top: .6rem; font-size: .85rem; padding: .3rem .5rem; border-left: 3px solid var(--c-accent); background: var(--c-accent-50); border-radius: 0 .3rem .3rem 0; }
.more-label { font-weight: 600; color: var(--c-accent-ink); }

.lab-summary .form-readonly { margin-bottom: .4rem; }
.lab-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.lab-manual { margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed var(--c-line); }

/* Trang cấu hình form */
.page-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.layout-section { padding: 0; }
.layout-row { display: grid; grid-template-columns: minmax(0, 1fr) 11rem 16rem 18rem; gap: .5rem 1rem; align-items: center; padding: .4rem .9rem; border-top: 1px solid var(--c-line); }
.default-edit { display: grid; gap: .25rem; }
.layout-row.is-section { border-top: 0; background: var(--c-surface-2); border-radius: 6px 6px 0 0; }
.layout-now { font-size: .8rem; color: var(--c-ink-2); }
.layout-items > summary { padding: .35rem .9rem; font-size: .82rem; color: var(--c-accent-600); cursor: pointer; }
.layout-items .layout-row .layout-label { padding-left: 1rem; }
@media (max-width: 767.98px) {
    .layout-row { grid-template-columns: minmax(0, 1fr); }
}

@media print {
    .add-section-bar, .layout-btn, .sec-meta, .lab-actions { display: none !important; }
    .section-head { position: static; }
}

/* ---------- Hội chẩn: tình hình bệnh nhân, hộp "Xem đầy đủ" (docs/KHAM-GON-VA-TRINH-CHIEU.md, Đợt 3) ---------- */
.situation .panel-header { background: var(--c-accent-50); }
.situation-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .6rem; margin-top: .6rem; }
.situation .brief-chart .chart-wrap svg { max-height: 220px; }
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.record-dialog { width: min(1180px, calc(100vw - 24px)); height: calc(100vh - 24px); max-height: none; max-width: none; padding: 0; border: 0; border-radius: .6rem; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); color: var(--c-ink); background: var(--c-bg); }
.record-dialog[open] { display: flex; flex-direction: column; }
.record-dialog::backdrop { background: rgba(15, 38, 40, .45); }
.record-dialog-head { display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; background: var(--c-surface); border-bottom: 1px solid var(--c-line); }
.record-dialog-body { flex: 1; overflow-y: auto; padding: .9rem 1rem 1.5rem; }
.record-patient { margin-bottom: .5rem; }
.rd-tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 2px solid var(--c-line); margin-bottom: .9rem; position: sticky; top: -.9rem; background: var(--c-bg); padding-top: .4rem; z-index: 2; }
.rd-tabs button { border: 0; background: none; padding: .45rem .8rem; color: var(--c-ink-2); font-weight: 500; border-bottom: 3px solid transparent; margin-bottom: -2px; display: inline-flex; align-items: center; gap: .4rem; }
.rd-tabs button.active { color: var(--c-accent-600); border-bottom-color: var(--c-accent); font-weight: 600; }
.rd-tabs button.is-empty { color: var(--c-muted); }
.record-text { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: .4rem; padding: .75rem 1rem; margin-bottom: .75rem; }
.rt-meta { font-size: .85rem; color: var(--c-ink-2); }
.rt-heading { margin: .9rem 0 .35rem; font-size: .8rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--c-accent-600); }
.rt-table caption { caption-side: top; font-weight: 600; color: var(--c-ink); padding: .2rem 0; }
.rt-list { margin-bottom: .5rem; }

/* ---------- Xem nhanh hồ sơ dạng trang trong hội chẩn (Đợt 4) ---------- */
.deck-dialog { inset: 0; width: auto; height: auto; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--c-bg); color: var(--c-ink); overflow: hidden; }
/* Hộp xem nhanh / hồ sơ đầy đủ đang mở: khoá cuộn trang phía sau (không lòi thanh cuộn, không lệch hộp). */
html:has(dialog.deck-dialog[open]), html:has(dialog.record-dialog[open]) { overflow: hidden; }
.deck-dialog[open] { display: flex; flex-direction: column; }
.deck-dialog::backdrop { background: rgba(15, 38, 40, .55); }
.deck-dialog-body { flex: 1; overflow-y: auto; }
.deck-dialog .deck { height: 100%; min-height: 0; }
.deck-dialog-body { overflow: hidden; display: flex; flex-direction: column; }
.deck-dialog-body > .deck { flex: 1; }
.deck:fullscreen { height: 100vh; }
@media (max-width: 767.98px) {
    .deck-wide { display: none !important; }
    .deck-bar { gap: .3rem; padding: .35rem .5rem; }
    .deck-bar .btn { padding: .15rem .5rem; font-size: .8rem; }
    .deck-count { min-width: 3.2rem; }
    .deck-track { padding: .5rem 0; }
    .deck-track .slide { flex-basis: calc(100% - 1rem); margin: 0 .5rem; }
    .slide-title { padding: .6rem .9rem; }
    .slide-body { padding: .7rem .9rem; overflow-x: hidden; }
    .sl-table { table-layout: fixed; width: 100%; font-size: .8em; overflow-wrap: anywhere; }
}
.slide-body.slide-body, body.slide-body { background: var(--c-bg); }
.deck { min-height: 100vh; display: flex; flex-direction: column; background: var(--c-bg); }
.deck-bar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .5rem 1rem; background: var(--c-surface); border-bottom: 1px solid var(--c-line); }
.deck-title { font-size: .95rem; }
.deck-nav { display: inline-flex; align-items: center; gap: .35rem; }
.deck-count { min-width: 4.5rem; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.deck-sync { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.deck-follow { color: var(--c-accent-ink); background: var(--c-accent-50); border-radius: 99px; padding: .15rem .6rem; }
.deck-stage { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding: 1rem; }
/* Màn hình: các trang xếp ngang, lướt theo ngón tay rồi hít vào đúng trang. */
.deck-track { position: relative; min-height: 0; justify-content: flex-start; align-items: stretch; gap: 0; padding: .75rem 0; overflow-x: auto; overflow-y: hidden;
    scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch; outline: none; }
.deck-track::-webkit-scrollbar { display: none; }
@media (hover: hover) and (pointer: fine) { .deck-track { cursor: grab; } }
.deck-track.is-dragging { cursor: grabbing; scroll-snap-type: none; user-select: none; }
/* Mỗi lần thấy đúng một trang: trang rộng tối đa 1320px, lề hai bên bù cho đủ bề rộng khung nên trang đầu / cuối cũng canh giữa. */
.deck-track .slide { flex: 0 0 min(1320px, calc(100% - 2rem)); width: auto; height: auto; aspect-ratio: auto;
    margin: 0 max(1rem, calc((100% - 1320px) / 2)); scroll-snap-align: center; scroll-snap-stop: always; }
.slide { width: min(1280px, 100%); aspect-ratio: 16 / 9; min-height: 0; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: .6rem; box-shadow: 0 6px 24px rgba(15, 38, 40, .12); display: flex; flex-direction: column; overflow: hidden; }
.slide-title { margin: 0; padding: .9rem 1.4rem; font-size: clamp(1.1rem, 2.2vw, 1.7rem); font-weight: 700; color: var(--c-surface); background: var(--c-accent); }
.slide-body { flex: 1; overflow-y: auto; padding: 1rem 1.4rem; font-size: clamp(.85rem, 1.25vw, 1.1rem); display: grid; gap: .8rem; align-content: start; }
.slide-foot { display: flex; justify-content: space-between; padding: .35rem 1.4rem; font-size: .75rem; color: var(--c-muted); border-top: 1px solid var(--c-line); }
.deck:fullscreen { background: var(--c-bg); }
.deck:fullscreen .deck-stage { align-items: center; }
.deck:fullscreen .slide { width: min(100%, calc((100vh - 6rem) * 16 / 9)); }
.sl-section h3 { font-size: 1em; font-weight: 700; color: var(--c-accent-600); margin: 0 0 .3rem; text-transform: uppercase; letter-spacing: .03em; }
.sl-lines { margin: 0 0 .3rem; padding-left: 1.2rem; }
.sl-lines li { margin-bottom: .15rem; }
.sl-table { font-size: .92em; margin-bottom: .3rem; }
.sl-table caption { caption-side: top; font-weight: 600; color: var(--c-ink); padding: 0 0 .2rem; }
.sl-cover { display: grid; gap: .6rem; align-content: center; min-height: 100%; }
.sl-cover-name { font-size: clamp(1.6rem, 3.6vw, 2.8rem); font-weight: 800; color: var(--c-accent-ink); }
.sl-cover-meta { font-size: 1.1em; color: var(--c-ink-2); }
.sl-question { border-left: 5px solid var(--c-warn); background: var(--c-warn-bg); border-radius: 0 .4rem .4rem 0; padding: .6rem .9rem; font-size: 1.1em; white-space: pre-line; }
.sl-question > span { display: block; font-size: .7em; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--c-warn); }
.sl-callout { border: 1px dashed var(--c-warn); background: var(--c-warn-bg); border-radius: .4rem; padding: .5rem .8rem; }
.sl-callout-title { font-weight: 700; color: var(--c-warn); }
.sl-callout-title span { font-weight: 500; font-size: .85em; }
.sl-note { font-size: .92em; color: var(--c-ink-2); border-left: 4px solid var(--c-accent); padding: .3rem .7rem; background: var(--c-accent-50); }
.sl-files { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .6rem; }
.sl-files figure { margin: 0; }
.sl-files img { width: 100%; max-height: 40vh; object-fit: contain; background: var(--c-surface-2); border-radius: .3rem; }
.sl-files figcaption { font-size: .75em; color: var(--c-muted); }
.sl-chart .chart-wrap svg { display: block; width: auto; max-width: 100%; max-height: 24vh; margin: 0 auto; }
.slide .kpis { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.deck-toc { position: fixed; inset: 3.2rem 1rem 1rem; z-index: 6; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: .6rem; box-shadow: 0 12px 40px rgba(0, 0, 0, .25); padding: .8rem 1rem; overflow-y: auto; }
.deck-toc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.deck-toc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem; }
.deck-toc-item { text-align: left; border: 1px solid var(--c-line); border-radius: .4rem; background: var(--c-surface); padding: .5rem .7rem; color: var(--c-ink); display: flex; gap: .5rem; }
.deck-toc-item span { font-weight: 700; color: var(--c-accent); }
.deck-toc-item:hover, .deck-toc-item:focus-visible { background: var(--c-accent-50); border-color: var(--c-accent); }
.deck.is-print .deck-stage { flex-direction: column; align-items: center; gap: 1rem; }
@media (max-width: 767.98px) {
    .slide { aspect-ratio: auto; min-height: 70vh; }
}
@media print {
    @page { size: A4 landscape; margin: 8mm; }
    body.slide-body, .deck { background: #fff; }
    .no-print, .deck-bar { display: none !important; }
    .deck-stage { padding: 0; display: block; }
    .slide { width: 100%; aspect-ratio: auto; height: 190mm; box-shadow: none; border: 1px solid #999; border-radius: 0; break-after: page; page-break-after: always; }
    .slide:last-child { break-after: auto; page-break-after: auto; }
    .slide[hidden] { display: flex !important; }
    .slide-body { overflow: visible; font-size: 10.5pt; }
    .slide-title { color: #000; background: #e6e6e6; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* ---------- File kết quả: tiến độ tải, hộp trạng thái góc dưới bên phải ---------- */
.status-reading { background: var(--c-accent-50); color: var(--c-accent-ink); }
.upload-progress { display: flex; align-items: center; gap: .75rem; margin-top: .5rem; font-size: .9rem; color: var(--c-ink-2); }
.upload-progress[hidden] { display: none; }
.upload-progress progress { flex: 0 1 16rem; height: .6rem; accent-color: var(--c-accent); }
.reading-note { display: flex; gap: .6rem; align-items: flex-start; }
.reading-note .spinner-border { flex: none; margin-top: .2rem; }
.read-tray {
    position: fixed; right: 1rem; bottom: 1rem; z-index: 1070;
    width: min(23rem, calc(100vw - 2rem)); display: flex; flex-direction: column; gap: .5rem;
}
.read-tray[hidden] { display: none; }
.read-item {
    display: flex; align-items: flex-start; gap: .6rem; padding: .65rem .75rem;
    background: var(--c-surface); color: var(--c-ink); border: 1px solid var(--c-line); border-left: 4px solid var(--c-accent);
    border-radius: .5rem; box-shadow: 0 6px 20px rgb(15 38 40 / 18%); text-decoration: none; font-size: .9rem;
}
.read-item.is-done { border-left-color: var(--c-ok); cursor: pointer; }
.read-item.is-done:hover, .read-item.is-done:focus-visible { background: var(--c-ok-bg); color: var(--c-ink); }
.read-mark { flex: none; margin-top: .15rem; color: var(--c-accent); }
.read-ok { width: 1.2rem; height: 1.2rem; border-radius: 50%; background: var(--c-ok); color: var(--c-surface); display: inline-flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; }
.read-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.read-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.read-text span { color: var(--c-ink-2); }
.read-close { flex: none; font-size: .65rem; margin-top: .2rem; }
@media print { .read-tray { display: none !important; } }

/* ---------- Trang phiếu báo lỗi (docs/BAO-LOI.md); nút và hộp gửi ở bug-report.css ---------- */
.bug-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.bug-status-new { background: var(--c-accent-50); color: var(--c-accent-ink); }
.bug-status-closed { background: var(--c-surface-2); color: var(--c-ink-2); }
.bug-excerpt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 36rem; overflow-wrap: anywhere; }
.bug-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bug-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .3rem 1rem; margin: 0; font-size: .875rem; }
.bug-facts dt { color: var(--c-ink-2); font-weight: 500; }
.bug-facts dd { margin: 0; overflow-wrap: anywhere; }
.bug-image summary { cursor: pointer; color: var(--c-accent); }
.bug-image img { display: block; max-width: 100%; margin-top: .6rem; border: 1px solid var(--c-line); }
.bug-actions { display: flex; flex-direction: column; align-items: flex-start; gap: .75rem; }
.bug-close { width: 100%; max-width: 40rem; }
.bug-close-buttons { display: flex; gap: .5rem; margin-top: .6rem; }

/* Phiếu hình ảnh: khung sửa ở màn hình đối chiếu, bảng trong hồ sơ, trang xem */
.img-report { border-bottom: 1px solid var(--c-line); }
.img-text { resize: vertical; }
.reinterpret { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; border-top: 1px solid var(--c-line); }
.imaging-table td, .imaging-table th { vertical-align: top; }
.report-facts { display: flex; flex-wrap: wrap; gap: .5rem 2rem; margin: 0 0 1rem; }
.report-facts dt { font-size: .78rem; font-weight: 600; color: var(--c-muted); }
.report-facts dd { margin: 0; }
.report-heading { font-size: .95rem; font-weight: 600; margin: 1rem 0 .35rem; }
.report-text { white-space: pre-line; overflow-wrap: anywhere; line-height: 1.55; }
.report-conclusion { font-weight: 600; }
.wrap-any { overflow-wrap: anywhere; }
.clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }

/* Cây kết quả của hồ sơ: cây bên trái, nội dung bên phải; điện thoại thì xếp chồng */
.tree-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; border-bottom: 1px solid var(--c-line); }
.tree-filter { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.tree-filter .tree-search { width: 14rem; max-width: 100%; }
.tree-date-field { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; color: var(--c-ink-2); }
.tree-date-field input { width: auto; max-width: 100%; }
.tree-count { margin-left: auto; }
.tree-layout { display: grid; grid-template-columns: minmax(200px, 280px) minmax(0, 1fr); }
.tree-nav { border-right: 1px solid var(--c-line); padding: .5rem 0; max-height: 70vh; overflow-y: auto; }
.tree-branch > summary { padding: .35rem .9rem; font-size: .88rem; font-weight: 600; cursor: pointer; color: var(--c-ink); }
.tree-branch > summary:hover { background: var(--c-surface-2); }
.tree-leaves { list-style: none; margin: 0 0 .25rem; padding: 0; }
.tree-leaf { display: block; width: 100%; text-align: left; border: 0; background: transparent; color: var(--c-ink-2); padding: .3rem .9rem .3rem 2rem; font-size: .88rem; overflow-wrap: anywhere; }
.tree-leaf:hover { background: var(--c-surface-2); color: var(--c-ink); }
.tree-leaf:focus-visible { outline: 2px solid var(--c-accent); outline-offset: -2px; }
.tree-leaf.is-active { background: var(--c-accent-50); color: var(--c-accent-ink); font-weight: 600; box-shadow: inset 3px 0 0 var(--c-accent); }
.tree-bad { color: var(--c-bad); font-weight: 600; }
.tree-content { min-width: 0; padding: .75rem .9rem; }
.tree-pane-title { font-size: 1rem; font-weight: 600; margin: 0 0 .5rem; }
.tree-table td.num, .tree-table th.num { text-align: right; white-space: nowrap; }
.tree-table td:first-child { overflow-wrap: anywhere; }
.tree-conclusion { max-height: 18rem; overflow-y: auto; }
.tree-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.tree-report { padding-bottom: .75rem; }
.tree-report + .tree-report { border-top: 1px solid var(--c-line); }
.tree-report .report-heading { overflow-wrap: anywhere; margin-top: .5rem; }
.tree-files { list-style: none; margin: 0; padding: 0; }
.tree-files li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .3rem .75rem; padding: .3rem 0; border-top: 1px solid var(--c-line); }
.tree-file-name { overflow-wrap: anywhere; min-width: 0; }
.results-more > summary.panel-header { cursor: pointer; justify-content: flex-start; list-style: none; }
.results-more > summary.panel-header::-webkit-details-marker { display: none; }
.results-more > summary.panel-header::before { content: "▸"; color: var(--c-muted); }
.results-more[open] > summary.panel-header::before { content: "▾"; }
.results-more:not([open]) > summary.panel-header { border-bottom: 0; }
@media (max-width: 767.98px) {
    .tree-layout { grid-template-columns: minmax(0, 1fr); }
    .tree-nav { border-right: 0; border-bottom: 1px solid var(--c-line); max-height: none; }
    .tree-count { margin-left: 0; }
}

/* Hộp xem file gốc */
.detail-dialog.wide { width: min(1100px, calc(100vw - 32px)); }
.file-viewer-body { min-height: 8rem; }
.file-viewer-frame { display: block; width: 100%; height: 72vh; border: 1px solid var(--c-line); border-radius: .3rem; background: var(--c-surface-2); }
.file-viewer-image { display: block; max-width: 100%; max-height: 72vh; margin: 0 auto; }
.file-viewer-actions { gap: .4rem; flex-wrap: wrap; }
.dlg-head[data-file-title] { overflow-wrap: anywhere; }

/* Tra cứu cận lâm sàng nhiều bệnh nhân (Pages/Results/Search): mỗi ngày xét nghiệm một khối, bốn ô tổng ở thẻ thống kê */
.search-filter .search-code { width: 8rem; max-width: 100%; }
.search-filter .search-select { width: auto; max-width: 100%; }
.search-filter .search-indicator { width: 22rem; max-width: 100%; }
.tree-date-field .form-check-input { flex: 0 0 auto; width: 1.1em; height: 1.1em; margin: 0; }
.search-table th { white-space: nowrap; }
.search-table { min-width: 34rem; }
.search-day { border-top: 1px solid var(--c-line); }
.search-day > summary { padding: .45rem .9rem; font-size: .9rem; font-weight: 600; cursor: pointer; background: var(--c-surface-2); color: var(--c-ink); }
.search-actions { white-space: nowrap; }
.search-actions .btn + .btn { margin-left: .25rem; }
.search-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .6rem; border-top: 1px solid var(--c-line); }
.search-totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; }
.search-total { background: var(--c-surface-2); border: 1px solid var(--c-line); border-radius: .4rem; padding: .5rem .75rem; min-width: 0; }
.search-total b { display: block; font-size: 1.4rem; font-variant-numeric: tabular-nums; color: var(--c-accent-ink); }
.search-total span { font-size: .8rem; color: var(--c-ink-2); }
.search-day td.num, .panel td.num, .panel th.num { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 767.98px) {
    .search-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .search-actions { white-space: normal; }
}

/* Hộp trang dùng chung (#pageModal, site.js Clinic.modal): trang phụ mở trên màn hình chính, thân cuộn dọc. */
.page-modal { width: min(720px, calc(100vw - 32px)); max-width: none; max-height: calc(100vh - 32px); padding: 0; }
.page-modal.wide { width: min(1200px, calc(100vw - 32px)); }
.page-modal[open] { display: flex; flex-direction: column; }
.page-modal-head { display: flex; align-items: center; gap: .75rem; padding: .65rem 1rem; border-bottom: 1px solid var(--c-line); background: var(--c-surface); }
.page-modal-title { flex: 1; margin: 0; font-size: 1.05rem; font-weight: 600; color: var(--c-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: .9rem 1rem 1rem; background: var(--c-bg); }
.page-modal-foot { display: flex; align-items: center; gap: .75rem; padding: .5rem 1rem; border-top: 1px solid var(--c-line); background: var(--c-surface); }
.page-modal-foot a { color: var(--c-accent-600); }
.page-modal-message { margin: 0; }
html:has(dialog.page-modal[open]) { overflow: hidden; }
html.page-modal-loading, html.page-modal-loading a[data-modal] { cursor: progress; }
@media print { .page-modal { display: none !important; } }
