.graph-webgis {
    --graph-sidebar-width: 380px;
    --graph-border: #d9dee8;
    --graph-muted: #667085;
    --graph-bg: #f6f7fb;
    --graph-card: rgba(255, 255, 255, 0.97);
    --graph-primary: #2f6fed;
    --graph-primary-dark: #1f4fb6;
    --graph-timeline-height: 182px;
    display: grid;
    grid-template-columns: var(--graph-sidebar-width) minmax(0, 1fr);
    height: calc(100vh - 57px);
    min-height: 620px;
    background: var(--graph-bg);
    overflow: hidden;
}

.graph-sidebar {
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 0.95rem;
    padding: 1.1rem;
    background: var(--graph-card);
    border-right: 1px solid var(--graph-border);
    box-shadow: 8px 0 22px rgba(16, 24, 40, 0.07);
    overflow: hidden;
}

.graph-sidebar__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.graph-sidebar__header--compact {
    align-items: center;
}

.graph-eyebrow {
    margin: 0;
    color: var(--graph-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.graph-badge {
    min-width: 2.5rem;
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 700;
    color: #fff;
    background: var(--graph-primary);
}

.graph-subtypes {
    padding: 0.85rem;
    border: 1px solid var(--graph-border);
    border-radius: 1rem;
    background: linear-gradient(180deg, rgba(248,250,252,0.95) 0%, rgba(241,245,249,0.84) 100%);
}

.graph-subtypes__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.7rem;
}

.graph-subtypes__label {
    display: block;
    color: var(--graph-muted);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.graph-subtypes__title {
    display: block;
    color: #101828;
    font-size: 1rem;
    line-height: 1.1;
}

.graph-subtypes__reset {
    border: 0;
    padding: 0.28rem 0.55rem;
    border-radius: 999px;
    color: var(--graph-primary-dark);
    background: rgba(47, 111, 237, 0.08);
    font-size: 0.76rem;
    font-weight: 700;
}

.graph-subtypes__reset:hover,
.graph-subtypes__reset:focus {
    color: #fff;
    background: var(--graph-primary);
    outline: none;
}

.graph-subtypes__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
}

.graph-subtypes__empty {
    grid-column: 1 / -1;
    padding: 0.5rem 0.2rem;
    color: var(--graph-muted);
    font-size: 0.82rem;
    text-align: center;
}

.graph-subtype-btn {
    display: grid;
    grid-template-columns: 2rem 1fr;
    grid-template-areas:
        "icon label"
        "icon count";
    align-items: center;
    gap: 0.05rem 0.55rem;
    width: 100%;
    padding: 0.55rem 0.6rem;
    border: 1px solid rgba(121, 139, 169, 0.22);
    border-radius: 0.85rem;
    color: #344054;
    background: rgba(255, 255, 255, 0.82);
    text-align: left;
    transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.graph-subtype-btn:hover,
.graph-subtype-btn:focus {
    border-color: rgba(47, 111, 237, 0.45);
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(16, 24, 40, 0.08);
    outline: none;
}

.graph-subtype-btn.is-active {
    border-color: rgba(47, 111, 237, 0.55);
    background: rgba(47, 111, 237, 0.08);
}

.graph-subtype-btn__icon {
    grid-area: icon;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    color: #1f4fb6;
    background: rgba(47, 111, 237, 0.10);
}

.graph-subtype-btn__icon svg {
    width: 1rem;
    height: 1rem;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.graph-subtype-btn__label {
    grid-area: label;
    font-size: 0.84rem;
    font-weight: 700;
    line-height: 1.15;
}

.graph-subtype-btn__count {
    grid-area: count;
    color: var(--graph-muted);
    font-size: 0.72rem;
}

.graph-stats-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
}

.graph-stat-card {
    padding: 0.75rem;
    border: 1px solid var(--graph-border);
    border-radius: 0.75rem;
    background: #fff;
}

.graph-stat-card strong {
    display: block;
    color: #101828;
    font-size: 1.12rem;
    line-height: 1;
    white-space: nowrap;
}

.graph-stat-card span {
    display: block;
    margin-top: 0.25rem;
    color: var(--graph-muted);
    font-size: 0.78rem;
}

.graph-controls {
    display: grid;
    gap: 0.8rem;
}

.graph-field {
    display: grid;
    gap: 0.35rem;
    margin: 0;
    color: #344054;
    font-size: 0.85rem;
    font-weight: 600;
}

.graph-field .form-control,
.graph-field .form-select {
    border-color: var(--graph-border);
    font-size: 0.92rem;
}

.graph-actions {
    display: flex;
    gap: 0.5rem;
}

.graph-status {
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--graph-border);
    border-radius: 0.75rem;
    color: #344054;
    background: #fff;
    font-size: 0.9rem;
}

.graph-status.is-error {
    border-color: #f2b8b5;
    color: #b42318;
    background: #fff4f3;
}

.graph-list {
    min-height: 0;
    overflow: auto;
    display: grid;
    gap: 0.65rem;
    padding-right: 0.25rem;
}

.graph-list__item {
    width: 100%;
    padding: 0.85rem;
    border: 1px solid var(--graph-border);
    border-radius: 0.75rem;
    text-align: left;
    color: #101828;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.graph-list__item:hover,
.graph-list__item:focus {
    border-color: var(--graph-primary);
    transform: translateY(-1px);
    box-shadow: 0 7px 16px rgba(16, 24, 40, 0.08);
    outline: none;
}

.graph-list__title {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 700;
}

.graph-list__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    color: var(--graph-muted);
    font-size: 0.8rem;
}

.graph-tipo-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    color: #1d2939;
    background: #eef4ff;
    font-size: 0.76rem;
    font-weight: 700;
}

.graph-map-shell {
    position: relative;
    min-width: 0;
    min-height: 0;
}

