/* cyrillic */
@font-face {
    font-family: 'Geist';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url(https://fonts.gstatic.com/s/geist/v4/gyByhwUxId8gMEwYGFWfOw.woff2) format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* latin-ext */
@font-face {
    font-family: 'Geist';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url(https://fonts.gstatic.com/s/geist/v4/gyByhwUxId8gMEwSGFWfOw.woff2) format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* latin */
@font-face {
    font-family: 'Geist';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url(https://fonts.gstatic.com/s/geist/v4/gyByhwUxId8gMEwcGFU.woff2) format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --app-font-size: 0.9rem;
    --sr-ai-panel-width: 440px;
    --sr-ai-panel-width-collapsed: 52px;
}

body {
    font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: var(--app-font-size);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

body.theme-dark {
    background: linear-gradient(135deg, #0b0f14 0%, #141a22 100%);
    color: #e2e8f0;
}

body.theme-dark .sidebar {
    background: #1C2128;
}

body.theme-dark .sidebar-header,
body.theme-dark .sidebar-nav {
    background: #1C2128;
    border-color: #1C2128;
}

body.theme-dark .sidebar-toggle-btn {
    color: #e2e8f0;
}

body.theme-dark .sidebar-toggle-btn:hover {
    color: #ffffff;
}

body.theme-dark .sidebar-nav-item {
    color: #8B949E;
}

body.theme-dark .sidebar-nav-text {
    color: #8B949E;
}

body.theme-dark .sidebar-nav-item:hover .sidebar-nav-text,
body.theme-dark .sidebar-nav-item.active .sidebar-nav-text {
    color: #ffffff;
}

body.theme-dark .sidebar-nav-icon {
    opacity: 1;
}

body.theme-dark .sidebar-nav-item:hover,
body.theme-dark .sidebar-nav-item.active {
    color: #e2e8f0;
    background: rgba(20, 184, 166, 0.14);
}

body.theme-dark .sidebar-footer {
    background: #1C2128;
    border-color: #1C2128;
}

body.theme-dark .sidebar-footer-text {
    color: #e5e7eb;
    opacity: 1;
}

body.theme-dark .main-content {
    background: #0E1117;
    color: #e2e8f0;
}

body.theme-dark .user-info-card {
    background: #0f141b;
    border-color: #24303c;
}

body.theme-dark .settings-page .settings-content-card,
body.theme-dark .report-composer-selected,
body.theme-dark .report-composer-library,
body.theme-dark .report-composer-add-menu {
    background: #0f141b;
    border-color: #24303c;
}

body.theme-dark .report-composer-title,
body.theme-dark .report-composer-subtitle,
body.theme-dark .report-composer-study-hint,
body.theme-dark .report-composer-library h3,
body.theme-dark .report-composer-selected h3,
body.theme-dark .report-composer-library-item-title,
body.theme-dark .report-composer-selected-label,
body.theme-dark .settings-content .form-group label {
    color: #e2e8f0;
}

body.theme-dark .settings-content .form-group select,
body.theme-dark .settings-content .form-select,
body.theme-dark .report-composer-add-btn,
body.theme-dark .report-composer-add-option,
body.theme-dark .report-composer-library-item,
body.theme-dark .report-composer-selected-item {
    background: #121a23;
    border-color: #2a3a4a;
    color: #e2e8f0;
}

body.theme-dark .report-composer-study-hint {
    background: #0e131a;
    border-color: #24303c;
}

body.theme-dark .settings-content .form-group select:focus,
body.theme-dark .settings-content .form-select:focus {
    border-color: #2dd4bf;
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.22);
}

/* Canvas / panel surfaces (Charts & content blocks) */
body.theme-dark .investigation-box {
    background: #0f172a;
    border-color: #24303c;
    box-shadow: none;
}

/* Bottom-right brand label (moved from sidebar footer by JS) */
.main-bottom-right-brand {
    position: fixed;
    right: 24px;
    bottom: 18px;
    z-index: 1200;
    font-size: 0.8rem;
    font-weight: 600;
    color: #F37C4D;
    opacity: 0.95;
    pointer-events: none;
}

body.theme-dark .main-bottom-right-brand {
    color: #8B949E;
    opacity: 0.95;
}

body.theme-dark .investigation-header {
    border-bottom-color: #24303c;
}

body.theme-dark .investigation-header h3 {
    color: #e5e7eb;
}

body.theme-dark .signal-selector-container {
    background: #0f172a;
}

body.theme-dark .signal-selector-label {
    color: #cbd5e1;
}

body.theme-dark .signal-chunk-select,
body.theme-dark .signal-range-input {
    background: #0f172a;
    border-color: #24303c;
    color: #e5e7eb;
}

body.theme-dark .investigation-update-btn {
    color: #aab3c2;
}

body.theme-dark .dash-chart-box {
    border-color: #24303c;
    background: #0f172a;
}

body.theme-dark .dash-chart-title,
body.theme-dark .dash-detail-title {
    color: #e5e7eb;
    border-bottom-color: #24303c;
}

body.theme-dark .dash-detail-empty {
    color: #aab3c2;
}

/* Analytics Library cards (Investigator > Analytics Library) */
body.theme-dark .dashboard-button.analysis-card {
    background: #0E1117;
    color: #E5E7EB;
    border: 1px solid #292E36;
    box-shadow: none;
}

body.theme-dark .dashboard-button.analysis-card:hover {
    box-shadow: none;
}

body.theme-dark .dashboard-button.analysis-card::before {
    background: linear-gradient(135deg, rgba(20, 184, 166, 0.20) 0%, rgba(41, 46, 54, 0.25) 100%);
}

body.theme-dark .analysis-card .button-content h2 {
    color: #E5E7EB;
}

body.theme-dark .analysis-card .button-content {
    color: #E5E7EB;
}

.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styles */
.sidebar {
    width: 52px;
    background: #2d3748;
    backdrop-filter: blur(10px);
    box-shadow: none;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    transition: width 0.3s ease;
    overflow: hidden;
}

.sidebar.expanded {
    width: 200px;
}

.sidebar-header {
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    background: #fff;
    min-height: 61px;
    border: 1px solid #c6c6c6;
}

.logo {
    max-width: 120px;
    height: auto;
    object-fit: contain;
    transition: opacity 0.3s ease, max-width 0.3s ease;
}

.sidebar-toggle-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #2d3748;
    cursor: pointer;
    outline: none;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.sidebar-toggle-btn:focus,
.sidebar-toggle-btn:focus-visible {
    outline: none;
    box-shadow: none;
}

.sidebar-toggle-btn:hover {
    color: #1a202c;
}

.sidebar-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    transform: rotate(180deg);
}

.sidebar-toggle-icon .sidebar-toggle-svg {
    display: block;
}

.sidebar.expanded .sidebar-toggle-icon {
    transform: rotate(0deg);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 8px;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid #c6c6c6;
}

.sidebar-nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: #a0aec0;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: var(--app-font-size);
    gap: 12px;
    position: relative;
    isolation: isolate;
}

/* Home tab icon uses a filled asset */
#home.sidebar-nav-item .sidebar-nav-icon {
    opacity: 0.95;
}

/* Push Analytics Library button to bottom of nav */
#analyses-functions.sidebar-nav-item {
    margin-top: auto;
    padding-top: 16px;
}

/* Soft separator above Analytics Library */
#analyses-functions.sidebar-nav-item::before {
    content: "";
    position: absolute;
    top: 0;
    left: 12px;
    right: 12px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.08) 10%, rgba(0, 0, 0, 0.08) 90%, transparent);
}

.sidebar-nav-item:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.sidebar-nav-item.active {
    background: transparent;
    color: #667eea;
    border-left: none;
}

.sidebar-nav-item.active::before {
    content: "";
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 8px;
    right: 8px;
    background: rgba(102, 126, 234, 0.2);
    border-radius: 6px;
    z-index: -1;
}

.sidebar-nav-icon {
    width: 20px;
    height: 20px;
    min-width: 20px;
    display: block;
    flex-shrink: 0;
    object-fit: contain;
}

.sidebar-nav-text {
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-weight: 500;
    font-size: 0.85rem;
    color: #525567;
}

.sidebar.expanded .sidebar-nav-text {
    opacity: 1;
}

/* Sidebar Loading Indicator */
.sidebar-loading {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 6px 0;
    background: transparent;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 10;
    margin-top: auto;
    flex-shrink: 0;
    border: none;
    box-shadow: none;
}

.sidebar-loading.show {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

.sidebar-loading .spinner-dot {
    background: #39465d;
}

.sidebar-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border: 1px solid #c6c6c6;
    border-top: none;
    background: #fff;
}

.sidebar:not(.expanded) .sidebar-footer {
    justify-content: center;
}

.sidebar:not(.expanded) .sidebar-footer-text {
    display: none;
}

/* Hide theme toggle when sidebar is folded */
.sidebar:not(.expanded) #theme-toggle-btn {
    display: none;
}

.sidebar-footer-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: #F37C4D;
    opacity: 0;
    transition: opacity 0.2s ease;
    white-space: nowrap;
    text-align: center;
}

.sidebar.expanded .sidebar-footer-text {
    opacity: 1;
}

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.spinner-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: white;
    animation: loading-pulse 1.2s ease-in-out infinite;
}

.spinner-dot:nth-child(1) {
    animation-delay: 0s;
}

.spinner-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.spinner-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes loading-pulse {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 1;
    }
}

/* Main Content Styles */
.main-content {
    flex: 1;
    margin-left: 52px;
    margin-right: 0;
    padding: 24px;
    min-height: 100vh;
    background: #fafafc;
    transition: margin-left 0.3s ease, margin-right 0.18s ease;
    position: relative;
}

.sidebar.expanded ~ .main-content {
    margin-left: 200px;
}

/* Dock the AI panel on the right by reserving space in main content */
body.sr-ai-open .main-content {
    margin-right: var(--sr-ai-panel-width);
}

body.sr-ai-collapsed .main-content {
    margin-right: var(--sr-ai-panel-width-collapsed);
}

.content-header {
    margin-bottom: 40px;
}

.content-header {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 20px;
}

.user-info-card {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    min-height: 40px;
    box-sizing: border-box;
    background: #2d3748;
    border: 1px solid #2d3748;
    border-radius: 8px;
    box-shadow: none;
    color: #ffffff;
    font-weight: 600;
}

.user-info-cards {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 12px;
}

.user-customer-card {
    min-height: 40px;
}

.user-info-customer {
    font-size: 0.9rem;
    color: #ffffff;
    white-space: nowrap;
}

