.health-section {
    margin-top: var(--gap-4);
}

/* Header layout */
.health-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--gap-3);
    flex-wrap: wrap;
}

.health-title-block {
    flex: 1;
    min-width: 240px;
}

.health-subtitle {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.health-header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.health-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.health-controls-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.health-window-help-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.health-window-help-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.3);
}

.health-window-help-tooltip {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 1000;
    width: 320px;
    max-width: 90vw;
    background: var(--panel-2, #161616);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    padding: 16px;
    animation: healthTooltipFadeIn 0.15s ease;
}

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

.health-window-help-content h4 {
    margin: 0 0 8px;
    font-size: 0.95rem;
    color: var(--text);
}

.health-window-help-content p {
    margin: 0 0 12px;
    font-size: 0.8rem;
    color: var(--muted);
}

.health-window-help-content dl {
    margin: 0 0 12px;
}

.health-window-help-content dt {
    font-size: 0.8rem;
    color: var(--text);
    margin-top: 8px;
}

.health-window-help-content dd {
    font-size: 0.75rem;
    color: var(--muted);
    margin: 2px 0 0 0;
    padding-left: 12px;
}

.health-window-help-note {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.75rem;
    color: var(--text);
    line-height: 1.5;
}

.health-compare-tag {
    display: inline-block;
    background: rgba(255, 255, 255, 0.1);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-right: 4px;
}

.health-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--muted);
}

/* Summary counters */
.health-overview-summary {
    display: flex;
    gap: 16px;
    margin: var(--gap-2) 0;
    font-size: 0.9rem;
}

.health-summary-item {
    padding: 4px 12px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
}

.health-summary-ok strong { color: var(--accent); }
.health-summary-warn strong { color: #ffcc66; }
.health-summary-error strong { color: #ff6b6b; }

/* Full-width overview table */
.health-overview--wide {
    width: 100%;
}

.health-overview--wide.summary-card {
    width: 100%;
}

.health-table--wide {
    width: 100%;
}

.health-table--wide th,
.health-table--wide td {
    padding: 10px 12px;
    text-align: left;
    white-space: nowrap;
    vertical-align: middle;
}

.health-table--wide th {
    position: sticky;
    top: 0;
    background: var(--panel-2);
    z-index: 1;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}

.health-table--wide tbody tr {
    cursor: pointer;
    transition: background 0.15s ease;
}

.health-table--wide tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

.health-table--wide tbody tr.is-active {
    background: rgba(var(--accent-rgb), 0.08);
}

/* Mini sparkline in table */
.health-table-spark {
    width: 60px;
    height: 20px;
}

.health-table-spark canvas {
    width: 100%;
    height: 100%;
}

/* Value + trend indicator cell */
.health-value-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
}

.health-value-cell .health-trend {
    font-size: 0.9rem;
}

/* Health score badge */
.health-score-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.8rem;
    min-width: 32px;
    text-align: center;
}

.health-score-badge.health-score-good {
    background: rgba(var(--accent-rgb), 0.18);
    color: var(--accent);
}

.health-score-badge.health-score-warn {
    background: rgba(255, 180, 0, 0.18);
    color: #ffcc66;
}

.health-score-badge.health-score-risk {
    background: rgba(255, 77, 79, 0.2);
    color: #ff6b6b;
}

/* Driver text in table */
.health-driver-text {
    font-size: 0.8rem;
    color: #ffcc66;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.health-driver-text.health-driver-ok {
    color: var(--accent);
}

/* Activity bar in table */
.health-activity-cell {
    white-space: nowrap;
}

.health-activity-bar {
    display: inline-block;
    width: 60px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.health-activity-bar-fill {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.health-activity-pct {
    font-size: 0.75rem;
    color: var(--muted);
}

/* Alerts badge */
.health-alerts-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255, 180, 0, 0.18);
    color: #ffcc66;
    font-size: 0.8rem;
    font-weight: 600;
}

.health-alerts-ok {
    color: var(--accent);
    font-size: 0.8rem;
}