.graph-map {
    width: 100%;
    height: 100%;
    min-height: 620px;
    background: #fff;
}

.graph-point-icon,
.graph-cluster-icon {
    background: transparent;
    border: 0;
}

.graph-point,
.graph-cluster-dot {
    display: block;
    position: relative;
    border-radius: 999px;
    pointer-events: auto;
}

.graph-point {
    width: var(--point-size, 18px);
    height: var(--point-size, 18px);
    border: 1px solid rgba(47, 111, 237, 0.60);
    background: rgba(47, 111, 237, var(--point-opacity, 0.42));
    box-shadow:
        0 0 0 4px rgba(47, 111, 237, 0.08),
        0 2px 8px rgba(16, 24, 40, 0.12);
}

.graph-point::after {
    content: "";
    position: absolute;
    inset: 38%;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.84);
}

.graph-cluster-dot {
    width: var(--cluster-size, 38px);
    height: var(--cluster-size, 38px);
    border: 1px solid rgba(47, 111, 237, 0.40);
    background: rgba(47, 111, 237, var(--cluster-opacity, 0.25));
    box-shadow:
        0 0 0 7px rgba(47, 111, 237, 0.06),
        0 4px 12px rgba(16, 24, 40, 0.10);
}

.graph-cluster-dot::after {
    content: "";
    position: absolute;
    inset: 36%;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.78);
}

.graph-timeline {
    position: absolute;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    z-index: 440;
    min-height: var(--graph-timeline-height);
    max-width: calc(100% - 2rem);
    padding: 0.85rem 1rem 0.75rem;
    box-sizing: border-box;
    overflow: hidden;
    border: 1px solid rgba(121, 139, 169, 0.20);
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.62);
    box-shadow: 0 10px 26px rgba(16, 24, 40, 0.08);
    backdrop-filter: blur(14px);
}

.graph-timeline.is-loading {
    opacity: 0.78;
}

.graph-timeline.is-disabled {
    display: none;
}

.graph-timeline__topline {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.45rem;
}

.graph-timeline__label {
    display: block;
    margin-bottom: 0.12rem;
    color: var(--graph-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.graph-timeline__topline strong {
    color: #101828;
    font-size: 1rem;
}

.graph-timeline__reset {
    border: 0;
    padding: 0.2rem 0.45rem;
    border-radius: 999px;
    color: var(--graph-primary-dark);
    background: rgba(47, 111, 237, 0.08);
    font-size: 0.78rem;
    font-weight: 700;
}

.graph-timeline__reset:hover,
.graph-timeline__reset:focus {
    color: #fff;
    background: var(--graph-primary);
    outline: none;
}

.graph-timeline__bars {
    width: 100%;
    height: 98px;
    display: grid;
    grid-template-columns: repeat(var(--timeline-years, 1), minmax(0, 1fr));
    align-items: end;
    column-gap: 1px;
    padding: 0 2px;
    box-sizing: border-box;
    overflow: hidden;
    border-bottom: 1px solid rgba(121, 139, 169, 0.30);
}

.graph-timeline__bar {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 3px 3px 0 0;
    appearance: none;
    -webkit-appearance: none;
    background: rgba(47, 111, 237, 0.16);
    cursor: pointer;
    line-height: 0;
    font-size: 0;
    transition: background 0.16s ease, opacity 0.16s ease, transform 0.16s ease;
}

.graph-timeline__bar.is-active {
    background: rgba(47, 111, 237, 0.52);
}

.graph-timeline__bar:hover,
.graph-timeline__bar:focus {
    opacity: 0.95;
    transform: translateY(-1px);
    outline: none;
}

.graph-timeline__empty {
    width: 100%;
    align-self: center;
    color: var(--graph-muted);
    font-size: 0.82rem;
    text-align: center;
}

.graph-range {
    position: relative;
    height: 32px;
    margin: 0.1rem 0 0;
}

.graph-range__track,
.graph-range__fill {
    position: absolute;
    left: 0;
    right: 0;
    top: 13px;
    height: 4px;
    border-radius: 999px;
}

.graph-range__track {
    background: rgba(121, 139, 169, 0.25);
}

.graph-range__fill {
    left: 0;
    right: 0;
    background: rgba(47, 111, 237, 0.56);
}

.graph-range__input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 28px;
    margin: 0;
    background: transparent;
    pointer-events: none;
    appearance: none;
    -webkit-appearance: none;
}

.graph-range__input::-webkit-slider-thumb {
    width: 17px;
    height: 17px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--graph-primary);
    box-shadow: 0 2px 8px rgba(16, 24, 40, 0.24);
    pointer-events: auto;
    cursor: grab;
    appearance: none;
    -webkit-appearance: none;
}

.graph-range__input::-moz-range-thumb {
    width: 17px;
    height: 17px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--graph-primary);
    box-shadow: 0 2px 8px rgba(16, 24, 40, 0.24);
    pointer-events: auto;
    cursor: grab;
}

.graph-range__input::-webkit-slider-runnable-track {
    background: transparent;
}

.graph-range__input::-moz-range-track {
    background: transparent;
}

.graph-range__tooltip {
    position: absolute;
    top: -1.35rem;
    z-index: 4;
    transform: translateX(-50%);
    min-width: 2.6rem;
    padding: 0.14rem 0.38rem;
    border-radius: 999px;
    color: #fff;
    background: rgba(16, 24, 40, 0.88);
    box-shadow: 0 4px 12px rgba(16, 24, 40, 0.20);
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1.1;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.graph-range__tooltip.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(-2px);
}

.graph-timeline__ticks {
    position: relative;
    height: 18px;
    margin: -0.15rem 0 0.1rem;
    border-top: 1px solid rgba(121, 139, 169, 0.16);
}

