* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background:
        linear-gradient(rgba(20, 24, 28, 0.45), rgba(20, 24, 28, 0.45)),
        url('header-badger.png') center/cover no-repeat;
    color: white;
    padding: 0.75rem 1rem;
    text-align: center;
    margin-bottom: 0.75rem;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

h1 {
    font-size: 1.35rem;
    margin-bottom: 0;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
}


.section-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}

.tab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}

.tab-header .section-title {
    margin: 0;
    border-bottom: none;
    padding-bottom: 0;
    flex: 1;
    min-width: 0;
}

.tab-header .tab-actions {
    margin: 0;
    flex-shrink: 0;
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #34495e;
}

/* Ensure modal form labels are always above inputs */
.modal-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #34495e;
}

input[type="number"], input[type="text"], input[type="date"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e1e8ed;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

input[type="number"]:focus, input[type="text"]:focus, input[type="date"]:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    padding: 1rem 2rem;
    border: none;
    border-radius: 5px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}


.tabs-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-top: 0;
    overflow: hidden;
}

.tabs-header {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #e1e8ed;
    flex-wrap: nowrap;
    align-items: center;
}

.header-tools {
    display: flex !important;
    gap: 0.5rem;
    align-items: center;
    margin-left: auto;
    padding: 0.5rem;
    flex-shrink: 0;
}
.mini-btn {
    background: #ecf0f1;
    color: #2c3e50;
    padding: 0.4rem 0.6rem;
    border: 1px solid #d0d7de;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
}
.mini-btn:hover { background: #e6ebef; }

.tab-button {
    flex: 0 1 auto;
    padding: 0.95rem 0.95rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 600;
    color: #7f8c8d;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
}

.tab-button.active {
    color: #3498db;
    background: white;
    border-bottom-color: #3498db;
}

.tab-button:hover {
    color: #3498db;
    background: rgba(52, 152, 219, 0.1);
}

.tab-content {
    display: none;
    padding: 2rem;
}

.tab-content.active {
    display: block;
}

.scenario-switcher[hidden] {
    display: none !important;
}

.scenario-switcher {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    padding: 0.65rem 1rem;
    margin: 0 0 1rem;
    background: #fff;
    border: 1px solid #e1e8ed;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.workspace-switcher {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.75rem 1rem;
    padding: 0.75rem 1rem;
    margin: 1.25rem 0 0.5rem;
    background: #fff;
    border: 1px solid #e1e8ed;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.workspace-switcher-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #5c6773;
}

.workspace-switcher-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.workspace-switcher-btn {
    appearance: none;
    border: 1px solid #d0d7de;
    background: #f8f9fa;
    color: #34495e;
    padding: 0.5rem 1.1rem;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.workspace-switcher-btn:hover {
    background: #eef2f5;
    border-color: #b8c2cc;
}

.workspace-switcher-btn.active {
    background: #2c3e50;
    border-color: #2c3e50;
    color: #fff;
}

.scenario-switcher-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    flex: 1 1 auto;
    min-width: 0;
}

.scenario-switcher-main[hidden] {
    display: none !important;
}

.scenario-manage-btn {
    appearance: none;
    margin-left: auto;
    border: 1px solid #d0d7de;
    background: #f8f9fa;
    color: #34495e;
    padding: 0.45rem 0.95rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    flex: 0 0 auto;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.scenario-manage-btn:hover {
    border-color: #3498db;
    color: #2980b9;
    background: #eef6fc;
}

.scenario-manage-btn.active {
    background: #3498db;
    border-color: #3498db;
    color: #fff;
}

.scenario-switcher-label {
    font-weight: 700;
    color: #2c3e50;
    font-size: 0.95rem;
}

.scenario-switcher-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    flex: 1 1 auto;
}

.scenario-switcher-btn {
    appearance: none;
    border: 1px solid #d0d7de;
    background: #fff;
    color: #34495e;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.scenario-switcher-btn:hover {
    border-color: #3498db;
    color: #2980b9;
}

.scenario-switcher-btn.active {
    background: #3498db;
    border-color: #3498db;
    color: #fff;
}

.scenario-switcher-desc {
    flex: 1 1 100%;
    margin: 0;
    color: #5c6773;
    font-size: 0.9rem;
    line-height: 1.4;
}

.scenario-switcher-desc:empty {
    display: none;
}

/* Toggle legend for individuals */
.legend-toggle-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 16px 0;
}
.legend-toggle {
    padding: 6px 10px;
    border: 1px solid #d0d7de;
    border-radius: 16px;
    background: #f6f8fa;
    color: #2c3e50;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
}
.legend-toggle.active {
    background: #d6eaf8;
    border-color: #3498db;
    color: #1b4f72;
}
.legend-toggle.property.active { background: rgba(52,152,219,0.2); border-color: #3498db; }
.legend-toggle.pensions.active { background: rgba(46,204,113,0.2); border-color: #2ecc71; }
.legend-toggle.lisa.active { background: rgba(241,196,15,0.2); border-color: #f1c40f; }
.legend-toggle.isa.active { background: rgba(230,126,34,0.2); border-color: #e67e22; }
.legend-toggle.savings.active { background: rgba(155,89,182,0.2); border-color: #9b59b6; }

.chart-container {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-top: 2rem;
}


/* Modal Overlay Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

/* Export modal */
#exportModal .modal-content { max-width: 800px; }
/* Scenario meta modal */
#scenarioMetaModal .modal-content { max-width: 640px; }
#scenarioMetaModal .modal-form input,
#scenarioMetaModal .modal-form textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e1e8ed;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#scenarioMetaModal .modal-form textarea {
    min-height: 140px;
    resize: vertical;
    line-height: 1.5;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    color: #2c3e50;
    background: #ffffff;
    white-space: pre-wrap;
    word-break: break-word;
}
#scenarioMetaModal .modal-form textarea::placeholder {
    color: #8a9aa9;
}
#scenarioMetaModal .modal-form input:focus,
#scenarioMetaModal .modal-form textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}
#exportText {
    width: 100%;
    height: 300px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    padding: 8px;
    box-sizing: border-box;
    background: #fafbfc;
}

/* Checkbox labels in modal forms */
.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: #34495e;
    margin-top: 1.75rem;
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* Joint owners checkbox layout (savings) */
#accountJointOwnersContainer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: center;
}
#accountJointOwnersContainer > div {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

/* Joint owners checkbox layout (mortgage) */
#mortgageJointOwnersContainer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: center;
}
#mortgageJointOwnersContainer > div {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

