/* Riquadri KPI cliccabili + scheda di dettaglio (assets/kpi_detail.js) */
[data-kpi-title] {
    cursor: pointer;
}

[data-kpi-title]:focus-visible {
    outline: 2px solid #5dade2;
    outline-offset: 2px;
    border-radius: 12px;
}

[data-kpi-title] .kpi-label::after {
    content: " ⓘ";
    opacity: 0.55;
    font-weight: 400;
}

.kpi-detail-wrap {
    height: 100%;
}

.kpi-detail-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(8, 11, 17, 0.62);
}

.kpi-detail-overlay[hidden] {
    display: none;
}

.kpi-detail-dialog {
    position: relative;
    width: min(520px, 100%);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 22px 24px;
    color: #edf2f7;
    background: #1c2128;
    border: 1px solid #3a4250;
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.kpi-detail-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 32px;
    height: 32px;
    color: inherit;
    font-size: 16px;
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.kpi-detail-close:hover,
.kpi-detail-close:focus-visible {
    background: rgba(255, 255, 255, 0.1);
}

.kpi-detail-kicker {
    padding-right: 34px;
    color: #8fd0ff;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
}

.kpi-detail-value {
    margin: 4px 0 14px;
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.kpi-detail-line {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 7px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.kpi-detail-line span {
    color: #aeb8c5;
}

.kpi-detail-good strong {
    color: #58d68d;
}

.kpi-detail-bad strong {
    color: #ff6b6b;
}

.kpi-detail-muted {
    color: #aeb8c5;
    font-size: 0.9rem;
}

.kpi-detail-rows table {
    width: 100%;
    margin-top: 14px;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.kpi-detail-rows th,
.kpi-detail-rows td {
    padding: 5px 6px;
    text-align: right;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.kpi-detail-rows th:first-child,
.kpi-detail-rows td:first-child {
    text-align: left;
}

.kpi-detail-rows th {
    color: #aeb8c5;
    font-weight: 700;
}

.kpi-detail-how {
    margin-top: 14px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.kpi-detail-how p {
    margin: 4px 0 0;
    color: #c5ced8;
}

body[data-theme="light"] .kpi-detail-overlay {
    background: rgba(31, 45, 61, 0.35);
}

body[data-theme="light"] .kpi-detail-dialog {
    color: #212529;
    background: #ffffff;
    border-color: #ced7e0;
    box-shadow: 0 24px 60px rgba(31, 45, 61, 0.25);
}

body[data-theme="light"] .kpi-detail-kicker {
    color: #1f6fa8;
}

body[data-theme="light"] .kpi-detail-line,
body[data-theme="light"] .kpi-detail-rows th,
body[data-theme="light"] .kpi-detail-rows td {
    border-bottom-color: rgba(0, 0, 0, 0.09);
}

body[data-theme="light"] .kpi-detail-line span,
body[data-theme="light"] .kpi-detail-muted,
body[data-theme="light"] .kpi-detail-rows th,
body[data-theme="light"] .kpi-detail-how p {
    color: #5b6570;
}

body[data-theme="light"] .kpi-detail-good strong {
    color: #1e8449;
}

body[data-theme="light"] .kpi-detail-bad strong {
    color: #c0392b;
}

body[data-theme="light"] .kpi-detail-close:hover {
    background: rgba(0, 0, 0, 0.07);
}