.graph-timeline__tick {
    position: absolute;
    top: 0;
    width: 1px;
    height: 7px;
    transform: translateX(-50%);
    background: rgba(102, 112, 133, 0.48);
}

.graph-timeline__tick span {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(102, 112, 133, 0.82);
    font-size: 0.64rem;
    font-weight: 700;
    white-space: nowrap;
}

.graph-timeline__years {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    color: var(--graph-muted);
    font-size: 0.78rem;
    font-weight: 700;
}

#graph-timeline-current {
    color: #344054;
}

.graph-timeline__year-edit {
    width: 4.7rem;
    min-width: 0;
    padding: 0.12rem 0.28rem;
    border: 1px solid rgba(121, 139, 169, 0.34);
    border-radius: 0.45rem;
    color: #344054;
    background: rgba(255, 255, 255, 0.76);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
    transition: border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
    appearance: textfield;
}

.graph-timeline__year-edit::-webkit-outer-spin-button,
.graph-timeline__year-edit::-webkit-inner-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

.graph-timeline__year-edit:hover,
.graph-timeline__year-edit:focus {
    border-color: var(--graph-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.12);
    outline: none;
}

.graph-popup h2 {
    margin: 0 0 0.35rem;
    font-size: 1rem;
    font-weight: 700;
}

.graph-popup p {
    margin: 0.25rem 0;
    color: #344054;
}

.graph-popup__actions {
    margin-top: 0.55rem;
}

.graph-empty {
    padding: 1rem;
    border: 1px dashed var(--graph-border);
    border-radius: 0.75rem;
    color: var(--graph-muted);
    background: rgba(255, 255, 255, 0.7);
    text-align: center;
}

@media (max-width: 900px) {
    .graph-webgis {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(520px, 1fr);
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .graph-sidebar {
        max-height: none;
        border-right: 0;
        border-bottom: 1px solid var(--graph-border);
        box-shadow: none;
    }

    .graph-subtypes__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .graph-list {
        max-height: 260px;
    }

    .graph-map {
        height: 75vh;
        min-height: 520px;
    }

    .graph-timeline {
        left: 0.75rem;
        right: 0.75rem;
        bottom: 0.75rem;
        max-width: calc(100% - 1.5rem);
        padding: 0.75rem;
    }

    .graph-timeline__bars {
        height: 74px;
    }

    .graph-timeline__topline {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.35rem;
    }
}


/* Compact event subtype filter: leaves room for the future vertical navigation. */
.graph-subtypes--compact {
    padding: 0.62rem;
    border-radius: 0.9rem;
}

.graph-subtypes--compact .graph-subtypes__head {
    align-items: center;
    margin-bottom: 0.52rem;
}

.graph-subtypes__summary {
    display: block;
    margin-top: 0.1rem;
    color: var(--graph-muted);
    font-size: 0.72rem;
    line-height: 1.1;
}

.graph-subtypes--compact .graph-subtypes__grid {
    grid-template-columns: repeat(auto-fill, minmax(2.25rem, 1fr));
    gap: 0.42rem;
}

.graph-subtypes--compact .graph-subtype-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border-radius: 999px;
    position: relative;
}

.graph-subtypes--compact .graph-subtype-btn__icon {
    width: 1.72rem;
    height: 1.72rem;
    background: transparent;
}

.graph-subtypes--compact .graph-subtype-btn__icon img {
    width: 1.34rem;
    height: 1.34rem;
    display: block;
    opacity: 0.78;
}

.graph-subtypes--compact .graph-subtype-btn.is-active .graph-subtype-btn__icon img {
    opacity: 1;
}

.graph-subtypes--compact .graph-subtype-btn__label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.graph-subtypes--compact .graph-subtype-btn__count {
    position: absolute;
    right: -0.24rem;
    bottom: -0.24rem;
    min-width: 1.05rem;
    height: 1.05rem;
    padding: 0 0.18rem;
    border: 1px solid rgba(255, 255, 255, 0.95);
    border-radius: 999px;
    color: #1f4fb6;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 4px rgba(16, 24, 40, 0.12);
    font-size: 0.58rem;
    font-weight: 800;
    line-height: 1rem;
    text-align: center;
}

.graph-timeline {
    background: rgba(255, 255, 255, 0.48);
    border-color: rgba(121, 139, 169, 0.16);
    box-shadow: 0 8px 22px rgba(16, 24, 40, 0.07);
    backdrop-filter: blur(16px);
}

.graph-timeline__bar {
    background: rgba(47, 111, 237, 0.12);
}

.graph-timeline__bar.is-active {
    background: rgba(47, 111, 237, 0.44);
}


/* Grouped subtype filter. Four compact blocks, with block-level selection. */
.graph-subtypes--compact .graph-subtypes__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.48rem;
}

.graph-subtype-group {
    --group-accent: #2f6fed;
    --group-bg: rgba(47, 111, 237, 0.08);
    --group-border: rgba(47, 111, 237, 0.18);
    padding: 0.42rem;
    border: 1px solid var(--group-border);
    border-radius: 0.8rem;
    background: var(--group-bg);
}

.graph-subtype-group--anagrafici {
    --group-accent: #475467;
    --group-bg: rgba(255, 255, 255, 0.88);
    --group-border: rgba(152, 162, 179, 0.32);
}

.graph-subtype-group--generale {
    --group-accent: #2f6fed;
    --group-bg: rgba(47, 111, 237, 0.08);
    --group-border: rgba(47, 111, 237, 0.18);
}

.graph-subtype-group--mobilita_volontaria {
    --group-accent: #16885a;
    --group-bg: rgba(22, 136, 90, 0.09);
    --group-border: rgba(22, 136, 90, 0.20);
}

.graph-subtype-group--mobilita_coatta {
    --group-accent: #b42318;
    --group-bg: rgba(180, 35, 24, 0.08);
    --group-border: rgba(180, 35, 24, 0.20);
}

