.tooltip {
    position: relative;
    cursor: help;
}

.tooltip > .tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 13px;
    height: 13px;
    margin-left: 4px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.07);
    color: #888;
    font-size: 9px;
    font-weight: 700;
    font-style: normal;
    line-height: 1;
    vertical-align: middle;
    cursor: help;
    transition: background 0.15s, color 0.15s;
    user-select: none;
}

.tooltip:hover > .tooltip-icon,
.tooltip:focus > .tooltip-icon,
.tooltip.tooltip-open > .tooltip-icon {
    background: rgba(56, 189, 248, 0.18);
    color: #38bdf8;
}

.tooltip::after {
    content: attr(data-msg);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 15, 22, 0.97);
    color: #d0d0d8;
    padding: 8px 11px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.45;
    letter-spacing: normal;
    text-transform: none;
    width: max-content;
    max-width: 260px;
    min-width: 60px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.06);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0s linear 0.15s;
    z-index: 99999;
    white-space: normal;
    text-align: left;
    font-family: 'Inter', sans-serif;
}

.tooltip::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(15, 15, 22, 0.97);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0s linear 0.15s;
    z-index: 99999;
}

.tooltip:hover::after,
.tooltip:hover::before,
.tooltip:focus::after,
.tooltip:focus::before,
.tooltip.tooltip-open::after,
.tooltip.tooltip-open::before {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.15s ease, visibility 0s linear 0s;
}

/* Tighter placement inside labels with caps + tracking */
.stat-label.tooltip::after,
.section-title.tooltip::after,
.tooltip .stat-label::after {
    bottom: calc(100% + 10px);
}

/* Small labels — keep tooltip legible */
.tiny-tooltip.tooltip::after {
    font-size: 11px;
    max-width: 220px;
    padding: 7px 10px;
}
