/* Sensitivity Analysis — heatmap table */

/* ── Container (sits inside .pnl-card) ── */
.sensitivity-controls {
    display: flex;
    gap: 12px;
    padding: 0 0 16px;
    flex-wrap: wrap;
}

.sensitivity-control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 120px;
}

.sensitivity-control-label {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sensitivity-select {
    font-size: 0.8125rem;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--fg);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
}

.sensitivity-select:focus {
    outline: none;
    border-color: var(--fg);
}

.sensitivity-select option:disabled {
    color: var(--muted);
}

/* ── Scrollable table wrapper ── */
.sensitivity-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
}

/* ── Grid table ── */
.sensitivity-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ── Corner cell (row label / col label) ── */
.sensitivity-corner {
    position: relative;
    min-width: 80px;
    height: 44px;
    padding: 6px 10px;
    text-align: left;
    border-bottom: 2px solid var(--fg);
    vertical-align: bottom;
}

.sensitivity-corner-row {
    position: absolute;
    bottom: 4px;
    left: 6px;
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sensitivity-corner-col {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Diagonal line in corner */
.sensitivity-corner::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to top right,
        transparent calc(50% - 0.5px),
        var(--border) calc(50% - 0.5px),
        var(--border) calc(50% + 0.5px),
        transparent calc(50% + 0.5px)
    );
    pointer-events: none;
}

/* ── Column headers ── */
.sensitivity-col-header {
    padding: 8px 10px;
    text-align: center;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--fg);
    border-bottom: 2px solid var(--fg);
}

.sensitivity-col-header.sensitivity-base-col {
    background: #f0fdf4;
    color: #15803d;
}

/* ── Row headers ── */
.sensitivity-row-header {
    padding: 8px 10px;
    text-align: left;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--fg);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.sensitivity-row-header.sensitivity-base-row {
    background: #f0fdf4;
    color: #15803d;
}

/* ── Data cells ── */
.sensitivity-cell {
    padding: 8px 10px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--fg);
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    transition: background 0.15s ease;
}

/* Base scenario cell highlight */
.sensitivity-base-cell {
    font-weight: 700;
    outline: 2px solid var(--fg);
    outline-offset: -2px;
    z-index: 1;
    position: relative;
}

/* Color scale — applied via JS based on data-raw and min/max */
/* Fallback colors if JS hasn't run */
.sensitivity-cell[data-raw=""] {
    background: #f8fafc;
    color: var(--muted);
}

/* ── Legend ── */
.sensitivity-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 0 0;
    justify-content: center;
}

.sensitivity-legend-label {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--muted);
}

.sensitivity-legend-bar {
    width: 120px;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #fca5a5, #fef3c7, #bbf7d0);
}