/* Joint owners checkbox layout (assets) */
#assetJointOwnersContainer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: center;
}
#assetJointOwnersContainer > div {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e1e8ed;
}

.modal-title {
    font-size: 1.5rem;
    color: #2c3e50;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #7f8c8d;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: #f8f9fa;
    color: #2c3e50;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.modal-form .form-row:last-child {
    grid-template-columns: 1fr;
    margin-top: 1rem;
}

.modal-form .form-group {
    display: flex;
    flex-direction: column;
}

.modal-form .form-group label {
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #34495e;
}


.modal-form .btn {
    width: 100%;
    margin-top: 1rem;
}

/* Individual tab specific improvements */
.individuals-table-container h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
    font-size: 1.2rem;
    font-weight: 600;
}

.individuals-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
    text-align: left;
}

.individuals-table td {
    vertical-align: middle;
}

@media (max-width: 768px) {
    .modal-form .form-row {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }
}


.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}


.btn-add {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    margin-top: 0;
    width: auto;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    display: inline-block;
}

.btn-add:hover {
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
}

.tab-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.chart-controls {
    display: flex;
    gap: 2rem;
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    align-items: center;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.9rem;
}

.control-group select {
    padding: 0.5rem;
    border: 1px solid #e1e8ed;
    border-radius: 4px;
    background: white;
    color: #2c3e50;
    font-size: 0.9rem;
    min-width: 120px;
}

.control-group select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

#growthChart, #balanceChart {
    width: 100%;
    max-width: 100%;
    height: 400px;
    display: block;
}

.savings-table-container, .individuals-table-container, .income-table-container, .mortgage-table-container, .spending-table-container, .assets-table-container {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.table-wrapper {
    overflow-x: auto;
}

.savings-table, .individuals-table, .income-table, .mortgage-table, .spending-table, .assets-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.savings-table th,
.savings-table td,
.individuals-table th,
.individuals-table td,
.income-table th,
.income-table td,
.mortgage-table th,
.mortgage-table td,
.spending-table th,
.spending-table td,
.assets-table th,
.assets-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e1e8ed;
}

