/* ========= Base Styles (Mobile First) ========= */

#dre-root {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
    box-sizing: border-box;
}

.dre-container {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    border: 1px solid #083141;
    padding: 16px;
    border-radius: 12px;
    background: #ffffff;
    width: 100%;
    box-sizing: border-box;
}

.dre-step {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e1e1e1;
}

.dre-step:last-child {
    border-bottom: none;
}

.dre-step h2 {
    margin: 0 0 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: #083141;
}

.dre-step-description {
    font-size: 0.9rem;
    color: #666;
    margin: 0 0 16px;
    line-height: 1.5;
    font-style: italic;
}

.dre-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 12px;
}

.dre-input-group {
    display: flex;
    flex-direction: column;
}

.dre-label {
    font-weight: 600;
    display: block;
    margin-bottom: 6px;
    color: #333;
    font-size: 0.9rem;
}

.dre-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #aaa;
    border-radius: 6px;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.dre-input:focus {
    outline: none;
    border-color: #083141;
    box-shadow: 0 0 0 2px rgba(8, 49, 65, 0.1);
}

.dre-help-text {
    font-size: 0.875rem;
    color: #666;
    margin: 0 0 12px;
    font-style: italic;
}

/* ========= Summary Section ========= */

.dre-summary-section {
    margin: 32px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e1e1e1;
}

.dre-summary-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.dre-summary-card {
    background: #ffffff;
    border: 1px solid #083141;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.dre-summary-card.dre-summary-highlight {
    border: 2px solid #2e7d32;
    background: #f1f8f4;
}

.dre-summary-label {
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dre-summary-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #083141;
    margin-bottom: 4px;
}

.dre-summary-subtext {
    font-size: 0.8rem;
    color: #666;
    margin-top: 4px;
}

.dre-badge {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 6px;
    display: inline-block;
    font-weight: 600;
    font-size: 0.95rem;
}

.dre-badge-success {
    background: #d7f6e3;
    color: #0a6b34;
    border: 1px solid #0a6b34;
}

.dre-badge-fail {
    background: #ffe6e6;
    color: #a30000;
    border: 1px solid #a30000;
}

/* ========= Breakdown Section ========= */

.dre-breakdown-section {
    margin: 32px 0;
}

.dre-section-title {
    margin: 0 0 20px;
    font-size: 1.5rem;
    font-weight: 700;
    color: #083141;
}

.dre-breakdown-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.dre-breakdown-card {
    background: #f8f9fa;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    padding: 20px;
}

.dre-breakdown-card h3 {
    margin: 0 0 16px;
    font-size: 1.2rem;
    font-weight: 700;
    color: #083141;
}

.dre-breakdown-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #e1e1e1;
    font-size: 0.95rem;
}

.dre-breakdown-item:last-of-type {
    border-bottom: none;
}

.dre-breakdown-item span {
    color: #666;
}

.dre-breakdown-item strong {
    color: #083141;
    font-weight: 600;
}

.dre-breakdown-total {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    margin-top: 12px;
    border-top: 2px solid #083141;
    font-size: 1.05rem;
    font-weight: 600;
}

.dre-breakdown-total span {
    color: #083141;
}

.dre-breakdown-total strong {
    color: #083141;
    font-size: 1.15rem;
}

/* ========= Charts Section ========= */

.dre-charts-section {
    margin: 32px 0;
}

.dre-charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-top: 20px;
    width: 100%;
    box-sizing: border-box;
}

.dre-chart-card {
    background: #ffffff;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.dre-chart-card h3 {
    margin: 0 0 8px;
    font-size: 1.2rem;
    font-weight: 700;
    color: #083141;
}

.dre-chart-description {
    font-size: 0.875rem;
    color: #666;
    margin: 0 0 16px;
}

.dre-chart-wrapper {
    position: relative;
    width: 100%;
    height: 300px;
    margin-top: 16px;
}

.dre-chart-wrapper canvas {
    max-width: 100%;
    height: auto;
}

/* ========= Comparison Section ========= */

.dre-comparison-section {
    margin: 32px 0;
    padding: 24px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e1e1e1;
}

.dre-comparison-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin: 20px 0;
}

.dre-comparison-card {
    background: #ffffff;
    border: 2px solid #e1e1e1;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.dre-comparison-card h3 {
    margin: 0 0 16px;
    font-size: 1.2rem;
    font-weight: 700;
    color: #083141;
}