/* =============================================
   MODAL STYLES (using nx-modal pattern)
   ============================================= */
.health-modal.nx-modal {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 3000;
}

.health-modal.nx-modal.is-open {
    display: block;
}

.health-modal .nx-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(3px);
}

.health-modal .nx-modal__panel.health-modal-panel {
    position: absolute;
    inset: auto 0 0 0;
    margin: auto;
    top: 4vh;
    width: min(1100px, 94vw);
    max-height: 90vh;
    background: linear-gradient(180deg, #1a1a1a, #0d0d0d);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
    animation: health-modal-pop 0.18s ease-out;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@keyframes health-modal-pop {
    from { transform: translateY(8px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

.health-modal .nx-modal__header.health-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

/* Close button */
.health-modal .nx-icon-btn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.health-modal .nx-icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
    color: var(--text);
}

.health-modal .nx-modal__body.health-modal-body {
    padding: 16px 20px 20px;
    overflow-y: auto;
    flex: 1 1 auto;
}

/* Modal title row with selector */
.health-modal-title-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

/* Dyno selector - uses telemetry classes from dashboard.css */
.health-dyno-selector {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* Only add minimal overrides needed for modal context */
.health-dyno-selector .telemetry-dyno-dropdown {
    z-index: 3100;  /* Above modal */
}

.health-modal-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.health-modal-timestamp {
    font-size: 0.75rem;
    color: var(--muted);
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 4px;
    cursor: help;
    white-space: nowrap;
}

/* Score pill */
.health-score-pill {
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
}

.health-score-pill.is-ok {
    background: rgba(var(--accent-rgb), 0.18);
    color: var(--accent);
}

.health-score-pill.is-warn {
    background: rgba(255, 180, 0, 0.18);
    color: #ffcc66;
}

.health-score-pill.is-risk {
    background: rgba(255, 77, 79, 0.2);
    color: #ffb2b4;
}

/* Status pill */
.health-status-pill[data-health-status="ok"] {
    background: rgba(var(--accent-rgb), 0.18);
    color: var(--accent);
}

.health-status-pill[data-health-status="missing"],
.health-status-pill[data-health-status="insufficient_data"] {
    background: rgba(255, 180, 0, 0.18);
    color: #ffcc66;
}

.health-status-pill[data-health-status="error"] {
    background: rgba(255, 77, 79, 0.2);
    color: var(--danger);
}

/* Refresh button */
.health-refresh.public-share-btn {
    padding: 6px 14px;
}

.health-refresh.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

.health-refresh-spinner {
    display: none;
    width: 10px;
    height: 10px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    margin-left: 6px;
}

.health-refresh.is-loading .health-refresh-spinner {
    display: inline-block;
    animation: health-spin 0.8s linear infinite;
}

/* Detail content in modal */
.health-detail {
    display: flex;
    flex-direction: column;
    gap: var(--gap-2);
}

/* Modal cards layout (2-column grid) */
.health-cards--modal {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--gap-2);
    margin-bottom: var(--gap-2);
}

.health-cards--modal .summary-card {
    width: auto;
    padding: 16px;
}

/* Wide cards layout (fallback) */
.health-cards--wide {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--gap-2);
}

.health-cards--wide .summary-card {
    width: auto;
}

/* Primary card styling */
.health-card-primary {
    border: 1px solid rgba(var(--accent-rgb), 0.25);
    background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.06) 0%, transparent 70%);
}

.health-card-primary h3 {
    color: var(--accent);
}

[data-health-score-value] {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
}

.health-score-good { color: var(--accent); }
.health-score-warn { color: #ffcc66; }
.health-score-risk { color: #ff6b6b; }

/* Drivers */
.health-drivers {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

.health-driver-item {
    font-size: 0.78rem;
    color: #ffcc66;
    padding: 4px 8px;
    background: rgba(255, 180, 0, 0.12);
    border-radius: 4px;
    line-height: 1.3;
}

.health-driver-ok {
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.12);
}

/* Card titles */
.health-card-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.health-card-title .tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 700;
}

/* Compare text */
.health-compare { color: var(--muted); }
.health-compare--ok { color: #8be7a8; }
.health-compare--warn { color: #ffcc66; }
.health-compare--risk { color: #ff9aa0; }

/* Deviation panel - full width */
.health-deviation-panel.summary-card {
    width: 100%;
    max-width: 100%;
    margin-bottom: var(--gap-2);
}

/* Deviation sparkline canvas wrapper */
.health-dev-spark-canvas-wrap {
    height: 80px;
    min-height: 80px;
    max-height: 80px;
    width: 100%;
    min-width: 0; /* Allow flex item to shrink */
    overflow: hidden;
}

.health-canvas[data-health-canvas^="dev-"] {
    height: 80px !important;
    max-height: 80px;
    width: 100% !important;
}

/* Activity panel - full width and responsive */
.health-activity-panel.summary-card {
    width: 100% !important;
    max-width: 100%;
    box-sizing: border-box;
    margin-bottom: var(--gap-2);
}

/* Combined Trends Panel - full width and responsive */
.health-trends-panel.summary-card {
    width: 100% !important;
    max-width: 100%;
    box-sizing: border-box;
    margin-bottom: var(--gap-2);
}

.health-trends-headers {
    display: grid;
    grid-template-columns: 80px repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 8px;
    padding-left: 0;
}

.health-trends-headers::before {
    content: '';  /* Empty space for row label column */
}

.health-trends-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-align: center;
    padding: 4px 0;
}

.health-trends-row {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.health-trends-row:last-child {
    margin-bottom: 0;
}

.health-trends-row-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--muted);
    text-align: right;
    padding-right: 8px;
    line-height: 1.3;
    cursor: help;
}

.health-trends-row-label small {
    font-weight: 400;
    opacity: 0.7;
}

.health-trends-cells {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.health-trends-cell {
    min-width: 0;
    overflow: hidden;
}

/* Raw value sparkline wrapper */
.health-spark-canvas-wrap {
    height: 60px;
    min-height: 60px;
    max-height: 60px;
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

.health-canvas[data-health-canvas^="spark-"] {
    height: 60px !important;
    max-height: 60px;
    width: 100% !important;
}

/* Responsive: stack on small screens */
@media (max-width: 600px) {
    .health-trends-headers {
        display: none;
    }

    .health-trends-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .health-trends-row-label {
        text-align: left;
        padding: 0 0 4px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        margin-bottom: 4px;
    }

    .health-trends-cells {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .health-trends-cell::before {
        content: attr(data-label);
        display: block;
        font-size: 0.65rem;
        color: var(--muted);
        text-transform: uppercase;
        margin-bottom: 2px;
    }
}

/* Panels row (histogram charts) - full width stacked */
.health-panels-row {
    display: flex;
    flex-direction: column;
    gap: var(--gap-2);
    margin-bottom: var(--gap-2);
}

/* Baseline toggle row */
.health-baseline-toggle-row {
    display: flex;
    justify-content: flex-end;
    margin-bottom: var(--gap-2);
    padding: 0 4px;
}

.health-baseline-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--muted);
    user-select: none;
}

.health-baseline-toggle input[type="checkbox"] {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.health-baseline-toggle-label {
    color: var(--text);
    font-weight: 500;
}

.health-baseline-toggle-hint {
    font-size: 0.7rem;
    color: var(--muted);
    opacity: 0.7;
}

.health-panels-row .summary-card {
    width: 100%;
    max-width: 100%;
}

.health-panels-row .health-canvas {
    height: 180px !important;
    max-height: 180px;
}

/* Wide panels row (fallback) */
.health-panels-row--wide {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--gap-2);
}

.health-panels-row--wide .summary-card {
    width: auto;
}

.health-panels-row--wide .health-canvas {
    height: 180px !important;
    max-height: 180px;
}

/* Full-width panel for time-series charts */
.health-panel-wide {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.health-panel-wide .health-canvas {
    height: 200px !important;
    max-height: 200px;
}

/* Canvas general */
.health-canvas {
    display: block;
    width: 100%;
}

/* Activity strip panel - full width and responsive */
.health-details .summary-card.health-panel {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.health-details .summary-card.health-panel > div {
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

/* Activity strip canvas - FIXED HEIGHT to prevent infinite growth */
.health-canvas[data-health-canvas="activity"] {
    height: 70px !important;
    max-height: 70px !important;
    min-height: 70px !important;
    width: 100% !important;
}

/* Details accordion */
.health-details {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.health-details summary {
    cursor: pointer;
    font-weight: 600;
}

.health-details[open] summary {
    margin-bottom: 12px;
}

/* Loading states */
.health-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--muted);
    padding: 8px 4px;
}

.health-loading[hidden] {
    display: none;
}

.health-header-spinner,
.health-detail-spinner,
.health-inline-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.18);
    border-top-color: rgba(255, 255, 255, 0.75);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.health-header-spinner.is-visible,
.health-detail-spinner.is-visible,
.health-inline-spinner.is-visible {
    opacity: 1;
    animation: health-spin 0.8s linear infinite;
}

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

/* Skeleton loading */
.health-skeleton-row td {
    padding: 12px 6px;
}

.health-skeleton-block {
    display: block;
    height: 12px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
    position: relative;
}

.health-skeleton-block::after {
    content: '';
    position: absolute;
    top: 0;
    left: -40%;
    width: 40%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.18), transparent);
    animation: health-shimmer 1.2s ease-in-out infinite;
}

@keyframes health-shimmer {
    0% { left: -40%; }
    100% { left: 100%; }
}

/* Empty/error states */
.health-error,
.health-empty {
    padding: 16px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.06);
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
}

.health-empty-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
}

.health-empty-spinner {
    display: none;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
}

.health-empty-spinner.is-visible {
    display: inline-block;
    animation: health-spin 0.8s linear infinite;
}

.health-error {
    border: 1px solid rgba(255, 77, 79, 0.35);
    color: #ffb2b4;
}

/* Help toggle */
.health-help-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    margin-left: 4px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: transparent;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.health-help-toggle:hover,
.health-help-toggle[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    color: var(--text);
}

.health-help-content {
    margin-top: 12px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.8rem;
    line-height: 1.5;
    text-align: left;
}

.health-help-content[hidden] {
    display: none;
}

.health-help-list {
    margin: 0;
    padding: 0;
}

.health-help-list dt {
    font-weight: 600;
    color: var(--accent);
    margin-top: 8px;
}

.health-help-list dt:first-child {
    margin-top: 0;
}

.health-help-list dd {
    margin: 2px 0 0 0;
    color: var(--muted);
}

.health-help-list dd strong {
    color: var(--text);
}

/* Formula styling in help tooltips */
.health-help-list dd.health-formula {
    margin-top: 6px;
    padding: 8px 10px;
    background: rgba(100, 180, 255, 0.08);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
    font-family: inherit;
}

.health-help-list dd.health-formula code {
    display: block;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.85em;
    color: var(--text);
    background: none;
    padding: 0;
    margin-bottom: 4px;
}

.health-help-list dd.health-formula small {
    display: block;
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.4;
}

/* Inline help list */
.health-help-list--inline {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}

.health-help-list--inline dt,
.health-help-list--inline dd {
    margin: 0;
}

.health-help-list--inline dd::after {
    display: none;
}

/* Subtle hint text */
.health-help-hint {
    margin: 8px 0 0;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.7rem;
    font-style: italic;
}

/* =============================================
   PREDICTIVE RISK STYLES
   ============================================= */

/* Risk badge in header (next to Salud pill) */
.health-risk-badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
}