.savings-table th,
.individuals-table th,
.income-table th,
.mortgage-table th,
.spending-table th,
.assets-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
}

.savings-table tr:hover,
.individuals-table tr:hover,
.income-table tr:hover,
.mortgage-table tr:hover,
.spending-table tr:hover,
.assets-table tr:hover {
    background: #f8f9fa;
}

.btn-edit, .btn-delete {
    padding: 0.25rem 0.5rem;
    margin: 0 0.25rem;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8rem;
    width: auto;
}

.btn-edit {
    background: #f39c12;
    color: white;
}

.btn-delete {
    background: #e74c3c;
    color: white;
}

.btn-edit:hover {
    background: #e67e22;
}

.btn-delete:hover {
    background: #c0392b;
}

select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e1e8ed;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Scenario controls - neutral styling for content area */
#scenarioControls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0.5rem 0 1rem; }
#scenarioControls .btn { background: #f1f3f5; color: #2c3e50; border: 1px solid #d0d7de; padding: 8px 12px; border-radius: 6px; box-shadow: none; transform: none; min-width: 110px; }
#scenarioControls .btn:hover { background: #e9ecef; }
#scenarioControls .btn-delete { border-color: #f1c0c0; color: #c92a2a; background: #fff0f0; }
.scenario-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin: 0.5rem 0 1rem; }
.scenario-item { padding: 10px 12px; border: 1px solid #d0d7de; border-radius: 6px; background: #ffffff; color: #2c3e50; cursor: pointer; text-align: center; user-select: none; }
.scenario-item:hover { background: #f8f9fa; }
.scenario-item.active { background: #e7f1ff; border-color: #84c5f4; box-shadow: inset 0 0 0 1px #84c5f4; font-weight: 600; }

@media (max-width: 768px) {
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .savings-table,
    .individuals-table,
    .income-table,
    .mortgage-table,
    .spending-table {
        font-size: 0.8rem;
    }
    
    .savings-table th,
    .savings-table td,
    .individuals-table th,
    .individuals-table td,
    .income-table th,
    .income-table td,
    .mortgage-table th,
    .mortgage-table td,
    .spending-table th,
    .spending-table td {
        padding: 0.5rem;
    }
    
    h1 {
        font-size: 2rem;
    }
}

.timeline-chart-wrap {
    width: 100%;
}

.timeline-panels {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.timeline-panel {
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    border-left: 4px solid #95a5a6;
}

.timeline-panel-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    border: none;
    background: #f8f9fa;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c3e50;
    text-align: left;
}

.timeline-panel-toggle:hover {
    background: #f1f3f5;
}

.timeline-panel-chevron {
    display: inline-block;
    width: 0.9rem;
    color: #7f8c8d;
    font-size: 0.75rem;
    transition: transform 0.15s ease;
}

.timeline-panel.collapsed .timeline-panel-chevron {
    transform: rotate(-90deg);
}

.timeline-panel-count {
    margin-left: auto;
    font-weight: 500;
    font-size: 0.82rem;
    color: #7f8c8d;
}

.timeline-panel-body {
    padding: 0 0 4px;
    overflow-x: auto;
}

.timeline-panel.collapsed .timeline-panel-body {
    display: none;
}

.timeline-panel-body canvas {
    display: block;
    width: 100%;
}

.timeline-empty {
    color: #7f8c8d;
    padding: 2rem;
    text-align: center;
}

.scenario-summary {
    color: #2c3e50;
    white-space: pre-wrap;
    margin-bottom: 0.45rem;
}

.scenario-summary-empty {
    color: #95a5a6;
    font-style: italic;
}

.scenario-tech-diffs {
    margin-top: 0.15rem;
}

.scenario-tech-diffs > summary {
    cursor: pointer;
    color: #5c6773;
    font-size: 0.82rem;
    font-weight: 600;
    user-select: none;
    list-style: none;
}

.scenario-tech-diffs > summary::-webkit-details-marker {
    display: none;
}

.scenario-tech-diffs > summary::before {
    content: '▸ ';
    display: inline-block;
    color: #95a5a6;
}

.scenario-tech-diffs[open] > summary::before {
    content: '▾ ';
}

.scenario-tech-diffs ul {
    margin: 0.4rem 0 0;
    padding-left: 1.1rem;
    color: #5c6773;
    font-size: 0.85rem;
    line-height: 1.35;
}