/* Calculator Modal Overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.modal-overlay.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

.modal-container {
    background: #ffffff;
    border-radius: 16px;
    width: min(780px, 96vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    animation: modalSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideIn {
    from { transform: translateY(16px) scale(0.97); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fafafa;
}

.modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 800;
    color: #0f172a;
}

.modal-title svg {
    color: var(--red);
}

.modal-close {
    border: 0;
    background: transparent;
    font-size: 24px;
    color: #64748b;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    border-radius: 6px;
}

.modal-close:hover {
    color: #0f172a;
    background: #e2e8f0;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.calc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.calc-inputs h4, .calc-results h4 {
    font-size: 14px;
    font-weight: 750;
    color: var(--red);
    margin: 0 0 14px;
    padding-bottom: 6px;
    border-bottom: 1.5px solid #fee2e2;
}

.calc-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.calc-form-group label {
    font-size: 12.5px;
    font-weight: 700;
    color: #334155;
}

.calc-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.calc-results {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 18px;
    display: flex;
    flex-direction: column;
}

.primary-result {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    color: #ffffff;
    padding: 18px;
    border-radius: 12px;
    margin-bottom: 16px;
    text-align: center;
}

.res-label {
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
}

.res-val {
    font-size: 32px;
    font-weight: 900;
    color: #38bdf8;
    margin: 6px 0 4px;
}

.res-val small {
    font-size: 14px;
    font-weight: 600;
    color: #cbd5e1;
}

.res-sub {
    font-size: 12px;
    color: #94a3b8;
}

.res-sub strong {
    color: #ffffff;
}

.result-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #475569;
    padding-bottom: 6px;
    border-bottom: 1px dashed #e2e8f0;
}

.detail-row strong {
    color: #0f172a;
    font-weight: 750;
}

.detail-row.highlight-row {
    border-bottom: 0;
    padding-top: 4px;
    color: var(--red);
    font-weight: 700;
}

.detail-row.highlight-row strong {
    color: var(--red);
    font-size: 15px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e2e8f0;
    background: #fafafa;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.btn-calc-done,
.modal-footer .button-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 24px;
    background: #e30613;
    color: #ffffff;
    border: none;
    border-radius: 9px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(227, 6, 19, 0.28);
    transition: background 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
    margin-left: auto;
}

.btn-calc-done:hover,
.modal-footer .button-primary:hover {
    background: #b70710;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(183, 7, 16, 0.38);
}

.btn-calc-done:active,
.modal-footer .button-primary:active {
    transform: translateY(0);
}

.modal-footer .button-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 18px;
    background: #ffffff;
    color: #334155;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.modal-footer .button-outline:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #0f172a;
}

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