.graph-subtype-group__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.graph-subtype-group__head strong {
    display: block;
    color: #1d2939;
    font-size: 0.76rem;
    line-height: 1.05;
}

.graph-subtype-group__head span {
    display: block;
    color: var(--graph-muted);
    font-size: 0.62rem;
    line-height: 1.05;
}

.graph-subtype-group__toggle {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.12rem 0.38rem;
    color: var(--group-accent);
    background: rgba(255, 255, 255, 0.68);
    font-size: 0.62rem;
    font-weight: 800;
    line-height: 1.2;
}

.graph-subtype-group__toggle:hover,
.graph-subtype-group__toggle:focus,
.graph-subtype-group__toggle.is-active {
    border-color: color-mix(in srgb, var(--group-accent) 40%, transparent);
    color: #fff;
    background: var(--group-accent);
    outline: none;
}

.graph-subtype-group__icons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.34rem;
}

.graph-subtype-group .graph-subtype-btn {
    flex: 0 0 auto;
    width: 2.05rem;
    min-width: 2.05rem;
    height: 2.05rem;
    border-color: color-mix(in srgb, var(--group-accent) 18%, transparent);
}

.graph-subtype-group .graph-subtype-btn.is-active {
    border-color: color-mix(in srgb, var(--group-accent) 54%, transparent);
    background: color-mix(in srgb, var(--group-accent) 13%, white);
}

.graph-subtype-group .graph-subtype-btn__icon img {
    width: 1.18rem;
    height: 1.18rem;
}

.graph-subtype-group .graph-subtype-btn__count {
    color: var(--group-accent);
}


/* --- Search filters / compact sidebar overrides --- */
.graph-search-stack {
    display: grid;
    gap: 0.65rem;
}

.graph-entity-search {
    position: relative;
    display: grid;
    gap: 0.35rem;
}

.graph-field--compact {
    gap: 0.22rem;
    font-size: 0.78rem;
}

.graph-field--compact .form-control {
    padding-top: 0.28rem;
    padding-bottom: 0.28rem;
    font-size: 0.86rem;
}

.graph-search-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.32rem;
    min-height: 0.15rem;
}

.graph-search-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    max-width: 100%;
    padding: 0.16rem 0.38rem 0.16rem 0.5rem;
    border: 1px solid rgba(47, 111, 237, 0.20);
    border-radius: 999px;
    color: #1d2939;
    background: rgba(47, 111, 237, 0.08);
    font-size: 0.72rem;
    font-weight: 700;
}

.graph-search-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.graph-search-chip button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    padding: 0;
    border: 0;
    border-radius: 999px;
    color: #1f4fb6;
    background: rgba(255, 255, 255, 0.65);
    font-size: 0.72rem;
    line-height: 1;
}

.graph-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 0.18rem);
    z-index: 700;
    display: none;
    max-height: 220px;
    overflow: auto;
    padding: 0.25rem;
    border: 1px solid rgba(121, 139, 169, 0.28);
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 12px 30px rgba(16, 24, 40, 0.14);
}

.graph-suggestions.is-visible {
    display: grid;
    gap: 0.18rem;
}

.graph-suggestion {
    width: 100%;
    padding: 0.45rem 0.55rem;
    border: 0;
    border-radius: 0.55rem;
    color: #1d2939;
    background: transparent;
    text-align: left;
}

.graph-suggestion:hover,
.graph-suggestion:focus {
    background: rgba(47, 111, 237, 0.08);
    outline: none;
}

.graph-suggestion strong {
    display: block;
    font-size: 0.82rem;
    line-height: 1.15;
}

.graph-suggestion span {
    display: block;
    margin-top: 0.12rem;
    color: var(--graph-muted);
    font-size: 0.7rem;
}

.graph-actions--compact {
    margin-top: -0.1rem;
}

.graph-timeline__count {
    display: inline-flex;
    align-items: center;
    margin-left: 0.5rem;
    padding: 0.08rem 0.42rem;
    border-radius: 999px;
    color: #1f4fb6;
    background: rgba(47, 111, 237, 0.10);
    font-size: 0.72rem;
    font-weight: 800;
    vertical-align: 0.08rem;
}

/* Popup centered on events */
.graph-popup {
    width: min(420px, 74vw);
}

.graph-popup__place-head {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 0 0 0.45rem;
    margin-bottom: 0.45rem;
    border-bottom: 1px solid rgba(121, 139, 169, 0.24);
    background: #fff;
}

.graph-popup__place-head h2 {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.18;
    font-weight: 800;
}

.graph-popup__place-meta {
    display: block;
    margin-top: 0.16rem;
    color: var(--graph-muted);
    font-size: 0.74rem;
}

.graph-popup__place-actions,
.graph-popup__event-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.48rem;
}

.graph-popup__place-actions .btn,
.graph-popup__event-actions .btn {
    color: #1f4fb6 !important;
    border-color: rgba(47, 111, 237, 0.48) !important;
    background: rgba(255, 255, 255, 0.95);
    font-weight: 700;
    text-decoration: none !important;
}

.graph-popup__summary {
    margin: 0.25rem 0 0.55rem;
    color: #344054;
    font-size: 0.82rem;
}

.graph-popup__event-group {
    margin-top: 0.55rem;
}

.graph-popup__event-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.28rem;
    color: #344054;
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.graph-popup__event-group-title span:last-child {
    color: var(--graph-muted);
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
}

.graph-popup__event-item {
    width: 100%;
    display: grid;
    grid-template-columns: 5.3rem minmax(0, 1fr);
    gap: 0.45rem;
    align-items: start;
    padding: 0.5rem 0.55rem;
    margin-bottom: 0.25rem;
    border: 1px solid rgba(121, 139, 169, 0.22);
    border-radius: 0.72rem;
    color: #1d2939;
    background: rgba(248, 250, 252, 0.88);
    text-align: left;
}