.dre-comparison-stay {
    border-color: #d32f2f;
}

.dre-comparison-downsize {
    border-color: #2e7d32;
}

.dre-comparison-item {
    display: flex;
    flex-direction: column;
    padding: 10px 0;
    border-bottom: 1px solid #e1e1e1;
    font-size: 0.95rem;
}

.dre-comparison-item > span {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.dre-comparison-item:last-of-type {
    border-bottom: none;
}

.dre-comparison-item span {
    color: #666;
}

.dre-comparison-item strong {
    color: #083141;
    font-weight: 600;
}

.dre-comparison-note {
    font-size: 0.75rem;
    color: #666;
    margin-top: 4px;
    font-style: italic;
    display: block;
    width: 100%;
}

.dre-comparison-difference {
    margin-top: 24px;
    padding: 20px;
    background: #EBF2F4;
    border: 2px solid #083141;
    border-radius: 8px;
    text-align: center;
}

.dre-comparison-difference h3 {
    margin: 0 0 12px;
    font-size: 1.2rem;
    font-weight: 700;
    color: #083141;
}

.dre-comparison-value {
    font-size: 2rem;
    font-weight: 700;
    color: #2e7d32;
    margin: 12px 0;
}

.dre-comparison-difference p {
    margin: 12px 0 0;
    font-size: 0.9rem;
    color: #666;
}

/* ========= Investment Example Section ========= */

.dre-investment-example-section {
    margin: 32px 0;
    padding: 24px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e1e1e1;
}

.dre-investment-example-card {
    background: #ffffff;
    border: 2px solid #2e7d32;
    border-radius: 8px;
    padding: 24px;
    margin-top: 16px;
}

.dre-investment-example-header h3 {
    margin: 0 0 12px;
    font-size: 1.3rem;
    font-weight: 700;
    color: #083141;
}

.dre-investment-example-header p {
    margin: 0 0 20px;
    font-size: 0.95rem;
    color: #666;
    line-height: 1.6;
}

.dre-investment-example-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #2e7d32;
    text-align: center;
    margin: 20px 0;
    padding: 20px;
    background: #f1f8f4;
    border-radius: 8px;
}

.dre-investment-example-note {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
    text-align: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e1e1e1;
}

/* ========= Table Section ========= */

.dre-table-section {
    margin: 32px 0;
}

.dre-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 12px;
}

.dre-export-btn {
    background: #083141;
    color: #ffffff;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.dre-export-btn:hover {
    background: #0a4a5f;
}

.dre-export-btn:active {
    background: #062a36;
}

.dre-export-btn--block {
    display: inline-block;
    margin-top: 4px;
}

/* CSV + MailerLite CTA (below year-by-year table), high-conversion block */
.dre-csv-cta {
    margin-top: 36px;
    padding: 28px 26px 30px;
    border-radius: 16px;
    background: linear-gradient(145deg, #ffffff 0%, #e8f5e9 45%, #c8e6c9 100%);
    border: 2px solid #2e7d32;
    box-shadow:
        0 12px 40px rgba(8, 49, 65, 0.12),
        0 0 0 1px rgba(46, 125, 50, 0.15);
    text-align: center;
}

.dre-csv-cta__headline {
    margin: 0 0 12px;
    font-size: clamp(1.35rem, 3.5vw, 1.85rem);
    font-weight: 900;
    line-height: 1.2;
    color: #083141;
    letter-spacing: -0.02em;
}

.dre-csv-cta__sub {
    margin: 0 auto 22px;
    max-width: 520px;
    font-size: 1.05rem;
    line-height: 1.55;
    color: #1b4332;
    font-weight: 500;
}

.dre-csv-cta__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: 18px 28px;
    font-size: 1.12rem;
    font-weight: 900;
    letter-spacing: 0.02em;
    line-height: 1.25;
    color: #fff;
    background: linear-gradient(180deg, #43a047 0%, #2e7d32 45%, #1b5e20 100%);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    box-shadow:
        0 6px 0 #145214,
        0 14px 32px rgba(46, 125, 50, 0.45);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
    font-family: inherit;
    text-align: center;
}

.dre-csv-cta__btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.05);
    box-shadow:
        0 8px 0 #145214,
        0 18px 40px rgba(46, 125, 50, 0.5);
}

