:root {
    --me-purple-950: #2c123b;
    --me-purple-900: #3c1552;
    --me-purple-800: #54206f;
    --me-purple-700: #6f2c91;
    --me-purple-600: #8b3faf;
    --me-pink-500: #ed5bb1;
    --me-pink-300: #f5a3d2;
    --me-pink-100: #fdebf6;
    --me-surface: #ffffff;
    --me-background: #f7f4f8;
    --me-text: #281f2c;
    --me-muted: #766d79;
    --me-border: #eadfea;
    --me-danger: #b42345;
}

.ms-public-map,
.ms-public-map * {
    box-sizing: border-box;
}

.ms-public-map {
    min-height: 100vh;
    padding: 38px clamp(18px, 4vw, 58px) 58px;
    color: var(--me-text);
    background:
        radial-gradient(
            circle at 95% 0,
            rgba(237, 91, 177, 0.12),
            transparent 27%
        ),
        radial-gradient(
            circle at 0 35%,
            rgba(111, 44, 145, 0.07),
            transparent 24%
        ),
        var(--me-background);
}

.ms-public-map__hero {
    max-width: 1480px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 30px;
    margin: 0 auto 25px;
}

.ms-public-map__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: var(--me-pink-500);
    font-size: 13px;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ms-public-map__hero h1 {
    margin: 0;
    color: var(--me-purple-950);
    font-size: clamp(34px, 5vw, 52px);
    line-height: 1.06;
    letter-spacing: -0.045em;
}

.ms-public-map__hero p {
    max-width: 800px;
    margin: 14px 0 0;
    color: var(--me-muted);
    font-size: 15px;
    line-height: 1.7;
}

.ms-public-map__home-link {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    flex: 0 0 auto;
    padding: 0 17px;
    border: 1px solid var(--me-border);
    border-radius: 13px;
    color: var(--me-purple-700);
    background: #fff;
    font-size: 12px;
    font-weight: 850;
    text-decoration: none;
    box-shadow: 0 10px 25px rgba(55, 24, 65, 0.055);
}

.ms-public-map__home-link:hover {
    color: var(--me-purple-950);
    transform: translateY(-1px);
}

.ms-public-map__summary {
    max-width: 1480px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin: 0 auto 20px;
}

.ms-map-kpi {
    min-height: 102px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
    border: 1px solid var(--me-border);
    border-radius: 18px;
    background: var(--me-surface);
    box-shadow: 0 12px 30px rgba(55, 24, 65, 0.055);
}

.ms-map-kpi__icon {
    width: 47px;
    height: 47px;
    flex: 0 0 47px;
    display: grid;
    place-items: center;
    border-radius: 15px;
    color: var(--me-purple-700);
    background: var(--me-pink-100);
    font-size: 17px;
}

.ms-map-kpi small,
.ms-map-kpi strong,
.ms-map-kpi div > span {
    display: block;
}

.ms-map-kpi small {
    color: var(--me-muted);
    font-size: 11px;
    font-weight: 750;
}

.ms-map-kpi strong {
    margin-top: 5px;
    color: var(--me-purple-950);
    font-size: 24px;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.ms-map-kpi div > span {
    margin-top: 4px;
    color: var(--me-muted);
    font-size: 10px;
}

.ms-map-kpi--featured strong {
    font-size: 16px;
}

.ms-public-map__workspace {
    max-width: 1480px;
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(330px, 0.65fr);
    gap: 18px;
    margin: 0 auto;
}

.ms-map-card,
.ms-map-details {
    overflow: hidden;
    border: 1px solid var(--me-border);
    border-radius: 20px;
    background: var(--me-surface);
    box-shadow: 0 15px 38px rgba(55, 24, 65, 0.07);
}

.ms-map-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 21px 22px 17px;
    border-bottom: 1px solid var(--me-border);
}

.ms-map-card__header > div:first-child > span,
.ms-map-details__header > div > span {
    display: block;
    color: var(--me-pink-500);
    font-size: 10px;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ms-map-card__header h2,
.ms-map-details__header h2 {
    margin: 5px 0 0;
    color: var(--me-purple-950);
    font-size: 20px;
    font-weight: 850;
    letter-spacing: -0.03em;
}

.ms-map-card__header p {
    max-width: 590px;
    margin: 7px 0 0;
    color: var(--me-muted);
    font-size: 12px;
    line-height: 1.55;
}

.ms-map-controls {
    width: min(100%, 340px);
    flex: 0 0 340px;
}

.ms-map-controls label {
    display: block;
    margin-bottom: 7px;
    color: var(--me-purple-950);
    font-size: 11px;
    font-weight: 800;
}

.ms-map-controls__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 43px;
    gap: 8px;
}

.ms-map-controls select {
    width: 100%;
    min-height: 43px;
    padding: 0 36px 0 12px;
    border: 1px solid var(--me-border);
    border-radius: 11px;
    outline: none;
    color: var(--me-text);
    background: #fff;
    font-size: 12px;
}

.ms-map-controls select:focus {
    border-color: var(--me-purple-600);
    box-shadow: 0 0 0 4px rgba(139, 63, 175, 0.1);
}

.ms-map-controls button {
    width: 43px;
    height: 43px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 11px;
    color: var(--me-purple-700);
    background: var(--me-pink-100);
    cursor: pointer;
}

.ms-map-card__body {
    position: relative;
    min-height: 620px;
    background: #fdfbfd;
}

.ms-map-container {
    width: 100%;
    min-height: 620px;
}