.graph-popup__event-item:hover,
.graph-popup__event-item:focus {
    border-color: rgba(47, 111, 237, 0.42);
    background: rgba(47, 111, 237, 0.06);
    outline: none;
}

.graph-popup__event-period {
    color: #1f4fb6;
    font-size: 0.72rem;
    font-weight: 800;
}

.graph-popup__event-title {
    display: block;
    overflow: hidden;
    color: #101828;
    font-size: 0.82rem;
    font-weight: 800;
    line-height: 1.18;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.graph-popup__event-people {
    display: block;
    margin-top: 0.1rem;
    overflow: hidden;
    color: var(--graph-muted);
    font-size: 0.72rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.graph-popup__detail {
    display: none;
}

.graph-popup__detail.is-visible {
    display: block;
}

.graph-popup__landing.is-hidden {
    display: none;
}

.graph-popup__back {
    border: 0;
    padding: 0.18rem 0.42rem;
    border-radius: 999px;
    color: #1f4fb6;
    background: rgba(47, 111, 237, 0.08);
    font-size: 0.74rem;
    font-weight: 800;
}

.graph-popup__detail h3 {
    margin: 0.5rem 0 0.35rem;
    color: #101828;
    font-size: 0.94rem;
    font-weight: 800;
}

.graph-popup__detail p {
    margin: 0.35rem 0;
    color: #344054;
    font-size: 0.82rem;
}

.graph-popup__people-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.28rem;
    margin-top: 0.28rem;
}

.graph-popup__person-chip {
    display: inline-flex;
    padding: 0.16rem 0.42rem;
    border-radius: 999px;
    color: #1d2939;
    background: rgba(47, 111, 237, 0.08);
    font-size: 0.72rem;
    font-weight: 700;
}

.graph-popup__empty {
    padding: 0.75rem;
    border: 1px dashed rgba(121, 139, 169, 0.35);
    border-radius: 0.75rem;
    color: var(--graph-muted);
    background: rgba(248, 250, 252, 0.8);
    text-align: center;
}

/* Runtime event modal: generated only when a marker is clicked. */
.graph-modal-open {
    overflow: hidden;
}

.graph-event-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
}

.graph-event-modal.is-visible {
    display: block;
}

.graph-event-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.34);
    backdrop-filter: blur(2px);
}

.graph-event-modal__panel {
    position: absolute;
    top: 5vh;
    left: 50%;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    width: min(760px, calc(100vw - 2rem));
    max-height: 90vh;
    transform: translateX(-50%);
    border: 1px solid rgba(121, 139, 169, 0.26);
    border-radius: 1.1rem;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 24px 70px rgba(16, 24, 40, 0.24);
    overflow: hidden;
}

.graph-event-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.1rem 0.8rem;
    border-bottom: 1px solid rgba(121, 139, 169, 0.20);
}

.graph-event-modal__kicker {
    display: block;
    margin-bottom: 0.12rem;
    color: var(--graph-muted);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.graph-event-modal__header h2 {
    margin: 0;
    color: #101828;
    font-size: 1.25rem;
    line-height: 1.15;
    font-weight: 800;
}

.graph-event-modal__header p {
    margin: 0.2rem 0 0;
    color: var(--graph-muted);
    font-size: 0.84rem;
}

.graph-event-modal__close {
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 999px;
    color: #344054;
    background: rgba(121, 139, 169, 0.10);
    font-size: 1.4rem;
    line-height: 1;
}

.graph-event-modal__close:hover,
.graph-event-modal__close:focus {
    background: rgba(47, 111, 237, 0.12);
    outline: none;
}

.graph-event-modal__body {
    min-height: 260px;
    overflow: auto;
    padding: 0.9rem 1.1rem 1rem;
}

.graph-event-modal__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.72rem 1.1rem;
    border-top: 1px solid rgba(121, 139, 169, 0.20);
    background: rgba(248, 250, 252, 0.96);
}

.graph-event-modal__footer.is-empty {
    display: none;
}

.graph-event-modal__loading,
.graph-event-modal__empty {
    padding: 1rem;
    border: 1px dashed rgba(121, 139, 169, 0.35);
    border-radius: 0.85rem;
    color: var(--graph-muted);
    background: rgba(248, 250, 252, 0.86);
    text-align: center;
}

.graph-modal-typebar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-bottom: 0.9rem;
}

.graph-modal-type-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.7rem;
    height: 2.7rem;
    padding: 0;
    border: 1px solid rgba(121, 139, 169, 0.24);
    border-radius: 999px;
    color: #1f4fb6;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 2px 8px rgba(16, 24, 40, 0.07);
    transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.graph-modal-type-btn:hover,
.graph-modal-type-btn:focus,
.graph-modal-type-btn.is-active {
    transform: translateY(-1px);
    border-color: rgba(47, 111, 237, 0.58);
    background: rgba(47, 111, 237, 0.09);
    outline: none;
}

.graph-modal-type-btn__icon img {
    width: 1.45rem;
    height: 1.45rem;
    display: block;
}

.graph-modal-type-btn__count {
    position: absolute;
    right: -0.18rem;
    bottom: -0.18rem;
    min-width: 1.18rem;
    height: 1.18rem;
    padding: 0 0.2rem;
    border: 1px solid rgba(255, 255, 255, 0.95);
    border-radius: 999px;
    color: #1f4fb6;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 1px 5px rgba(16, 24, 40, 0.14);
    font-size: 0.62rem;
    font-weight: 900;
    line-height: 1.08rem;
}

.graph-modal-type-btn__label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.graph-modal-group {
    margin-top: 0.85rem;
}

.graph-modal-group h3 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0 0 0.38rem;
    color: #344054;
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.045em;
}

