/* Modal Component */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease-in-out;
    backdrop-filter: blur(2px);
}

.modal-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.2s ease-in-out;
    display: flex;
    flex-direction: column;
}

dialog.modal:not([open]) {
    display: none;
}

dialog.modal[open] {
    display: flex;
}

.modal-overlay.is-open .modal {
    transform: scale(1);
}

.modal__header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
}

.modal__close {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal__close:hover {
    background-color: var(--gray-100);
    color: var(--gray-600);
}

.modal__body {
    padding: 1.5rem;
    color: var(--gray-600);
    font-size: var(--font-size-sm);
    line-height: 1.5;
}

.modal__footer {
    padding: 1.5rem;
    background-color: var(--gray-50);
    border-top: 1px solid var(--gray-100);
    border-bottom-left-radius: var(--border-radius-lg);
    border-bottom-right-radius: var(--border-radius-lg);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Modal Large Variant */
.modal__content--lg {
    max-width: 1040px;
    width: 100%;
}

/* Modal Info Grid */
.modal-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.modal-info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.modal-info-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
}

.modal-info-value {
    font-size: 0.9rem;
    color: var(--gray-900);
    font-weight: 500;
}

/* Modal Sections */
.modal-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--gray-100);
}

.modal-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.modal-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 1rem;
}

/* Financial Grid */
.modal-financial-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.financial-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background-color: var(--gray-50);
    border-radius: var(--border-radius);
}

.financial-item--highlight {
    grid-column: 1 / -1;
    background-color: var(--primary-50);
    border-left: 3px solid var(--primary-500);
    font-weight: 600;
}

.financial-item--sub {
    background-color: white;
    border: 1px solid var(--gray-200);
    font-size: 0.875rem;
}

.financial-item--sub .financial-label {
    color: var(--gray-600);
}

.financial-label {
    font-size: 0.875rem;
    color: var(--gray-700);
}

.financial-value {
    font-weight: 600;
    color: var(--gray-900);
}

/* Rentability Section */
.modal-rentability {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rentability-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: linear-gradient(135deg, var(--success-50) 0%, var(--success-100) 100%);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--success-500);
}

.rentability-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--success-700);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rentability-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success-900);
}

/* Grupo Modal Layout */
.grupo-modal .modal__body {
    background: linear-gradient(135deg, rgba(248, 250, 252, 0.8), rgba(255, 255, 255, 0.9));
}

.grupo-modal__layout {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(280px, 0.9fr);
    gap: 1.5rem;
}

.grupo-modal__column--primary {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.grupo-modal__column--side {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (max-width: 960px) {
    .grupo-modal__layout {
        grid-template-columns: 1fr;
    }

    .grupo-modal__column--side {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .grupo-summary-card {
        flex: 1 1 280px;
    }
}

.grupo-panel {
    background: #fff;
    border-radius: 1rem;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--gray-100);
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
}

.grupo-panel--info {
    padding-bottom: 1rem;
}

.grupo-panel__header {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.grupo-panel__header--split {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
}

.grupo-panel__header h3 {
    margin: 0;
    font-size: 1.05rem;
    color: var(--gray-900);
}

.grupo-panel__hint {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.grupo-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
}

.grupo-info__label {
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: var(--gray-500);
    margin-bottom: 0.25rem;
}

.grupo-info__value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--gray-900);
}

.grupo-costs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.grupo-cost-card {
    border-radius: 0.9rem;
    border: 1px solid var(--gray-100);
    padding: 1rem;
    background: var(--gray-0, #fff);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.03);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.grupo-cost-card--primary {
    grid-column: span 2;
    background: linear-gradient(135deg, rgba(224, 231, 255, 0.7), rgba(247, 244, 255, 0.95));
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 20px 35px rgba(79, 70, 229, 0.15);
}

.grupo-cost-card__label {
    font-size: 0.85rem;
    color: var(--gray-600);
}

.grupo-cost-card__value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gray-900);
}

.grupo-cost-card__meta {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.grupo-summary-card {
    border-radius: 1rem;
    padding: 1.5rem;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 18px 35px rgba(15, 23, 42, 0.12);
}

.grupo-summary-card--meta {
    padding: 1.25rem;
}

.grupo-summary__eyebrow {
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gray-500);
    margin-bottom: 0.5rem;
}

.grupo-summary__value {
    font-size: clamp(2rem, 3vw, 2.75rem);
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
}

.grupo-summary__subtitle {
    margin: 0.25rem 0;
    color: var(--gray-600);
    font-size: 0.95rem;
}

.grupo-summary__footnote {
    display: block;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.grupo-summary__metrics {
    margin-top: 0.75rem;
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--gray-600);
}

.grupo-summary__metrics strong {
    color: var(--gray-900);
    margin-right: 0.25rem;
}

.grupo-meta-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.grupo-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.grupo-meta-label {
    color: var(--gray-500);
}

.grupo-meta-value {
    font-weight: 600;
    color: var(--gray-900);
}

.modal-rentability small {
    display: block;
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.5rem;
    font-style: italic;
}

/* Table Compact Variant for Modal */
.table--compact {
    font-size: 0.875rem;
}

.table--compact th,
.table--compact td {
    padding: 0.5rem 0.75rem;
}

.table--compact thead {
    background-color: var(--gray-50);
}

/* Materiales List */
#modal-materiales-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#modal-materiales-list li {
    padding: 0.5rem 0.75rem;
    border-left: 3px solid var(--primary-500);
    background-color: var(--gray-50);
    margin-bottom: 0.5rem;
    border-radius: var(--border-radius);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .modal__content--lg {
        max-width: 95%;
    }

    .modal-financial-grid {
        grid-template-columns: 1fr;
    }

    .financial-item--highlight {
        grid-column: 1;
    }

    .rentability-value {
        font-size: 1.25rem;
    }
}