/* Compliance page */
#compliance-patient-select,
.compliance-study-select {
    height: auto;
    min-height: 32px;
    padding: 6px 12px;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    background: #fafafc;
    color: #2d3748;
    font-family: inherit;
    font-size: var(--app-font-size);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#compliance-patient-select:hover,
.compliance-study-select:hover {
    border-color: #a0aec0;
}

#compliance-patient-select:focus,
.compliance-study-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.compliance-metrics {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.compliance-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.compliance-study-filters {
    margin: 8px 0 14px;
    max-width: 360px;
}

.compliance-study-select {
    width: 100%;
}

.compliance-study-metrics {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.compliance-inline-loading {
    padding: 18px 0;
}

.compliance-trends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.compliance-trend-card {
    min-height: 320px;
}

.compliance-chart-wrap {
    position: relative;
    width: 100%;
    height: 250px;
}

.compliance-chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

.compliance-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.compliance-title-block h1 {
    font-size: 1.6rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0 0 6px 0;
}

.compliance-title-block p {
    margin: 0;
    font-size: 0.95rem;
    color: #4a5568;
}

.compliance-patient-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    margin-left: 4px;
    border-radius: 6px;
    background: #ebf8ff;
    color: #2b6cb0;
    font-weight: 600;
    font-size: 0.9rem;
}

.compliance-header-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.compliance-chip {
    padding: 4px 10px;
    border-radius: 6px;
    background: #edf2f7;
    color: #4a5568;
    font-size: 0.8rem;
    font-weight: 500;
}

.compliance-chip-secondary {
    background: #fff5f5;
    color: #c53030;
}

.compliance-overview-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr);
    gap: 16px;
}

.compliance-overview-row--with-device {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr);
}

.compliance-overview-row--single {
    grid-template-columns: 1fr;
}

.compliance-overall-card,
.compliance-issues-card,
.compliance-device-card {
    height: 100%;
}

.compliance-device-card .compliance-device-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.compliance-device-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
}

.compliance-device-img {
    max-width: 100%;
    width: 280px;
    height: auto;
    border-radius: 8px;
    object-fit: contain;
    background: #f7fafc;
}

.compliance-device-details {
    font-size: 0.9rem;
    color: #4a5568;
}

.compliance-device-name {
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 2px;
}

.compliance-device-model {
    font-weight: 500;
    color: #4a5568;
    margin-bottom: 6px;
}

.compliance-device-desc {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.4;
    color: #718096;
}

.compliance-device-empty {
    margin: 0;
    font-size: 0.9rem;
    color: #718096;
    font-style: italic;
}

.compliance-overall-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.compliance-overall-score {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.compliance-overall-score .score-main {
    font-size: 2.2rem;
    font-weight: 700;
    color: #2d3748;
}

.compliance-overall-score .score-suffix {
    font-size: 0.9rem;
    color: #718096;
}

.compliance-overall-bar {
    position: relative;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #edf2f7;
    overflow: hidden;
}

.compliance-overall-bar-fill {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    transform-origin: left center;
    transition: width 0.4s ease;
}

.compliance-overall-subtext {
    font-size: 0.85rem;
    color: #4a5568;
}

.compliance-issues-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.compliance-issues-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.compliance-issues-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: #4a5568;
}

.compliance-issues-label {
    font-weight: 500;
}

.compliance-issues-count {
    min-width: 28px;
    text-align: center;
    border-radius: 6px;
    padding: 2px 8px;
    font-weight: 600;
    font-size: 0.85rem;
}

.compliance-issues-note {
    margin: 4px 0 0 0;
    font-size: 0.8rem;
    color: #718096;
}

.compliance-status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.compliance-status-good {
    background: #c6f6d5;
    color: #22543d;
}

.compliance-status-warning {
    background: #fefcbf;
    color: #744210;
}

.compliance-status-critical {
    background: #fed7d7;
    color: #9b2c2c;
}

.compliance-metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.compliance-metric-card {
    height: 100%;
}

.compliance-metric-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.compliance-metric-label {
    font-weight: 600;
    font-size: 0.95rem;
    color: #2d3748;
}

.compliance-metric-context {
    font-size: 0.8rem;
    color: #718096;
}

.compliance-metric-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.compliance-metric-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.compliance-metric-highlight {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2d3748;
}

.compliance-metric-value {
    font-size: 0.9rem;
    color: #4a5568;
}

.compliance-metric-footer {
    display: flex;
    align-items: center;
    gap: 8px;
}

.compliance-metric-bar {
    flex: 1;
    height: 6px;
    border-radius: 4px;
    background: #edf2f7;
    overflow: hidden;
}

.compliance-metric-bar-fill {
    height: 100%;
    border-radius: inherit;
    transition: width 0.3s ease;
}

.compliance-metric-score {
    font-size: 0.8rem;
    color: #718096;
    font-weight: 500;
    min-width: 52px;
    text-align: right;
}

.compliance-placeholder {
    color: #718096;
    font-size: 0.95rem;
}

.content-header .user-info-card {
    align-self: flex-end;
}

.content-header .user-info-cards {
    align-self: flex-end;
}

.alerts-header .user-info-card {
    align-self: flex-end;
}

.alerts-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.alerts-header .user-info-cards {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
    margin-left: auto;
}

.alerts-header #open-add-alarm-modal {
    flex-shrink: 0;
}

/* Alerts: header row is actions-only (chips live in .content-header) */
.alerts-header {
    justify-content: flex-end;
    margin-bottom: 12px;
}

.user-info-name,
.user-info-role {
    font-size: 0.9rem;
    color: #ffffff;
    white-space: nowrap;
}

.user-info-name {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.user-info-name::before {
    content: "";
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    background: center / contain no-repeat;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M20 21a8 8 0 0 0-16 0'/><circle cx='12' cy='7' r='4'/></svg>");
}

.user-info-separator {
    width: 1px;
    height: 18px;
    background: rgba(255, 255, 255, 0.35);
}

.content-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #2d3748;
    margin: 0;
}

.monitoring-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 0;
    justify-content: flex-start;
}


.btn-add-alarm {
    min-height: 40px;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    background: transparent;
    color: #4a5568;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    padding: 8px 14px;
    margin: 0;
    line-height: 1;
    box-sizing: border-box;
    text-align: center;
    outline: none;
    box-shadow: none;
    font-size: 0.95rem;
    font-weight: 600;
}

#new-monitor-btn {
    color: #1CC691;
    border-color: #1CC691;
}

#open-add-alarm-modal,
#add-investigation-btn {
    color: #1CC691;
    border-color: #1CC691;
}

#monitoring-all-modal-save {
    background: #1CC691;
    color: white;
    border-color: #1CC691;
}

#monitoring-all-modal-save:hover {
    background: #18b382;
    color: white;
    border-color: #18b382;
}

.btn-add-alarm:hover {
    color: #2d3748;
    border-color: #cbd5e0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.monitoring-menu {
    position: relative;
}

.monitoring-menu-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: #fafafc;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
    box-shadow: none;
}

.monitoring-menu-btn:hover {
    box-shadow: none;
}

.monitoring-menu-dot {
    width: 4px;
    height: 4px;
    background: #718096;
    border-radius: 50%;
    border: none;
    box-shadow: none;
    outline: none;
}

.monitoring-menu.open .monitoring-menu-btn {
    box-shadow: none;
}

.monitoring-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: none;
    z-index: 1200;
}

.monitoring-menu-popover {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 520px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 80px);
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.2);
    padding: 0;
    z-index: 1210;
    display: none;
}

.monitoring-menu.open .monitoring-menu-popover {
    display: flex;
}

.monitoring-menu.open .monitoring-menu-overlay {
    display: block;
}

.monitoring-menu-tabs {
    display: flex;
    flex-direction: column;
    width: 150px;
    border-right: 1px solid #e2e8f0;
    background: #f7fafc;
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

.monitoring-menu-tab {
    padding: 12px 14px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.9rem;
    color: #4a5568;
    transition: color 0.2s ease, background 0.2s ease;
    text-align: left;
}

.monitoring-menu-tab:hover {
    color: #2d3748;
    background: rgba(102, 126, 234, 0.08);
}

.monitoring-menu-tab.active {
    color: #667eea;
    font-weight: 600;
    background: #ffffff;
    border-right: 2px solid #667eea;
}

.monitoring-menu-content {
    padding: 16px;
    overflow-y: auto;
    max-height: 100%;
    flex: 1;
}

.monitoring-subtabs {
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 12px;
    padding-bottom: 8px;
}

.monitoring-subtab {
    border: 1px solid transparent;
    background: #edf2f7;
    color: #4a5568;
    font-size: 0.8rem;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.monitoring-subtab:hover {
    background: #e2e8f0;
    color: #2d3748;
}

.monitoring-subtab.active {
    background: #39465D;
    color: #ffffff;
    border-color: #39465D;
}

.monitoring-menu-panel {
    display: none;
}

.monitoring-menu-panel.active {
    display: block;
}

.monitoring-subpanel {
    display: none;
}

.monitoring-subpanel.active {
    display: block;
}

.monitoring-parameters-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.monitoring-parameters-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #4a5568;
}

.monitoring-parameters-select {
    flex: 1;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.8rem;
    color: #2d3748;
    background: #ffffff;
}

.monitoring-parameters-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 4px;
}

.monitoring-parameter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #4a5568;
}

.monitoring-parameter-label {
    line-height: 1.2;
}
.monitoring-menu-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 12px;
}

.monitoring-menu-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.monitoring-menu-action {
    border: 1px solid #cbd5e0;
    background: transparent;
    color: #4a5568;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.monitoring-menu-action:hover {
    border-color: #a0aec0;
    color: #2d3748;
}

.monitoring-patient-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 260px;
    overflow-y: auto;
    padding-right: 4px;
}

.monitoring-patient-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    color: #2d3748;
    background: #f7fafc;
    border-radius: 8px;
    padding: 8px 10px;
}

.monitoring-patient-checkbox {
    width: 14px;
    height: 14px;
    accent-color: #a0aec0;
}

.monitoring-patient-label {
    font-weight: 600;
}

.monitoring-menu-empty,
.monitoring-menu-placeholder {
    color: #718096;
    font-size: 0.9rem;
    padding: 12px 0;
}

.analytics-library-header {
    flex-direction: column;
    align-items: flex-start;
}

.analytics-library-header .analytics-search-input {
    margin-top: 12px;
}

/* Buttons Grid */
.buttons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    max-width: 1200px;
}

.dashboard-button {
    background: white;
    border: none;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: left;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    overflow: hidden;
}

.dashboard-button.analysis-card {
    box-shadow: none;
}

.dashboard-button.analysis-card:hover {
    box-shadow: none;
}