.graph-modal-group h3 span {
    color: var(--graph-muted);
    font-size: 0.72rem;
    text-transform: none;
    letter-spacing: 0;
}

.graph-modal-event {
    margin-bottom: 0.38rem;
    border: 1px solid rgba(121, 139, 169, 0.22);
    border-radius: 0.8rem;
    background: rgba(248, 250, 252, 0.9);
    overflow: hidden;
}

.graph-modal-event[open] {
    border-color: rgba(47, 111, 237, 0.34);
    background: rgba(255, 255, 255, 0.98);
}

.graph-modal-event__summary {
    display: grid;
    grid-template-columns: 5.5rem minmax(0, 1fr);
    gap: 0.55rem;
    align-items: center;
    padding: 0.6rem 0.72rem;
    cursor: pointer;
}

.graph-modal-event__summary::marker {
    color: var(--graph-primary);
}

.graph-modal-event__period {
    color: #1f4fb6;
    font-size: 0.72rem;
    font-weight: 900;
}

.graph-modal-event__main {
    min-width: 0;
}

.graph-modal-event__main strong,
.graph-modal-event__main em {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.graph-modal-event__main strong {
    color: #101828;
    font-size: 0.86rem;
    font-style: normal;
}

.graph-modal-event__main em {
    margin-top: 0.1rem;
    color: var(--graph-muted);
    font-size: 0.74rem;
    font-style: normal;
}

.graph-modal-event__content {
    padding: 0 0.72rem 0.72rem 6.77rem;
    color: #344054;
    font-size: 0.84rem;
}

.graph-modal-event__content p {
    margin: 0.35rem 0;
}

.graph-modal-event__meta {
    color: var(--graph-muted);
    font-size: 0.78rem;
}

.graph-modal-event__people {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin: 0.55rem 0;
}

.graph-modal-person-chip {
    display: inline-flex;
    padding: 0.18rem 0.48rem;
    border-radius: 999px;
    color: #1d2939;
    background: rgba(47, 111, 237, 0.08);
    font-size: 0.74rem;
    font-weight: 750;
    text-decoration: none;
}

.graph-modal-person-chip:hover,
.graph-modal-person-chip:focus {
    color: #1f4fb6;
    background: rgba(47, 111, 237, 0.14);
}

.graph-modal-event__actions {
    margin-top: 0.55rem;
}

.graph-modal-event__actions .btn,
.graph-event-modal__footer .btn {
    color: #fff !important;
    font-weight: 800;
    text-decoration: none !important;
}

@media (max-width: 720px) {
    .graph-event-modal__panel {
        top: 1rem;
        width: calc(100vw - 1rem);
        max-height: calc(100vh - 2rem);
    }

    .graph-modal-event__summary {
        grid-template-columns: 1fr;
        gap: 0.2rem;
    }

    .graph-modal-event__content {
        padding: 0 0.72rem 0.72rem;
    }
}


/* Fix record buttons inside runtime event modal */
.graph-modal-record-button,
.graph-modal-event__actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 1.85rem;
    padding: 0.34rem 0.72rem;
    border: 1px solid rgba(47, 111, 237, 0.95) !important;
    border-radius: 999px;
    color: #fff !important;
    background: #2f6fed !important;
    box-shadow: 0 4px 10px rgba(47, 111, 237, 0.18);
    font-size: 0.78rem;
    font-weight: 800;
    line-height: 1.1;
    text-decoration: none !important;
}

.graph-modal-record-button:hover,
.graph-modal-record-button:focus,
.graph-modal-event__actions .btn:hover,
.graph-modal-event__actions .btn:focus {
    color: #fff !important;
    background: #1f4fb6 !important;
    border-color: #1f4fb6 !important;
    outline: none;
}

.graph-modal-person-button {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.05rem;
    max-width: 100%;
    padding: 0.32rem 0.58rem;
    border: 1px solid rgba(47, 111, 237, 0.35);
    border-radius: 0.72rem;
    color: #1d2939 !important;
    background: rgba(47, 111, 237, 0.08);
    text-decoration: none !important;
}

.graph-modal-person-button span {
    max-width: 100%;
    overflow: hidden;
    font-size: 0.76rem;
    font-weight: 800;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.graph-modal-person-button strong {
    color: #1f4fb6;
    font-size: 0.66rem;
    font-weight: 800;
    line-height: 1.1;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.graph-modal-person-button:hover,
.graph-modal-person-button:focus {
    color: #fff !important;
    background: #2f6fed;
    border-color: #2f6fed;
    outline: none;
}

.graph-modal-person-button:hover span,
.graph-modal-person-button:focus span,
.graph-modal-person-button:hover strong,
.graph-modal-person-button:focus strong {
    color: #fff;
}


/* --- Sidebar mode switch and co-occurrence analysis --- */
.graph-sidebar-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
    padding: 0.25rem;
    border: 1px solid rgba(121, 139, 169, 0.22);
    border-radius: 999px;
    background: rgba(248, 250, 252, 0.92);
}

.graph-sidebar-switch__btn {
    border: 0;
    border-radius: 999px;
    padding: 0.34rem 0.6rem;
    color: #475467;
    background: transparent;
    font-size: 0.78rem;
    font-weight: 800;
}

.graph-sidebar-switch__btn.is-active {
    color: #fff;
    background: #2f6fed;
    box-shadow: 0 3px 8px rgba(47, 111, 237, 0.18);
}

.graph-sidebar-panel {
    display: none;
    min-height: 0;
}

.graph-sidebar-panel.is-active {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    min-height: 0;
    flex: 1 1 auto;
}

.graph-analysis-settings {
    flex: 0 0 auto;
    display: grid;
    gap: 0.55rem;
    max-height: 26vh;
    padding: 0.62rem;
    border: 1px solid rgba(121, 139, 169, 0.22);
    border-radius: 0.9rem;
    background: rgba(255, 255, 255, 0.90);
    overflow: visible;
}

.graph-analysis-settings__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.graph-analysis-search-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.45rem;
}

