/* ── National construction map (/construction) ─────────────────────────────────
   Side panel + MapLibre map. Status colors, chips, status pills and document
   rows come from construction.css. */
.cxm {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    height: calc(100vh - 150px);
    min-height: 640px;
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.cxm a {
    color: var(--color-primary);
    text-decoration: none;
}

.cxm a:hover {
    text-decoration: underline;
}

.cxm-muted {
    color: var(--color-text-tertiary);
    font-size: var(--font-size-sm);
}

/* ── Side panel ─────────────────────────────────────────────────────────────── */
.cxm-side {
    overflow-y: auto;
    padding: 20px 20px 24px;
    border-right: 1px solid var(--color-border-light);
}

.cxm-title {
    text-align: left;
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    margin: 0;
}

.cxm-asof {
    margin-top: 2px;
    font-size: var(--font-size-sm);
    color: var(--color-text-tertiary);
}

.cxm-search {
    position: relative;
    margin-top: 16px;
}

.cxm-search input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md, 8px);
    font: inherit;
    font-size: var(--font-size-md);
}

.cxm-search input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.cxm-dropdown {
    position: absolute;
    z-index: 5;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 320px;
    overflow-y: auto;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.cxm-dropdown button {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    font: inherit;
    font-size: var(--font-size-md);
    text-align: left;
    cursor: pointer;
}

.cxm-dropdown button:hover {
    background: var(--color-bg-light);
}

.cxm-dropdown-empty {
    padding: 10px 12px;
    color: var(--color-text-tertiary);
    font-size: var(--font-size-sm);
}

.cxm-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 10px 8px 12px;
    background: var(--color-primary-light);
    border-radius: var(--radius-md, 8px);
}

.cxm-pill-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.cxm-pill-name {
    font-weight: var(--font-weight-semibold);
    color: var(--color-primary-dark);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cxm-pill-close {
    border: none;
    background: none;
    font-size: 20px;
    line-height: 1;
    color: var(--color-primary-dark);
    cursor: pointer;
    padding: 0 4px;
}

.cxm-hero {
    display: flex;
    flex-direction: column;
    margin: 20px 0 4px;
}

.cxm-hero-value {
    font-size: 34px;
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.cxm-hero-label {
    font-size: var(--font-size-md);
    color: var(--color-text-secondary);
}

.cxm-hero-sub {
    font-size: var(--font-size-sm);
    color: var(--color-text-tertiary);
}

.cxm-block {
    margin-top: 20px;
}

.cxm-block-title--row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* Active-only / all switch next to the status title */
.cxm-seg {
    display: flex;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    overflow: hidden;
}

.cxm-seg button {
    border: none;
    background: none;
    padding: 3px 9px;
    font: inherit;
    font-size: 11px;
    text-transform: none;
    letter-spacing: 0;
    color: var(--color-text-secondary);
    cursor: pointer;
}

.cxm-seg button + button {
    border-left: 1px solid var(--color-border);
}

.cxm-seg button.active {
    background: #1A1A2E;
    color: #FFFFFF;
}

.cxm-block--row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 16px;
}

.cxm-block-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-tertiary);
    margin-bottom: 8px;
}

/* Status rows: toggles with a bar of their share */
.cxm-status-row {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) 70px 56px;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 5px 6px;
    margin: 0 -6px;
    border: none;
    border-radius: 6px;
    background: none;
    font: inherit;
    font-size: var(--font-size-md);
    text-align: left;
    cursor: pointer;
    box-sizing: content-box;
}

.cxm-status-row:hover,
.cxm-status-row.on {
    background: var(--color-bg-light);
}

.cxm-status-row.off {
    opacity: 0.4;
}

.cxm-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.cxm-status-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cxm-status-bar {
    height: 6px;
    background: var(--color-bg-light);
    border-radius: 3px;
    overflow: hidden;
}

.cxm-status-bar i {
    display: block;
    height: 100%;
    border-radius: 3px;
}

.cxm-status-n {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--color-text-secondary);
}

.cxm-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cxm-period {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--color-text-tertiary);
}

.cxm-period select {
    padding: 4px 6px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: var(--font-size-sm);
    background: var(--color-bg);
}