.dre-csv-cta__btn:active {
    transform: translateY(2px);
    box-shadow:
        0 3px 0 #145214,
        0 8px 20px rgba(46, 125, 50, 0.35);
}

/* MailerLite signup modal (matches other RC calculators) */
.dre-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    padding: 20px;
    box-sizing: border-box;
}

.dre-modal {
    background: #fff;
    border: 3px solid #083141;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    max-width: 540px;
    width: 100%;
    z-index: 1000000;
    box-sizing: border-box;
}

.dre-modal-header {
    padding: 24px 28px;
    background: linear-gradient(135deg, #083141, #0a4a5f);
    border-radius: 17px 17px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dre-modal-header h3 {
    margin: 0;
    font-size: clamp(1.15rem, 4vw, 1.45rem);
    font-weight: 900;
    color: #fff;
    line-height: 1.25;
    padding-right: 8px;
}

.dre-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 28px;
    color: #fff;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    line-height: 1;
}

.dre-modal-body {
    padding: 24px 28px;
}

.dre-modal-lead {
    margin: 0 0 20px;
    font-size: 1.05rem;
    line-height: 1.6;
    color: #1e293b;
    font-weight: 500;
}

.dre-modal-label {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 8px;
    display: block;
    color: #0f172a;
}

.dre-modal-input {
    font-size: 16px;
    padding: 12px 14px;
    border: 2px solid #083141;
    width: 100%;
    border-radius: 10px;
    box-sizing: border-box;
    margin-bottom: 14px;
}

.dre-modal-trust {
    background: #e8f5e9;
    padding: 14px 16px;
    border-radius: 10px;
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.45;
    color: #1b4332;
}

.dre-modal-footer {
    padding: 20px 28px;
    border-top: 2px solid #c8e6c9;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-wrap: wrap;
    background: #f1f8f4;
    border-radius: 0 0 17px 17px;
}

.dre-modal-submit {
    flex: 1 1 auto;
    min-width: min(100%, 240px);
    min-height: 54px;
    border: 2px solid #1b5e20;
    background: linear-gradient(180deg, #43a047 0%, #2e7d32 50%, #1b5e20 100%);
    color: #fff;
    padding: 16px 28px;
    border-radius: 14px;
    font-weight: 900;
    cursor: pointer;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 14px rgba(46, 125, 50, 0.35);
    transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
}

.dre-modal-submit:hover:not(:disabled) {
    filter: brightness(1.06);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(46, 125, 50, 0.45);
}

.dre-modal-btn-secondary {
    border: 2px solid #cbd5e1;
    background: #fff;
    color: #0f172a;
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    min-height: 46px;
}

.dre-modal-error {
    color: #c62828;
    font-size: 14px;
    margin-top: 4px;
    margin-bottom: 8px;
}

.dre-modal-success {
    font-size: 17px;
    font-weight: 700;
    color: #2e7d32;
    text-align: center;
    padding: 16px 8px;
    margin: 0;
}

@media (max-width: 540px) {
    .dre-modal {
        max-width: 100%;
    }

    .dre-modal-footer {
        flex-direction: column;
    }

    .dre-modal-submit,
    .dre-modal-btn-secondary {
        width: 100%;
        min-width: 0;
    }
}

.dre-table-wrapper {
    overflow-x: auto;
    margin-top: 18px;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
}

.dre-table {
    border-collapse: collapse;
    width: 100%;
    min-width: 900px;
    font-size: 0.85rem;
    table-layout: auto;
}

.dre-table th,
.dre-table td {
    padding: 8px 10px;
    border: 1px solid #e1e1e1;
    text-align: left;
    white-space: nowrap;
}

.dre-table th {
    background: #EBF2F4;
    font-weight: 700;
    color: #083141;
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: normal;
    font-size: 0.8rem;
    line-height: 1.3;
}

.dre-table-number {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
}

.dre-table-group-header {
    background: #EBF2F4 !important;
    text-align: center !important;
    font-weight: 700;
    color: #083141;
    border: 2px solid #083141;
    white-space: nowrap;
}

.dre-table-difference {
    font-weight: 700;
    color: #2e7d32;
}

.dre-table-explanation {
    margin-top: 24px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e1e1e1;
}

.dre-table-explanation h3 {
    margin: 0 0 16px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #083141;
}

.dre-table-explanation ul {
    margin: 0;
    padding-left: 20px;
    list-style-type: disc;
}

.dre-table-explanation li {
    margin-bottom: 12px;
    line-height: 1.6;
    color: #333;
    font-size: 0.9rem;
}

.dre-table-explanation li:last-child {
    margin-bottom: 0;
}

.dre-table-explanation strong {
    color: #083141;
    font-weight: 600;
}

.dre-table-explanation em {
    font-style: italic;
    color: #2e7d32;
}

.dre-table tbody tr:hover {
    background: #f8f9fa;
}

.dre-table-row-negative {
    background: #fff5f5;
}

.dre-table-row-negative td {
    color: #a30000;
}

/* ========= Desktop Styles (1100px and above) ========= */

@media (min-width: 1100px) {
    #dre-root {
        max-width: 1100px;
        margin: 0 auto;
        padding: 0 1rem;
    }
    
    .dre-container {
        padding: 32px;
    }

    .dre-step {
        margin-bottom: 32px;
        padding-bottom: 24px;
    }

    .dre-step h2 {
        font-size: 1.5rem;
        margin-bottom: 16px;
    }

    .dre-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }

    .dre-summary-section {
        padding: 32px;
    }


    .dre-summary-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }

    .dre-summary-card {
        padding: 24px;
    }

    .dre-summary-value {
        font-size: 1.75rem;
    }

    .dre-section-title {
        font-size: 1.75rem;
    }

    .dre-breakdown-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }

    .dre-breakdown-card {
        padding: 24px;
    }

    .dre-charts-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .dre-chart-wrapper {
        height: 400px;
    }

    .dre-table {
        font-size: 0.9rem;
        min-width: 1000px;
    }
    
    .dre-table th {
        font-size: 0.85rem;
        padding: 8px 10px;
    }
    
    .dre-table td {
        padding: 8px 10px;
    }

    .dre-table th,
    .dre-table td {
        padding: 12px 16px;
    }
}