.dashboard-button.add-analysis-card {
    box-shadow: none;
}

.dashboard-button.add-analysis-card:hover {
    box-shadow: none;
}

.dashboard-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.dashboard-button:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.dashboard-button:hover::before {
    opacity: 1;
}

.dashboard-button:active {
    transform: translateY(-2px);
}

.button-icon {
    font-size: 2rem;
    line-height: 1;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.button-content {
    flex: 1;
    position: relative;
    z-index: 1;
}

.button-content h2 {
    font-size: 1rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0;
    line-height: 1.3;
}

/* Analysis Cards Grid - Specific to Analytics Library page */
.analysis-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 90px);
    gap: 12px;
    max-width: 1200px;
}

.add-analysis-grid {
    margin-bottom: 18px;
}

.analysis-sections-container {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.analysis-section {
    border-top: 1px solid #e2e8f0;
    padding-top: 12px;
}

.analysis-section-title {
    margin: 0 0 10px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #4a5568;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}

.analysis-section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 90px);
    gap: 12px;
    max-width: 1200px;
}

/* Add New Analysis Card Styles */
.add-analysis-card,
.analysis-card {
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    justify-content: center;
    width: 90px;
    height: 90px;
    min-width: 90px;
    max-width: 90px;
    min-height: 90px;
    max-height: 90px;
}

.add-analysis-card {
    border: 2px dashed #cbd5e0;
    background: #f7fafc;
}

.add-analysis-card:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

/* Analysis Card Styles */
.analysis-card {
    border: 2px solid #e2e8f0;
}

.add-analysis-card .button-content,
.analysis-card .button-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-analysis-card .button-content h2,
.analysis-card .button-content h2 {
    font-size: 0.75rem;
    line-height: 1.2;
    text-align: center;
}

.analysis-card:hover {
    border-color: #667eea;
}

/* Analysis Card Wrapper */
.analysis-card-wrapper {
    position: relative;
    width: 90px;
    height: 90px;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
    padding: 20px;
}

.modal-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: slideUp 0.3s ease-out;
}

/* Expanded Card Styles - Now used as modal */
.analysis-card-expanded {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 0;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.monitoring-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1200;
    padding: 24px;
}

.monitoring-modal-overlay.open {
    display: flex;
}

.monitoring-modal {
    background: #ffffff;
    border-radius: 8px;
    max-width: 720px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    overflow: hidden;
}

.monitoring-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
}

.monitoring-modal-header h2 {
    margin: 0;
    font-size: 1.4rem;
    color: #1a202c;
}

.monitoring-modal-close {
    background: transparent;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: #718096;
}

.monitoring-modal-body {
    padding: 20px 24px 24px;
    overflow-y: auto;
}

.monitoring-confirm-modal {
    max-width: 480px;
}

.monitoring-confirm-text {
    margin: 0 0 20px;
    color: #4a5568;
    font-size: 1rem;
    line-height: 1.5;
}

.monitoring-modal-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.monitoring-modal-field label {
    font-size: 0.9rem;
    color: #4a5568;
    font-weight: 600;
}

.monitoring-modal-field input {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    font-size: 0.95rem;
}

#monitoring-patient-id,
#monitoring-patient-name {
    background-color: #ffffff;
    color: #1a202c;
    border-color: #e2e8f0;
    color-scheme: light;
}

#monitoring-patient-id {
    min-height: 44px;
    padding: 12px 14px;
}

#monitoring-patient-id::placeholder,
#monitoring-patient-name::placeholder {
    color: #a0aec0;
}

input[type="checkbox"][data-parameter="br"] {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 0 0 1px #e2e8f0 inset;
    accent-color: #ffffff;
}

.monitoring-modal-section {
    margin-top: 10px;
    border-top: 1px solid #e2e8f0;
    padding-top: 16px;
}

.monitoring-modal-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    color: #2d3748;
    font-weight: 600;
}

.monitoring-modal-hint {
    font-size: 0.8rem;
    color: #718096;
    font-weight: 400;
}

.monitoring-parameters-add {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.monitoring-parameters-divider {
    width: 1px;
    height: 24px;
    background: #e2e8f0;
}

.monitoring-parameters-add-select {
    flex: 1;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #cbd5e0;
    font-size: 0.9rem;
    background: #ffffff;
    color: #2d3748;
}

.monitoring-parameters-add-btn {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #f7fafc;
    color: #2d3748;
    font-weight: 600;
    cursor: pointer;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.monitoring-parameters-add-btn:hover {
    border-color: #cbd5e0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.monitoring-parameters-add-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

.monitoring-parameters-picker {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.monitoring-parameter-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
}

.monitoring-parameter-select {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #2d3748;
}

.monitoring-parameter-name {
    font-weight: 600;
    color: #2d3748;
    min-width: 70px;
}

.monitoring-parameter-limits {
    display: grid;
    grid-template-columns: repeat(2, minmax(90px, 1fr));
    gap: 8px;
}

.monitoring-parameter-limits input {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #cbd5e0;
    font-size: 0.85rem;
    background-color: #ffffff;
    color: #1a202c;
}

input[type="number"][data-parameter="br"][data-limit],
input[type="number"][data-parameter="br"][data-limit]::placeholder {
    background-color: #ffffff;
    color: #1a202c;
}

input[type="number"][data-parameter="br"][data-limit]::placeholder {
    color: #a0aec0;
}

input[type="checkbox"][data-parameter="ecg"] {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 0 0 1px #e2e8f0 inset;
    accent-color: #ffffff;
}

.monitoring-parameter-remove {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: #ffffff;
    color: #a0aec0;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.monitoring-parameter-remove:hover {
    background: #fff5f5;
    color: #e53e3e;
}

.monitoring-parameter-limits.disabled {
    opacity: 0.45;
    pointer-events: none;
}

.monitoring-modal-error {
    margin-top: 12px;
    color: #c53030;
    font-size: 0.9rem;
    min-height: 20px;
}

@media (max-width: 768px) {
    .modal-overlay {
        padding: 10px;
    }
    
    .modal-container {
        max-width: 100%;
        max-height: 95vh;
    }
    
    .analysis-card-expanded {
        max-height: 95vh;
        border-radius: 12px;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.expanded-content {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .expanded-content {
        padding: 20px;
    }
}

.expanded-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: none;
}

.expanded-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #2d3748;
}

.close-expanded {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #718096;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.close-expanded:hover {
    background: #f7fafc;
    color: #2d3748;
}

.expanded-section {
    margin-bottom: 20px;
}

.expanded-section:last-child {
    margin-bottom: 0;
}

.expanded-section h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #4a5568;
    margin: 0 0 10px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.expanded-section p {
    font-size: 0.95rem;
    color: #2d3748;
    line-height: 1.6;
    margin: 0;
}

.description-content {
    font-size: 0.95rem;
    color: #2d3748;
    line-height: 1.8;
}

.description-content p {
    margin: 0 0 12px 0;
}

.description-content p:last-child {
    margin-bottom: 0;
}

.description-content h1,
.description-content h2,
.description-content h3,
.description-content h4,
.description-content h5,
.description-content h6 {
    font-weight: 600;
    color: #2d3748;
    margin: 16px 0 8px 0;
    line-height: 1.4;
}

.description-content h1 { font-size: 1.5rem; }
.description-content h2 { font-size: 1.3rem; }
.description-content h3 { font-size: 1.1rem; }
.description-content h4 { font-size: 1rem; }
.description-content h5 { font-size: 0.95rem; }
.description-content h6 { font-size: 0.9rem; }

.description-content ul,
.description-content ol {
    margin: 8px 0 12px 20px;
    padding-left: 20px;
}

.description-content li {
    margin: 4px 0;
}

.description-content code {
    background-color: #edf2f7;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #e53e3e;
}

.description-content pre {
    background-color: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 12px;
    overflow-x: auto;
    margin: 12px 0;
}

.description-content pre code {
    background-color: transparent;
    padding: 0;
    color: #2d3748;
}

.description-content strong {
    font-weight: 600;
    color: #2d3748;
}

.description-content em {
    font-style: italic;
}

.description-content blockquote {
    border-left: 4px solid #cbd5e0;
    padding-left: 16px;
    margin: 12px 0;
    color: #4a5568;
    font-style: italic;
}

.description-content a {
    color: #3182ce;
    text-decoration: none;
}

.description-content a:hover {
    text-decoration: underline;
}

.description-content hr {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 16px 0;
}

/* KaTeX math rendering styles */
.description-content .katex {
    font-size: 1.1em;
}

.description-content .katex-display {
    margin: 16px 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.parameters-list {
    list-style-type: disc;
    padding-left: 20px;
    margin: 0;
}

.expanded-section .parameters-list .parameter-item {
    font-size: 0.95rem;
    color: #2d3748;
    line-height: 1.8;
    padding: 0 !important;
    margin: 0 0 6px 0 !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    display: list-item !important;
    aspect-ratio: auto !important;
    min-width: auto !important;
    max-width: none !important;
    flex-direction: row !important;
    list-style-position: outside;
}

.expanded-section .parameters-list .parameter-item:last-child {
    margin-bottom: 0 !important;
}

.expanded-section .parameters-list .parameter-item strong {
    font-weight: 600;
    color: #2d3748;
    margin-right: 8px;
    display: inline;
}

.expanded-section .parameter-description {
    color: #718096;
    font-size: 0.95rem;
    line-height: 1.8;
    display: inline;
}

.keywords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.keyword-tag {
    display: inline-block;
    padding: 6px 12px;
    background: #edf2f7;
    color: #4a5568;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Back Button Styles */
.back-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    color: #a0aec0;
    font-size: 1.2rem;
    text-decoration: none;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    outline: none;
}

.back-button:hover {
    background: rgba(102, 126, 234, 0.2);
    color: #667eea;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    transform: translateY(-1px);
}

.back-button:active {
    transform: translateY(0);
}

.back-button:focus {
    outline: none;
}

/* Page Content Styles */
.page-content {
    padding: 20px 0;
    color: #4a5568;
    line-height: 1.6;
}

.page-content p {
    font-size: 1.1rem;
    margin-bottom: 16px;
}

/* Patient Monitoring Styles */

/* Monitoring Filters */
.monitoring-filters {
    display: flex;
    align-items: center;
    gap: 24px;
}

.monitoring-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
}

.observations-actions-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 16px;
}

.monitoring-filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.monitoring-filter-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #4a5568;
    white-space: nowrap;
}

.monitoring-filter-select {
    min-width: 180px;
    padding: 8px 12px;
    font-size: 0.875rem;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    background: #fafafc;
    color: #2d3748;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.monitoring-filter-select:hover {
    border-color: #a0aec0;
}

.monitoring-filter-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.patient-box.filtered-out {
    display: none;
}

.patients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 24px;
    margin-top: 20px;
}