.graph-analysis-types {
    display: flex;
    flex-wrap: wrap;
    gap: 0.34rem;
}

.graph-analysis-type {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    min-height: 1.55rem;
    padding: 0.14rem 0.42rem;
    border: 1px solid rgba(47, 111, 237, 0.18);
    border-radius: 999px;
    color: #1d2939;
    background: rgba(47, 111, 237, 0.07);
    font-size: 0.68rem;
    font-weight: 800;
    cursor: pointer;
}

.graph-analysis-type--off {
    background: rgba(255, 255, 255, 0.76);
    border-color: rgba(121, 139, 169, 0.24);
}

.graph-analysis-type input {
    width: 0.82rem;
    height: 0.82rem;
    margin: 0;
}

.graph-status--analysis {
    flex: 0 0 auto;
}

.graph-analysis-results {
    min-height: 0;
    flex: 1 1 auto;
    overflow: auto;
    display: grid;
    align-content: start;
    gap: 0.7rem;
    padding-right: 0.25rem;
}

.graph-analysis-card {
    padding: 0.78rem;
    border: 1px solid rgba(121, 139, 169, 0.24);
    border-radius: 0.95rem;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 5px 14px rgba(16, 24, 40, 0.05);
    cursor: pointer;
}

.graph-analysis-card:hover {
    border-color: rgba(47, 111, 237, 0.45);
}

.graph-analysis-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.55rem;
}

.graph-analysis-card__head h3 {
    margin: 0;
    color: #101828;
    font-size: 0.96rem;
    font-weight: 850;
    line-height: 1.15;
}

.graph-analysis-card__head span {
    display: block;
    margin-top: 0.12rem;
    color: var(--graph-muted);
    font-size: 0.72rem;
}

.graph-analysis-card__head strong {
    flex: 0 0 auto;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    color: #9f1239;
    background: rgba(244, 63, 94, 0.10);
    font-size: 0.72rem;
    font-weight: 850;
}

.graph-analysis-segment {
    display: grid;
    gap: 0.28rem;
    margin-top: 0.5rem;
}

.graph-analysis-segment__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem;
    color: #344054;
    font-size: 0.74rem;
}

.graph-analysis-segment__meta strong {
    color: #101828;
    font-size: 0.78rem;
}

.graph-analysis-segment__meta span {
    color: var(--graph-muted);
    font-weight: 800;
}

.graph-analysis-bar {
    position: relative;
    height: 0.55rem;
    border-radius: 999px;
    background: rgba(121, 139, 169, 0.16);
    overflow: hidden;
}

.graph-analysis-bar span {
    position: absolute;
    top: 0;
    bottom: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(244, 63, 94, 0.55), rgba(244, 63, 94, 0.90));
}