/* ========= Tablet Styles (768px - 1099px) ========= */

@media (min-width: 768px) and (max-width: 1099px) {
    .dre-container {
        padding: 24px;
    }

    .dre-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 18px;
    }

    .dre-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dre-breakdown-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dre-comparison-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dre-charts-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        width: 100%;
    }

    .dre-chart-wrapper {
        height: 350px;
    }
}

/* ========= Mobile Optimizations ========= */

@media (max-width: 767px) {
    .dre-container {
        padding: 12px;
        border-radius: 8px;
    }

    .dre-step {
        margin-bottom: 20px;
        padding-bottom: 16px;
    }

    .dre-step h2 {
        font-size: 1.1rem;
    }

    .dre-summary-section {
        padding: 16px;
        margin: 24px 0;
    }


    .dre-summary-value {
        font-size: 1.25rem;
    }

    .dre-section-title {
        font-size: 1.25rem;
    }

    .dre-breakdown-card {
        padding: 16px;
    }

    .dre-chart-card {
        padding: 16px;
    }

    .dre-chart-wrapper {
        height: 250px;
    }

    .dre-table {
        font-size: 0.85rem;
        min-width: 600px;
    }

    .dre-table th,
    .dre-table td {
        padding: 8px 10px;
    }

    .dre-badge {
        font-size: 0.875rem;
        padding: 10px 12px;
        display: block;
        text-align: center;
    }

    .dre-comparison-section {
        padding: 16px;
    }

    .dre-comparison-value {
        font-size: 1.5rem;
    }

    .dre-table-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .dre-export-btn {
        width: 100%;
        margin-top: 8px;
    }

    .dre-csv-cta {
        padding: 22px 16px 24px;
        margin-top: 28px;
    }

    .dre-csv-cta__btn {
        max-width: none;
        padding: 16px 18px;
        font-size: 1.05rem;
    }
}

/* ========= Print Styles ========= */

@media print {
    .dre-container {
        border: none;
        padding: 0;
    }

    .dre-step {
        page-break-inside: avoid;
        border-bottom: 1px solid #ccc;
    }

    .dre-table-wrapper {
        overflow: visible;
    }

    .dre-chart-wrapper {
        page-break-inside: avoid;
    }

    .dre-comparison-section {
        page-break-inside: avoid;
    }

    .dre-export-btn {
        display: none;
    }

    .dre-csv-cta,
    .dre-csv-cta__btn {
        display: none;
    }

    .dre-modal-overlay {
        display: none !important;
    }

    .dre-comparison-card {
        page-break-inside: avoid;
    }
}