.patient-box {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    padding: 24px;
    box-shadow: none;
    transition: none;
}


.patient-box:hover {
    box-shadow: none;
    transform: none;
}

.patient-box.hidden {
    display: none;
}

.patient-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e2e8f0;
}

.patient-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.patient-anomalies-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: #ffffff;
    color: #4a5568;
    font-weight: 700;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.patient-anomalies-btn:hover {
    border-color: #cbd5e0;
    background: #f7fafc;
}

.patient-anomalies-btn.has-anomaly {
    border-color: #feb2b2;
    background: #fff5f5;
    color: #c53030;
}

.patient-anomalies-btn.has-anomaly:hover {
    border-color: #f56565;
    background: #fed7d7;
}

.patient-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0;
}

.patient-header-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.patient-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #718096;
    flex-wrap: wrap;
}

.patient-study,
.patient-site {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.patient-battery.patient-battery-low {
    color: #e53e3e;
    font-weight: 600;
}

.patient-meta-separator {
    color: #cbd5e0;
    font-weight: 300;
}

.patient-status {
    font-size: 1.5rem;
    transition: color 0.3s ease;
}

.patient-menu-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    padding: 0;
}

.patient-menu-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #4a5568;
    display: block;
}

.patient-menu-btn:hover {
    background: transparent;
}

.patient-delete-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: #4a5568;
    font-size: 1.5rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.patient-delete-btn:hover {
    background: #f7fafc;
}

.patient-status.active {
    color: #48bb78;
    animation: pulse 2s infinite;
}

.patient-status.inactive {
    color: #cbd5e0;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.patient-data {
    min-height: 100px;
}

.no-data {
    color: #a0aec0;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.no-patients {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #718096;
    background: #f7fafc;
    border-radius: 12px;
    border: 2px dashed #cbd5e0;
}

.monitoring-empty-state,
.investigation-empty-state {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 40px;
}

.monitoring-empty-card,
.investigation-empty-card {
    background: #ffffff;
    border: 2px dashed #cbd5e0;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    max-width: 480px;
    width: 100%;
    box-shadow: none;
}

.monitoring-empty-card h2,
.investigation-empty-card h2 {
    margin: 0 0 8px;
    color: #2d3748;
}

.monitoring-empty-card p,
.investigation-empty-card p {
    margin: 0 0 20px;
    color: #718096;
}

.monitoring-empty-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.patient-parameters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}

/* Adjust grid to accommodate larger signal parameters */
.patient-parameters:has(.signal-parameter) {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* Adjust grid when history charts are shown */
.patient-parameters:has(.history-parameter) {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.parameter-item {
    background: transparent;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid #cbd5e0;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 150px;
    max-width: 200px;
}

.parameter-item.anomaly {
    background: #fff5f5;
    border-color: #feb2b2;
}

/* Larger size for signal parameters (like ECG) */
.parameter-item.signal-parameter {
    min-width: 300px;
    max-width: 400px;
    aspect-ratio: 1.2;
    padding: 16px;
}

.parameter-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.parameter-title {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.parameter-controls {
    display: flex;
    align-items: center;
    position: relative;
    margin-left: auto;
}

.parameter-range-toggle {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: #4a5568;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
}

.parameter-range-toggle:hover {
    border-color: transparent;
}

.parameter-range-toggle:focus,
.parameter-range-toggle:focus-visible,
.parameter-range-toggle:active {
    outline: none !important;
    box-shadow: none !important;
    border-color: transparent;
}

.parameter-range-dots {
    font-size: 1.1rem;
    letter-spacing: 2px;
    line-height: 1;
    font-weight: 600;
}

.parameter-range-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 140px;
    padding: 6px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
    display: none;
    z-index: 50;
}

.parameter-controls.open .parameter-range-menu {
    display: block;
}

.parameter-range-option {
    width: 100%;
    border: none;
    background: transparent;
    padding: 6px 8px;
    font-size: 0.85rem;
    color: #2d3748;
    text-align: left;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.parameter-range-option:hover {
    background: #f7fafc;
}

.parameter-range-option.active {
    background: #edf2f7;
    color: #667eea;
    font-weight: 600;
}

.patient-anomalies-popover {
    position: fixed;
    width: 360px;
    max-width: calc(100vw - 48px);
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.16);
    padding: 10px 12px;
    z-index: 1300;
    display: none;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.patient-anomalies-popover.open {
    display: block;
}

.patient-anomalies-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1290;
    display: none;
}

.patient-anomalies-overlay.open {
    display: block;
}

.patient-anomalies-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 6px;
    margin-bottom: 8px;
}

.patient-anomalies-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2d3748;
}

.patient-anomalies-close {
    border: none;
    background: transparent;
    font-size: 1.1rem;
    color: #718096;
    cursor: pointer;
}

.patient-anomalies-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
}

.patient-anomalies-item {
    border: 1px solid #fee2e2;
    background: #fff5f5;
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.8rem;
}

.patient-anomalies-parameter {
    font-weight: 600;
    color: #9b2c2c;
}

.patient-anomalies-value {
    color: #742a2a;
}

.patient-anomalies-time {
    color: #718096;
}

.patient-anomalies-empty {
    font-size: 0.85rem;
    color: #718096;
    padding: 6px 0;
}

.parameter-item.history-parameter {
    min-width: 0;
    max-width: 100%;
    width: 100%;
    aspect-ratio: auto;
    padding: 16px;
    min-height: 0;
    overflow: hidden;
}

.parameter-name {
    font-weight: 600;
    color: #2d3748;
    font-size: 0.9rem;
}

/* Larger text for signal parameters */
.parameter-item.signal-parameter .parameter-name {
    font-size: 1.2rem;
}

.parameter-timestamp {
    font-size: 0.75rem;
    color: #718096;
}

/* Larger timestamp for signal parameters */
.parameter-item.signal-parameter .parameter-timestamp {
    font-size: 0.95rem;
}

.value-display {
    font-size: 1.5rem;
    font-weight: 700;
    color: #3A465A;
    text-align: center;
    padding: 8px 0;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.signal-container {
    height: 160px;
    position: relative;
    margin-top: 8px;
    flex: 1;
    overflow: hidden;
}

.history-container {
    height: 160px;
    margin-top: 12px;
    width: 100%;
}

.no-history {
    font-size: 0.85rem;
    color: #a0aec0;
    text-align: center;
    padding: 16px 0;
}

/* Larger signal container for signal parameters */
.parameter-item.signal-parameter .signal-container {
    height: 220px;
    margin-top: 12px;
}

.signal-chart {
    display: block;
    width: 100%;
    height: 100%;
    max-height: 160px;
}

/* Larger chart for signal parameters */
.parameter-item.signal-parameter .signal-chart {
    max-height: 220px;
}

.signal-unit {
    font-size: 0.75rem;
    color: #718096;
    text-align: center;
    margin-top: 4px;
}

/* Larger unit text for signal parameters */
.parameter-item.signal-parameter .signal-unit {
    font-size: 1rem;
    margin-top: 8px;
}

/* Responsive adjustments for patient grid */
@media (max-width: 768px) {
    .patients-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .patient-box {
        padding: 16px;
    }
    
    .content-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .content-header h1 {
        font-size: 2rem;
    }
    
    .monitoring-filters {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        width: 100%;
        margin-top: 12px;
    }
    
    .monitoring-filter-group {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    
    .monitoring-filter-select {
        min-width: 100%;
    }
    
    .monitoring-actions-bar {
        margin-top: 12px;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        width: 52px;
    }

    .sidebar.expanded {
        width: 52px;
    }

    .sidebar-nav-text {
        display: none;
    }

    .sidebar-header {
        padding: 10px;
    }

    .logo {
        max-width: 30px;
    }

    .main-content {
        margin-left: 52px;
        padding: 20px;
    }

    .content-header h1 {
        font-size: 2rem;
        color: #2d3748;
    }

    .buttons-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .dashboard-button {
        padding: 16px;
    }
    
    .button-icon {
        font-size: 1.5rem;
    }
    
    .button-content h2 {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 0;
        overflow: hidden;
    }

    .sidebar.expanded {
        width: 0;
    }

    .main-content {
        margin-left: 0;
    }
}

/* Patient Observations Styles */
.observations-canvas {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
    gap: 24px;
    margin-top: 20px;
}

.investigation-box {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    min-height: 300px;
    min-width: min-content;
}

.investigation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: nowrap;
}

.investigation-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0;
}

.investigation-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    flex-shrink: 0;
}

.signal-selector-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 6px;
    border-radius: 8px;
    background: #f7fafc;
}

.signal-selector-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.signal-selector-label {
    font-size: 0.75rem;
    color: #4a5568;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
}

.signal-chunk-select {
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.85rem;
    color: #2d3748;
    background: #ffffff;
}

.signal-range-input {
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.85rem;
    color: #2d3748;
    background: #ffffff;
    width: 80px;
}

.signal-range-input:focus {
    outline: none;
    border-color: #667eea;
}

.investigation-update-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: #718096;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.investigation-update-btn:hover {
    background: #f7fafc;
    color: #667eea;
    transform: rotate(180deg);
}

.investigation-menu-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #718096;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.investigation-menu-btn:hover {
    background: #f7fafc;
    color: #2d3748;
}

.investigation-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #718096;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1;
}

.investigation-close:hover {
    background: #f7fafc;
    color: #e53e3e;
}

.investigation-chart-container {
    flex: 0 0 auto;
    height: 260px;
    min-height: 260px;
    position: relative;
}

.investigation-special-plots-container {
    margin-top: 12px;
    width: 100%;
}

.investigation-special-plot-block {
    margin-bottom: 12px;
}

.investigation-special-plot-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 6px;
}

.investigation-special-plot-img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: #fff;
}

.investigation-special-plot-canvas {
    width: 100% !important;
    height: 220px !important;
    display: block;
}

.investigation-special-plot-heatmap {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    image-rendering: pixelated;
}

.investigation-analytics-chart-container {
    margin-top: 16px;
    height: 220px;
    min-height: 220px;
    position: relative;
    display: none;
}

.investigation-chart-container canvas,
.investigation-analytics-chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.analytics-chart-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 8px;
}

/* ── Heatmap / Spectrogram Visualization ────────────────────── */

.investigation-heatmap-container {
    display: none;
    margin-top: 16px;
}

.heatmap-block {
    margin-bottom: 14px;
}

.heatmap-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.heatmap-dims {
    font-size: 0.75rem;
    font-weight: 500;
    color: #718096;
    background: #edf2f7;
    border-radius: 6px;
    padding: 2px 8px;
}