.graph-analysis-segment__people {
    overflow: hidden;
    color: var(--graph-muted);
    font-size: 0.7rem;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.graph-point--analysis {
    border-color: rgba(225, 29, 72, 0.68);
    background: rgba(225, 29, 72, var(--point-opacity, 0.55));
    box-shadow:
        0 0 0 5px rgba(225, 29, 72, 0.10),
        0 3px 11px rgba(16, 24, 40, 0.14);
}

.graph-point--analysis::after {
    background: rgba(255, 255, 255, 0.88);
}


.graph-cluster-dot--analysis {
    border-color: rgba(225, 29, 72, 0.46);
    background: rgba(225, 29, 72, var(--cluster-opacity, 0.28));
    box-shadow:
        0 0 0 7px rgba(225, 29, 72, 0.07),
        0 4px 12px rgba(16, 24, 40, 0.10);
}

.graph-cluster-dot--analysis::after {
    background: rgba(255, 255, 255, 0.82);
}

/* --- Final tuning: discreet mode switch, themed modes, scrollable sidebar --- */
.graph-webgis.is-mode-filter {
    --graph-mode-accent: #2f6fed;
    --graph-mode-soft: rgba(47, 111, 237, 0.09);
    --graph-mode-track: rgba(47, 111, 237, 0.48);
}

.graph-webgis.is-mode-analysis {
    --graph-mode-accent: #e11d48;
    --graph-mode-soft: rgba(225, 29, 72, 0.08);
    --graph-mode-track: rgba(225, 29, 72, 0.48);
}

.graph-webgis.is-mode-analysis .graph-sidebar {
    border-right-color: rgba(225, 29, 72, 0.22);
    box-shadow: 8px 0 22px rgba(225, 29, 72, 0.07);
}

.graph-sidebar-switch {
    width: max-content;
    align-self: flex-start;
    grid-template-columns: repeat(2, 2.35rem);
    gap: 0.18rem;
    padding: 0.18rem;
    border-radius: 999px;
}

.graph-sidebar-switch__btn {
    width: 2.35rem;
    height: 2.05rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.graph-sidebar-switch__btn span {
    font-size: 1.05rem;
    line-height: 1;
}

.graph-sidebar-switch__btn strong {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.graph-sidebar-switch__btn.is-active {
    background: var(--graph-mode-accent, #2f6fed);
}

.graph-sidebar-panel.is-active {
    overflow-y: auto;
    overflow-x: visible;
    padding-right: 0.18rem;
}

.graph-analysis-settings {
    max-height: none;
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(225, 29, 72, 0.18);
    box-shadow: 0 6px 16px rgba(16, 24, 40, 0.06);
}

.graph-analysis-results {
    overflow: visible;
}

.graph-webgis.is-mode-analysis .graph-timeline {
    border-color: rgba(225, 29, 72, 0.18);
}

.graph-webgis.is-mode-analysis .graph-timeline__bar.is-active,
.graph-webgis.is-mode-analysis .graph-range__fill {
    background: var(--graph-mode-track);
}

.graph-webgis.is-mode-analysis .graph-timeline__count,
.graph-webgis.is-mode-analysis .graph-timeline__reset {
    color: #9f1239;
    background: rgba(225, 29, 72, 0.10);
}

.graph-webgis.is-mode-analysis .graph-timeline__reset:hover,
.graph-webgis.is-mode-analysis .graph-timeline__reset:focus {
    color: #fff;
    background: #e11d48;
}

/* Icon buttons for macro event types in analysis panel */
.graph-analysis-types {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.38rem;
}

.graph-analysis-type {
    position: relative;
    min-height: 2.55rem;
    padding: 0.28rem 0.18rem;
    flex-direction: column;
    justify-content: center;
    gap: 0.12rem;
    border-radius: 0.75rem;
    opacity: 0.48;
    filter: grayscale(0.15);
}

.graph-analysis-type:has(input:checked) {
    opacity: 1;
    filter: none;
    box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
}

.graph-analysis-type input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.graph-analysis-type img {
    width: 1.14rem;
    height: 1.14rem;
    display: block;
}

.graph-analysis-type span {
    font-size: 0.58rem;
    line-height: 1;
}

.graph-analysis-type--nascita {
    border-color: rgba(121, 139, 169, 0.22);
    background: rgba(255, 255, 255, 0.82);
}

.graph-analysis-type--morte,
.graph-analysis-type--generale {
    border-color: rgba(47, 111, 237, 0.22);
    background: rgba(47, 111, 237, 0.07);
}

.graph-analysis-type--volontaria {
    border-color: rgba(22, 163, 74, 0.24);
    background: rgba(22, 163, 74, 0.08);
}

.graph-analysis-type--coatta {
    border-color: rgba(225, 29, 72, 0.25);
    background: rgba(225, 29, 72, 0.08);
}

/* Collapsible analysis cards */
.graph-analysis-card {
    display: block;
}

.graph-analysis-card__head {
    cursor: pointer;
    list-style: none;
    margin-bottom: 0;
}

.graph-analysis-card__head::-webkit-details-marker {
    display: none;
}

.graph-analysis-card__head::before {
    content: "▸";
    flex: 0 0 auto;
    color: #e11d48;
    font-size: 0.8rem;
    transform: translateY(0.15rem);
}

.graph-analysis-card[open] .graph-analysis-card__head::before {
    content: "▾";
}

.graph-analysis-card__body {
    margin-top: 0.6rem;
}

.graph-analysis-bar span {
    display: block;
    right: auto !important;
    min-width: 2px;
}

.graph-analysis-bar {
    height: 0.46rem;
    background: rgba(121, 139, 169, 0.18);
}

.graph-analysis-bar span {
    background: linear-gradient(90deg, rgba(225, 29, 72, 0.42), rgba(225, 29, 72, 0.86));
}

.graph-analysis-segment__people {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.graph-modal-type-btn.is-loading {
    opacity: 0.55;
    cursor: wait;
}

.graph-event-modal__loading {
    padding: 0.8rem;
    color: var(--graph-muted);
    text-align: center;
}

@media (max-height: 760px) {
    .graph-analysis-settings {
        position: relative;
    }
}


/* --- Loading feedback: WebGIS, map and modal --- */
.graph-webgis {
    position: relative;
}

.graph-webgis::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 690;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--graph-primary), transparent);
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
}

.graph-webgis.is-loading::before {
    opacity: 1;
    animation: graph-loading-bar 1.15s ease-in-out infinite;
}

.graph-sidebar {
    position: relative;
}

.graph-sidebar::after {
    content: "Aggiornamento dati…";
    position: absolute;
    top: 0.65rem;
    right: 0.7rem;
    z-index: 20;
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.55rem;
    border: 1px solid rgba(47, 111, 237, 0.16);
    border-radius: 999px;
    color: var(--graph-primary-dark);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 8px 18px rgba(16, 24, 40, 0.08);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    opacity: 0;
    transform: translateY(-0.35rem);
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: none;
}

.graph-webgis.is-loading .graph-sidebar::after {
    opacity: 1;
    transform: translateY(0);
}

.graph-webgis.is-loading .graph-list,
.graph-analysis-settings.is-loading,
.graph-sidebar-panel.is-loading .graph-analysis-results {
    cursor: progress;
}

.graph-map-loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 438;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 1rem;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.28), rgba(248, 250, 252, 0.08));
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s ease, visibility 0.18s ease;
    pointer-events: none;
}

.graph-map-loading-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

.graph-map-loading-overlay__inner,
.graph-loading-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.48rem;
}

.graph-map-loading-overlay__inner {
    padding: 0.52rem 0.75rem;
    border: 1px solid rgba(121, 139, 169, 0.22);
    border-radius: 999px;
    color: #1d2939;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 10px 26px rgba(16, 24, 40, 0.12);
    font-size: 0.82rem;
    font-weight: 800;
    backdrop-filter: blur(10px);
}

.graph-loading-spinner {
    width: 1.08rem;
    height: 1.08rem;
    flex: 0 0 auto;
    color: var(--graph-primary);
    animation: graph-spin 0.82s linear infinite;
}

.graph-map-spinner {
    width: 1.18rem;
    height: 1.18rem;
}

.graph-event-modal.is-loading .graph-event-modal__panel,
.graph-sidebar-panel.is-loading {
    cursor: progress;
}

.graph-event-modal__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.52rem;
}

.graph-empty--loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 4.5rem;
}

.graph-sidebar-panel.is-loading .graph-analysis-results {
    opacity: 0.84;
}

@keyframes graph-spin {
    to { transform: rotate(360deg); }
}

@keyframes graph-loading-bar {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(0%); }
    100% { transform: translateX(100%); }
}