.cxm-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    font-size: var(--font-size-md);
    color: var(--color-text-secondary);
    cursor: pointer;
}

.cxm-chart {
    position: relative;
    height: 170px;
}

/* Top developers */
.cxm-dev {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 8px;
    padding: 7px 0;
    border-bottom: 1px solid var(--color-border-light);
}

.cxm-dev:last-child {
    border-bottom: none;
}

.cxm-dev-name {
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    font-size: var(--font-size-md);
    color: var(--color-text);
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cxm-dev-name:hover {
    color: var(--color-primary);
}

.cxm-dev-n {
    font-weight: var(--font-weight-semibold);
    font-variant-numeric: tabular-nums;
}

.cxm-dev-bar {
    grid-column: 1 / -1;
    position: relative;
    height: 4px;
    background: var(--color-bg-light);
    border-radius: 2px;
}

.cxm-dev-bar i,
.cxm-dev-bar b {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    border-radius: 2px;
}

.cxm-dev-bar i { background: #F9C98F; }
.cxm-dev-bar b { background: var(--color-success); }

.cxm-dev-sub {
    grid-column: 1 / -1;
}

/* Object card */
.cxm-back {
    border: none;
    background: none;
    padding: 0;
    margin-bottom: 14px;
    font: inherit;
    font-size: var(--font-size-md);
    color: var(--color-primary);
    cursor: pointer;
}

.cxm-obj-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.cxm-obj-name {
    margin: 10px 0 4px;
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    line-height: 1.35;
    color: var(--color-text);
}

.cxm-obj-place {
    font-size: var(--font-size-md);
    color: var(--color-text-secondary);
    margin-bottom: 10px;
}

.cxm-facts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
    margin: 16px 0 4px;
}

.cxm-facts div {
    display: flex;
    flex-direction: column;
}

.cxm-facts span {
    font-size: var(--font-size-sm);
    color: var(--color-text-tertiary);
}

.cxm-facts b {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
}

.cxm-obj-block {
    margin-top: 18px;
    font-size: var(--font-size-md);
}

/* ── Map ────────────────────────────────────────────────────────────────────── */
.cxm-map-wrap {
    position: relative;
    min-width: 0;
}

#cxm-map {
    position: absolute;
    inset: 0;
}

.cxm-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: var(--color-primary);
    opacity: 0;
    z-index: 2;
    transition: opacity 0.2s;
}

.cxm-progress.active {
    opacity: 1;
    animation: cxm-progress 1.2s ease-in-out infinite;
}

@keyframes cxm-progress {
    0%   { left: 0;   width: 0; }
    50%  { left: 20%; width: 60%; }
    100% { left: 100%; width: 0; }
}

.cxm-modes {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    display: flex;
    background: var(--color-bg);
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}

.cxm-modes button {
    border: none;
    background: none;
    padding: 7px 14px;
    font: inherit;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
    cursor: pointer;
}

.cxm-modes button.active {
    background: #1A1A2E;
    color: #FFFFFF;
}

.cxm-empty {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.85);
    color: var(--color-text-secondary);
    font-size: var(--font-size-lg);
}

.cxm-empty[hidden] {
    display: none;
}

.cxm-cluster {
    cursor: pointer;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.25));
    transition: transform 0.12s;
}

.cxm-cluster:hover {
    transform: scale(1.08);
    z-index: 1;
}

.cxm-cluster text {
    font-family: var(--font-family);
    font-weight: 700;
    fill: #1A1A2E;
}

.cxm-popup .maplibregl-popup-content {
    padding: 8px 10px;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    font-size: var(--font-size-sm);
}

.cxm-tip-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
}

.cxm-tip-status i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.cxm-tip-sub {
    color: var(--color-text-secondary);
}

.cxm-tip-hint {
    color: var(--color-text-tertiary);
    font-size: 11px;
    margin-top: 2px;
}

@media (max-width: 900px) {
    .cxm {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: 60vh auto;
        height: auto;
        min-height: 0;
    }
    .cxm-map-wrap {
        order: -1;
    }
    .cxm-side {
        border-right: none;
        border-top: 1px solid var(--color-border-light);
        overflow: visible;
    }
}