.health-risk-badge--stable {
    background: rgba(var(--accent-rgb), 0.18);
    color: var(--accent);
}

.health-risk-badge--degrading {
    background: rgba(255, 214, 0, 0.2);
    color: #ffd600;
}

.health-risk-badge--unstable {
    background: rgba(255, 159, 67, 0.22);
    color: #ff9f43;
}

.health-risk-badge--critical {
    background: rgba(255, 77, 79, 0.2);
    color: #ff6b6b;
}

/* Risk card styling */
.health-card-risk {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.02) 0%, transparent 70%);
}

.health-card-risk.health-risk--stable {
    border-color: rgba(var(--accent-rgb), 0.3);
    background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.06) 0%, transparent 70%);
}

.health-card-risk.health-risk--degrading {
    border-color: rgba(255, 214, 0, 0.35);
    background: linear-gradient(135deg, rgba(255, 214, 0, 0.06) 0%, transparent 70%);
}

.health-card-risk.health-risk--unstable {
    border-color: rgba(255, 159, 67, 0.35);
    background: linear-gradient(135deg, rgba(255, 159, 67, 0.06) 0%, transparent 70%);
}

.health-card-risk.health-risk--critical {
    border-color: rgba(255, 107, 107, 0.35);
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.06) 0%, transparent 70%);
}

