/* ── Construction section (ЄДЕССБ) ─────────────────────────────────────────────
   Reuses the land section's summary widget (.land-summary*, land.css) and the
   ownership section's tab strip (.group-view-tabs, company.css). */
#construction-section {
    margin-top: 32px;
}

.cx-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 10px;
}

#construction-section a {
    color: var(--color-primary);
    text-decoration: none;
}

#construction-section a:hover {
    text-decoration: underline;
}

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

#construction-tabs {
    margin-bottom: var(--spacing-lg);
}

/* ── KPIs under the status bar ──────────────────────────────────────────────── */
.cx-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
    flex: 1;
}

.cx-kpis--stack {
    grid-template-columns: 1fr 1fr;
}

.cx-kpi {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.cx-kpi-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.cx-kpi-value {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    white-space: nowrap;
}

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

/* ── Layout: map + side column ──────────────────────────────────────────────── */
.cx-grid {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.cx-grid--role {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.cx-side {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    min-width: 0;
}

.cx-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--spacing-lg);
    min-width: 0;
}

.cx-grid .cx-card,
.cx-side .cx-card {
    margin: 0;
}

.cx-card + .cx-card {
    margin-top: 0;
}

.cx-card-title {
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    margin-bottom: var(--spacing-md);
}

.cx-map-card {
    padding: 0;
}

#construction-map {
    width: 100%;
    height: 380px;
}

.cx-chart-wrap {
    position: relative;
    height: 200px;
}

.cx-partner-block + .cx-partner-block {
    margin-top: var(--spacing-md);
}

.cx-partner {
    display: flex;
    justify-content: space-between;
    gap: var(--spacing-md);
    padding: 4px 0;
    font-size: var(--font-size-sm);
    border-bottom: 1px solid var(--color-border-light);
}

.cx-partner:last-child {
    border-bottom: none;
}

.cx-partner > span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Toolbar: status chips + search ─────────────────────────────────────────── */
.cx-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

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

.cx-chip {
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text-secondary);
    border-radius: 999px;
    padding: 4px 12px;
    font: inherit;
    font-size: var(--font-size-sm);
    cursor: pointer;
}

.cx-chip span {
    color: var(--color-text-tertiary);
    margin-left: 4px;
}

.cx-chip.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.cx-chip.active span {
    color: rgba(255, 255, 255, 0.8);
}

.cx-search {
    flex: 0 1 320px;
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: var(--font-size-sm);
}

/* ── Table ──────────────────────────────────────────────────────────────────── */
.cx-table-wrap {
    overflow-x: auto;
}

.cx-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

.cx-table th {
    text-align: left;
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-secondary);
    padding: 8px;
    border-bottom: 2px solid var(--color-border-light);
    white-space: nowrap;
}

.cx-table td {
    text-align: left;
    padding: 8px;
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: top;
}

.cx-row {
    cursor: pointer;
}

.cx-row:hover,
.cx-row.open {
    background: var(--color-bg-light);
}

.cx-num {
    text-align: right !important;
    white-space: nowrap;
}

.cx-nowrap {
    white-space: nowrap;
}

.cx-name {
    min-width: 260px;
    max-width: 520px;
}

.cx-name-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--color-text);
}

.cx-name-sub {
    color: var(--color-text-tertiary);
    font-size: 12px;
    margin-top: 2px;
}

.cx-empty {
    text-align: center;
    color: var(--color-text-tertiary);
    padding: var(--spacing-lg) !important;
}

.cx-cc {
    display: inline-block;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: var(--font-weight-semibold);
    background: var(--color-bg-light);
    color: var(--color-text-secondary);
}

.cx-cc--2 { background: #FFF3E0; color: #B35C00; }
.cx-cc--3 { background: #FDECEA; color: #B71C1C; }

.cx-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    white-space: nowrap;
}

.cx-status--building { background: #FFF3E0; color: #B35C00; }
.cx-status--done     { background: #E8F5E9; color: #1B5E20; }
.cx-status--legal    { background: #E3EDF7; color: #0D3B66; }
.cx-status--cancel   { background: #FDECEA; color: #B71C1C; }
.cx-status--other    { background: var(--color-bg-light); color: var(--color-text-secondary); }

.cx-more {
    text-align: center;
    margin-top: var(--spacing-md);
}

/* ── Expanded row ───────────────────────────────────────────────────────────── */
.cx-detail > td {
    background: var(--color-bg-light);
    padding: var(--spacing-md) var(--spacing-lg) !important;
}

.cx-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--spacing-md) var(--spacing-xl);
}

.cx-detail-grid .cx-detail-block:first-child {
    grid-column: 1 / -1;
}

.cx-detail-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-tertiary);
    margin-bottom: 4px;
}

.cx-doc {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    padding: 2px 0;
}

.cx-doc-date {
    min-width: 80px;
    font-variant-numeric: tabular-nums;
}

.cx-mono {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12px;
}

.cx-locate {
    margin-top: var(--spacing-md);
    font-size: 12px;
}

@media (max-width: 900px) {
    .cx-grid,
    .cx-grid--role {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 700px) {
    .cx-name {
        min-width: 200px;
    }
    .cx-search {
        flex-basis: 100%;
    }
}