.heatmap-body {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.heatmap-canvas-wrap {
    flex: 1 1 auto;
    position: relative;
    min-height: 180px;
    max-height: 320px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    background: #1a202c;
}

.heatmap-canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.heatmap-tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(26, 32, 44, 0.9);
    color: #f7fafc;
    font-size: 0.78rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    padding: 4px 8px;
    border-radius: 5px;
    white-space: nowrap;
    z-index: 10;
}

.heatmap-colorbar-wrap {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    width: 44px;
    min-height: 180px;
    max-height: 320px;
}

.heatmap-colorbar-canvas {
    flex: 1 1 auto;
    width: 16px;
    border-radius: 3px;
    border: 1px solid #e2e8f0;
}

.heatmap-colorbar-label {
    font-size: 0.7rem;
    color: #718096;
    text-align: center;
    font-family: 'SF Mono', 'Fira Code', monospace;
    line-height: 1;
    padding: 2px 0;
}

.heatmap-info {
    font-size: 0.78rem;
    color: #718096;
    margin-top: 4px;
}

.analytics-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.analytics-result-item {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 12px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.analytics-result-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #2d3748;
}

.analytics-result-value {
    font-size: 1rem;
    color: #1a202c;
    word-break: break-word;
}

/* Modal Content Styles */
.modal-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    padding: 24px 30px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: #718096;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f7fafc;
    color: #2d3748;
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    color: #4a5568;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group input:disabled,
.form-group select:disabled {
    background: #f7fafc;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Specific styling for patient observations form selects and input */
#patient_id,
#parameter,
#state_check_operator,
#state_check_value,
#state_check_value_min,
#state_check_value_max,
#edit_patient_id,
#edit_parameter,
#edit_state_check_operator,
#edit_state_check_value,
#edit_state_check_value_min,
#edit_state_check_value_max,
#investigation-patient,
#investigation-parameter {
    background-color: white;
    color: #4a5568;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

#monitoring-modal-save,
#submit-btn,
#edit-submit-btn,
#submit-investigation-btn {
    padding: 8px 24px;
}

#monitoring-modal-save {
    background: #1CC691;
    color: white;
    border: 1px solid #1CC691;
    box-shadow: none;
}

#monitoring-modal-save:hover {
    background: #18b382;
    color: white;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
}

.btn-danger {
    background: #e53e3e;
    color: #ffffff;
}

.btn-danger:hover {
    background: #c53030;
    box-shadow: 0 4px 12px rgba(229, 62, 62, 0.35);
    transform: translateY(-2px);
}

/* Normal styling for submit button */
#submit-btn,
#edit-submit-btn,
#submit-investigation-btn {
    background: #1CC691;
    color: white;
    border: 1px solid #1CC691;
}

#submit-btn:hover,
#edit-submit-btn:hover,
#submit-investigation-btn:hover {
    background: #18b382;
    color: white;
    transform: none;
    box-shadow: none;
}

.analytics-apply-btn {
    background: #1CC691;
    color: white;
    border: 1px solid #1CC691;
    padding: 6px 20px;
    line-height: 1;
}

.analytics-apply-btn:hover {
    background: #18b382;
    color: white;
    transform: none;
    box-shadow: none;
}

.message-container {
    margin-bottom: 20px;
}

.success-message {
    padding: 12px 16px;
    background: #c6f6d5;
    color: #22543d;
    border-radius: 8px;
    font-size: 0.95rem;
}

.error-message {
    padding: 12px 16px;
    background: #fed7d7;
    color: #742a2a;
    border-radius: 8px;
    font-size: 0.95rem;
}

/* Settings Modal Styles */
.modal-container.settings-modal-container {
    width: 700px;
    max-width: 90vw;
    height: 1000px;
    max-height: 85vh;
    align-items: stretch;
}

.settings-modal-content {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
}

.settings-modal-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    padding: 0;
}

.settings-sidebar {
    width: 200px;
    background: #f7fafc;
    border-right: 1px solid #e2e8f0;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-tab {
    width: 100%;
    padding: 12px 24px;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font-size: 0.95rem;
    color: #718096;
    transition: all 0.2s;
    font-family: inherit;
    border-left: 3px solid transparent;
}

.settings-tab:hover {
    background: rgba(102, 126, 234, 0.05);
    color: #2d3748;
}

.settings-tab.active {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border-left-color: #667eea;
    font-weight: 600;
}

.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}

.settings-tab-content {
    display: none;
}

.settings-tab-content.active {
    display: block;
}

/* Configurations page (templates/settings.html) layout */
.settings-page .settings-config-layout {
    display: flex;
    flex-direction: row;
    gap: 18px;
    width: 100%;
}

.settings-page .settings-top-tabs-card {
    background: transparent;
    border: none;
    border-radius: 14px;
    padding: 0;
    flex-shrink: 0;
    width: fit-content;
    min-width: 0;
}

.settings-page .settings-top-tabs {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    flex-direction: column;
    flex-wrap: nowrap;
    width: 100%;
}

.settings-page .settings-top-tabs .settings-tab {
    width: 100% !important;
    border-left: none !important;
    border-left-color: transparent !important;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    white-space: nowrap;
    padding: 8px 16px;
    box-sizing: border-box;
    border: none !important;
    border-radius: 6px;
    text-align: left;
    background: transparent !important;
    color: #4a5568;
    font-weight: 500;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.08s ease;
}

.settings-page .settings-top-tabs .settings-tab:hover {
    background: transparent !important;
    color: #2d3748;
}

.settings-page .settings-top-tabs .settings-tab.active {
    background: rgba(102, 126, 234, 0.18) !important;
    border-color: transparent !important;
    color: #2b6cb0;
    font-weight: 600;
}

#theme-toggle-btn {
    position: static;
    top: auto;
    left: auto;
    right: auto;
    z-index: auto;
    width: 34px;
    height: 34px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    background: transparent;
    color: #ffffff;
    padding: 0;
    font-size: 0;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 0;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#theme-toggle-btn:hover {
    border-color: #a0aec0;
}

#theme-toggle-btn .theme-icon {
    display: block;
}

#theme-toggle-btn .theme-icon.hidden {
    display: none;
}

#theme-toggle-btn[aria-pressed="true"] {
    border-color: #2d3748;
    color: #ffffff;
}

.settings-page .settings-content-card {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 18px;
    flex: 1;
    min-width: 0;
}

.settings-preferences-title {
    margin-bottom: 10px;
    color: #2d3748;
    font-size: 1.1rem;
}

.settings-preferences-copy {
    color: #4a5568;
    line-height: 1.6;
}

body.theme-dark .settings-page .settings-top-tabs .settings-tab {
    color: #e5e7eb;
}

body.theme-dark .settings-page .settings-top-tabs .settings-tab:hover {
    color: #f8fafc;
}

body.theme-dark .settings-page .settings-top-tabs .settings-tab.active {
    background: rgba(20, 184, 166, 0.2) !important;
    color: #2dd4bf;
}

body.theme-dark #theme-toggle-btn {
    background: transparent;
    color: #ffffff;
    border-color: #2a3a4a;
}

body.theme-dark #theme-toggle-btn:hover {
    border-color: #3b4a5a;
}

body.theme-dark #theme-toggle-btn[aria-pressed="true"] {
    border-color: #14b8a6;
    color: #f8fafc;
}

body.theme-dark .settings-preferences-title,
body.theme-dark .settings-preferences-copy {
    color: #e2e8f0;
}

.settings-content .form-group {
    margin-bottom: 24px;
}

.settings-content .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2d3748;
    font-size: 0.95rem;
}

.settings-content .form-group input[type="color"] {
    width: 100%;
    height: 50px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.settings-content .form-group input[type="color"]:hover {
    border-color: #667eea;
}

.settings-content .form-group input[type="color"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.settings-content .form-group select,
.settings-content .form-select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background-color: white;
    color: #2d3748;
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s;
}

.settings-content .form-group select:hover,
.settings-content .form-select:hover {
    border-color: #cbd5e0;
}

.settings-content .form-group select:focus,
.settings-content .form-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.settings-content .form-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #667eea;
}

/* Report Composer (Configurations > Report Composer) */
.report-composer {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.report-composer-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.report-composer-title {
    margin: 0;
    color: #2d3748;
    font-size: 1.1rem;
}

.report-composer-subtitle {
    margin: 0;
    color: #4a5568;
    line-height: 1.5;
    font-size: 0.92rem;
}

.report-composer-form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #2d3748;
}

.report-composer-workspace.hidden {
    display: none;
}

.report-composer-study-hint {
    color: #4a5568;
    font-size: 0.9rem;
    border: 1px dashed #cbd5e0;
    border-radius: 8px;
    padding: 10px 12px;
    background: #f8fafc;
}

.report-composer-study-hint.hidden {
    display: none;
}

.report-composer-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
}

.report-composer-library,
.report-composer-selected {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #ffffff;
    padding: 14px;
    min-height: 220px;
}

.report-composer-library h3,
.report-composer-selected h3 {
    margin: 0 0 10px 0;
    font-size: 0.95rem;
    color: #2d3748;
}

.report-composer-selected-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.report-composer-selected-header h3 {
    margin: 0;
}

.report-composer-add {
    position: relative;
}

.report-composer-add-btn {
    border: 1px solid #cbd5e0;
    background: #ffffff;
    color: #2d3748;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.report-composer-add-btn:hover {
    background: #edf2f7;
}

.report-composer-add-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.report-composer-add-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 250px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    padding: 8px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.report-composer-add-menu.hidden {
    display: none;
}

.report-composer-add-option {
    border: 1px solid #edf2f7;
    border-radius: 6px;
    background: #f8fafc;
    color: #2d3748;
    font-size: 0.86rem;
    text-align: left;
    padding: 8px 10px;
    cursor: pointer;
}

.report-composer-add-option:hover {
    background: #edf2f7;
}

.report-composer-library-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.report-composer-library-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    border: 1px solid #edf2f7;
    border-radius: 8px;
    padding: 10px 12px;
    background: #f8fafc;
}

.report-composer-library-item-title {
    color: #2d3748;
    font-weight: 500;
    font-size: 0.9rem;
}

