.geo-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.geo-card {
    perspective: 1200px;
}

.geo-card-inner {
    position: relative;
    min-height: 268px;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.geo-card.is-flip .geo-card-inner {
    transform: rotateY(180deg);
}

.geo-face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--card-shadow);
    backface-visibility: hidden;
}

.geo-face-back {
    transform: rotateY(180deg);
}

.geo-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.geo-head h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0;
}

.geo-add,
.geo-back {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: inherit;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition:
        transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
        background 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.geo-back {
    display: grid;
    place-items: center;
}

.geo-back svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.geo-add:hover {
    transform: rotate(90deg);
    background: #1f7a4d;
    border-color: #1f7a4d;
    color: #fff;
    box-shadow: 0 6px 16px rgba(31, 122, 77, 0.28);
}

.geo-add:active {
    transform: rotate(90deg) scale(0.9);
}

.geo-back:hover {
    background: #1f7a4d;
    border-color: #1f7a4d;
    color: #fff;
    box-shadow: 0 6px 16px rgba(31, 122, 77, 0.28);
}

.geo-back:hover svg {
    transform: translateX(-3px);
}

.geo-back:active {
    transform: scale(0.92);
}

.geo-count {
    margin: 6px 0 8px;
    color: var(--muted, var(--text-muted));
    font-size: 11px;
    font-weight: 600;
}

.geo-list {
    display: grid;
    align-content: start;
    gap: 6px;
    max-height: 186px;
    overflow: auto;
    padding-right: 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(31, 122, 77, 0.35) transparent;
}

.geo-list::-webkit-scrollbar {
    width: 4px;
}

.geo-list::-webkit-scrollbar-thumb {
    background: rgba(31, 122, 77, 0.35);
    border-radius: 99px;
}

.geo-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
    align-items: center;
    padding: 7px 8px 7px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    cursor: pointer;
}

.geo-item:hover,
.geo-item.is-hot {
    border-color: var(--primary, #1f7a4d);
}

.geo-item.is-off {
    opacity: 0.55;
}

.geo-item strong {
    display: block;
    font-size: 12px;
}

.geo-item small {
    display: block;
    color: var(--muted, var(--text-muted));
    font-size: 10px;
}

.geo-item-actions {
    display: flex;
    gap: 2px;
}

.geo-form {
    display: grid;
    gap: 10px;
    margin-top: 12px;
    min-width: 0;
}

.geo-form .field,
.geo-form .field-control,
.geo-form .field-select {
    min-width: 0;
}

/* Formularios compactos y consistentes para conservar las tres tarjetas
   en la misma altura sin que sus controles se desborden. */
.geo-card .geo-face {
    padding: 12px;
}

.geo-card .geo-form {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 6px;
    margin-top: 9px;
}

.geo-card .field {
    gap: 3px;
}

.geo-card .field-label {
    min-height: 14px;
    font-size: 11px;
    line-height: 14px;
}

.geo-card .field-control,
.geo-card .field-select,
.geo-card .select-picker-trigger {
    height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 12px;
}

.geo-card .geo-form-actions .primary-button {
    padding: 8px 12px;
    font-size: 12px;
}

.geo-form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: auto;
    padding-top: 4px;
}

.geo-join .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

#tblTerritorioBody tr.is-hot td,
#tblEstructuraBody tr.is-hot td {
    background: rgba(31, 122, 77, 0.1);
}

#registrosEstructura table {
    table-layout: fixed;
}

#registrosEstructura th,
#registrosEstructura td {
    width: 50%;
    text-align: center;
    white-space: normal;
}

@media (max-width: 1100px) {
    .geo-grid {
        grid-template-columns: 1fr;
    }

    .geo-card-inner {
        min-height: 268px;
    }
}

#mantenedorGeo .geo-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 860px) {
    #mantenedorGeo .geo-grid {
        grid-template-columns: 1fr;
    }
}