/* Risk value display */
[data-health-risk="value"] {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text);
}

/* Risk state label */
[data-health-risk="state"] {
    display: inline-block;
    padding: 3px 8px;
    margin-top: 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
}

[data-health-risk="state"].health-risk-state--stable {
    background: rgba(var(--accent-rgb), 0.15);
    color: var(--accent);
}

[data-health-risk="state"].health-risk-state--degrading {
    background: rgba(255, 214, 0, 0.18);
    color: #ffd600;
}

[data-health-risk="state"].health-risk-state--unstable {
    background: rgba(255, 159, 67, 0.18);
    color: #ff9f43;
}

[data-health-risk="state"].health-risk-state--critical {
    background: rgba(255, 77, 79, 0.15);
    color: #ff6b6b;
}

/* Risk driver text */
.health-risk-driver {
    display: block;
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--muted);
}

.health-risk-driver:empty {
    display: none;
}

/* =============================================
   SPC CHART STYLES
   ============================================= */

.health-spc-panel.summary-card {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-bottom: var(--gap-2);
}

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

.health-spc-badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
}

.health-spc-badge--ok {
    background: rgba(var(--accent-rgb), 0.18);
    color: var(--accent);
}

.health-spc-badge--warn {
    background: rgba(255, 107, 107, 0.2);
    color: #ff6b6b;
}