.report-composer-selected-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.report-composer-selected-item {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 9px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.report-composer-selected-label {
    color: #2d3748;
    font-size: 0.9rem;
    font-weight: 500;
}

.report-composer-item-actions {
    display: inline-flex;
    gap: 6px;
}

.report-composer-icon-btn {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    color: #4a5568;
    min-width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 0.82rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.report-composer-icon-btn:hover {
    background: #edf2f7;
}

.report-composer-empty {
    color: #718096;
    font-size: 0.88rem;
    margin-top: 2px;
}

.report-composer-empty.hidden {
    display: none;
}

.report-composer-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.report-composer-btn {
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-weight: 600;
    cursor: pointer;
}

.report-composer-btn-primary {
    background: #667eea;
    color: #ffffff;
}

.report-composer-btn-primary:hover {
    background: #5a67d8;
}

.report-composer-btn-secondary {
    background: #edf2f7;
    color: #2d3748;
}

.report-composer-btn-secondary:hover {
    background: #e2e8f0;
}

.report-composer-status {
    min-height: 20px;
    font-size: 0.86rem;
}

.report-composer-status.success {
    color: #276749;
}

.report-composer-status.error {
    color: #c53030;
}

/* Report composer: layout preview — solid panel on dimmed backdrop (not floating fragments) */
.rc-preview-overlay {
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.55);
}

.rc-preview-modal {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: min(1120px, 96vw);
    max-height: min(92vh, 900px);
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    animation: slideUp 0.28s ease-out;
}

.rc-preview-modal-header {
    flex-shrink: 0;
    padding: 18px 22px 12px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.rc-preview-modal-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a202c;
}

.rc-preview-modal-subtitle {
    margin: 6px 0 0;
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.4;
}

.rc-preview-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 20px 20px;
    -webkit-overflow-scrolling: touch;
}

#rc-preview-body.rc-preview-body--site-report {
    max-height: none;
    padding: 0;
}

.rc-preview-modal-footer {
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding: 14px 20px 16px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

body.theme-dark .rc-preview-modal {
    background: #1e293b;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

body.theme-dark .rc-preview-modal-header,
body.theme-dark .rc-preview-modal-footer {
    background: #0f172a;
    border-color: #334155;
}

body.theme-dark .rc-preview-modal-title {
    color: #f1f5f9;
}

body.theme-dark .rc-preview-modal-subtitle {
    color: #94a3b8;
}

body.theme-dark .rc-preview-overlay {
    background: rgba(0, 0, 0, 0.65);
}

.rc-preview-site-report {
    padding: 4px 8px 20px;
}

.rc-preview-controls-mock .dash-study-selector-input {
    opacity: 0.75;
    cursor: not-allowed;
}

.rc-preview-attention-placeholder {
    color: #718096;
    font-size: 0.9rem;
    padding: 12px;
    border: 1px dashed #cbd5e0;
    border-radius: 8px;
    text-align: center;
}

body.theme-dark .rc-preview-attention-placeholder {
    color: #94a3b8;
    border-color: #475569;
}

.report-composer-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}

.report-composer-preview-study {
    color: #2d3748;
    font-weight: 600;
    font-size: 0.9rem;
}

.report-composer-preview-count {
    color: #4a5568;
    font-size: 0.82rem;
}

.report-composer-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.report-composer-preview-card {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #ffffff;
    padding: 12px;
}

.report-composer-preview-card h4 {
    margin: 0 0 8px 0;
    color: #2d3748;
    font-size: 0.92rem;
}

.report-composer-preview-card p {
    margin: 0;
    color: #4a5568;
    font-size: 0.85rem;
    line-height: 1.45;
}

.report-composer-preview-metric {
    color: #2b6cb0;
    font-size: 1.02rem;
    font-weight: 700;
    margin: 0 0 6px 0;
}

/* Analytics Settings */
.analytics-settings {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.analytics-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.analytics-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #2d3748;
}

.analytics-add-btn {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 0.85rem;
}

.analytics-add-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.analytics-message {
    font-size: 0.9rem;
    color: #4a5568;
}

.analytics-message.success {
    color: #22543d;
}

.analytics-message.error {
    color: #742a2a;
}

.analytics-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.analytics-empty,
.analytics-params-empty {
    color: #718096;
    font-size: 0.9rem;
}

.analytics-card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.analytics-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 12px;
}

.analytics-card-title {
    font-weight: 600;
    color: #2d3748;
}

.analytics-card-title--danger {
    color: #c53030;
}

.analytics-shape {
    font-size: 0.8rem;
    color: #4a5568;
    background: #edf2f7;
    padding: 4px 8px;
    border-radius: 999px;
}

.analytics-card-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.analytics-remove-btn {
    border: none;
    background: none;
    color: #a0aec0;
    font-size: 1rem;
    line-height: 1;
    padding: 2px 4px;
    cursor: pointer;
    transition: color 0.15s ease;
}

.analytics-remove-btn:hover {
    color: #c53030;
}

.analytics-params-wrapper {
    margin-bottom: 12px;
}

.analytics-params-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    padding: 4px 0;
    font-size: 0.82rem;
    font-weight: 600;
    color: #718096;
    cursor: pointer;
    font-family: inherit;
    transition: color 0.15s;
}

.analytics-params-toggle:hover {
    color: #4a5568;
}

.analytics-params-chevron {
    display: inline-block;
    font-size: 0.6rem;
    transition: transform 0.2s ease;
}

.analytics-params-count {
    background: #edf2f7;
    color: #718096;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 999px;
}

.analytics-params {
    display: grid;
    gap: 12px;
    margin-top: 10px;
    overflow: hidden;
    max-height: 500px;
    opacity: 1;
    transition: max-height 0.25s ease, opacity 0.2s ease, margin-top 0.25s ease;
}

.analytics-params--collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

.analytics-parameter label {
    display: block;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 6px;
}

.analytics-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
}

.analytics-parameter-desc {
    font-size: 0.8rem;
    color: #718096;
    margin-top: 6px;
}

.analytics-actions {
    display: flex;
    justify-content: flex-end;
}

.analytics-function-modal-container {
    width: 720px;
    max-width: 720px;
}

.analytics-function-modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.analytics-search-input {
    width: 50%;
    padding: 12px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    background-color: #ffffff;
}

.analytics-library-actions {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-top: 16px;
    margin-bottom: 16px;
}

.analytics-function-message {
    font-size: 0.9rem;
    color: #718096;
}

.analytics-function-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.analytics-function-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    margin-right: 8px;
    flex-shrink: 0;
    border-radius: 4px;
}

.analytics-function-item {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 16px;
    text-align: left;
    background: #ffffff;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.analytics-function-item:hover {
    border-color: #667eea;
    box-shadow: 0 6px 14px rgba(102, 126, 234, 0.12);
}

.analytics-section-title {
    padding-bottom: 6px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 10px;
}

.analytics-function-item.disabled {
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
    border-color: #e2e8f0;
}

.analytics-function-docs-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    padding: 4px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f7fafc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.analytics-function-docs-btn:hover {
    background: #edf2f7;
    border-color: #667eea;
}

.analytics-function-docs-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.analytics-function-title {
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 6px;
}

.analytics-function-keywords {
    font-size: 0.85rem;
    color: #718096;
}

.analytics-function-tag {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.75rem;
    color: #9b2c2c;
    background: #fed7d7;
    padding: 2px 8px;
    border-radius: 999px;
}

@media (max-width: 768px) {
    .observations-canvas {
        grid-template-columns: 1fr;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .modal-header {
        padding: 20px;
    }
    
    .settings-modal-body {
        flex-direction: column;
    }
    
    .settings-sidebar {
        width: 100%;
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        padding: 0;
        overflow-x: auto;
    }
    
    .settings-tab {
        padding: 12px 20px;
        border-left: none;
        border-bottom: 3px solid transparent;
        white-space: nowrap;
    }
    
    .settings-tab.active {
        border-left: none;
        border-bottom-color: #667eea;
    }
    
    .settings-content {
        padding: 20px;
    }
}

/* Function Icon Styles */
.function-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    margin-bottom: 4px;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
    border-radius: 4px;
}

.function-icon:hover {
    transform: scale(1.1);
    opacity: 0.8;
}

.analysis-card .button-content {
    flex-direction: column;
    gap: 4px;
}

.analysis-card .button-content h2 {
    font-size: 0.7rem;
    line-height: 1.2;
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* ═══════════════════════════════════════════════════════════
   Home / Dashboard – Study-based drill-down layout
   ═══════════════════════════════════════════════════════════ */

.home-metrics {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.home-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.home-header-actions{
    display: flex;
    align-items: flex-start;
    gap: 14px;
    width: 100%;
}

.dash-study-selector{
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-right: auto; /* Pushes the refresh button to the far right */
}

.dash-study-selector-label{
    font-size: 0.78rem;
    font-weight: 600;
    color: #4a5568;
}

.dash-study-selector-input{
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    color: #4a5568;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    min-width: 260px;
}

.dash-study-selector-input:hover{
    border-color: #cbd5e0;
}

.dash-study-selector-input:focus{
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.home-title-block h1 {
    font-size: 1.6rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0 0 6px 0;
}

.home-title-block p {
    margin: 0;
    font-size: 0.95rem;
    color: #4a5568;
}

/* Dashboard reload button */
.home-reload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    color: #4a5568;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.home-reload-btn:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
    color: #2d3748;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.home-reload-btn:active {
    background: #edf2f7;
}

.home-reload-icon {
    width: 16px;
    height: 16px;
    transition: transform 0.3s;
}

.home-reload-btn--loading .home-reload-icon {
    animation: spin-reload 0.8s linear infinite;
}

@keyframes spin-reload {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* (Summary bar removed – no longer used) */

/* ── Loading state ── */
.dash-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 0;
    font-size: 0.95rem;
    color: #718096;
}

.dash-loading .spinner-dot {
    background: #667eea;
}

/* ── Empty state ── */
.dash-empty {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
}

#sr-empty-config-cta {
    width: min(560px, 100%);
    align-items: center;
    text-align: center;
    gap: 12px;
}

#sr-go-config-btn {
    background: #2d3748 !important;
    border-color: #2d3748 !important;
    color: #ffffff !important;
    padding: 6px 10px;
}

#sr-go-config-btn:hover {
    background: #24303f !important;
    border-color: #24303f !important;
}

/* ── Studies grid ── */
.dash-studies-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

/* ── Study card ── */
.dash-study-card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    overflow: hidden;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.dash-study-card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.07);
}

.dash-study-card--open {
    border-color: #667eea;
}

.dash-study-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}

.dash-study-header:hover {
    background: #f7fafc;
}

.dash-study-title-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    min-width: 0;
}

.dash-study-name {
    font-size: 1.15rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0;
    white-space: nowrap;
}

.dash-study-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.dash-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: #edf2f7;
    color: #4a5568;
}

.dash-badge--alert {
    background: #fed7d7;
    color: #9b2c2c;
}

.dash-badge--ok {
    background: #c6f6d5;
    color: #22543d;
}