.ms-map-loading,
.ms-map-error {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 30px;
    color: var(--me-muted);
    background: rgba(253, 251, 253, 0.95);
    text-align: center;
}

.ms-map-loading i,
.ms-map-error i {
    margin-bottom: 5px;
    color: var(--me-purple-600);
    font-size: 28px;
}

.ms-map-error i,
.ms-map-error strong {
    color: var(--me-danger);
}

.ms-map-error span {
    font-size: 12px;
}

.ms-map-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 20px;
    border-top: 1px solid var(--me-border);
    color: var(--me-muted);
    background: #fcfafc;
    font-size: 10px;
}

.ms-map-card__footer p {
    margin: 0;
}

.ms-map-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.ms-map-legend__gradient {
    width: 150px;
    height: 9px;
    display: block;
    border-radius: 999px;
    background:
        linear-gradient(
            90deg,
            #f7e4f1,
            #e9b7d7,
            #d88fc1,
            #bd62a4,
            #8b3faf
        );
}

.ms-map-details {
    min-height: 720px;
}

.ms-map-details__empty {
    min-height: 720px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 35px;
    text-align: center;
}

.ms-map-details__empty > span {
    width: 65px;
    height: 65px;
    display: grid;
    place-items: center;
    margin-bottom: 14px;
    border-radius: 20px;
    color: var(--me-purple-700);
    background: var(--me-pink-100);
    font-size: 23px;
}

.ms-map-details__empty h2 {
    margin: 0;
    color: var(--me-purple-950);
    font-size: 20px;
    font-weight: 850;
}

.ms-map-details__empty p {
    max-width: 315px;
    margin: 10px 0 0;
    color: var(--me-muted);
    font-size: 12px;
    line-height: 1.6;
}

.ms-map-details__content {
    min-height: 720px;
}

.ms-map-details__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 15px;
    padding: 21px 20px 17px;
    border-bottom: 1px solid var(--me-border);
}

.ms-map-details__header strong {
    flex: 0 0 auto;
    padding: 7px 10px;
    border-radius: 999px;
    color: var(--me-purple-700);
    background: var(--me-pink-100);
    font-size: 10px;
    font-weight: 850;
}

.ms-map-details__loading,
.ms-map-details__error {
    min-height: 575px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 30px;
    color: var(--me-muted);
    text-align: center;
}

.ms-map-details__loading i {
    color: var(--me-purple-600);
    font-size: 25px;
}

.ms-map-details__error i,
.ms-map-details__error strong {
    color: var(--me-danger);
}

.ms-map-details__error span {
    font-size: 11px;
}

.ms-map-statistics {
    padding: 17px;
}

.ms-map-statistics:empty::before {
    min-height: 520px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--me-muted);
    content: "Sin información disponible.";
    font-size: 12px;
    text-align: center;
}

/* Compatibilidad con la respuesta template.incidentTable */
.ms-map-statistics table {
    width: 100% !important;
    margin: 0 !important;
    border-collapse: separate !important;
    border-spacing: 0;
    font-size: 12px;
}

.ms-map-statistics table thead th {
    padding: 11px 10px !important;
    border: 0 !important;
    color: #fff !important;
    background: var(--me-purple-900) !important;
    font-size: 10px;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.ms-map-statistics table thead th:first-child {
    border-radius: 10px 0 0 10px;
}

.ms-map-statistics table thead th:last-child {
    border-radius: 0 10px 10px 0;
}

.ms-map-statistics table tbody td {
    padding: 11px 10px !important;
    border-bottom: 1px solid var(--me-border) !important;
    color: var(--me-text);
    background: #fff !important;
    vertical-align: middle;
}

.ms-map-statistics table tbody tr:hover td {
    background: #fcf8fb !important;
}

.ms-map-statistics h1,
.ms-map-statistics h2,
.ms-map-statistics h3,
.ms-map-statistics h4 {
    color: var(--me-purple-950);
    font-weight: 850;
}

.ms-map-statistics .table-responsive {
    overflow-x: auto;
}

.ms-public-map__notice {
    max-width: 1480px;
    display: flex;
    align-items: flex-start;
    gap: 13px;
    margin: 18px auto 0;
    padding: 16px 18px;
    border: 1px solid rgba(111, 44, 145, 0.15);
    border-radius: 15px;
    color: var(--me-purple-800);
    background: rgba(139, 63, 175, 0.055);
}

.ms-public-map__notice > i {
    margin-top: 3px;
}

.ms-public-map__notice strong {
    display: block;
    font-size: 12px;
}

.ms-public-map__notice p {
    margin: 4px 0 0;
    font-size: 11px;
    line-height: 1.55;
}

@media (max-width: 1120px) {
    .ms-public-map__summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ms-public-map__workspace {
        grid-template-columns: 1fr;
    }

    .ms-map-details,
    .ms-map-details__empty,
    .ms-map-details__content {
        min-height: 400px;
    }
}

@media (max-width: 760px) {
    .ms-public-map {
        padding: 27px 15px 45px;
    }

    .ms-public-map__hero,
    .ms-map-card__header,
    .ms-map-card__footer {
        align-items: stretch;
        flex-direction: column;
    }

    .ms-public-map__home-link,
    .ms-map-controls {
        width: 100%;
        flex-basis: auto;
    }

    .ms-public-map__summary {
        grid-template-columns: 1fr;
    }

    .ms-map-card__body,
    .ms-map-container {
        min-height: 500px;
    }

    .ms-map-legend {
        justify-content: space-between;
    }

    .ms-map-legend__gradient {
        width: min(42vw, 150px);
    }
}