.health-spc-chart-wrap {
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

.health-canvas[data-health-canvas="spc"] {
    height: 200px !important;
    max-height: 200px;
    width: 100% !important;
}

.health-spc-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.7rem;
    color: var(--muted);
}

.health-spc-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.health-spc-legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.health-spc-legend-dot--ok {
    background: rgba(68, 255, 102, 0.9);
}

.health-spc-legend-dot--violation {
    background: rgba(239, 68, 68, 0.9);
}

.health-spc-legend-line {
    display: inline-block;
    width: 16px;
    height: 2px;
    border-radius: 1px;
}

.health-spc-legend-line--ucl,
.health-spc-legend-line--lcl {
    background: rgba(239, 68, 68, 0.6);
}

.health-spc-legend-line--center {
    background: rgba(255, 255, 255, 0.5);
}

/* Responsive */
@media (max-width: 900px) {
    .health-cards--modal {
        grid-template-columns: 1fr;
    }

    .health-cards--wide {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 800px) {
    .health-modal .nx-modal__panel.health-modal-panel {
        top: 2vh;
        width: 98vw;
        max-height: 94vh;
    }

    .health-modal .nx-modal__header.health-modal-header {
        padding: 12px 14px;
    }

    .health-modal .nx-modal__body.health-modal-body {
        padding: 12px 14px 14px;
    }

    .health-modal-title-row {
        gap: 10px;
    }

    .health-cards--modal,
    .health-cards--wide {
        grid-template-columns: 1fr;
    }

    .health-panels-row,
    .health-panels-row--wide {
        grid-template-columns: 1fr;
    }


    .health-table--wide {
        font-size: 0.85rem;
    }

    .health-table--wide th,
    .health-table--wide td {
        padding: 8px;
    }

    .health-dyno-selector .telemetry-selected-name {
        max-width: 120px;
    }
}