.dash-study-toggle {
    border: none;
    background: transparent;
    padding: 4px;
    cursor: pointer;
    color: #a0aec0;
    transition: transform 0.25s ease, color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dash-study-card--open .dash-study-toggle {
    transform: rotate(180deg);
    color: #667eea;
}

/* ── Study body (expanded) ── */
.dash-study-body {
    padding: 0 20px 20px;
    animation: dashFadeIn 0.25s ease;
}

@keyframes dashFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Charts row ── */
.dash-charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.dash-chart-box {
    border: 1px solid #edf2f7;
    border-radius: 10px;
    background: #fafafc;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

.dash-chart-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #4a5568;
}

.dash-chart-canvas-wrap {
    position: relative;
    width: 100%;
    height: 220px;
    min-height: 180px;
}

.dash-chart-canvas-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ── Detail titles & empties ── */
.dash-detail-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e2e8f0;
}

.dash-detail-empty {
    font-size: 0.88rem;
    color: #718096;
    padding: 8px 0;
}

/* ── Patient table (now inside the patients modal) ── */
.dash-patient-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.dash-patient-table th,
.dash-patient-table td {
    padding: 7px 10px;
    text-align: left;
    border-bottom: 1px solid #edf2f7;
}

.dash-patient-table th {
    font-weight: 600;
    color: #4a5568;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: #f7fafc;
}

.dash-patient-table tbody tr:hover {
    background: #edf2f7;
}

/* Patient search inside modal */
.dash-patient-search {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #2d3748;
    margin-bottom: 12px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

.dash-patient-search:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.dash-patient-search::placeholder {
    color: #a0aec0;
}

/* ── Status pills ── */
.dash-status-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.dash-status-pill--ok      { background: #c6f6d5; color: #22543d; }
.dash-status-pill--warning  { background: #fefcbf; color: #744210; }
.dash-status-pill--critical { background: #fed7d7; color: #9b2c2c; }
.dash-status-pill--oor      { background: #fce4ec; color: #880e4f; }

/* ── Patients badge (clickable) ── */
.dash-badge--patients {
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.dash-badge--patients:hover {
    background: #667eea;
    color: #ffffff;
}

/* ═══ Alerts section (grouped by type) ═══ */
.dash-alerts-section {
    margin-top: 8px;
}

.dash-alert-groups-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.dash-alert-group {
    border: 1px solid #edf2f7;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0;
}

.dash-alert-group--full {
    grid-column: 1 / -1;
}

.dash-alert-group--half {
    grid-column: span 1;
}

.dash-ag-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-weight: 600;
    font-size: 0.88rem;
}

.dash-ag--warning .dash-ag-header  { background: #fffbeb; color: #744210; }
.dash-ag--critical .dash-ag-header { background: #fff5f5; color: #9b2c2c; }
.dash-ag--oor .dash-ag-header      { background: #fce4ec; color: #880e4f; }

.dash-ag-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #38465D;
    line-height: 0;
}

.dash-ag-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dash-ag-label {
    flex: 1;
}

.dash-ag-count {
    background: rgba(0,0,0,0.08);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.dash-ag-dismiss-all {
    margin-left: 8px;
    border: 1px solid rgba(136, 14, 79, 0.25);
    background: rgba(255, 255, 255, 0.75);
    color: #880e4f;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.dash-ag-dismiss-all:hover {
    background: #ffe4ef;
    border-color: rgba(136, 14, 79, 0.4);
}

.dash-ag-dismiss-all:disabled {
    opacity: 0.65;
    cursor: default;
}

.dash-ag-body {
    background: #fafafc;
}

.dash-ag-footer {
    padding: 8px 16px 10px;
    border-top: 1px solid #edf2f7;
    background: #ffffff;
}

.dash-ag-toggle {
    border: 1px solid #d6e0ff;
    background: #eef2ff;
    color: #3c56d4;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.dash-ag-toggle:hover {
    background: #e3e9ff;
    border-color: #b8c6ff;
}

.dash-alert-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    border-top: 1px solid #edf2f7;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 0.84rem;
}

.dash-alert-row:hover {
    background: #edf2f7;
}

.dash-ar-patient {
    font-weight: 600;
    color: #2d3748;
    min-width: 120px;
    flex-shrink: 0;
}

.dash-ar-summary {
    flex: 1;
    color: #4a5568;
}

.dash-ar-arrow {
    color: #a0aec0;
    font-size: 1.2rem;
    line-height: 1;
}

/* ── OOR row actions (dismiss & investigate) ── */
.dash-ar-investigate,
.dash-ar-dismiss {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1.05rem;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.dash-ar-investigate {
    color: #38465D;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.dash-ar-investigate:hover {
    background: #ebf4ff;
    color: #38465D;
}

.dash-ar-investigate svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dash-ar-dismiss {
    color: #a0aec0;
    font-size: 1.2rem;
    font-weight: 700;
}
.dash-ar-dismiss:hover {
    background: #fed7d7;
    color: #c53030;
}

/* ── Nested anomaly alarm groups ── */
.dash-oor-alarm-group {
    border-top: 1px solid #edf2f7;
    background: #ffffff;
}

.dash-oor-alarm-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
}

.dash-oor-toggle {
    width: 22px;
    height: 22px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #f8fafc;
    color: #6b46c1;
    font-size: 0.72rem;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
}

.dash-oor-alarm-group[data-expanded="true"] .dash-oor-toggle {
    transform: rotate(90deg);
    background: #edf2ff;
}

.dash-oor-title {
    flex: 1;
    font-size: 0.82rem;
    color: #2d3748;
    font-weight: 600;
}

.dash-oor-count {
    background: rgba(136, 14, 79, 0.12);
    color: #880e4f;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 0.74rem;
    font-weight: 700;
}

.dash-oor-alarm-body {
    padding: 0 14px 10px 48px;
    background: #fafafc;
}

.dash-oor-trigger-row {
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid #edf2f7;
    padding: 8px 4px;
    font-size: 0.8rem;
}

.dash-oor-trigger-time {
    min-width: 170px;
    color: #4a5568;
}

.dash-oor-trigger-value {
    flex: 1;
    color: #2d3748;
    font-weight: 600;
}

.dash-oor-load-more-wrap {
    padding-top: 8px;
}

/* ── Real-time alarm toast ── */
.dash-alarm-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 520px;
    padding: 12px 18px;
    border-radius: 10px;
    background: #1a202c;
    color: #fff;
    font-size: 0.85rem;
    box-shadow: 0 8px 30px rgba(0,0,0,0.25);
    transform: translateY(120%);
    opacity: 0;
    transition: transform 0.35s ease, opacity 0.35s ease;
}
.dash-alarm-toast--visible {
    transform: translateY(0);
    opacity: 1;
}

.dash-alarm-toast-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.dash-alarm-toast-text {
    flex: 1;
    line-height: 1.35;
}

.dash-alarm-toast-action {
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 5px 12px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.15s ease;
}
.dash-alarm-toast-action:hover {
    background: #5a67d8;
}

.dash-alarm-toast-close {
    background: none;
    border: none;
    color: #a0aec0;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 4px;
    flex-shrink: 0;
}
.dash-alarm-toast-close:hover {
    color: #fff;
}

/* ═══ Dashboard modals ═══ */
.dash-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(3px);
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.dash-modal-overlay.open {
    visibility: visible;
    opacity: 1;
}

.dash-modal {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    width: 92%;
    max-width: 480px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(12px);
    transition: transform 0.2s ease;
}

.dash-modal-overlay.open .dash-modal {
    transform: translateY(0);
}

.dash-modal--wide {
    max-width: 640px;
}

.dash-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid #e2e8f0;
}

.dash-modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0;
}

.dash-modal-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    color: #718096;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.15s ease;
}

.dash-modal-close:hover {
    color: #2d3748;
}

.dash-modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

/* Alert description in modal */
.dash-modal-alert-desc {
    font-size: 0.92rem;
    color: #2d3748;
    line-height: 1.55;
    margin-bottom: 18px;
    padding: 12px 14px;
    background: #f7fafc;
    border: 1px solid #edf2f7;
    border-left: 4px solid #667eea;
    border-radius: 6px;
}

/* Tracking table inside alert modal */
.dash-modal-tracking {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.dash-modal-tracking td {
    padding: 10px 12px;
    border-bottom: 1px solid #edf2f7;
    color: #4a5568;
}

.dash-modal-tracking td:first-child {
    font-weight: 500;
}

.dash-modal-tracking td:last-child {
    text-align: right;
}

.dash-track-val {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
}

.dash-track-val--yes {
    background: #c6f6d5;
    color: #22543d;
}

.dash-track-val--no {
    background: #fed7d7;
    color: #9b2c2c;
}

/* ── Legacy metric classes (used by device-status page) ── */
.home-metric-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.home-metric-table th,
.home-metric-table td {
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid #edf2f7;
}

.home-metric-table th {
    font-weight: 600;
    color: #4a5568;
}

.home-metric-empty {
    font-size: 0.9rem;
    color: #718096;
    padding: 4px 0;
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .dash-charts-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .dash-study-title-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .dash-modal {
        width: 98%;
        max-height: 92vh;
    }
}

/* Icon Expansion Modal */
.icon-expansion-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease-out;
}

.icon-expansion-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.icon-expansion-content {
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2001;
    animation: slideUp 0.3s ease-out;
}

.icon-expansion-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #2d3748;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
    z-index: 2002;
}

.icon-expansion-close:hover {
    background: rgba(0, 0, 0, 0.2);
    transform: scale(1.1);
}

.expanded-icon-image {
    max-width: 80vw;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Device Status Page */
.device-status-content {
    padding: 0;
}

.device-status-header {
    margin-bottom: 24px;
}

.device-status-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 8px 0;
}

.device-status-header p {
    color: #718096;
    margin: 0;
}

.device-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.device-status-toggle {
    border: 1px solid #d6e0ff;
    background: #eef2ff;
    color: #3c56d4;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.device-status-toggle:hover {
    background: #e3e9ff;
    border-color: #b8c6ff;
}

.analytics-card-body {
    padding: 16px;
}

.device-status-card-tools {
    margin-bottom: 12px;
}

.device-status-search {
    width: 100%;
    max-width: 320px;
    padding: 9px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #2d3748;
    background: #ffffff;
}

.device-status-search:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.16);
}

.device-status-filter-empty {
    margin-top: 10px;
}

/* Battery indicators */
.battery-value {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85rem;
}

.battery-good {
    background-color: #c6f6d5;
    color: #22543d;
}

.battery-medium {
    background-color: #feebc8;
    color: #744210;
}

.battery-low {
    background-color: #fed7d7;
    color: #742a2a;
}

