/* contracts-stats.php — аналитика по городам (GSE-бренд) */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800&display=swap');

body.gdi-contracts-stats-page {
    background: var(--gse-bg, #f3eef8) !important;
}

.gdi-city-stats {
    font-family: 'Montserrat', 'Segoe UI', system-ui, sans-serif;
    color: var(--gse-text, #1f1937);
    padding-bottom: 3rem;
}

.gdi-city-stats__hero {
    position: relative;
    overflow: hidden;
    border-radius: var(--gse-radius, 16px);
    background: var(--gse-hero, linear-gradient(135deg, #ffffff 0%, #f7f4fc 48%, #efe8ff 100%));
    border: 1px solid var(--gse-border, #e8e4f0);
    box-shadow: var(--gse-shadow, 0 10px 28px rgba(91, 33, 182, 0.07));
    padding: 1.75rem 1.5rem 1.6rem;
    margin-bottom: 1.25rem;
}

.gdi-city-stats__hero-copy {
    position: relative;
    z-index: 1;
    max-width: 42rem;
}

.gdi-city-stats__eyebrow {
    margin: 0 0 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--gse-primary, #6a1b9a);
}

.gdi-city-stats__title {
    margin: 0 0 0.55rem;
    font-size: clamp(1.55rem, 3.2vw, 2.15rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.gdi-city-stats__lead {
    margin: 0 0 1.1rem;
    color: var(--gse-muted, #7a7490);
    font-size: 0.98rem;
    line-height: 1.55;
    font-weight: 500;
}

.gdi-city-stats__hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.gdi-city-stats .gse-btn--ghost {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.65rem 1.05rem;
    border-radius: 999px;
    border: 1px solid var(--gse-border, #e8e4f0);
    background: #fff;
    color: var(--gse-text, #1f1937);
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
    transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.gdi-city-stats .gse-btn--ghost:hover {
    border-color: var(--gse-primary, #6a1b9a);
    color: var(--gse-primary, #6a1b9a);
    transform: translateY(-1px);
}

.gdi-city-stats__hero-glow {
    position: absolute;
    right: -8%;
    top: -40%;
    width: 48%;
    height: 160%;
    background:
        radial-gradient(circle at 40% 50%, rgba(106, 27, 154, 0.18), transparent 62%),
        radial-gradient(circle at 70% 40%, rgba(91, 33, 182, 0.12), transparent 55%);
    pointer-events: none;
    animation: gdiCityStatsGlow 8s ease-in-out infinite alternate;
}

@keyframes gdiCityStatsGlow {
    from { transform: translate3d(0, 0, 0) scale(1); opacity: 0.85; }
    to { transform: translate3d(-12px, 8px, 0) scale(1.06); opacity: 1; }
}

.gdi-city-stats__search {
    position: relative;
    margin-bottom: 1.25rem;
    background: var(--gse-surface, #fff);
    border: 1px solid var(--gse-border, #e8e4f0);
    border-radius: var(--gse-radius, 16px);
    box-shadow: var(--gse-shadow, 0 10px 28px rgba(91, 33, 182, 0.07));
    padding: 1rem 1.15rem 1.05rem;
}

.gdi-city-stats__search-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gse-muted, #7a7490);
    margin-bottom: 0.45rem;
}

.gdi-city-stats__search-row {
    display: flex;
    gap: 0.55rem;
    align-items: stretch;
}

.gdi-city-stats__search-input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--gse-border, #e8e4f0);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--gse-text, #1f1937);
    background: #faf8fc;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.gdi-city-stats__search-input:focus {
    border-color: var(--gse-primary, #6a1b9a);
    box-shadow: 0 0 0 3px rgba(106, 27, 154, 0.12);
    background: #fff;
}

.gdi-city-stats__search-clear {
    border: 1px solid var(--gse-border, #e8e4f0);
    background: #fff;
    border-radius: 12px;
    padding: 0 1rem;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--gse-muted, #7a7490);
    cursor: pointer;
}

.gdi-city-stats__search-clear:hover {
    color: var(--gse-primary, #6a1b9a);
    border-color: var(--gse-primary, #6a1b9a);
}

.gdi-city-stats__search-results {
    position: absolute;
    left: 1.15rem;
    right: 1.15rem;
    top: calc(100% - 0.35rem);
    z-index: 40;
    background: #fff;
    border: 1px solid var(--gse-border, #e8e4f0);
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(31, 25, 55, 0.14);
    max-height: 320px;
    overflow: auto;
    padding: 0.35rem;
}

.gdi-city-stats__search-item {
    display: grid;
    grid-template-columns: 4.5rem 1fr auto;
    gap: 0.65rem;
    align-items: center;
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
}

.gdi-city-stats__search-item:hover {
    background: #f7f2ff;
}

.gdi-city-stats__search-item-type {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gse-primary, #6a1b9a);
}

.gdi-city-stats__search-item-name {
    font-weight: 700;
    color: var(--gse-text, #1f1937);
}

.gdi-city-stats__search-item-meta {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--gse-muted, #7a7490);
    white-space: nowrap;
}

.gdi-city-stats__search-empty {
    padding: 0.9rem 1rem;
    color: var(--gse-muted, #7a7490);
    font-weight: 600;
    font-size: 0.9rem;
}

.gdi-city-stats__kpi {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}

.gdi-city-stats__growth-controls {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: min(100%, 280px);
}

.gdi-city-stats__growth-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gse-muted, #7a7490);
}

.gdi-city-stats__growth-select {
    border: 1px solid var(--gse-border, #e8e4f0);
    border-radius: 12px;
    padding: 0.65rem 0.9rem;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--gse-text, #1f1937);
    background: #fff;
    cursor: pointer;
}

.gdi-city-stats__chart-card--wide {
    margin-top: 0.15rem;
}

.gdi-city-stats__chart-wrap--tall {
    height: 320px;
}

.gdi-city-stats__place-btn {
    border: 0;
    background: none;
    padding: 0;
    color: var(--gse-primary, #6a1b9a);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-align: left;
}

.gdi-city-stats__place-btn:hover {
    text-decoration: underline;
}

.gdi-city-stats__row-click {
    cursor: pointer;
}

body.gdi-city-stats-modal-open {
    overflow: hidden;
}

.gdi-city-stats-modal {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.gdi-city-stats-modal[hidden] {
    display: none !important;
}

.gdi-city-stats-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 14, 40, 0.55);
    backdrop-filter: blur(3px);
    animation: gdiCityStatsFade 0.2s ease;
}

.gdi-city-stats-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(720px, 100%);
    max-height: min(92vh, 900px);
    overflow: auto;
    background: linear-gradient(165deg, #ffffff 0%, #faf7ff 100%);
    border: 1px solid var(--gse-border, #e8e4f0);
    border-radius: 20px;
    box-shadow: 0 28px 70px rgba(31, 25, 55, 0.28);
    padding: 1.35rem 1.35rem 1.2rem;
    animation: gdiCityStatsPop 0.28s cubic-bezier(0.2, 0.85, 0.25, 1);
}

@keyframes gdiCityStatsFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes gdiCityStatsPop {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.gdi-city-stats-modal__close {
    position: absolute;
    top: 0.75rem;
    right: 0.85rem;
    width: 2.2rem;
    height: 2.2rem;
    border: 0;
    border-radius: 999px;
    background: #f3eef8;
    color: #1f1937;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.gdi-city-stats-modal__close:hover {
    background: #ebe3f7;
}

.gdi-city-stats-modal__eyebrow {
    margin: 0 0 0.25rem;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--gse-primary, #6a1b9a);
}

.gdi-city-stats-modal__title {
    margin: 0 0 1rem;
    padding-right: 2rem;
    font-size: clamp(1.35rem, 3vw, 1.75rem);
    font-weight: 800;
    letter-spacing: -0.02em;
}

.gdi-city-stats-modal__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
    margin-bottom: 1.1rem;
}

.gdi-city-stats-modal__cell {
    background: #fff;
    border: 1px solid var(--gse-border, #e8e4f0);
    border-radius: 14px;
    padding: 0.75rem 0.85rem;
}

.gdi-city-stats-modal__cell-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--gse-muted, #7a7490);
    margin-bottom: 0.25rem;
}

.gdi-city-stats-modal__cell-value {
    display: block;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--gse-text, #1f1937);
}

.gdi-city-stats-modal__chart-wrap {
    background: #fff;
    border: 1px solid var(--gse-border, #e8e4f0);
    border-radius: 14px;
    padding: 0.85rem 0.9rem 0.65rem;
    height: 240px;
    margin-bottom: 1rem;
}

.gdi-city-stats-modal__chart-wrap canvas {
    max-height: 180px;
}

.gdi-city-stats-modal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.gdi-city-stats__kpi-card {
    background: var(--gse-surface, #fff);
    border: 1px solid var(--gse-border, #e8e4f0);
    border-radius: var(--gse-radius, 16px);
    box-shadow: var(--gse-shadow, 0 10px 28px rgba(91, 33, 182, 0.07));
    padding: 1.05rem 1.1rem 1rem;
    min-height: 7.2rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gdi-city-stats__kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(91, 33, 182, 0.1);
}

.gdi-city-stats__kpi-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--gse-muted, #7a7490);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}

.gdi-city-stats__kpi-value {
    display: block;
    font-size: clamp(1.35rem, 2.4vw, 1.85rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--gse-text, #1f1937);
    line-height: 1.2;
}

.gdi-city-stats__kpi-hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--gse-muted, #7a7490);
    font-weight: 500;
    line-height: 1.35;
}

.gdi-city-stats__kpi-card.is-skeleton .gdi-city-stats__kpi-value {
    color: transparent;
    background: linear-gradient(90deg, #eee 25%, #f7f4fc 50%, #eee 75%);
    background-size: 200% 100%;
    animation: gdiCityStatsShimmer 1.2s linear infinite;
    border-radius: 8px;
    min-height: 1.6rem;
}

@keyframes gdiCityStatsShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.gdi-city-stats__section {
    margin-bottom: 1.75rem;
}

.gdi-city-stats__section-head {
    margin-bottom: 0.85rem;
}

.gdi-city-stats__section-head--row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem 1rem;
}

.gdi-city-stats__h2 {
    margin: 0 0 0.25rem;
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.gdi-city-stats__h3 {
    margin: 0 0 0.65rem;
    font-size: 0.92rem;
    font-weight: 700;
}

.gdi-city-stats__section-lead {
    margin: 0;
    color: var(--gse-muted, #7a7490);
    font-size: 0.88rem;
    font-weight: 500;
}

.gdi-city-stats__charts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.85rem;
}

.gdi-city-stats__chart-card {
    background: var(--gse-surface, #fff);
    border: 1px solid var(--gse-border, #e8e4f0);
    border-radius: var(--gse-radius, 16px);
    box-shadow: var(--gse-shadow, 0 10px 28px rgba(91, 33, 182, 0.07));
    padding: 1rem 1rem 0.75rem;
}

.gdi-city-stats__chart-wrap {
    position: relative;
    height: 280px;
}

.gdi-city-stats__table-wrap {
    overflow: auto;
    background: var(--gse-surface, #fff);
    border: 1px solid var(--gse-border, #e8e4f0);
    border-radius: var(--gse-radius, 16px);
    box-shadow: var(--gse-shadow, 0 10px 28px rgba(91, 33, 182, 0.07));
}

.gdi-city-stats__table {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
    font-size: 0.9rem;
}

.gdi-city-stats__table th,
.gdi-city-stats__table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gse-border, #e8e4f0);
    white-space: nowrap;
}

.gdi-city-stats__table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gse-muted, #7a7490);
    font-weight: 700;
    background: #faf8fc;
    position: sticky;
    top: 0;
}

.gdi-city-stats__table tbody tr {
    transition: background 0.15s ease;
}

.gdi-city-stats__table tbody tr:hover {
    background: #faf7ff;
}

.gdi-city-stats__table a {
    color: var(--gse-primary, #6a1b9a);
    font-weight: 700;
    text-decoration: none;
}

.gdi-city-stats__table a:hover {
    text-decoration: underline;
}

.gdi-city-stats__table .is-skeleton-row td {
    color: var(--gse-muted, #7a7490);
    font-weight: 600;
}

.gdi-city-stats__metric-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.25rem;
    background: #fff;
    border: 1px solid var(--gse-border, #e8e4f0);
    border-radius: 999px;
}

.gdi-city-stats__tab {
    border: 0;
    background: transparent;
    color: var(--gse-muted, #7a7490);
    font-family: inherit;
    font-weight: 700;
    font-size: 0.82rem;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.gdi-city-stats__tab.is-active {
    background: var(--gse-primary, #6a1b9a);
    color: #fff;
}

.gdi-city-stats__map-shell {
    position: relative;
    background: var(--gse-surface, #fff);
    border: 1px solid var(--gse-border, #e8e4f0);
    border-radius: var(--gse-radius, 16px);
    box-shadow: var(--gse-shadow, 0 10px 28px rgba(91, 33, 182, 0.07));
    overflow: hidden;
}

.gdi-city-stats__map {
    height: min(62vh, 520px);
    min-height: 360px;
    width: 100%;
    background: #e9e4f2;
}

.gdi-city-stats__map-legend {
    position: absolute;
    left: 12px;
    bottom: 44px;
    z-index: 500;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.7rem;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--gse-border, #e8e4f0);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gse-muted, #7a7490);
}

.gdi-city-stats__legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.gdi-city-stats__legend-dot--low {
    background: rgba(106, 27, 154, 0.25);
    box-shadow: 0 0 0 2px rgba(106, 27, 154, 0.15);
}

.gdi-city-stats__legend-dot--high {
    background: rgba(106, 27, 154, 0.9);
    box-shadow: 0 0 0 2px rgba(106, 27, 154, 0.25);
}

.gdi-city-stats__map-note {
    margin: 0;
    padding: 0.55rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gse-muted, #7a7490);
    border-top: 1px solid var(--gse-border, #e8e4f0);
    background: #faf8fc;
}

.gdi-city-stats__stamp {
    margin: 0.5rem 0 0;
    font-size: 0.75rem;
    color: var(--gse-muted, #7a7490);
    font-weight: 500;
}

.gdi-city-stats__error {
    margin: 1rem 0;
    padding: 0.9rem 1rem;
    border-radius: 12px;
    background: #fff5f5;
    border: 1px solid #f3c6c6;
    color: #8a1f1f;
    font-weight: 600;
}

@media (max-width: 1100px) {
    .gdi-city-stats__charts {
        grid-template-columns: 1fr;
    }
    .gdi-city-stats__chart-wrap {
        height: 240px;
    }
}

@media (max-width: 1100px) {
    .gdi-city-stats__kpi {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .gdi-city-stats__kpi {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .gdi-city-stats-modal__grid {
        grid-template-columns: 1fr;
    }
    .gdi-city-stats__search-item {
        grid-template-columns: 1fr;
        gap: 0.2rem;
    }
}

@media (max-width: 560px) {
    .gdi-city-stats__hero {
        padding: 1.25rem 1rem 1.2rem;
    }
    .gdi-city-stats__kpi {
        grid-template-columns: 1fr 1fr;
        gap: 0.65rem;
    }
    .gdi-city-stats__map {
        min-height: 300px;
        height: 360px;
    }
    .gdi-city-stats__chart-wrap--tall {
        height: 260px;
    }
}
