/* --- Global Variables & Reset --- */
:root {
    --primary: #2c3e50;
    --accent: #3498db;
    --success: #27ae60;
    --danger: #e74c3c;
    --bg: #f4f7f6;
    --card-bg: #ffffff;
    --border: #edf2f7;
    --text-muted: #64748b;
}

body {
    background: var(--bg);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    padding: 20px;
    color: var(--primary);
    margin: 0;
    line-height: 1.5;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* --- Card Components --- */
.card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

h1,
h2,
h3 {
    margin-top: 0;
    color: #1a2b3c;
}

.req {
    color: var(--danger);
    font-weight: bold;
}

/* --- Top Methods Grid (1, 2, 3 Side-by-Side) --- */
.methods-explanation {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 15px 0;
}

.method-box {
    background: #f1f6fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--accent);
}

.method-box h3 {
    font-size: 1rem;
    margin-bottom: 10px;
}

.method-box ul {
    padding-left: 18px;
    margin: 0;
    font-size: 0.85rem;
    color: #444;
}

.reference {
    font-size: 0.85rem;
    margin-top: 10px;
}

.reference a {
    color: var(--accent);
    text-decoration: none;
}

/* --- Dashboard Layout --- */
.dashboard {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.sidebar {
    flex: 0 0 340px;
}

.main-content {
    flex: 1;
    min-width: 0;
}

/* --- Form Elements & Assumptions Grid --- */
.input-group {
    margin-bottom: 15px;
}

/* Styling for disabled sidebar fields */
.input-group.disabled {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(1);
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: #444;
}

input,
select {
    width: 100%;
    padding: 10px;
    border: 1px solid #d1d9e0;
    border-radius: 6px;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-calculate {
    width: 100%;
    padding: 14px;
    background: #3fa2f6;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
    margin-top: 10px;
    transition: background 0.2s;
}

.btn-calculate:hover {
    background: var(--accent);
}

/* --- Results Cards (Side-by-Side) --- */
.results-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.result-card {
    border-top: 4px solid #3fa2f6;
    background-color: #f1f6fa;
    /* Annual SEPP Specific Color */
}

.summary-pane {
    background-color: white;
    border-top: 4px solid #e2e8f0;
}

.lump-pane,
.danger-border {
    border-top: 4px solid var(--danger);
    background-color: white;
}

.hero-value {
    font-size: 2.8rem;
    font-weight: 800;
    color: var(--primary);
    margin: 5px 0;
}

.sub-label {
    font-size: 0.9rem;
    color: #666;
}

.stat {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed #eee;
    padding: 10px 0;
    font-size: 0.95rem;
}

.stat-value {
    font-weight: 700;
}

.text-danger {
    color: var(--danger) !important;
}

.text-success {
    color: var(--success) !important;
}

.table-container {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    /* Changed to auto to allow columns to shrink */
}

th,
td {
    padding: 12px 8px;
    border-bottom: 1px solid #eee;
    font-size: 0.82rem;
    white-space: nowrap;
    text-align: right;
    /* Aligns headers and numbers vertically */
}

th {
    background: #f9f9f9;
    font-weight: 600;
    color: #666;
}

/* Removes excessive gaps by allowing columns to fit their content */
#adventure-table th,
#adventure-table td {
    padding: 8px 4px;
    /* Reduced padding to save space */
    text-align: right;
    width: auto;
    /* Allows browser to determine best fit */
}

/* Specific alignments and small-width columns */
#adventure-table th:nth-child(1),
#adventure-table td:nth-child(1) {
    width: 10%;
    text-align: center;
}

/* Year */
#adventure-table th:nth-child(2),
#adventure-table td:nth-child(2) {
    width: 8%;
    text-align: center;
}

/* Age */
#adventure-table th:nth-child(3),
#adventure-table td:nth-child(3) {
    width: 12%;
    text-align: left;
}

/* Status */

/* The rest of the columns will now naturally sit closer together */
#adventure-table th:nth-child(4),
#adventure-table td:nth-child(4) {
    width: 125px;
}

#adventure-table th:nth-child(5),
#adventure-table td:nth-child(5) {
    width: 105px;
}

#adventure-table th:nth-child(6),
#adventure-table td:nth-child(6) {
    width: 115px;
}

#adventure-table th:nth-child(7),
#adventure-table td:nth-child(7) {
    width: 85px;
}

#adventure-table th:nth-child(8),
#adventure-table td:nth-child(8) {
    width: 105px;
}

#adventure-table th:nth-child(9),
#adventure-table td:nth-child(9) {
    width: 145px;
}

#adventure-table th:nth-child(10),
#adventure-table td:nth-child(10) {
    width: 125px;
}

/* End Balance Highlight */
#adventure-table th:nth-child(9),
#adventure-table td:nth-child(9) {
    width: 130px;
    background-color: #f0fff4;
    color: #2f855a;
    font-weight: 700;
    padding-right: 15px;
}

#adventure-table th:nth-child(10),
#adventure-table td:nth-child(10) {
    width: 115px;
}

/* --- Tooltip Styling --- */
.tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
    color: var(--accent);
    font-weight: 600;
    border-bottom: 1px dotted var(--accent);
    text-decoration: none;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 220px;
    background-color: #2c3e50;
    color: #fff;
    text-align: left;
    border-radius: 6px;
    padding: 10px;
    position: absolute;
    z-index: 99;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.75rem;
    font-weight: normal;
    line-height: 1.4;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    white-space: normal;
}

.tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #2c3e50 transparent transparent transparent;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

.hero-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 25px;
    font-weight: 500;
}

.story-snippet {
    max-width: 800px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* --- Responsive Adjustments --- */
@media (max-width: 1200px) {
    .dashboard {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .results-grid,
    .methods-explanation {
        grid-template-columns: 1fr;
    }
}

/* --- Mobile Adjustments (Applied only to screens smaller than 1024px) --- */
@media (max-width: 1024px) {

    /* 1. Stacks the Sidebar on top of the Results instead of side-by-side */
    .dashboard {
        flex-direction: column !important;
    }

    /* 2. Forces the Sidebar to take full width */
    .sidebar {
        width: 100% !important;
        flex: none !important;
    }

    /* 3. Stacks the 3 Methodology Boxes (Amortization, Annuitization, RMD) vertically */
    .methods-explanation {
        grid-template-columns: 1fr !important;
    }

    /* 4. Stacks the 3 Summary Cards (Annual SEPP, Summary, Lump Sum) vertically */
    .results-grid {
        grid-template-columns: 1fr !important;
    }

    /* 5. Shrinks the large hero numbers so they fit on a phone screen */
    .hero-value {
        font-size: 2.2rem !important;
    }

    /* Inside @media (max-width: 1024px) */
    .table-container {
        overflow-x: hidden;
        /* Removes the scroll */
    }

    table {
        min-width: 100% !important;
        /* Forces table to fit screen width */
        font-size: 0.7rem;
        /* Shrinks text slightly to ensure no overlap */
    }
}