/* =====================================================
   EHR (Electronic Health Record) Mode Styles
   Consistent with Virtual Learning Platform design
   ===================================================== */

/* ── Page-level Layout ── */
.ehr-page-body {
    margin: 0;
    padding: 0;
    background: var(--body-bg, #f7f8fa);
    font-family: var(--font-family);
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header: match the platform's transparent minimal header ── */
.ehr-app-header {
    background: transparent !important;
    border: none !important;
    padding: 0.75rem 1.5rem 0.4rem !important;
    flex-shrink: 0;
    align-items: center !important;
}

.ehr-app-header .header-left {
    gap: 1rem;
    align-items: center;
}

.ehr-app-header h1 {
    font-size: 1.1rem !important;
    font-weight: 500 !important;
    color: #5f6368 !important;
    letter-spacing: -0.01em !important;
}

.ehr-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 4px 10px;
    background: none;
    border: 1px solid #d1d5da;
    border-radius: 6px;
    color: var(--text-secondary, #5f6368);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.ehr-back-btn:hover {
    background: #f3f4f6;
    color: var(--text-primary, #202124);
}

.ehr-mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 3px 10px;
    background: rgba(var(--primary-color-rgb, 0, 86, 179), 0.08);
    color: var(--primary-color, #0056b3);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

/* ── EHR Container ── */
.ehr-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    padding: 0.25rem 0.5rem 0.5rem;
    gap: 0.4rem;
}

/* ── Patient Info Banner — light card, consistent with platform panels ── */
.ehr-patient-banner {
    background: var(--panel-bg, #ffffff);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.04);
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.ehr-patient-avatar-wrap {
    flex-shrink: 0;
}

.ehr-patient-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(var(--primary-color-rgb, 0, 86, 179), 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color, #0056b3);
}

.ehr-patient-info {
    flex: 1;
    min-width: 0;
}

.ehr-patient-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary, #202124);
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ehr-patient-meta {
    display: flex;
    gap: 1.25rem;
    font-size: 0.8rem;
    color: var(--text-secondary, #5f6368);
}

.ehr-patient-meta strong {
    font-weight: 600;
    color: var(--text-primary, #202124);
}

/* Patient Alerts Panel */
.ehr-patient-alerts-panel {
    text-align: right;
    font-size: 0.78rem;
    color: var(--text-secondary, #5f6368);
    flex-shrink: 0;
}

.ehr-see-alerts-btn {
    background: none;
    border: none;
    color: var(--primary-color, #0056b3);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    margin-bottom: 0.3rem;
    font-family: var(--font-family);
    display: block;
    margin-left: auto;
    transition: opacity 0.15s;
}

.ehr-see-alerts-btn:hover {
    text-decoration: underline;
    opacity: 0.8;
}

.ehr-alert-row {
    margin-bottom: 0.12rem;
    font-size: 0.76rem;
    color: var(--text-secondary, #5f6368);
}

.ehr-alert-label {
    font-weight: 600;
    margin-right: 0.25rem;
    color: var(--text-primary, #202124);
    opacity: 0.7;
}

.ehr-alert-value {
    font-weight: 400;
}

/* ── Case Metadata tab ── */
.ehr-nav-btn-meta {
    border-top: 1px solid var(--border-color, #d1d9e0);
}

.ehr-nav-spacer {
    flex: 1;
}

.ehr-meta-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-width: 520px;
}

.ehr-meta-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    align-items: baseline;
    padding: 0.5rem 0;
    font-size: 0.875rem;
}

/* ── Inline editable input for Case Name in admin meta row ── */
.ehr-meta-inline-input {
    width: 100%;
    max-width: 320px;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 5px;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-primary, #374151);
    background: #fff;
}
.ehr-meta-inline-input:focus {
    outline: none;
    border-color: var(--primary-color, #0056b3);
    box-shadow: 0 0 0 2px rgba(0,86,179,0.12);
}

.ehr-meta-row--top {
    align-items: start;
}

.ehr-meta-row:last-child {
    border-bottom: none;
}

.ehr-meta-key {
    font-weight: 600;
    color: var(--text-secondary, #5f6368);
}

.ehr-meta-value {
    color: var(--text-primary, #202124);
}

.ehr-editors-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.ehr-editor-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.18rem 0.55rem;
    font-size: 0.8rem;
    border-radius: 999px;
    background: #e8f0fe;
    color: var(--primary-color, #0056b3);
    font-weight: 500;
}

.ehr-editor-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--primary-color, #0056b3);
    opacity: 0.6;
    transition: opacity 0.15s;
    line-height: 1;
}

.ehr-editor-chip-remove:hover {
    opacity: 1;
}

/* ── Course codes in Admin tab ── */
.ehr-meta-cc-value {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    position: relative;
}

.ehr-meta-cc-pills-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    min-height: 1.2em;
}

.ehr-meta-cc-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: #fff;
    padding: 0.15rem 0.5rem 0.15rem 0.6rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(59,130,246,0.25);
}

.ehr-meta-cc-pill-remove {
    background: rgba(255,255,255,0.25);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 15px;
    height: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 0;
    transition: background 0.15s;
    flex-shrink: 0;
}

.ehr-meta-cc-pill-remove:hover {
    background: rgba(255,255,255,0.45);
}

.ehr-meta-cc-add-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ehr-meta-cc-input {
    flex: 1;
    min-width: 0;
    max-width: 180px;
    padding: 0.28rem 0.5rem;
    font-size: 0.8rem;
    border: 1px solid #dadce0;
    border-radius: 6px;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ehr-meta-cc-input:focus {
    outline: none;
    border-color: var(--primary-color, #1a73e8);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.12);
}

/* Hide edit controls when not in edit mode */
body:not(.ehr-edit-mode) .ehr-meta-cc-add-row { display: none; }
body:not(.ehr-edit-mode) .ehr-meta-cc-pill-remove { display: none; }

/* Staged-edit actions bar */
.ehr-meta-edit-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color, #e8ecef);
    margin-top: 0.5rem;
}
.ehr-meta-edit-hint {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text-secondary, #5f6368);
}
.ehr-meta-edit-actions .modal-footer-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* ── EHR Body (sidebar + main) ── */
.ehr-body {
    flex: 1;
    display: flex;
    gap: 0.4rem;
    overflow: hidden;
    min-height: 0;
}

/* ── Left Sidebar Navigation — platform panel style ── */
.ehr-sidebar {
    width: 200px;
    background: var(--panel-bg, #ffffff);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.04);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0;
}

.ehr-nav-btn {
    width: 100%;
    text-align: left;
    padding: 0.6rem 0.75rem 0.6rem 1rem;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
    font-weight: 600;
    color: #9ca3af;
    font-family: var(--font-family);
    transition: background 0.15s, color 0.15s;
    border-radius: 8px;
    margin: 0 0.25rem;
    width: calc(100% - 0.5rem);
    position: relative;
}

.ehr-nav-btn:hover {
    background: #f3f4f6;
    color: #4b5563;
}

.ehr-nav-btn.active {
    background: white;
    color: var(--primary-color, #0056b3);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}

.ehr-nav-btn.active .ehr-nav-arrow {
    color: var(--primary-color, #0056b3);
    opacity: 0.7;
}

.ehr-nav-arrow {
    color: #9ca3af;
    opacity: 0.5;
    flex-shrink: 0;
    transition: opacity 0.15s, color 0.15s;
}

.ehr-nav-btn:hover .ehr-nav-arrow {
    opacity: 0.7;
}

/* ── Main Content Area — platform panel style ── */
.ehr-main {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--panel-bg, #ffffff);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.04);
}

/* ── Section Panel ── */
.ehr-section-panel {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
    border-radius: 12px;
}

.ehr-section-panel.active {
    display: flex;
}

/* Section Header */
.ehr-section-header {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #d1d9e0);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ehr-section-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.ehr-section-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary, #202124);
    margin: 0;
}

.ehr-edit-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 4px 10px;
    background: none;
    border: 1px solid #d1d5da;
    border-radius: 6px;
    color: var(--text-secondary, #5f6368);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-family);
    transition: background 0.15s, border-color 0.15s;
}

.ehr-edit-btn:hover {
    background: #f3f4f6;
}

/* ── Edit Mode: hide all edit/add buttons when toggle is off ── */
body:not(.ehr-edit-mode) .ehr-edit-btn {
    display: none !important;
}

body:not(.ehr-edit-mode) .ehr-actions-col,
body:not(.ehr-edit-mode) .ehr-ms-item-actions {
    display: none !important;
}

/* ── Edit Mode Toggle (header top-right) ── */
.ehr-edit-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.ehr-edit-toggle-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary, #5f6368);
    user-select: none;
}

.ehr-toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.ehr-toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.ehr-toggle-track {
    display: inline-flex;
    align-items: center;
    width: 36px;
    height: 20px;
    border-radius: 999px;
    background: #d1d5da;
    transition: background 0.2s;
    position: relative;
}

.ehr-toggle-switch input:checked + .ehr-toggle-track {
    background: #1a73e8;
}

.ehr-toggle-thumb {
    position: absolute;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
    transition: transform 0.2s;
}

.ehr-toggle-switch input:checked + .ehr-toggle-track .ehr-toggle-thumb {
    transform: translateX(16px);
}

.ehr-save-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.9rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-family);
    border: none;
    border-radius: 6px;
    background: #1a73e8;
    color: #fff;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}

.ehr-save-btn:hover:not(:disabled) {
    background: #1558b0;
}

.ehr-save-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ── Sub-tabs — match platform's tab-button style ── */
.ehr-sub-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem 0.5rem 0;
    flex-shrink: 0;
    background: transparent;
}

.ehr-sub-tab {
    padding: 0.625rem 0.75rem 0.75rem;
    border: none;
    border-radius: 8px 8px 0 0;
    background: transparent;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    color: #9ca3af;
    font-family: var(--font-family);
    transition: all 0.2s ease;
    position: relative;
}

.ehr-sub-tab:hover {
    background: #f3f4f6;
    color: #4b5563;
}

.ehr-sub-tab.active {
    background: white;
    color: var(--primary-color, #0056b3);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}

/* ── Sub-panels ── */
.ehr-sub-panel {
    display: none;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.ehr-sub-panel.active {
    display: block;
}

/* ── Content Sections ── */
.ehr-content-section {
    padding: 0.75rem 1.5rem;
}

/* ── Case Name banner in Case Introduction ── */
.ehr-case-name-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem 0.55rem;
    border-bottom: 1px solid #e8eaed;
    background: #f8f9fa;
}

.ehr-case-name-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #80868b;
    flex-shrink: 0;
}

.ehr-case-name-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary, #202124);
    line-height: 1.3;
}

.ehr-info-notice {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.25rem;
    background: #fff8e1;
    border-bottom: 1px solid #ffe082;
    font-size: 0.82rem;
    color: #795548;
    flex-shrink: 0;
}

.ehr-info-notice svg {
    flex-shrink: 0;
    color: #f57c00;
}

.ehr-content-heading {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary, #202124);
    margin: 0 0 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ehr-patient-desc-meta {
    display: flex;
    flex-direction: row;
    gap: 1.5rem;
    font-size: 0.82rem;
    color: var(--text-secondary, #5f6368);
    margin-bottom: 0.75rem;
}

.ehr-description-text {
    font-size: 0.9rem;
    color: var(--text-primary, #202124);
    line-height: 1.65;
    margin: 0;
}

.ehr-diagnosis-block {
    margin-top: 1rem;
    padding: 0.875rem 1rem;
    background: var(--bg-color, #f1f3f4);
    border-radius: 8px;
    border: 1px solid var(--border-color, #d1d9e0);
}

.ehr-diagnosis-heading {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary, #202124);
    margin: 0 0 0.5rem;
}

.ehr-empty-state {
    font-size: 0.875rem;
    color: var(--text-secondary, #5f6368);
    font-style: italic;
    padding: 3rem 0;
    text-align: center;
    margin: 0;
}

/* ── Diagnosis List ── */
.ehr-diag-group {
    margin-bottom: 1rem;
    border: 1px solid var(--border-color, #d1d9e0);
    border-radius: 8px;
    overflow: hidden;
}

.ehr-diag-group:last-child {
    margin-bottom: 0;
}

.ehr-diag-row {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding: 0.45rem 0.875rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color, #d1d9e0);
}

.ehr-diag-row:last-child {
    border-bottom: none;
}

.ehr-diag-datetime {
    color: var(--text-secondary, #5f6368);
    font-size: 0.8rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.ehr-diag-condition {
    color: var(--text-primary, #202124);
    font-weight: 500;
}

/* ── Scrollbar — consistent with platform ── */
.ehr-sidebar::-webkit-scrollbar,
.ehr-sub-panel::-webkit-scrollbar {
    width: 6px;
}

.ehr-sidebar::-webkit-scrollbar-track,
.ehr-sub-panel::-webkit-scrollbar-track {
    background: transparent;
}

.ehr-sidebar::-webkit-scrollbar-thumb,
.ehr-sub-panel::-webkit-scrollbar-thumb {
    background: var(--border-color, #d1d9e0);
    border-radius: 3px;
}

.ehr-sidebar::-webkit-scrollbar-thumb:hover,
.ehr-sub-panel::-webkit-scrollbar-thumb:hover {
    background: #b0bec5;
}

/* ══════════════════════════════════════
   Clinical Notes
   ══════════════════════════════════════ */

/* Filter bar */
.ehr-cn-filters {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #d1d9e0);
    background: var(--bg-color, #f1f3f4);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.ehr-cn-filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ehr-cn-search-group {
    flex: 1;
    min-width: 160px;
}

.ehr-cn-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary, #5f6368);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.ehr-cn-select {
    padding: 0.4rem 2rem 0.4rem 0.65rem;
    border: 1px solid var(--border-color, #d1d9e0);
    border-radius: 6px;
    background: var(--bg-secondary, #fff) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235f6368' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 0.5rem center;
    appearance: none;
    font-size: 0.875rem;
    font-family: var(--font-family);
    color: var(--text-primary, #202124);
    cursor: pointer;
    min-width: 130px;
}

.ehr-cn-select:focus {
    outline: none;
    border-color: var(--primary-color, #0056b3);
}

.ehr-cn-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.ehr-cn-search-wrap svg {
    position: absolute;
    left: 0.6rem;
    color: var(--text-secondary, #5f6368);
    pointer-events: none;
}

.ehr-cn-search {
    width: 100%;
    padding: 0.4rem 0.65rem 0.4rem 2rem;
    border: 1px solid var(--border-color, #d1d9e0);
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: var(--font-family);
    color: var(--text-primary, #202124);
    background: var(--bg-secondary, #fff);
}

.ehr-cn-search:focus {
    outline: none;
    border-color: var(--primary-color, #0056b3);
}

.ehr-cn-filter-actions {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    padding-bottom: 1px;
}

.ehr-cn-btn-clear {
    padding: 0.4rem 1rem;
    border: 1px solid var(--border-color, #d1d9e0);
    border-radius: 6px;
    background: var(--bg-secondary, #fff);
    font-size: 0.875rem;
    font-family: var(--font-family);
    color: var(--text-secondary, #5f6368);
    cursor: pointer;
    transition: background 0.15s;
}

.ehr-cn-btn-clear:hover {
    background: var(--bg-color, #f1f3f4);
}

.ehr-cn-btn-search {
    padding: 0.4rem 1.25rem;
    border: none;
    border-radius: 6px;
    background: var(--primary-color, #0056b3);
    font-size: 0.875rem;
    font-family: var(--font-family);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

.ehr-cn-btn-search:hover {
    opacity: 0.88;
}

/* Table wrapper */
.ehr-cn-table-wrap {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.ehr-cn-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    font-family: var(--font-family);
}

.ehr-cn-table thead tr {
    background: #ffffff;
    color: #2e4da3;
    text-align: left;
    border-bottom: 2px solid #2e4da3;
}

.ehr-cn-table th {
    padding: 0.65rem 1rem;
    font-weight: 600;
    font-size: 0.82rem;
    white-space: nowrap;
    cursor: default;
}

.ehr-cn-table th .sort-icon {
    margin-left: 0.3rem;
    opacity: 0.7;
    font-size: 0.7rem;
}

.ehr-cn-table tbody tr {
    border-bottom: 1px solid var(--border-color, #d1d9e0);
    transition: background 0.12s;
}

.ehr-cn-table tbody tr:hover {
    background: #f0f4ff;
}

.ehr-cn-table td {
    padding: 0.6rem 1rem;
    color: var(--text-primary, #202124);
    vertical-align: middle;
}

.ehr-cn-table td:nth-child(2) {
    font-weight: 600;
}

.ehr-cn-type-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 500;
    background: #e8f0fe;
    color: var(--primary-color, #0056b3);
}

.ehr-cn-type-badge.type-table {
    background: #e6f4ea;
    color: #1e7e34;
}

.ehr-cn-type-badge.type-soap {
    background: #fff3e0;
    color: #e65100;
}

/* Action buttons */
.ehr-cn-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    white-space: nowrap;
}

.ehr-cn-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: var(--font-family);
    padding: 0.2rem 0.35rem;
    border-radius: 4px;
    transition: background 0.12s;
}

.ehr-cn-action-btn.edit {
    color: var(--primary-color, #0056b3);
}

.ehr-cn-action-btn.edit:hover {
    background: #e8f0fe;
}

.ehr-cn-action-btn.delete {
    color: var(--danger-color, #c0392b);
}

.ehr-cn-action-btn.delete:hover {
    background: #fde8e8;
}

.ehr-fte-table-empty {
    font-size: 0.8rem;
    color: var(--text-secondary, #9ca3af);
    font-style: italic;
    padding: 0.4rem 0;
}

/* Inline editable table grid inside a table block */
.ehr-fte-inline-table-wrap {
    padding: 0.75rem 1rem 0.6rem;
    background: var(--bg-primary, #fff);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.ehr-fte-inline-table-scroll {
    overflow-x: auto;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 6px;
}

.ehr-fte-inline-table {
    border-collapse: collapse;
    min-width: 100%;
    table-layout: auto;
}

/* Header cells – styled to match the lab table template editor */
.ehr-fte-inline-th {
    background: #f7f8fa;
    border: 1px solid var(--border-color, #d1d9e0);
    border-bottom: 2px solid var(--border-color, #c8cdd6);
    padding: 4px 6px;
    vertical-align: middle;
    min-width: 100px;
    position: relative;
}

.ehr-fte-inline-delrow-th {
    background: #f7f8fa;
    border: 1px solid var(--border-color, #d1d9e0);
    border-bottom: 2px solid var(--border-color, #c8cdd6);
    width: 1%;
    padding: 0;
}

/* Bold header input text to match lab template style */
.ehr-fte-inline-th .ehr-fte-inline-input {
    font-weight: 600;
    padding-right: 22px;
}

/* Input row inside each header cell */
.ehr-fte-th-input-row {
    padding: 5px 8px 4px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

/* Delete-column strip – always visible, subtle */
.ehr-fte-th-del-row {
    padding: 0;
    display: flex;
    justify-content: center;
}

/* Body cells */
.ehr-fte-inline-table td {
    border-right: 1px solid var(--border-color, #d1d9e0);
    border-top: 1px solid var(--border-color, #d1d9e0);
    padding: 2px 4px;
    vertical-align: middle;
}

.ehr-fte-inline-delrow-td {
    border: none !important;
    border-top: 1px solid var(--border-color, #d1d9e0) !important;
    padding: 2px 0 2px 8px !important;
    width: 1%;
    white-space: nowrap;
    background: transparent;
}

/* Shared input style */
.ehr-fte-inline-input {
    width: 100%;
    min-width: 70px;
    border: none;
    background: transparent;
    font-size: 0.82rem;
    color: var(--text-primary, #111827);
    padding: 2px 4px;
    outline: none;
    box-sizing: border-box;
    display: block;
}

.ehr-fte-inline-input:focus {
    background: rgba(59, 130, 246, 0.06);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
    border-radius: 3px;
}

/* Delete-column button — small × icon at top-right corner of header cell */
.ehr-fte-inline-del-col {
    position: absolute;
    top: 2px;
    right: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    border-radius: 3px;
    background: transparent;
    color: #b0b7c3;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
    line-height: 1;
}

.ehr-fte-inline-th:hover .ehr-fte-inline-del-col {
    opacity: 1;
}

.ehr-fte-inline-del-col:hover {
    color: #ef4444;
    background: #fee2e2;
    opacity: 1;
}

/* Blank header cell above the per-row delete buttons */
.ehr-fte-inline-delrow-th {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    width: 1%;
}

/* Add-column button (now lives below the table alongside Add Row) */
.ehr-fte-inline-addcol-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 9px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px dashed var(--border-color, #d1d5db);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.ehr-fte-inline-addcol-btn:hover {
    background: #eff6ff;
    color: var(--primary-color, #3b82f6);
    border-color: var(--primary-color, #3b82f6);
}

/* Delete-row button */
.ehr-fte-inline-del-row {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 1px solid var(--border-color, #e5e7eb);
    background: var(--bg-primary, #fff);
    color: #9ca3af;
    cursor: pointer;
    border-radius: 5px;
    padding: 0;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.ehr-fte-inline-del-row:hover {
    color: #ef4444;
    background: #fef2f2;
    border-color: #fca5a5;
}

/* Actions row: Add Row + Add Col side by side below the table */
.ehr-fte-inline-tbl-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

/* Add-row button */
.ehr-fte-inline-addrow-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    font-size: 0.78rem;
    font-weight: 500;
    border: 1px dashed var(--border-color, #d1d5db);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    align-self: flex-start;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.ehr-fte-inline-addrow-btn:hover {
    background: #eff6ff;
    color: var(--primary-color, #3b82f6);
    border-color: var(--primary-color, #3b82f6);
}

/* ── FTE inline table: row drag-handle column ── */
.ehr-fte-inline-handle-th {
    background: #f7f8fa;
    border: 1px solid var(--border-color, #d1d9e0);
    border-bottom: 2px solid var(--border-color, #c8cdd6);
    width: 24px;
    min-width: 24px;
    padding: 0;
}

.ehr-fte-inline-handle-td {
    border: none !important;
    border-top: 1px solid var(--border-color, #d1d9e0) !important;
    padding: 2px 0 !important;
    width: 24px;
    background: transparent;
    vertical-align: middle;
}

/* ── FTE inline table: column drag-handle (absolute in <th>) ── */
.ehr-fte-col-drag-handle {
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    cursor: grab;
    color: #b0b7c3;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    user-select: none;
}

.ehr-fte-inline-th:hover .ehr-fte-col-drag-handle {
    opacity: 1;
}

.ehr-fte-col-drag-handle:hover {
    color: var(--primary-color, #0056b3);
}

.ehr-fte-col-drag-handle:active {
    cursor: grabbing;
}

/* Reserve space at bottom of header cell for the column drag handle */
.ehr-fte-inline-th {
    padding-bottom: 14px !important;
}

/* Footer */
.ehr-cn-footer {
    padding: 0.6rem 1.25rem;
    border-top: 1px solid var(--border-color, #d1d9e0);
    font-size: 0.8rem;
    color: var(--text-secondary, #5f6368);
    flex-shrink: 0;
    background: var(--bg-color, #f1f3f4);
}

/* ══════════════════════════════════════
   Clinical Note Detail Panel (slide-in)
   ══════════════════════════════════════ */

.ehr-note-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: 400;
}

.ehr-note-overlay.open {
    display: block;
}

.ehr-note-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 900px;
    max-width: 90vw;
    height: 100vh;
    background: var(--bg-secondary, #fff);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    z-index: 401;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease;
}

.ehr-note-panel.open {
    transform: translateX(0);
}

.ehr-note-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1.25rem 1.5rem 0.75rem;
    flex-shrink: 0;
}

.ehr-note-panel-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary, #202124);
    margin-bottom: 0.2rem;
}

.ehr-note-panel-subtitle {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary, #5f6368);
}

.ehr-note-panel-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary, #5f6368);
    padding: 0.25rem;
    border-radius: 4px;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.ehr-note-panel-close:hover {
    background: var(--bg-color, #f1f3f4);
    color: var(--text-primary, #202124);
}

.ehr-note-panel-divider {
    border: none;
    border-top: 1px solid var(--border-color, #d1d9e0);
    margin: 0;
}

.ehr-note-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    font-size: 0.9rem;
    color: var(--text-primary, #202124);
    line-height: 1.7;
}

/* Free text content */
.ehr-note-text {
    font-family: var(--font-family);
    font-size: 0.9rem;
    color: var(--text-primary, #202124);
}

/* ── Alert List Modal ── */
.ehr-alert-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 300;
}

.ehr-alert-modal-overlay.open {
    display: block;
}

.ehr-alert-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(860px, 94vw);
    max-height: 85vh;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    z-index: 301;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.ehr-alert-modal.open {
    display: flex;
}

.ehr-alert-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.25rem 0.75rem;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color, #d1d9e0);
}

.ehr-alert-modal-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary, #202124);
    margin: 0;
}

.ehr-alert-modal-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ehr-alert-modal-filters {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background: #f7f8fa;
    border-bottom: 1px solid var(--border-color, #d1d9e0);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.ehr-alert-table-wrap {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 1.25rem;
}

#alert-list-view {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.ehr-alert-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.ehr-alert-type-badge.badge-alert {
    background: #fff3cd;
    color: #856404;
}

.ehr-alert-type-badge.badge-allergy {
    background: #f8d7da;
    color: #842029;
}

.ehr-alert-type-badge.badge-adr {
    background: #cff4fc;
    color: #055160;
}

/* ── Alert Detail View ── */
.ehr-alert-detail-body {
    overflow-y: auto;
    padding: 1rem 1.25rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 1.25rem;
    align-content: start;
}

.ehr-alert-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ehr-alert-field.full-width {
    grid-column: 1 / -1;
}

.ehr-alert-field-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary, #202124);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.ehr-alert-required {
    color: #dc3545;
}

.ehr-alert-field-value {
    padding: 0.45rem 0;
    font-size: 0.9rem;
    color: var(--text-primary, #202124);
    min-height: 2.1rem;
    display: flex;
    align-items: center;
}

.ehr-alert-field-multiline {
    align-items: flex-start;
    min-height: 3.5rem;
    line-height: 1.6;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.ehr-alert-field-row {
    justify-content: space-between;
}

.ehr-alert-more-btn {
    background: #8b1a1a;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 1px 7px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 1px;
    line-height: 1.5;
    flex-shrink: 0;
}

.ehr-alert-detail-footer {
    display: flex;
    justify-content: flex-end;
    padding: 0.65rem 1.25rem;
    border-top: 1px solid var(--border-color, #d1d9e0);
    flex-shrink: 0;
}

#alert-detail-view {
    overflow: hidden;
}

/* ── Alert Add Form ── */
#alert-add-view {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ehr-alert-form-header {
    padding: 0.6rem 1.25rem 0;
    flex-shrink: 0;
}

.ehr-alert-form-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary, #202124);
    margin: 0;
}

.ehr-alert-add-input,
.ehr-alert-add-select {
    padding: 0.45rem 0.75rem;
    background: #ffffff;
    border: 1px solid #e2e4e8;
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: var(--font-family);
    color: var(--text-primary, #202124);
    min-height: 2.1rem;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.ehr-alert-add-input:focus,
.ehr-alert-add-select:focus {
    outline: none;
    border-color: var(--primary-color, #0056b3);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.1);
}

.ehr-alert-add-input.input-error,
.ehr-alert-add-select.input-error {
    border-color: #dc3545;
}

.ehr-alert-add-textarea {
    padding: 0.5rem 0.75rem;
    background: #ffffff;
    border: 1px solid #e2e4e8;
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: var(--font-family);
    color: var(--text-primary, #202124);
    min-height: 4.5rem;
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
    line-height: 1.6;
    transition: border-color 0.15s;
}

.ehr-alert-add-textarea:focus {
    outline: none;
    border-color: var(--primary-color, #0056b3);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.1);
}

.ehr-alert-add-error {
    font-size: 0.75rem;
    color: #dc3545;
    margin: 0.2rem 0 0;
    display: none;
}

.ehr-note-text p {
    line-height: 1.7;
    margin: 0 0 1rem;
}

.ehr-note-text p:last-child {
    margin-bottom: 0;
}
/* Table content */
.ehr-note-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    font-family: var(--font-family);
}

.ehr-note-table thead tr {
    background: #5b9bd5;
    color: #fff;
}

.ehr-note-table th {
    padding: 0.55rem 0.875rem;
    font-weight: 600;
    font-size: 0.82rem;
    text-align: left;
    white-space: nowrap;
}

.ehr-note-table tbody tr {
    border-bottom: 1px solid var(--border-color, #d1d9e0);
}

.ehr-note-table tbody tr:hover {
    background: #f0f4ff;
}

.ehr-note-table td {
    padding: 0.5rem 0.875rem;
    vertical-align: middle;
}

.ehr-note-table td:first-child {
    font-weight: 600;
    color: var(--text-secondary, #5f6368);
    white-space: nowrap;
}

.ehr-note-table-section-header td {
    background: #f1f3f4;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary, #5f6368);
    padding: 0.4rem 0.875rem;
    border-bottom: 1px solid var(--border-color, #d1d9e0);
}

.ehr-lab-flag-low {
    color: #c0392b;
    font-size: 0.75rem;
    font-weight: 700;
    margin-left: 0.2rem;
}

.ehr-lab-flag-high {
    color: #c0392b;
    font-size: 0.75rem;
    font-weight: 700;
    margin-left: 0.2rem;
}

.ehr-note-field {
    margin-top: 1.25rem;
    padding: 0.75rem 1rem;
    background: var(--bg-color, #f1f3f4);
    border-radius: 6px;
    font-size: 0.875rem;
}

.ehr-note-field-label {
    font-weight: 700;
    color: var(--text-secondary, #5f6368);
    margin-right: 0.5rem;
}

.ehr-note-field-value {
    color: var(--text-primary, #202124);
    white-space: pre-wrap;
}

/* ══════════════════════════════════════
   Laboratory extras
   ══════════════════════════════════════ */

.ehr-edit-btn-primary {
    background: var(--primary-color, #0056b3);
    color: #fff;
    border-color: var(--primary-color, #0056b3);
}

.ehr-edit-btn-primary:hover {
    background: #004494;
    border-color: #004494;
    color: #fff;
}

.ehr-lab-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ehr-lab-pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.ehr-lab-page-btn {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color, #d1d9e0);
    border-radius: 4px;
    background: var(--bg-secondary, #fff);
    color: var(--text-secondary, #5f6368);
    font-size: 0.8rem;
    font-family: var(--font-family);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}

.ehr-lab-page-btn:hover:not(:disabled) {
    background: var(--bg-color, #f1f3f4);
    border-color: var(--primary-color, #0056b3);
    color: var(--primary-color, #0056b3);
}

.ehr-lab-page-btn.active {
    background: var(--primary-color, #0056b3);
    border-color: var(--primary-color, #0056b3);
    color: #fff;
}

.ehr-lab-page-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.ehr-lab-type-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 500;
    background: #e8f0fe;
    color: var(--primary-color, #0056b3);
}

.ehr-lab-type-badge.type-haematology {
    background: #fce8e6;
    color: #c0392b;
}

.ehr-lab-type-badge.type-microbiology {
    background: #e6f4ea;
    color: #1e7e34;
}

.ehr-lab-type-badge.type-immunology {
    background: #fff3e0;
    color: #e65100;
}

/* ══════════════════════════════════════
   Medication Hx — breadcrumb & back btn
   ══════════════════════════════════════ */

.ehr-medhx-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.2rem;
    font-size: 0.82rem;
    color: var(--text-secondary, #5f6368);
}

.ehr-medhx-back-btn {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.82rem;
    font-family: var(--font-family);
    color: var(--primary-color, #0056b3);
    cursor: pointer;
    font-weight: 500;
}

.ehr-medhx-back-btn:hover {
    text-decoration: underline;
}

.ehr-medhx-breadcrumb-sep {
    color: var(--text-secondary, #5f6368);
}

#medhx-detail-list-name {
    font-weight: 600;
    color: var(--text-primary, #202124);
}

/* ══════════════════════════════════════
   Dispensing two-panel layout
   ══════════════════════════════════════ */

.ehr-dispensing-layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.ehr-disp-left {
    flex: 1.4;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    border-bottom: 1px solid var(--border-color, #d1d9e0);
}

.ehr-disp-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 140px;
}

.ehr-disp-resizer {
    height: 5px;
    flex-shrink: 0;
    background: var(--border-color, #d1d9e0);
    cursor: row-resize;
    transition: background 0.15s;
    position: relative;
}

.ehr-disp-resizer:hover,
.ehr-disp-resizer.dragging {
    background: var(--primary-color, #0056b3);
}

.ehr-disp-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem 0.5rem;
    flex-shrink: 0;
}

.ehr-disp-panel-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary, #202124);
    margin: 0;
}

/* Sub-tabs */
.ehr-disp-subtabs {
    display: flex;
    gap: 0;
    padding: 0 1.25rem;
    border-bottom: 2px solid var(--border-color, #d1d9e0);
    flex-shrink: 0;
}

.ehr-disp-subtab {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.5rem 0.875rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: var(--font-family);
    color: var(--text-secondary, #5f6368);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.ehr-disp-subtab:hover {
    color: var(--text-primary, #202124);
}

.ehr-disp-subtab.active {
    color: var(--primary-color, #0056b3);
    border-bottom-color: var(--primary-color, #0056b3);
    font-weight: 600;
}

/* Dispensing orders table */
.ehr-disp-table-wrap {
    flex: 1;
    overflow: auto;
    min-height: 0;
}

.ehr-disp-table th,
.ehr-disp-table td {
    white-space: nowrap;
}

.ehr-disp-table th:first-child,
.ehr-disp-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #ffffff;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.06);
}

.ehr-disp-table thead th:first-child {
    background: #ffffff;
    z-index: 3;
}

.ehr-disp-table tbody tr:hover td:first-child {
    background: #f0f4ff;
}

.ehr-disp-table td:first-child,
.ehr-disp-table td:nth-child(9) {
    white-space: normal;
    min-width: 140px;
    max-width: 200px;
}

/* Approval buttons */
.ehr-disp-approve-btn,
.ehr-disp-reject-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.78rem;
    font-family: var(--font-family);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s;
}

.ehr-disp-approve-btn {
    background: #e6f4ea;
    color: #1e7e34;
}

.ehr-disp-reject-btn {
    background: #fde8e8;
    color: #c0392b;
}

.ehr-disp-approve-btn:hover,
.ehr-disp-reject-btn:hover {
    opacity: 0.8;
}

.ehr-disp-approval-cell {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

/* Medication Status list */
.ehr-ms-list-wrap {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.ehr-ms-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #d1d9e0);
    gap: 0.75rem;
    min-height: 0;
}

.ehr-ms-item:hover {
    background: #f0f4ff;
}

.ehr-ms-item-row {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: 0.5rem;
    overflow: hidden;
}

.ehr-ms-item-desc {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary, #202124);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
    min-width: 0;
}

.ehr-ms-item-chips {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-shrink: 0;
}

.ehr-ms-item-chip {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 500;
    color: #3c4858;
    background: #eef2fb;
    border: 1px solid #d5dff5;
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    white-space: nowrap;
}

.ehr-ms-item-date {
    font-size: 0.78rem;
    color: var(--text-secondary, #5f6368);
    white-space: nowrap;
    flex-shrink: 0;
}

.ehr-ms-item-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ── Cases button in EHR header ── */
.ehr-cases-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid #dadce0;
    border-radius: 6px;
    background: #fff;
    color: var(--text-primary, #202124);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.ehr-cases-btn:hover {
    background: #f0f4ff;
    border-color: var(--primary-color, #0056b3);
    color: var(--primary-color, #0056b3);
}

.ehr-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: var(--font-family);
    border: 1px solid #dadce0;
    border-radius: 6px;
    background: #fff;
    color: var(--text-primary, #202124);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ehr-export-btn:hover {
    background: #f0fff4;
    border-color: #1e7e34;
    color: #1e7e34;
}

.ehr-admin-export-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.ehr-admin-export-hint {
    font-size: 0.82rem;
    color: var(--text-secondary, #5f6368);
}

.ehr-admin-export-hint code {
    font-family: monospace;
    background: #f1f3f4;
    padding: 1px 5px;
    border-radius: 4px;
}

/* ── Case Picker Modal overlay ── */
.ehr-picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 1100;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}
.ehr-picker-overlay.open {
    display: flex;
    opacity: 1;
    pointer-events: all;
}

/* ── Case Picker Modal panel ── */
.ehr-picker-modal {
    background: #fff;
    border-radius: 10px;
    width: min(920px, calc(100vw - 2rem));
    max-height: calc(100vh - 4rem);
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 24px rgba(0,0,0,0.13);
    transform: translateY(12px);
    transition: transform 0.2s;
    overflow: hidden;
    border: 1px solid #e0e4ea;
}
.ehr-picker-overlay.open .ehr-picker-modal {
    transform: translateY(0);
}

.ehr-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem 0.85rem;
    border-bottom: 2px solid var(--primary-color, #0056b3);
    flex-shrink: 0;
    background: #fff;
}
.ehr-picker-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-color, #0056b3);
}
.ehr-picker-header-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.ehr-picker-import-inline-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    width: auto;
    margin-bottom: 0;
    padding: 0.4rem 0.9rem;
    font-size: 0.875rem;
}
.ehr-picker-close-btn {
    background: none;
    border: none;
    border-radius: 4px;
    color: var(--text-secondary, #5f6368);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.ehr-picker-close-btn:hover {
    background: #f1f3f4;
    color: var(--text-primary, #202124);
}
.ehr-picker-refresh-btn {
    background: none;
    border: 1px solid #dadce0;
    border-radius: 4px;
    color: var(--text-secondary, #5f6368);
    cursor: pointer;
    padding: 0.25rem 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ehr-picker-refresh-btn:hover {
    background: #f1f3f4;
    border-color: #bdc1c6;
    color: var(--text-primary, #202124);
}
.ehr-picker-refresh-btn.spinning svg {
    animation: ehrc-spin 0.7s linear infinite;
}

.ehr-picker-body {
    overflow-y: auto;
    flex: 1;
}

/* ── Loading / empty / error states inside picker ── */
.ehr-picker-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3.5rem 1.5rem;
    color: var(--text-secondary, #5f6368);
    font-size: 0.875rem;
}
.ehr-picker-state svg {
    flex-shrink: 0;
    opacity: 0.45;
}

/* Patient name link inside picker table */
.ehr-picker-name {
    font-weight: 600;
    color: var(--primary-color, #0056b3);
    cursor: pointer;
}
.ehr-picker-name:hover {
    text-decoration: underline;
}

.ehr-picker-case-name {
    font-size: 0.82rem;
    color: var(--text-secondary, #5f6368);
    max-width: 160px;
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

/* Course code pills inside picker table */
.ehr-picker-courses {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

/* Person name badges (owner / editors) inside picker table */
.ehr-picker-person-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 500;
    color: #3c4a5e;
    background: #eef1f6;
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    white-space: nowrap;
}
.ehr-picker-editors {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

/* Open button — matches .ehr-cn-action-btn edit style */
.ehr-picker-open-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.2rem 0.35rem;
    border-radius: 4px;
    color: var(--primary-color, #0056b3);
    transition: background 0.12s;
}
.ehr-picker-open-btn:hover {
    background: #e8f0fe;
}

/* ── Add Editor button (inside editors row) ── */
.ehr-editor-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.45rem;
    padding: 0.22rem 0.6rem;
    border: 1px dashed var(--primary-color, #0056b3);
    background: transparent;
    color: var(--primary-color, #0056b3);
    border-radius: 5px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    line-height: 1.4;
}
.ehr-editor-add-btn:hover {
    background: #edf2fb;
}

/* Pending-addition chip variant (green tint) */
.ehr-editor-chip--pending {
    border-color: #1e7e34;
    color: #1e7e34;
    background: #f0faf3;
}

/* ── Add Editor Modal overlay ── */
.ehr-add-editor-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.ehr-add-editor-overlay.open {
    opacity: 1;
    pointer-events: all;
}

/* ── Add Editor Modal panel ── */
.ehr-add-editor-modal {
    background: #fff;
    border-radius: 10px;
    width: min(820px, calc(100vw - 2rem));
    max-height: 76vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e0e4ea;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    transform: translateY(16px);
    transition: transform 0.2s;
}
.ehr-add-editor-overlay.open .ehr-add-editor-modal {
    transform: translateY(0);
}

.ehr-add-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e0e4ea;
    flex-shrink: 0;
}
.ehr-add-editor-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary, #202124);
}

.ehr-add-editor-search-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-bottom: 1px solid #f0f2f5;
    flex-shrink: 0;
}
.ehr-add-editor-search-wrap .ehr-cn-select {
    flex-shrink: 0;
    width: auto;
}
.ehr-add-editor-search-inner {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}
.ehr-add-editor-search-inner > svg {
    position: absolute;
    left: 0.65rem;
    color: #999;
    pointer-events: none;
    flex-shrink: 0;
}
.ehr-add-editor-search {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    border: 1px solid #dde1e7;
    border-radius: 6px;
    font-size: 0.875rem;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s;
}
.ehr-add-editor-search:focus {
    border-color: var(--primary-color, #0056b3);
}

.ehr-add-editor-results {
    flex: 1;
    overflow-y: auto;
    padding: 0.35rem 0;
}
.ehr-add-editor-state {
    padding: 2rem 1.25rem;
    text-align: center;
    color: var(--text-secondary, #5f6368);
    font-size: 0.875rem;
    font-style: italic;
}

/* ── User rows inside the Add Editor modal ── */
.ehr-user-list-header {
    display: grid;
    grid-template-columns: 1fr 90px 100px 90px;
    gap: 0.75rem;
    align-items: center;
    padding: 0.4rem 1.25rem;
    border-bottom: 2px solid #e0e4ea;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary, #5f6368);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    background: #fafbfc;
}
.ehr-user-row {
    display: grid;
    grid-template-columns: 1fr 90px 100px 90px;
    gap: 0.75rem;
    align-items: center;
    padding: 0.55rem 1.25rem;
    transition: background 0.1s;
}
.ehr-user-row:hover {
    background: #f6f8fc;
}
.ehr-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e8edf5;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--primary-color, #0056b3);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
}
.ehr-user-info {
    flex: 1;
    min-width: 0;
}
.ehr-user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary, #202124);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ehr-user-email {
    font-size: 0.775rem;
    color: var(--text-secondary, #5f6368);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ehr-user-role-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: capitalize;
    background: #e8edf5;
    color: #3c5a9a;
    white-space: nowrap;
}
.ehr-user-role-badge.role-teacher  { background: #fff3cd; color: #856404; }
.ehr-user-role-badge.role-admin    { background: #f8d7da; color: #842029; }
.ehr-user-role-badge.role-tester   { background: #d1ecf1; color: #0c5460; }
.ehr-user-cohort {
    font-size: 0.8rem;
    color: var(--text-secondary, #5f6368);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ehr-user-add-btn {
    flex-shrink: 0;
    padding: 0.28rem 0.7rem;
    border: 1px solid var(--primary-color, #0056b3);
    background: transparent;
    color: var(--primary-color, #0056b3);
    border-radius: 5px;
    font-size: 0.775rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.ehr-user-add-btn:hover:not(:disabled) {
    background: var(--primary-color, #0056b3);
    color: #fff;
}
.ehr-user-add-btn:disabled {
    border-color: #1e7e34;
    color: #1e7e34;
    background: #f0faf3;
    cursor: default;
}
.ehr-add-editor-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    gap: 0.5rem;
    color: var(--text-secondary, #5f6368);
    font-size: 0.875rem;
}

/* ── Table Editor Modal (reusable for any tab with table entries) ── */
.ehr-te-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.38);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ehr-te-modal {
    width: min(960px, 96vw);
    max-height: 88vh;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ehr-te-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 0.9rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--border-color, #d1d9e0);
    flex-shrink: 0;
}

.ehr-te-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary, #202124);
    margin: 0;
}

.ehr-te-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary, #5f6368);
    margin-top: 3px;
}

.ehr-te-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
}

.ehr-te-table-scroll {
    overflow: auto;
    flex: 1;
    min-height: 0;
    border: 1px solid var(--border-color, #d1d9e0);
    border-radius: 8px;
}

.ehr-te-table {
    border-collapse: collapse;
    min-width: max-content;
}

.ehr-te-table th,
.ehr-te-table td {
    padding: 4px;
    vertical-align: middle;
    border: 1px solid var(--border-color, #d1d9e0);
}

.ehr-te-table thead tr th {
    background: #f7f8fa;
}

.ehr-te-table td.ehr-te-actions-td {
    border: none;
    background: transparent;
    vertical-align: middle;
    padding: 2px 4px;
}

.ehr-te-th-wrap {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
}

.ehr-te-th-main {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 100px;
}

.ehr-te-drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    min-width: 16px;
    padding: 2px 1px;
    cursor: grab;
    color: #c4c9d4;
    border-radius: 3px;
    transition: color 0.15s, background 0.15s;
    user-select: none;
    flex-shrink: 0;
}

.ehr-te-drag-handle:hover {
    color: var(--primary-color, #0056b3);
    background: rgba(0, 86, 179, 0.07);
}

.ehr-te-drag-handle:active {
    cursor: grabbing;
}

.ehr-te-col-dragging {
    opacity: 0.35;
}

.ehr-te-col-drag-over-left {
    background: rgba(0, 86, 179, 0.06) !important;
    box-shadow: inset 3px 0 0 var(--primary-color, #0056b3);
}

.ehr-te-col-drag-over-right {
    background: rgba(0, 86, 179, 0.06) !important;
    box-shadow: inset -3px 0 0 var(--primary-color, #0056b3);
}

.ehr-te-row-handle-th {
    width: 24px;
    min-width: 24px;
    padding: 0 !important;
}

.ehr-te-row-drag-td {
    width: 24px;
    min-width: 24px;
    padding: 0 2px !important;
    vertical-align: middle;
}

.ehr-te-row-drag-handle {
    margin: auto;
}

.ehr-te-row-dragging {
    opacity: 0.35;
}

.ehr-te-row-drag-over-top td,
.ehr-te-row-drag-over-top {
    box-shadow: inset 0 3px 0 var(--primary-color, #0056b3) !important;
}

.ehr-te-row-drag-over-bottom td,
.ehr-te-row-drag-over-bottom {
    box-shadow: inset 0 -3px 0 var(--primary-color, #0056b3) !important;
}

.ehr-te-del-col-wrap {
    display: flex;
    justify-content: flex-end;
}

.ehr-te-cell-input {
    display: block;
    width: 100%;
    min-width: 90px;
    padding: 4px 7px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 0.84rem;
    font-family: var(--font-family);
    background: transparent;
    color: var(--text-primary, #202124);
    outline: none;
    transition: border-color 0.15s, background 0.15s;
    box-sizing: border-box;
}

.ehr-te-cell-input:hover {
    border-color: #c9d0d8;
    background: #fafbfc;
}

.ehr-te-cell-input:focus {
    border-color: var(--primary-color, #0056b3);
    background: #fff;
    box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.1);
}

.ehr-te-table thead .ehr-te-cell-input {
    font-weight: 600;
}

.ehr-te-del-col-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: none;
    border: 1px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    color: #9ca3af;
    padding: 0;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.ehr-te-del-col-btn:hover {
    color: #dc3545;
    background: #fef2f2;
    border-color: #fca5a5;
}

.ehr-te-del-row-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    color: #9ca3af;
    padding: 0;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.ehr-te-del-row-btn:hover {
    color: #dc3545;
    background: #fef2f2;
    border-color: #fca5a5;
}

.ehr-te-add-col-th {
    background: #fafbfc !important;
    vertical-align: middle;
    text-align: center;
    border-style: dashed !important;
    border-color: #d1d5da !important;
    padding: 6px 10px !important;
    white-space: nowrap;
}

.ehr-te-add-col-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: none;
    border: 1px dashed #c9d0d8;
    border-radius: 5px;
    font-size: 0.8rem;
    font-family: var(--font-family);
    color: var(--text-secondary, #5f6368);
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.ehr-te-add-col-btn:hover {
    border-color: var(--primary-color, #0056b3);
    color: var(--primary-color, #0056b3);
    background: rgba(0, 86, 179, 0.04);
}

.ehr-te-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-color, #d1d9e0);
    flex-shrink: 0;
    gap: 0.75rem;
    background: #f7f8fa;
}

.ehr-te-footer-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.ehr-te-add-row-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 14px;
    background: none;
    border: 1px dashed #c9d0d8;
    border-radius: 6px;
    font-size: 0.82rem;
    font-family: var(--font-family);
    color: var(--text-secondary, #5f6368);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.ehr-te-add-row-btn:hover {
    border-color: var(--primary-color, #0056b3);
    color: var(--primary-color, #0056b3);
    background: rgba(0, 86, 179, 0.04);
}

.ehr-te-add-row-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Lab table editor extras ── */
.ehr-te-footer-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ehr-te-add-section-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 14px;
    background: none;
    border: 1px dashed #c9d0d8;
    border-radius: 6px;
    font-size: 0.82rem;
    font-family: var(--font-family);
    color: var(--text-secondary, #5f6368);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.ehr-te-add-section-btn:hover {
    border-color: var(--primary-color, #0056b3);
    color: var(--primary-color, #0056b3);
    background: rgba(0, 86, 179, 0.04);
}

.ehr-te-note-section {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.65rem 1.25rem;
    border-top: 1px solid var(--border-color, #d1d9e0);
    background: #f7f8fa;
    flex-shrink: 0;
}

.ehr-te-lab-meta {
    padding: 0.65rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #d1d9e0);
    background: #f7f8fa;
    flex-shrink: 0;
}

.ehr-te-lab-meta-row {
    display: flex;
    gap: 1rem;
}

.ehr-te-lab-meta-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
    min-width: 0;
}

.ehr-te-lab-meta-input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--border-color, #d1d9e0);
    border-radius: 5px;
    font-size: 0.84rem;
    font-family: var(--font-family);
    color: var(--text-primary, #202124);
    outline: none;
    background: #fff;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ehr-te-lab-meta-input:focus {
    border-color: var(--primary-color, #0056b3);
    box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.1);
}

.ehr-te-note-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary, #5f6368);
    white-space: nowrap;
    flex-shrink: 0;
}

.ehr-te-note-input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--border-color, #d1d9e0);
    border-radius: 5px;
    font-size: 0.84rem;
    font-family: var(--font-family);
    color: var(--text-primary, #202124);
    outline: none;
    background: #fff;
    resize: vertical;
    line-height: 1.5;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ehr-te-note-input:focus {
    border-color: var(--primary-color, #0056b3);
    box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.1);
}

.ehr-te-fixed-col {
    background: #f9fafb !important;
}

.ehr-te-fixed-col .ehr-te-cell-input[readonly] {
    color: var(--text-secondary, #6b7280);
    font-style: italic;
    cursor: default;
}

.ehr-te-section-row .ehr-te-section-td {
    background: #f1f3f4;
    padding: 4px 8px;
}

.ehr-te-section-td-inner {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ehr-te-section-td-inner .ehr-te-cell-input {
    flex: 1;
}

.ehr-te-section-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: #e1e4e8;
    color: #586069;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 0.03em;
}

@keyframes ehr-te-spin {
    to { transform: rotate(360deg); }
}

.ehr-te-spin {
    animation: ehr-te-spin 0.7s linear infinite;
    flex-shrink: 0;
}


/* ════════════════════════════════════════════════════════════════════
   EHR Templates Modals (list + create/edit form)
   ════════════════════════════════════════════════════════════════════ */

.ehr-tmpl-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    padding: 1.5rem;
}

.ehr-tmpl-modal {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    width: 100%;
    overflow: hidden;
}

.ehr-tmpl-modal--wide  { max-width: 840px; }
.ehr-tmpl-modal--narrow { max-width: 480px; }

/* Header */
.ehr-tmpl-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e8ecef;
    flex-shrink: 0;
    gap: 0.75rem;
}

.ehr-tmpl-modal-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.ehr-tmpl-modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1a2332;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ehr-tmpl-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.65rem;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    background: #fff;
    color: #444;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s;
}
.ehr-tmpl-back-btn:hover { background: #f3f4f6; border-color: #b0b8c1; }

/* Body */
.ehr-tmpl-modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

/* Footer (form modal) */
.ehr-tmpl-modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.6rem;
    padding: 0.9rem 1.25rem;
    border-top: 1px solid #e8ecef;
    flex-shrink: 0;
}

.ehr-tmpl-modal-footer .modal-footer-btn,
.ehr-te-footer-actions .modal-footer-btn,
.ehr-fte-footer-right .modal-footer-btn,
.ehr-soap-footer .modal-footer-btn,
.ehr-cei-footer .modal-footer-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* Loading / empty states */
.ehr-tmpl-loading,
.ehr-tmpl-empty {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #6b7280;
    font-size: 0.88rem;
    padding: 1.5rem 0;
}

/* Form fields */
.ehr-tmpl-field {
    margin-bottom: 1.1rem;
}

.ehr-tmpl-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    font-size: 0.875rem;
    color: #1a2332;
    background: #fff;
    margin-top: 0.3rem;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.ehr-tmpl-input:focus {
    outline: none;
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.ehr-tmpl-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    padding-right: 2rem;
    cursor: pointer;
}

.ehr-tmpl-required {
    color: #e53e3e;
    margin-left: 2px;
}

/* Type / Visibility toggle */
.ehr-tmpl-type-toggle {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.35rem;
    flex-wrap: wrap;
}

.ehr-tmpl-type-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.9rem;
    border: 1.5px solid #d0d7de;
    border-radius: 6px;
    background: #fff;
    color: #555;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    position: relative;
}
.ehr-tmpl-type-btn:hover:not(:disabled) {
    border-color: var(--primary-color, #3b82f6);
    color: var(--primary-color, #3b82f6);
}
.ehr-tmpl-type-btn--active {
    border-color: var(--primary-color, #3b82f6);
    background: color-mix(in srgb, var(--primary-color, #3b82f6) 10%, #fff);
    color: var(--primary-color, #3b82f6);
    font-weight: 600;
}
.ehr-tmpl-type-btn--disabled,
.ehr-tmpl-type-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.ehr-tmpl-coming-soon {
    font-size: 0.65rem;
    font-weight: 700;
    background: #e8ecef;
    color: #6b7280;
    border-radius: 999px;
    padding: 1px 6px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

/* Error message */
.ehr-tmpl-error {
    color: #c0392b;
    font-size: 0.83rem;
    padding: 0.5rem 0.75rem;
    background: #fef0ef;
    border-radius: 6px;
    border: 1px solid #fbd5d5;
    margin-top: 0.25rem;
}


/* Sortable column headers in the template list table */
.ehr-tmpl-sortable {
    cursor: pointer;
    user-select: none;
}
.ehr-tmpl-sortable:hover {
    background: #f0f4ff;
}
.ehr-sort-indicator {
    font-size: 0.7rem;
    color: #2e4da3;
    margin-left: 0.2rem;
}

/* Filter bar inside the template list modal */
#ehr-tmpl-list-overlay .ehr-cn-filters {
    border-top: none;
    border-radius: 0;
    border-bottom: 1px solid var(--border-color, #d1d9e0);
}

/* Private badge in the list table */
.ehr-tmpl-private-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 2px 8px;
    background: #f1f3f4;
    color: #5f6368;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Action buttons in template list rows */
.ehr-tmpl-row-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}


/* ════════════════════════════════════════════════════════════════════
   Build with AI — button in table editor footer
   ════════════════════════════════════════════════════════════════════ */

.ehr-te-ai-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border: 1.5px solid var(--primary-color, #3b82f6);
    border-radius: 6px;
    background: color-mix(in srgb, var(--primary-color, #3b82f6) 8%, #fff);
    color: var(--primary-color, #3b82f6);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.ehr-te-ai-btn:hover {
    background: color-mix(in srgb, var(--primary-color, #3b82f6) 16%, #fff);
}

/* ════════════════════════════════════════════════════════════════════
   Build with AI — upload modal
   ════════════════════════════════════════════════════════════════════ */

.ehr-ai-hint {
    font-size: 0.85rem;
    color: #555;
    margin: 0 0 1rem;
    line-height: 1.5;
}

.ehr-ai-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 2rem 1rem;
    border: 2px dashed #d0d7de;
    border-radius: 8px;
    background: #fafbfc;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    text-align: center;
}
.ehr-ai-drop-zone:hover,
.ehr-ai-drop-zone.ehr-ai-drag-over {
    border-color: var(--primary-color, #3b82f6);
    background: color-mix(in srgb, var(--primary-color, #3b82f6) 5%, #fff);
}
.ehr-ai-drop-zone span {
    font-size: 0.85rem;
    color: #555;
}
.ehr-ai-file-types {
    font-size: 0.75rem !important;
    color: #9ca3af !important;
}
.ehr-ai-browse-link {
    color: var(--primary-color, #3b82f6);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

.ehr-ai-file-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #f1f5f9;
    border-radius: 6px;
    font-size: 0.83rem;
    color: #374151;
}
.ehr-ai-file-preview span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ehr-ai-remove-file {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px;
    border: none;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    border-radius: 4px;
    flex-shrink: 0;
    transition: color 0.15s;
}
.ehr-ai-remove-file:hover { color: #ef4444; }

.ehr-ai-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--primary-color, #3b82f6);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Free Text Note Editor Modal  (#ehr-fte-overlay)
   ═══════════════════════════════════════════════════════════════════════════ */

.ehr-fte-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.ehr-fte-modal {
    background: var(--bg-primary, #fff);
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    width: min(960px, 96vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.ehr-fte-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.4rem 1rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    flex-shrink: 0;
}

.ehr-fte-header-info {
    min-width: 0;
}

.ehr-fte-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary, #111827);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ehr-fte-subtitle {
    font-size: 0.78rem;
    color: var(--text-secondary, #6b7280);
    margin-top: 2px;
}

/* Body */
.ehr-fte-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.1rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ehr-fte-blocks {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Empty state */
.ehr-fte-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-secondary, #6b7280);
    font-size: 0.85rem;
    font-style: italic;
    border: 2px dashed var(--border-color, #e5e7eb);
    border-radius: 8px;
}

/* Individual block card */
.ehr-fte-block {
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-secondary, #f9fafb);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ehr-fte-block:focus-within {
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

/* Block header bar */
.ehr-fte-block-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    background: var(--bg-primary, #fff);
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.ehr-fte-block-badge {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 4px;
    flex-shrink: 0;
}

.ehr-fte-block-badge.badge-section {
    background: #dbeafe;
    color: #1d4ed8;
}

.ehr-fte-block-badge.badge-table {
    background: #dcfce7;
    color: #15803d;
}

.ehr-fte-block-actions {
    margin-left: auto;
    display: flex;
    gap: 0.3rem;
}

.ehr-fte-block-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-size: 0.72rem;
    font-weight: 500;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 5px;
    background: var(--bg-primary, #fff);
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    line-height: 1.4;
}

.ehr-fte-block-btn:hover {
    background: var(--bg-secondary, #f3f4f6);
    color: var(--text-primary, #111827);
    border-color: #9ca3af;
}

.ehr-fte-block-btn.danger:hover {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fca5a5;
}

.ehr-fte-block-btn svg {
    flex-shrink: 0;
}

/* Move up/down buttons */
.ehr-fte-move-btns {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.ehr-fte-move-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 16px;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 3px;
    background: var(--bg-primary, #fff);
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    padding: 0;
    transition: background 0.15s, color 0.15s;
}

.ehr-fte-move-btn:hover {
    background: var(--bg-secondary, #f3f4f6);
    color: var(--text-primary, #111827);
}

.ehr-fte-move-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Section editor container (Quill mounts here) */
.ehr-fte-section-body {
    background: var(--bg-primary, #fff);
}

.ehr-fte-section-editor {
    min-height: 160px;
}

/* Override Quill's snow theme to blend with our design */
.ehr-fte-section-body .ql-toolbar.ql-snow {
    border: none;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    padding: 6px 10px;
    background: var(--bg-secondary, #f9fafb);
    border-radius: 0;
}

/* Ensure toolbar buttons show pointer cursor and tooltip is accessible */
.ehr-fte-section-body .ql-toolbar button,
.ehr-fte-section-body .ql-toolbar .ql-picker-label {
    cursor: pointer;
    position: relative;
}

.ehr-fte-section-body .ql-container.ql-snow {
    border: none;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-primary, #111827);
    min-height: 130px;
    /* Needed so .ql-tooltip is positioned relative to this container */
    position: relative;
}

/* ── Quill tooltip (video URL box, link box) ──────────────────────────────
   Quill positions .ql-tooltip absolutely and applies a translateX to centre
   it on the cursor, which pushes it outside the modal viewport.
   Override: pin it inside the container, cancel the inline transform.     */
.ehr-fte-section-body .ql-tooltip {
    position: absolute;
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-width: 100%;
    transform: none !important;
    z-index: 10;
    white-space: normal;
    box-sizing: border-box;
}

.ehr-fte-section-body .ql-tooltip input[type="text"] {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.ehr-fte-section-body .ql-editor {
    min-height: 130px;
    padding: 0.75rem 1rem;
    line-height: 1.65;
}

.ehr-fte-section-body .ql-editor p {
    margin: 0 0 0.4em;
}

.ehr-fte-section-body .ql-editor img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    cursor: pointer;
}

.ehr-fte-section-body .ql-editor img.fte-img-selected {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

/* ── FTE Image Resize Overlay ── */
.fte-img-resize-overlay {
    position: fixed;
    box-sizing: border-box;
    border: 2px solid #3b82f6;
    pointer-events: none;
    z-index: 10000;
    border-radius: 2px;
    display: none;
}

.fte-img-resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #3b82f6;
    border: 2px solid #fff;
    border-radius: 2px;
    pointer-events: all;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    transform: translate(-50%, -50%);
}

.fte-img-resize-handle.nw { top: 0;    left: 0;    cursor: nw-resize; }
.fte-img-resize-handle.ne { top: 0;    left: 100%; cursor: ne-resize; }
.fte-img-resize-handle.sw { top: 100%; left: 0;    cursor: sw-resize; }
.fte-img-resize-handle.se { top: 100%; left: 100%; cursor: se-resize; }
.fte-img-resize-handle.n  { top: 0;    left: 50%;  cursor: n-resize; }
.fte-img-resize-handle.s  { top: 100%; left: 50%;  cursor: s-resize; }
.fte-img-resize-handle.w  { top: 50%;  left: 0;    cursor: w-resize; }
.fte-img-resize-handle.e  { top: 50%;  left: 100%; cursor: e-resize; }

.fte-img-resize-label {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 41, 59, 0.85);
    color: #fff;
    font-size: 11px;
    font-family: ui-monospace, monospace;
    padding: 2px 7px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    line-height: 1.6;
}

.ehr-fte-section-body .ql-editor video {
    max-width: 100%;
    border-radius: 4px;
}

/* Table block preview */
.ehr-fte-table-body {
    padding: 0.75rem 1rem;
    overflow-x: auto;
    background: var(--bg-primary, #fff);
}

.ehr-fte-table-preview {
    border-collapse: collapse;
    font-size: 0.8rem;
    width: auto;
}

.ehr-fte-table-preview th,
.ehr-fte-table-preview td {
    border: 1px solid var(--border-color, #e5e7eb);
    padding: 5px 10px;
    text-align: left;
    white-space: nowrap;
    color: var(--text-primary, #111827);
}

.ehr-fte-table-preview th {
    background: var(--bg-secondary, #f3f4f6);
    font-weight: 600;
}

/* View panel: block-based content spacing */
.ehr-fte-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1.4rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
    background: var(--bg-primary, #fff);
    flex-shrink: 0;
}

.ehr-fte-footer-left {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ehr-fte-footer-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

/* View panel: block-based content spacing */
.ehr-note-block-section {
    margin-bottom: 1rem;
}

.ehr-note-block-section img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 0.4rem 0;
}

.ehr-note-block-section video {
    max-width: 100%;
    border-radius: 4px;
    margin: 0.4rem 0;
}

.ehr-note-block-table {
    margin-bottom: 1rem;
}

/* Quill snow theme adjustments for dark mode */
@media (prefers-color-scheme: dark) {
    .ehr-fte-section-body .ql-toolbar.ql-snow {
        background: var(--bg-secondary, #1f2937);
        border-bottom-color: var(--border-color, #374151);
    }
    .ehr-fte-section-body .ql-toolbar .ql-stroke { stroke: #9ca3af; }
    .ehr-fte-section-body .ql-toolbar .ql-fill   { fill:   #9ca3af; }
    .ehr-fte-section-body .ql-toolbar .ql-picker-label { color: #9ca3af; }
    .ehr-fte-section-body .ql-toolbar button:hover .ql-stroke,
    .ehr-fte-section-body .ql-toolbar button.ql-active .ql-stroke { stroke: #60a5fa; }
    .ehr-fte-section-body .ql-toolbar button:hover .ql-fill,
    .ehr-fte-section-body .ql-toolbar button.ql-active .ql-fill   { fill:   #60a5fa; }
    .ehr-fte-section-body .ql-container.ql-snow { color: #e5e7eb; }
    .ehr-fte-section-body .ql-editor.ql-blank::before { color: #6b7280; }
}

/* ── Add Clinical Note modal ── */

/* Override modal width for this dialog */
.ehr-cn-add-modal {
    width: 480px;
    max-width: calc(100vw - 2rem);
}

/* Wider variant for modals with more fields */
.ehr-ms-modal {
    width: 560px;
}

/* Two-column grid inside a modal form */
.ehr-cn-add-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}

/* Each label + input pair */
.ehr-cn-add-form-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
}
.ehr-cn-add-form-row:last-child {
    margin-bottom: 0;
}

.ehr-cn-add-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary, #555);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Text and datetime inputs */
.ehr-cn-add-input {
    padding: 0.45rem 0.65rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color, #d0d5dd);
    border-radius: 6px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #111);
    outline: none;
    transition: border-color 0.15s;
    width: 100%;
    box-sizing: border-box;
}
.ehr-cn-add-input:focus {
    border-color: var(--primary-color, #0056b3);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.12);
}

/* Input with a fixed unit suffix (e.g. number + "days") */
.ehr-input-with-unit {
    display: flex;
    align-items: center;
    gap: 0;
}
.ehr-input-with-unit .ehr-cn-add-input {
    border-right: none;
    border-radius: 6px 0 0 6px;
    flex: 1;
    min-width: 0;
}
.ehr-input-with-unit .ehr-cn-add-input:focus {
    border-right: none;
}
.ehr-input-unit {
    display: inline-flex;
    align-items: center;
    padding: 0 0.7rem;
    height: 100%;
    min-height: 2.05rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary, #555);
    background: var(--bg-secondary, #f5f5f5);
    border: 1px solid var(--border-color, #d0d5dd);
    border-left: none;
    border-radius: 0 6px 6px 0;
    white-space: nowrap;
    user-select: none;
    pointer-events: none;
}

/* Inline validation error */
.ehr-cn-add-error {
    font-size: 0.78rem;
    color: #c0392b;
    margin: 0;
}

/* Segmented button group */
.ehr-cn-add-seg-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.ehr-cn-add-seg-btn {
    padding: 0.35rem 0.85rem;
    font-size: 0.825rem;
    font-weight: 500;
    border: 1.5px solid var(--border-color, #d0d5dd);
    border-radius: 6px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #333);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    line-height: 1.4;
}
.ehr-cn-add-seg-btn:hover:not(:disabled):not(.active) {
    background: var(--bg-secondary, #f5f7fa);
    border-color: var(--primary-color, #0056b3);
    color: var(--primary-color, #0056b3);
}
.ehr-cn-add-seg-btn.active {
    background: var(--primary-color, #0056b3);
    border-color: var(--primary-color, #0056b3);
    color: #fff;
}
.ehr-cn-add-seg-btn:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    border-style: dashed;
}

/* "Next →" button — add left gap from Cancel */
#ehr-cn-add-next-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* ── SOAP Note Editor Modal ── */

.ehr-soap-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1100;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}
.ehr-soap-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.ehr-soap-modal {
    background: var(--bg-primary, #fff);
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    width: min(720px, 96vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.ehr-soap-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.4rem 1rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    flex-shrink: 0;
}
.ehr-soap-header-info { min-width: 0; }
.ehr-soap-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary, #111);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ehr-soap-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary, #666);
    margin-top: 0.15rem;
}

/* Scrollable body */
.ehr-soap-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.2rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

/* Individual S/O/A/P field */
.ehr-soap-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.ehr-soap-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary, #555);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.ehr-soap-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 4px;
    background: var(--primary-color, #0056b3);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}
.ehr-soap-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 0.55rem 0.7rem;
    font-size: 0.875rem;
    font-family: inherit;
    line-height: 1.55;
    border: 1px solid var(--border-color, #d0d5dd);
    border-radius: 6px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #111);
    resize: vertical;
    outline: none;
    transition: border-color 0.15s;
}
.ehr-soap-textarea:focus {
    border-color: var(--primary-color, #0056b3);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.12);
}

/* Footer */
.ehr-soap-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.6rem;
    padding: 0.85rem 1.4rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
    flex-shrink: 0;
}

/* Read-only panel sections for SOAP notes */
.ehr-soap-panel-section {
    margin-bottom: 1.1rem;
}
.ehr-soap-panel-section:last-child { margin-bottom: 0; }
.ehr-soap-panel-heading {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary-color, #0056b3);
    margin-bottom: 0.3rem;
    padding-bottom: 0.25rem;
    border-bottom: 1.5px solid var(--primary-color, #0056b3);
    opacity: 0.85;
}
.ehr-soap-panel-text {
    font-size: 0.875rem;
    line-height: 1.6;
}
.ehr-soap-panel-text p { margin: 0 0 0.25rem; }

/* ── Supplementary Resource Upload Drop Zone ── */
.suppl-drop-zone {
    border: 2px dashed #dadce0;
    border-radius: 8px;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    color: var(--text-secondary, #5f6368);
}
.suppl-drop-zone:hover,
.suppl-drop-zone.drag-over {
    border-color: var(--primary-color, #0056b3);
    background: #f0f4ff;
}
.suppl-drop-zone.has-file {
    border-color: #34a853;
    background: #f0faf3;
}
.suppl-drop-zone-text {
    margin: 0;
    font-size: 0.875rem;
}
.suppl-browse-link {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.875rem;
    color: var(--primary-color, #0056b3);
    cursor: pointer;
    text-decoration: underline;
    font-weight: 500;
}
.suppl-drop-zone-selected {
    font-size: 0.82rem;
    font-weight: 500;
    color: #34a853;
    margin: 0;
    word-break: break-all;
}
#suppl-upload-confirm-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ════════════════════════════════════════════════════════════════════════════
   Edit Case Introduction Modal  (ehr-cei-*)
   ════════════════════════════════════════════════════════════════════════════ */

.ehr-cei-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.ehr-cei-modal {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
}

/* Header */
.ehr-cei-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.ehr-cei-header-info {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--primary-color, #0056b3);
}

.ehr-cei-title {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.ehr-cei-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    padding: 0.25rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
}

.ehr-cei-close-btn:hover {
    color: #111827;
    background: #f3f4f6;
}

/* Body */
.ehr-cei-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Section */
.ehr-cei-section {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.ehr-cei-section-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid #f0f0f0;
}

.ehr-cei-hint {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.78rem;
    color: #9ca3af;
}

/* Field grid */
.ehr-cei-field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 1rem;
}

.ehr-cei-field-grid--single {
    grid-template-columns: 1fr;
}

.ehr-cei-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.ehr-cei-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #374151;
}

.ehr-cei-input,
.ehr-cei-select,
.ehr-cei-textarea {
    width: 100%;
    font-size: 0.875rem;
    padding: 0.45rem 0.65rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #111827;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}

.ehr-cei-input:focus,
.ehr-cei-select:focus,
.ehr-cei-textarea:focus {
    outline: none;
    border-color: var(--primary-color, #0056b3);
    box-shadow: 0 0 0 3px rgba(0,86,179,0.1);
}

.ehr-cei-textarea {
    resize: vertical;
    min-height: 72px;
}

.ehr-cei-select {
    appearance: auto;
    cursor: pointer;
}

/* Diagnosis rows */
.ehr-cei-diag-header {
    display: grid;
    grid-template-columns: 180px 1fr 32px;
    gap: 0.5rem;
    padding: 0 0 0.2rem 0;
}

.ehr-cei-diag-col-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ehr-cei-diag-row {
    display: grid;
    grid-template-columns: 180px 1fr 32px;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.45rem;
}

.ehr-cei-diag-row input {
    font-size: 0.85rem;
    padding: 0.4rem 0.55rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #111827;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.ehr-cei-diag-row input:focus {
    outline: none;
    border-color: var(--primary-color, #0056b3);
    box-shadow: 0 0 0 3px rgba(0,86,179,0.1);
}

.ehr-cei-diag-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    padding: 0.3rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.ehr-cei-diag-remove:hover {
    color: #ef4444;
    background: #fef2f2;
}

.ehr-cei-add-diag-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--primary-color, #0056b3);
    background: none;
    border: 1px dashed var(--primary-color, #0056b3);
    border-radius: 6px;
    padding: 0.35rem 0.75rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    margin-top: 0.2rem;
    align-self: flex-start;
}

.ehr-cei-add-diag-btn:hover {
    background: rgba(0,86,179,0.05);
}

.ehr-cei-diag-empty {
    font-size: 0.82rem;
    color: #9ca3af;
    margin: 0;
}

/* Error */
.ehr-cei-error {
    font-size: 0.82rem;
    color: #ef4444;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin: 0;
}

/* Footer */
.ehr-cei-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    padding: 0.9rem 1.25rem;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

/* Responsive */
@media (max-width: 520px) {
    .ehr-cei-field-grid {
        grid-template-columns: 1fr;
    }
    .ehr-cei-diag-header,
    .ehr-cei-diag-row {
        grid-template-columns: 150px 1fr 32px;
    }
}

/* ════════════════════════════════════════════════════════════════════
   Add Medications with AI — multi-file list + confirm table
   ════════════════════════════════════════════════════════════════════ */

.ehr-ai-file-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.75rem;
}

.ehr-ai-file-list-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: #f1f5f9;
    border-radius: 6px;
    font-size: 0.83rem;
    color: #374151;
}

.ehr-ai-file-list-item svg {
    flex-shrink: 0;
    color: #6b7280;
}

.ehr-ai-file-list-item span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ehr-ai-file-list-item .ehr-ai-remove-file {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px;
    border: none;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    border-radius: 4px;
    flex-shrink: 0;
    transition: color 0.15s;
}

.ehr-ai-file-list-item .ehr-ai-remove-file:hover { color: #ef4444; }

.ehr-medai-confirm-wrap {
    overflow-x: auto;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.ehr-medai-confirm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.ehr-medai-confirm-table th {
    padding: 0.5rem 0.6rem;
    background: #f8fafc;
    font-weight: 600;
    color: #374151;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

.ehr-medai-confirm-table td {
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid #f1f5f9;
    color: #374151;
    vertical-align: top;
}

.ehr-medai-confirm-table tr:last-child td {
    border-bottom: none;
}

.ehr-medai-confirm-table tr.ehr-medai-row-unchecked td {
    opacity: 0.4;
}

.ehr-medai-confirm-table input[type="checkbox"] {
    cursor: pointer;
    width: 15px;
    height: 15px;
    accent-color: var(--primary-color, #3b82f6);
}

/* ── Adjust Dates Confirm Modal ── */

.ehr-adj-confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 1300;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.ehr-adj-confirm-modal {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 740px;
    max-height: 90vh;
    overflow: hidden;
}

.ehr-adj-confirm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 12px;
    border-bottom: 1px solid var(--border-color, #d1d9e0);
    flex-shrink: 0;
}

.ehr-adj-confirm-summary {
    padding: 10px 18px 8px;
    font-size: 0.85rem;
    color: var(--text-secondary, #6b7280);
    border-bottom: 1px solid var(--border-color, #d1d9e0);
    flex-shrink: 0;
}

.ehr-adj-confirm-body {
    overflow-y: auto;
    flex: 1;
    padding: 0;
}

.ehr-adj-confirm-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--border-color, #d1d9e0);
    flex-shrink: 0;
}

/* Changes table */
.ehr-adj-changes-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.ehr-adj-changes-table thead th {
    position: sticky;
    top: 0;
    background: var(--bg-secondary, #f6f8fa);
    padding: 7px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary, #5f6368);
    border-bottom: 1px solid var(--border-color, #d1d9e0);
    white-space: nowrap;
}

.ehr-adj-changes-section-row td {
    background: var(--bg-secondary, #f6f8fa);
    padding: 5px 14px;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--text-secondary, #5f6368);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-top: 1px solid var(--border-color, #d1d9e0);
}

.ehr-adj-changes-table tbody tr:not(.ehr-adj-changes-section-row):hover {
    background: #f0f7ff;
}

.ehr-adj-changes-label {
    padding: 6px 14px;
    color: var(--text-primary, #202124);
    max-width: 220px;
    word-break: break-word;
}

.ehr-adj-changes-old {
    padding: 6px 14px;
    color: #b91c1c;
    font-family: monospace;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 300px;
}

.ehr-adj-changes-new {
    padding: 6px 14px;
    color: #15803d;
    font-family: monospace;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 300px;
}


.ehr-adj-current-date-display {
    margin: 4px 0 0;
    font-size: 0.9rem;
    color: var(--text-secondary, #6b7280);
}

.ehr-adj-delta-preview {
    margin: 8px 0 0;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--primary-color, #3b82f6);
    min-height: 1.2em;
}

.ehr-adj-warning {
    font-size: 0.8rem;
    color: #9ca3af;
    line-height: 1.5;
    margin-top: 4px;
}

.ehr-adj-quick-btns {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.ehr-adj-quick-group {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.ehr-adj-quick-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
    margin-right: 2px;
    min-width: 36px;
    text-align: right;
    letter-spacing: 0.01em;
}

.ehr-adj-quick-sep {
    display: inline-block;
    width: 1px;
    height: 20px;
    background: var(--border-color, #d1d5da);
    margin: 0 6px;
}

.ehr-adj-quick-btn {
    padding: 3px 10px;
    border: 1px solid var(--border-color, #d1d5da);
    border-radius: 5px;
    background: none;
    color: var(--text-secondary, #5f6368);
    font-size: 0.82rem;
    font-family: var(--font-family);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    min-width: 32px;
    text-align: center;
}

.ehr-adj-quick-btn:hover {
    background: var(--hover-bg, #f3f4f6);
    border-color: var(--primary-color, #3b82f6);
    color: var(--primary-color, #3b82f6);
}


/* ===========================================================================
   Verify Case with AI — Modal Styles
   Reuses .ehr-cei-overlay / .ehr-cei-header / .ehr-cei-footer from above.
   Only defines the parts that are unique to the verify flow.
   =========================================================================== */

/* Widen the modal beyond the standard 600px to give chat room to breathe */
.ehr-verify-modal {
    max-width: 1200px;
    max-height: 88vh;
}

/* The chat-view is a flex column that fills available modal height */
.ehr-verify-chat-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Scrollable message list */
.ehr-verify-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 200px;
}

/* Individual message bubbles */
.ehr-verify-msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
}

.ehr-verify-msg.user {
    align-self: flex-end;
    align-items: flex-end;
}

.ehr-verify-msg.assistant {
    align-self: flex-start;
    align-items: flex-start;
}

.ehr-verify-msg-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.ehr-verify-msg-bubble {
    padding: 0.5rem 0.85rem;
    border-radius: 10px;
    font-size: 0.8rem;
    line-height: 1.55;
    word-break: break-word;
}

.ehr-verify-msg.user .ehr-verify-msg-bubble {
    background: var(--primary-color, #0056b3);
    color: #fff;
    border-bottom-right-radius: 3px;
}

.ehr-verify-msg.assistant .ehr-verify-msg-bubble {
    background: var(--bg-secondary, #f6f8fa);
    color: var(--text-primary, #202124);
    border: 1px solid var(--border-color, #e5e7eb);
    border-bottom-left-radius: 3px;
}

/* Markdown rendered inside assistant bubbles */
.ehr-verify-msg.assistant .ehr-verify-msg-bubble p { margin: 0 0 0.4em; }
.ehr-verify-msg.assistant .ehr-verify-msg-bubble p:last-child { margin-bottom: 0; }
.ehr-verify-msg.assistant .ehr-verify-msg-bubble ul,
.ehr-verify-msg.assistant .ehr-verify-msg-bubble ol { margin: 0.3em 0 0.3em 1.2em; padding: 0; }
.ehr-verify-msg.assistant .ehr-verify-msg-bubble li { margin-bottom: 0.2em; }
.ehr-verify-msg.assistant .ehr-verify-msg-bubble strong { font-weight: 600; }
.ehr-verify-msg.assistant .ehr-verify-msg-bubble code {
    background: rgba(0,0,0,0.06);
    border-radius: 3px;
    padding: 1px 4px;
    font-size: 0.83em;
    font-family: ui-monospace, monospace;
}

/* .rendered-markdown inside AI bubbles — reset font size to match bubble */
.ehr-verify-msg-bubble .ehr-verify-markdown {
    font-size: inherit;
    line-height: 1.55;
}

.ehr-verify-msg-bubble .ehr-verify-markdown > *:first-child { margin-top: 0; }
.ehr-verify-msg-bubble .ehr-verify-markdown > *:last-child  { margin-bottom: 0; }

/* Plan message bubble */
.ehr-verify-msg.plan .ehr-verify-msg-bubble {
    background: rgba(var(--primary-color-rgb, 0, 86, 179), 0.04);
}

/* Loading skeleton shown while AI is thinking */
.ehr-verify-msg-loading {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.5rem 0.9rem;
    background: var(--bg-secondary, #f6f8fa);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 10px;
    border-bottom-left-radius: 3px;
    font-size: 0.85rem;
    color: var(--text-secondary, #6b7280);
    align-self: flex-start;
    max-width: 88%;
}

.ehr-verify-msg-loading .ehr-verify-dots span {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-secondary, #9ca3af);
    margin: 0 1px;
    animation: ehr-verify-bounce 1.2s infinite ease-in-out;
}

.ehr-verify-msg-loading .ehr-verify-dots span:nth-child(1) { animation-delay: 0s; }
.ehr-verify-msg-loading .ehr-verify-dots span:nth-child(2) { animation-delay: 0.2s; }
.ehr-verify-msg-loading .ehr-verify-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ehr-verify-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-5px); }
}

/* Input area */
.ehr-verify-input-area {
    display: flex;
    align-items: center;
    gap: 0;
    margin: 0.6rem 1.1rem 0.25rem;
    padding: 0.3rem 0.3rem 0.3rem 0.85rem;
    border: 1px solid var(--border-color, #e2e5e9);
    border-radius: 12px;
    background: var(--bg-primary, #fff);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: border-color 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
}

.ehr-verify-input-area:focus-within {
    border-color: var(--primary-color, #1a73e8);
    box-shadow: 0 0 0 3px rgba(26,115,232,0.08);
}

.ehr-verify-input {
    flex: 1;
    padding: 0.3rem 0;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    font-family: var(--font-family);
    color: var(--text-primary, #202124);
    resize: none;
    line-height: 1.5;
    outline: none;
    max-height: 120px;
    overflow-y: auto;
}

.ehr-verify-send-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--primary-color, #1a73e8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, transform 0.1s;
    margin-bottom: 1px;
    opacity: 0.75;
}

.ehr-verify-send-btn:hover:not(:disabled) {
    background: rgba(26,115,232,0.08);
    opacity: 1;
}

.ehr-verify-send-btn:active:not(:disabled) {
    transform: scale(0.9);
    background: rgba(26,115,232,0.14);
}

.ehr-verify-send-btn:disabled {
    opacity: 0.25;
    cursor: default;
}

/* Footer row for action buttons */
.ehr-verify-footer {
    justify-content: space-between !important;
    padding: 0.4rem 1.1rem 0.75rem;
    border-top: none;
    gap: 0.5rem;
}

.ehr-verify-footer-right {
    display: flex;
    gap: 0.45rem;
    align-items: center;
}

/* Compact button overrides scoped to the verify footer */
.ehr-verify-footer .ehr-cn-btn-clear {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    border-color: transparent;
    background: transparent;
    color: var(--text-secondary, #6b7280);
}

.ehr-verify-footer .ehr-cn-btn-clear:hover {
    background: var(--bg-hover, #f3f4f6);
    border-color: var(--border-color, #e5e7eb);
}

.ehr-verify-footer .modal-footer-btn {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 6px;
    box-shadow: none;
}

.ehr-verify-footer .modal-footer-btn:hover:not(:disabled) {
    transform: none;
    box-shadow: none;
    background-color: #e8ecf1;
}

.ehr-verify-footer .modal-footer-btn.primary:hover:not(:disabled) {
    transform: none;
    box-shadow: none;
    background-color: #1557b0;
}

/* Draft Changes Plan — blue accent */
#ehr-verify-draft-plan {
    color: #1a73e8;
    background: rgba(26, 115, 232, 0.07);
}
#ehr-verify-draft-plan:hover:not(:disabled) {
    background: rgba(26, 115, 232, 0.14) !important;
    color: #1557b0;
}

/* View Changes — teal accent */
#ehr-verify-view-changes {
    color: #0891b2;
    background: rgba(8, 145, 178, 0.07);
}
#ehr-verify-view-changes:hover:not(:disabled) {
    background: rgba(8, 145, 178, 0.14) !important;
    color: #0e7490;
}

/* Implement Changes — green accent */
#ehr-verify-implement {
    color: #059669;
    background: rgba(5, 150, 105, 0.07);
}
#ehr-verify-implement:hover:not(:disabled) {
    background: rgba(5, 150, 105, 0.14) !important;
    color: #047857;
}

/* Keyboard hint below the input container */
.ehr-verify-input-hint {
    padding: 0 1.1rem 0;
    font-size: 0.72rem;
    color: var(--text-secondary, #9ca3af);
    user-select: none;
    line-height: 1.6;
    flex-shrink: 0;
}

/* Changes confirmation view fills the modal body */
.ehr-verify-changes-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Scrollable area for the diff table */
.ehr-verify-changes-body {
    overflow-y: auto;
    flex: 1;
    padding: 0;
}

/* Table wrap inside changes view */
.ehr-verify-changes-table-wrap {
    border-top: 1px solid var(--border-color, #e5e7eb);
}

/* Diff value rendering helpers */
.ehr-diff-key {
    font-weight: 600;
    opacity: 0.85;
}
.ehr-diff-obj-item {
    padding: 2px 0;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    line-height: 1.5;
}
.ehr-diff-obj-item:last-child {
    border-bottom: none;
}
.ehr-diff-sentinel {
    font-style: italic;
    opacity: 0.6;
    font-family: inherit;
}
.ehr-diff-html {
    font-family: inherit;
    white-space: normal;
    line-height: 1.5;
    font-size: 0.82rem;
}
.ehr-diff-html p { margin: 0 0 4px; }
.ehr-diff-html ul, .ehr-diff-html ol { margin: 0; padding-left: 1.2em; }

.ehr-adj-changes-rationale {
    padding: 6px 14px;
    color: var(--text-secondary, #5f6368);
    font-size: 0.8rem;
    font-style: italic;
    max-width: 260px;
    word-break: break-word;
    white-space: pre-wrap;
}

/* Disabled state for Draft Changes Plan button */
#ehr-verify-draft-plan:disabled {
    opacity: 0.45;
    cursor: default;
}

/* ===========================================================================
   Verify Case — Plan Items Table
   Interactive table rendered inside the chat message stream when the user
   clicks "Draft Changes Plan". Each row has a checkbox so the user can
   accept or deselect individual proposed changes before implementing.
   =========================================================================== */

.ehr-verify-plan-summary {
    font-size: 0.88rem;
    color: var(--text-primary, #202124);
    line-height: 1.55;
    margin: 0 0 10px;
}

.ehr-verify-plan-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0 8px;
    flex-wrap: wrap;
}
.ehr-verify-plan-controls.readonly {
    opacity: 0.6;
}

.ehr-verify-plan-count {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary, #5f6368);
    letter-spacing: 0.02em;
}

.ehr-verify-plan-ctrl-btns {
    display: flex;
    gap: 6px;
}

.ehr-verify-plan-ctrl-btn {
    font-size: 0.75rem;
    padding: 2px 10px;
    border-radius: 12px;
    border: 1px solid var(--border-color, #d1d9e0);
    background: var(--bg-secondary, #f6f8fa);
    color: var(--text-secondary, #5f6368);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.ehr-verify-plan-ctrl-btn:hover {
    background: var(--bg-hover, #eef1f5);
    border-color: var(--border-active, #a0aec0);
}

.ehr-verify-plan-table-wrap {
    overflow-x: auto;
    border-radius: 6px;
    border: 1px solid var(--border-color, #d1d9e0);
}

.ehr-verify-plan-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    font-family: inherit;
    table-layout: fixed;
}

.ehr-verify-plan-table thead th {
    background: var(--bg-secondary, #f6f8fa);
    padding: 7px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary, #5f6368);
    border-bottom: 1px solid var(--border-color, #d1d9e0);
    white-space: nowrap;
}
.ehr-verify-plan-table thead th:first-child { width: 32px; text-align: center; }
.ehr-verify-plan-table thead th:nth-child(2) { width: 120px; }
.ehr-verify-plan-table thead th:nth-child(3) { width: 45%; }
.ehr-verify-plan-table thead th:nth-child(4) { width: auto; }

.ehr-verify-plan-table tbody tr {
    border-bottom: 1px solid var(--border-color, #e8eaed);
    transition: background 0.1s;
}
.ehr-verify-plan-table tbody tr:last-child { border-bottom: none; }
.ehr-verify-plan-table tbody tr:hover { background: #f5f8ff; }

.ehr-verify-plan-table tbody td {
    padding: 8px 12px;
    vertical-align: top;
    word-break: break-word;
    white-space: pre-wrap;
    line-height: 1.45;
}

.ehr-verify-plan-cb-cell {
    text-align: center;
    width: 32px;
    padding: 8px 4px !important;
    vertical-align: middle !important;
}
.ehr-verify-plan-cb-cell input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: var(--primary-color, #1a73e8);
}
.ehr-verify-plan-static-cb {
    font-size: 0.85rem;
    color: var(--text-secondary, #5f6368);
}

.ehr-verify-plan-section {
    font-weight: 600;
    color: var(--text-primary, #202124);
    font-size: 0.8rem;
}

.ehr-verify-plan-desc {
    color: var(--text-primary, #202124);
}

.ehr-verify-plan-rationale {
    color: var(--text-secondary, #5f6368);
    font-style: italic;
    font-size: 0.8rem;
}

/* Deselected (unchecked) rows are dimmed */
.ehr-verify-plan-row-off {
    opacity: 0.4;
}
.ehr-verify-plan-row-off .ehr-verify-plan-cb-cell { opacity: 1; }

/* ===========================================================================
   Verify Case — Initial Analysis Suggestions Table
   5-column variant of the plan table (adds Issue Found column).
   =========================================================================== */

.ehr-verify-analysis-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0 8px;
    flex-wrap: wrap;
    border-top: 1px solid var(--border-color, #e5e7eb);
    margin-top: 12px;
}

.ehr-verify-analysis-header {
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--text-primary, #202124);
    flex-shrink: 0;
}

.ehr-verify-analysis-count {
    font-size: 0.78rem;
    color: var(--text-secondary, #5f6368);
    flex: 1;
}

/* 5-column widths for the analysis table */
.ehr-verify-analysis-table thead th:first-child { width: 32px; }
.ehr-verify-analysis-table thead th:nth-child(2) { width: 100px; }
.ehr-verify-analysis-table thead th:nth-child(3) { width: 22%; }
.ehr-verify-analysis-table thead th:nth-child(4) { width: 28%; }
.ehr-verify-analysis-table thead th:nth-child(5) { width: auto; }

.ehr-verify-analysis-issue {
    color: #b45309;
    font-size: 0.82rem;
    word-break: break-word;
    white-space: pre-wrap;
    line-height: 1.45;
    padding: 8px 12px;
    vertical-align: top;
}

/* Auto-generated selection-commit: neutral annotation strip, not a user bubble */
.ehr-verify-msg.context {
    align-self: stretch;
    align-items: center;
}
.ehr-verify-msg.context .ehr-verify-msg-label {
    display: none;
}
.ehr-verify-msg.context .ehr-verify-msg-bubble {
    background: var(--bg-secondary, #f6f8fa);
    border: 1px dashed var(--border-color, #c9d1d9);
    border-radius: 6px;
    color: var(--text-secondary, #5f6368);
    max-width: 100%;
    padding: 7px 14px;
}
.ehr-verify-selection-commit {
    font-size: 0.83rem;
    font-style: italic;
    line-height: 1.5;
}
.ehr-verify-selection-commit p  { margin: 0 0 3px; }
.ehr-verify-selection-commit ol,
.ehr-verify-selection-commit ul { margin: 2px 0; padding-left: 1.2em; }
.ehr-verify-selection-commit li { margin-bottom: 1px; }

/* ===========================================================================
   Verify Case — Pinned Issues Panel
   Always-visible panel above the message list, with collapsible table.
   =========================================================================== */

.ehr-verify-issues-panel {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    height: 220px;
    min-height: 72px;
    background: var(--bg-primary, #fff);
    overflow: hidden;
}

.ehr-verify-issues-panel-hdr {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    user-select: none;
}

.ehr-verify-issues-panel-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary, #202124);
    flex-shrink: 0;
}

.ehr-verify-issues-panel-count {
    font-size: 0.78rem;
    color: var(--text-secondary, #5f6368);
    flex: 1;
    min-width: 0;
}

.ehr-verify-issues-collapse-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text-secondary, #6b7280);
    transition: background 0.15s;
    padding: 0;
}

.ehr-verify-issues-collapse-btn:hover {
    background: var(--bg-hover, #f0f2f5);
}

.ehr-verify-issues-collapse-btn svg {
    transition: transform 0.2s;
}

.ehr-verify-issues-collapse-btn.collapsed svg {
    transform: rotate(180deg);
}

.ehr-verify-issues-panel-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 0 14px 10px;
}

/* ── Resize handle between issues panel and chat messages ── */
.ehr-verify-resize-handle {
    flex-shrink: 0;
    height: 5px;
    background: var(--border-color, #e5e7eb);
    cursor: row-resize;
    position: relative;
    transition: background 0.15s;
    z-index: 1;
}

.ehr-verify-resize-handle::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 3px;
    border-radius: 2px;
    background: var(--text-secondary, #9ca3af);
    opacity: 0.5;
    transition: opacity 0.15s, width 0.15s;
}

.ehr-verify-resize-handle:hover,
.ehr-verify-resize-handle.dragging {
    background: var(--accent-color, #1a73e8);
}

.ehr-verify-resize-handle:hover::after,
.ehr-verify-resize-handle.dragging::after {
    opacity: 1;
    width: 48px;
    background: #fff;
}