.timestamp-cell {
    color: #718096;
    font-size: 0.8rem;
    white-space: nowrap;
}

.timestamp-stale {
    color: #e53e3e;
    font-weight: 600;
}

/* Insights & Reports */
.insights-filters-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 12px;
    margin-bottom: 16px;
}

.insights-select {
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
}

.insights-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.insights-section-title {
    margin: 0;
    font-size: 1.05rem;
}

.insights-plus-btn {
    border: 1px solid #cbd5e0;
    background: #fff;
    border-radius: 8px;
    width: 34px;
    height: 34px;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
}

.insights-metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.insights-metric-card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
    background: #fff;
}

.insights-metric-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.insights-metric-header h4 {
    margin: 0;
    font-size: 0.95rem;
}

.insights-value-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.insights-value-label {
    color: #4a5568;
    font-size: 0.88rem;
}

.insights-value-pill {
    padding: 6px 12px;
    border-radius: 999px;
    background: #718096;
    color: #fff;
    font-weight: 600;
    font-size: 0.88rem;
    white-space: nowrap;
}

.insights-pie-wrap {
    position: relative;
    height: 180px;
}

.insights-timeline-wrap {
    position: relative;
    height: 170px;
    margin-top: 8px;
}

.insights-insight-text {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #4a5568;
}

.insights-export-title {
    margin: 8px 0;
    font-size: 1rem;
}

.insights-export-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.insights-export-box {
    border: 1px solid #cbd5e0;
    border-radius: 10px;
    padding: 8px 10px;
    background: #fff;
    cursor: pointer;
}

.insights-export-box.selected {
    border-color: #2f855a;
    background: #f0fff4;
    color: #22543d;
}

.insights-export-progress {
    margin: 8px 0 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #edf2f7;
    color: #2d3748;
    font-size: 0.9rem;
}

.insights-inline-loading {
    grid-column: 1 / -1;
    border: 1px dashed #cbd5e0;
    border-radius: 10px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #4a5568;
}

.insights-docs-content p,
.insights-docs-content li {
    line-height: 1.5;
}

@media (max-width: 1200px) {
    .insights-metrics-grid {
        grid-template-columns: 1fr;
    }
}

/* ──────────────────────────────────────────────────────────────
   Daily Site Report (Dashboard)
   ────────────────────────────────────────────────────────────── */

.site-report-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.site-report-content {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0 12px;
}

.site-report-title {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin: 6px 0 14px;
}

.site-report-title-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sr-ai-btn {
    border: none;
    background: transparent;
    color: #2d3748;
    border-radius: 10px;
    padding: 6px;
    cursor: pointer;
    font-weight: 800;
    white-space: nowrap;
}

.sr-ai-btn-icon {
    display: block;
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.sr-ai-btn:hover {
    background: rgba(15, 23, 42, 0.06);
}

.sr-ai-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.sr-ai-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 2000;
}

.sr-ai-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: min(var(--sr-ai-panel-width), 92vw);
    min-width: 320px;
    max-width: 60vw;
    background: #fff;
    border-left: 1px solid #e2e8f0;
    box-shadow: none;
    transform: translateX(110%);
    transition: transform 180ms ease, width 180ms ease, min-width 180ms ease, max-width 180ms ease;
    z-index: 2010;
    display: grid;
    grid-template-rows: auto 1fr;
    resize: horizontal;
    overflow: auto;
}

.sr-ai-panel.is-open {
    transform: translateX(0);
}

.sr-ai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 61px;
    padding: 10px 14px;
    border-bottom: 1px solid #e2e8f0;
    background: #f7fafc;
    position: relative;
}

.sr-ai-panel-title {
    font-weight: 900;
    color: #1a202c;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
}

.sr-ai-panel-toggle-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #2d3748;
    cursor: pointer;
    outline: none;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.sr-ai-panel-toggle-btn:hover {
    color: #1a202c;
    background: rgba(15, 23, 42, 0.06);
}

.sr-ai-panel-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.18s ease;
    transform: rotate(180deg);
}

.sr-ai-panel-toggle-icon .sidebar-toggle-svg {
    display: block;
}

body.sr-ai-collapsed .sr-ai-panel-toggle-icon {
    transform: rotate(0deg);
}

body.sr-ai-collapsed .sr-ai-panel-body,
body.sr-ai-collapsed .sr-ai-panel-title {
    display: none;
}

body.sr-ai-collapsed .sr-ai-panel {
    resize: none;
    overflow: hidden;
    width: var(--sr-ai-panel-width-collapsed);
    min-width: var(--sr-ai-panel-width-collapsed);
    max-width: var(--sr-ai-panel-width-collapsed);
}

body.sr-ai-collapsed .sr-ai-panel-header {
    justify-content: center;
    gap: 0;
}

.sr-ai-panel-body {
    padding: 12px 14px;
    overflow: auto;
}

.sr-ai-panel-status {
    border-radius: 12px;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    background: #f7fafc;
    color: #4a5568;
    font-weight: 700;
    margin-bottom: 10px;
}

.sr-ai-panel-status--error {
    border-color: rgba(229, 62, 62, 0.32);
    background: rgba(229, 62, 62, 0.08);
    color: #742a2a;
}

.sr-ai-panel-content {
    line-height: 1.5;
    color: #2d3748;
}

.sr-ai-md-h3 {
    margin: 14px 0 8px;
    font-size: 1rem;
    font-weight: 900;
    color: #1a202c;
}

.sr-ai-md-p {
    margin: 0 0 10px;
    color: #2d3748;
}

.sr-ai-md-ul {
    margin: 0 0 10px 18px;
    padding: 0;
    display: grid;
    gap: 6px;
}

.sr-ai-md-pre {
    margin: 10px 0;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #0f172a;
    color: #e2e8f0;
    overflow: auto;
    font-size: 0.85rem;
}

.sr-ai-md-pre code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    white-space: pre;
}

.sr-ai-md-spacer {
    height: 8px;
}

@media (max-width: 900px) {
    body.sr-ai-open .main-content {
        margin-right: 0;
    }
    .sr-ai-panel {
        resize: none;
        max-width: none;
        box-shadow: -12px 0 28px rgba(15, 23, 42, 0.18);
    }
}

.site-report-title-main h1 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
    color: #1a202c;
}

.site-report-subtitle {
    margin-top: 6px;
    font-size: 0.92rem;
    color: #718096;
}

.site-report-cards {
    display: grid;
    grid-template-columns: repeat(5, 140px);
    gap: 12px;
    margin: 12px 0 10px;
    width: 100%;
    justify-content: start;
}

.sr-card {
    background: #f1f5f9;
    border: none;
    border-radius: 12px;
    width: 140px;
    height: 140px;
    padding: 12px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.sr-card-label {
    font-size: 0.95rem;
    color: #718096;
    font-weight: 600;
}

.sr-card-value {
    margin-top: 6px;
    font-size: 1.95rem;
    font-weight: 800;
    color: #1a202c;
}

.sr-card--enrolled .sr-card-value,
.sr-card--sites .sr-card-value {
    color: #3182ce;
}

.site-report-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 18px 0 12px;
}

.site-report-section-title {
    margin: 0 0 10px;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    color: #718096;
    text-transform: uppercase;
}

.site-report-table-wrap {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
}

.site-report-table {
    width: 100%;
    border-collapse: collapse;
}

.site-report-table thead th {
    font-size: 0.88rem;
    text-align: left;
    padding: 12px 12px;
    background: #f7fafc;
    color: #4a5568;
    border-bottom: 1px solid #e2e8f0;
}

.site-report-table tbody td {
    padding: 12px 12px;
    border-bottom: 1px solid #edf2f7;
    font-size: 0.94rem;
    color: #2d3748;
}

.sr-table-empty {
    color: #718096;
    font-style: italic;
}

.sr-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 700;
    border: 1px solid #e2e8f0;
    background: #edf2f7;
    color: #2d3748;
}

.sr-pill--watch {
    background: rgba(214, 158, 46, 0.18);
    border-color: rgba(214, 158, 46, 0.35);
    color: #744210;
}

.sr-pill--alert {
    background: rgba(229, 62, 62, 0.16);
    border-color: rgba(229, 62, 62, 0.32);
    color: #742a2a;
}

.site-report-status-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.sr-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border-radius: 999px;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #2d3748;
    font-weight: 700;
    font-size: 0.9rem;
}

.sr-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
}

.sr-dot--ok { background: #38a169; }
.sr-dot--watch { background: #d69e2e; }
.sr-dot--alert { background: #e53e3e; }

.site-report-attention {
    display: grid;
    gap: 12px;
}

.sr-att-block {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
}

.sr-att-block-title {
    padding: 10px 12px;
    background: #f7fafc;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 800;
    color: #2d3748;
    font-size: 0.92rem;
}

.sr-att-block-body {
    padding: 10px 12px;
    display: grid;
    gap: 10px;
}

/* Attention block collapse (show 3 rows by default) */
.sr-att-row.is-extra {
    display: none;
}

.sr-att-block.is-expanded .sr-att-row.is-extra {
    display: grid;
}

.sr-att-toggle {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px dashed #e2e8f0;
    border-radius: 10px;
    background: transparent;
    color: #4a5568;
    font-weight: 700;
    cursor: pointer;
}

.sr-att-toggle:hover {
    border-color: #cbd5e0;
    color: #2d3748;
}

.sr-att-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 12px;
    padding: 10px 10px;
    border: 1px solid #edf2f7;
    border-radius: 10px;
    background: #fff;
}

.sr-att-left {
    display: grid;
    gap: 4px;
}

.sr-att-patient {
    font-weight: 900;
    color: #1a202c;
}

.sr-att-detail {
    color: #4a5568;
    font-size: 0.9rem;
}

.sr-att-metric-list {
    margin: 6px 0 0;
    padding-left: 1.15rem;
    color: #4a5568;
    font-size: 0.85rem;
}

.sr-att-metric-list li {
    margin: 2px 0;
}

.sr-drill-btn {
    border: 1px solid #cbd5e0;
    background: #fff;
    color: #2d3748;
    border-radius: 10px;
    padding: 7px 10px;
    cursor: pointer;
    font-weight: 700;
}

.sr-drill-btn:hover {
    background: #f7fafc;
}

.sr-att-empty {
    color: #718096;
    font-style: italic;
}

.sr-modal-text {
    line-height: 1.5;
    color: #2d3748;
}

@media (max-width: 900px) {
    .site-report-cards {
        grid-template-columns: 140px;
        justify-content: start;
    }
    .sr-att-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }
}

.report-composer-metric-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.report-composer-metric-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: #4a5568;
    margin-bottom: 6px;
}