/* ==========================================================================
   Combined and Refactored Stylesheet
   Includes base styles and styles moved from the growth_projection and
   risk_return_modeler templates.
   ========================================================================== */

/* ======= Variables ======= */
:root {
    --apple-primary: #0071e3;
    --apple-primary-dark: #0062cc;
    --apple-secondary: #86868b;
    --apple-background: #fbfbfd; /* Main page background */
    --apple-content-background: #ffffff; /* Card/content area background */
    --apple-light-gray: #f5f5f7; /* Lighter element background (e.g., result-box, table headers) */
    --apple-very-light-gray: #f8f9fa; /* Slightly off-white (e.g., plot background) */
    --apple-dark: #1d1d1f; /* Main text color */
    --apple-border: #d2d2d7; /* Standard borders */
    --apple-success: #4fd15a;
    --apple-error: #ff3b30;
    --apple-warning: #fd7e14; /* MERGED: Added a warning color for consistency */
    --apple-error-dark: #b02a37; /* MERGED: Added a darker error color */
    --chart-background: var(--apple-very-light-gray); /* Use a light background for charts */
    --transition-standard: all 0.3s ease;
    --border-radius-standard: 12px; /* Consistent radius */
    --border-radius-large: 18px; /* Larger radius for cards */
    --border-radius-small: 8px; /* Smaller radius for buttons, inputs */
}

/* ======= Base Styles ======= */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--apple-dark);
    background-color: var(--apple-background);
    line-height: 1.5;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: 0; /* Ensure no default padding conflicts */
}

/* ======= Layout & Container ======= */
.container {
    max-width: 1200px;
    padding: 0 20px;
    margin: 0 auto;
    flex: 1;
}

.page-shell {
    padding-top: 3.5rem;
    padding-bottom: 4rem;
}

body.landing-page .page-shell {
    padding-top: 2.5rem;
}

/* MERGED: Added a wider container variant for pages that need more space, like the risk/return modeler. */
.container-wide {
    max-width: 1400px;
}

/* Specific wrapper for main content area below header */
.content-wrapper {
    margin-top: 20px; /* Spacing below page header */
    width: 100%; /* Ensure it takes full width within container */
}


/* ======= Typography ======= */
h1 {
    font-size: 2.5rem; /* Default */
    font-weight: 600;
    letter-spacing: -0.5px;
    margin-bottom: 1rem;
    color: var(--apple-dark);
    line-height: 1.1;
}

h2 {
    font-size: 2rem; /* Default */
    font-weight: 600;
    margin-bottom: 1rem; /* Default */
    color: var(--apple-dark);
}

h3 {
    font-size: 1.5rem; /* Default */
    font-weight: 600;
    margin-bottom: 0.75rem; /* Default margin */
    color: var(--apple-dark);
}

h4 {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 1rem;
    color: var(--apple-dark);
}

h5 {
    font-size: 1.1rem; /* Consistent size */
    font-weight: 500;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--apple-dark);
}

p {
    margin-bottom: 1rem; /* Default margin */
}

p:last-child {
    margin-bottom: 0;
}

ul {
    padding-left: 20px;
    margin-bottom: 1rem;
}

li {
    margin-bottom: 0.5rem;
}

.text-muted {
    color: var(--apple-secondary) !important;
    font-size: 0.9rem;
}

/* MERGED: Added text color utilities for stat cards. */
.text-primary { color: var(--apple-primary) !important; }
.text-success { color: var(--apple-success) !important; }
.text-error { color: var(--apple-error) !important; }
.text-error-dark { color: var(--apple-error-dark) !important; }
.text-warning { color: var(--apple-warning) !important; }

.subtitle {
    font-size: 1.25rem; /* Adjusted from 24px */
    font-weight: 400;
    color: var(--apple-secondary);
    margin-bottom: 2rem; /* Adjusted from 40px */
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

hr {
    border-top: 1px solid var(--apple-border);
    margin: 1rem 0; /* Standard margin for dividers */
}

/* ======= Navigation ======= */
.main-nav {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(210, 210, 215, 0.55);
    padding: 1.1rem 0;
}

.nav-wrapper {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.nav-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.9rem;
    text-decoration: none;
    color: var(--apple-dark);
}

.brand-mark {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: linear-gradient(135deg, #0b66ff 0%, #00d2ff 100%);
    position: relative;
}

.brand-mark::after {
    content: "";
    position: absolute;
    inset: -5px;
    border-radius: 999px;
    border: 1px solid rgba(11, 102, 255, 0.25);
}

.brand-mark.is-small {
    width: 10px;
    height: 10px;
}

.brand-mark.is-small::after {
    inset: -3px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.brand-title {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.brand-subtitle {
    font-size: 0.75rem;
    color: var(--apple-secondary);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--border-radius-small);
    color: var(--apple-secondary);
    text-decoration: none;
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.nav-link:hover {
    color: var(--apple-dark);
    background-color: var(--apple-light-gray);
    transform: translateY(-1px);
}

.nav-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 999px;
    color: #ffffff;
    text-decoration: none;
    background: linear-gradient(135deg, #0b66ff 0%, #6018dc 100%);
    box-shadow: 0 12px 30px rgba(11, 102, 255, 0.22);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.nav-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 34px rgba(11, 102, 255, 0.28);
}

.nav-cta span[aria-hidden="true"] {
    font-size: 1rem;
}

body.landing-page .nav-cta {
    background: linear-gradient(135deg, #0f172a 0%, #172554 100%);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.28);
}

/* ======= Landing Hero ======= */
.landing-hero {
    display: grid;
    gap: 3rem;
    padding: 4rem 0 3rem;
    position: relative;
}

@media (min-width: 992px) {
    .landing-hero {
        grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
        align-items: center;
    }
}

.hero-content {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    max-width: 600px;
}

.hero-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    background: rgba(11, 102, 255, 0.12);
    color: #0b66ff;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.landing-hero h1 {
    font-size: 3rem;
    line-height: 1.05;
    letter-spacing: -0.02em;
    margin: 0;
}

.hero-subtitle {
    margin: 0;
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--apple-secondary);
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.hero-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.75rem 1.6rem;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.hero-primary {
    color: #ffffff;
    background: linear-gradient(135deg, #0b66ff 0%, #6018dc 100%);
    box-shadow: 0 18px 40px rgba(11, 102, 255, 0.32);
}

.hero-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 44px rgba(11, 102, 255, 0.38);
}

.hero-secondary {
    color: var(--apple-dark);
    background: rgba(15, 23, 42, 0.05);
    border: 1px solid rgba(15, 23, 42, 0.12);
}

.hero-secondary:hover {
    transform: translateY(-2px);
    background: rgba(15, 23, 42, 0.08);
}

.hero-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1.75rem;
    margin: 0;
}

.hero-stat {
    min-width: 140px;
}

.hero-stat dt {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--apple-secondary);
}

.hero-stat dd {
    margin: 0.35rem 0 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--apple-dark);
}

.hero-visual {
    display: flex;
    justify-content: flex-end;
}

.hero-visual-card {
    width: 100%;
    max-width: 360px;
    background: linear-gradient(145deg, #0f172a 0%, #1e293b 40%, #312e81 100%);
    border-radius: 24px;
    padding: 2rem;
    color: #e2e8f0;
    box-shadow: 0 30px 70px rgba(15, 23, 42, 0.35);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.hero-visual-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.hero-visual-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(226, 232, 240, 0.75);
}

.hero-visual-ticker {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: rgba(226, 232, 240, 0.15);
}

.hero-visual-caption {
    margin: 0;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: rgba(226, 232, 240, 0.75);
}

.hero-visual-value {
    font-size: 2.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #f8fafc;
}

.hero-visual-meta {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    font-size: 0.9rem;
    color: rgba(226, 232, 240, 0.85);
}

.hero-visual-link {
    align-self: flex-start;
    color: #a5b4fc;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.2s ease, transform 0.2s ease;
}

.hero-visual-link:hover {
    color: #c7d2fe;
    transform: translateY(-1px);
}

/* ======= Landing Modules ======= */
.tool-section {
    padding: 2rem 0 0;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.tool-section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 2rem;
    flex-wrap: wrap;
}

.tool-section-subtitle {
    margin: 0.85rem 0 0;
    max-width: 620px;
    color: var(--apple-secondary);
}

.tool-section-link {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--apple-dark);
    text-decoration: none;
    border-bottom: 1px solid rgba(15, 23, 42, 0.25);
    padding-bottom: 0.1rem;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.tool-section-link:hover {
    color: #0b66ff;
    border-color: #0b66ff;
}

.tool-grid {
    display: grid;
    gap: 2rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.tool-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(250, 250, 252, 0.95) 100%);
    border: 1px solid rgba(210, 210, 215, 0.5);
    border-radius: 22px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100%;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border 0.3s ease;
}

.tool-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 30px 60px rgba(15, 23, 42, 0.12);
    border-color: rgba(11, 102, 255, 0.35);
}

.tool-card__media {
    position: relative;
    width: 100%;
    height: 180px;
    background-size: cover;
    background-position: center;
    transition: transform 0.5s ease;
}

.tool-card:hover .tool-card__media {
    transform: scale(1.05);
}

.tool-card__body {
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
    flex: 1;
}

.tool-card__category {
    align-self: flex-start;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--apple-secondary);
}

.tool-card h3 {
    font-size: 1.5rem;
    margin: 0;
}

.tool-card p {
    margin: 0;
    color: var(--apple-secondary);
    line-height: 1.55;
}

.tool-card__features {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.5rem;
}

.tool-card__features li {
    padding: 0.55rem 0.75rem;
    border-radius: var(--border-radius-small);
    background: var(--apple-light-gray);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--apple-dark);
}

.tool-card__footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.tool-card__cta {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--border-radius-small);
    background: rgba(11, 102, 255, 0.12);
    color: #0b66ff;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s ease, transform 0.2s ease;
}

.tool-card__cta::after {
    content: "↗";
    font-size: 0.95rem;
}

.tool-card__cta:hover {
    background: rgba(11, 102, 255, 0.18);
    transform: translateY(-1px);
}

.tool-card__meta {
    font-size: 0.75rem;
    color: var(--apple-secondary);
}

/* ======= Page Headers (Specific Pages) ======= */
.tool-header { /* Example: Recovery Tool */
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.tool-header h1 {
    margin-bottom: 0; /* Override default h1 margin */
}

.page-header { /* General Page Header (like Growth Projection) */
    text-align: center;
    padding: 40px 0 20px; /* Adjusted padding */
}

.page-header h1 {
    font-size: 2.5rem; /* Adjusted from 48px */
    font-weight: 600;
    letter-spacing: -0.5px;
    margin-bottom: 1rem; /* Adjusted from 16px */
}

.page-header .subtitle { /* Scoped version for this header */
    font-size: 1.2rem; /* Adjusted from 20px */
    color: var(--apple-secondary);
    max-width: 700px;
    margin: 0 auto 1.5rem; /* Adjusted bottom margin */
}

.landing-header { /* Landing Page Header */
    text-align: center;
    padding: 60px 0 40px; /* Adjusted padding */
}

.landing-header h1 {
    font-size: 3rem; /* Adjusted from 56px */
    margin-bottom: 1rem; /* Adjusted from 16px */
}
/* Use .subtitle class directly under .landing-header */


/* ======= Cards & Containers ======= */
/* General Content Card (Used for forms, info sections etc.) */
.content-card {
    background-color: var(--apple-content-background);
    padding: 2rem;
    border-radius: var(--border-radius-large);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.07);
    margin-bottom: 2.5rem;
    border: 1px solid var(--apple-border);
}

/* Results Container (Card with Header/Body structure) */
.results-container {
    background-color: var(--apple-content-background);
    padding: 0; /* No padding on container itself */
    border-radius: var(--border-radius-large);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.07);
    margin-top: 2.5rem;
    margin-bottom: 2.5rem;
    border: 1px solid var(--apple-border);
    overflow: visible; /* Allows potential dropdowns/tooltips to overflow */
}

.results-header {
    background-color: var(--apple-light-gray);
    border-bottom: 1px solid var(--apple-border);
    padding: 1.5rem;
    border-top-left-radius: var(--border-radius-large); /* Match container */
    border-top-right-radius: var(--border-radius-large); /* Match container */
}

.results-body {
    padding: 1.5rem 2rem;
}

/* Specific Card Styles */
/* Landing Page Card */
.landing-card {
    background-color: var(--apple-content-background);
    border-radius: 20px; /* Specific radius */
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
    transition: var(--transition-standard);
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid var(--apple-border);
}

.landing-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
}

.card-img-container {
    height: 220px;
    overflow: hidden;
    background-color: var(--apple-light-gray);
    position: relative;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.landing-card:hover .card-img {
    transform: scale(1.05);
}

.card-content {
    padding: 30px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-title { /* Landing card specific title */
    font-size: 1.75rem; /* Adjusted from 28px */
    font-weight: 600;
    margin-bottom: 0.75rem; /* Adjusted from 12px */
    color: var(--apple-dark);
}

.card-description { /* Landing card specific description */
    color: var(--apple-secondary);
    margin-bottom: 1.25rem; /* Adjusted from 20px */
    flex: 1;
}

.card-features { /* Landing card specific features list */
    margin-bottom: 1.25rem; /* Adjusted from 20px */
    padding-left: 20px; /* Inherits default ul padding */
}

.card-features li {
    margin-bottom: 0.5rem; /* Adjusted from 8px */
    color: var(--apple-secondary);
}

/* Performance Metric Box (Optimization & Risk/Return stat cards) */
.performance-metric {
    background-color: var(--apple-light-gray);
    border-radius: var(--border-radius-standard);
    padding: 1rem;
    margin-bottom: 1rem;
    height: 100%; /* For equal height in grids */
    border: 1px solid var(--apple-border);
    text-align: center; /* MERGED: Added for stat card centering */
}

.performance-metric h3, /* MERGED: Added h3 selector for stat cards */
.performance-metric h4 {
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    color: var(--apple-secondary);
    font-weight: 400;
    margin-top: 0;
}

.performance-metric p {
    margin-bottom: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--apple-dark);
    line-height: 1.2;
}

/* Result Box (Growth Projection - used within .results-content) */
.result-box {
    background-color: var(--apple-light-gray);
    border-radius: var(--border-radius-standard); /* Consistent radius */
    padding: 1.5rem; /* Padding */
    margin-bottom: 1.5rem; /* Spacing between boxes */
    border: 1px solid var(--apple-border);
}

.result-box h3 {
    font-size: 1.1rem; /* Adjusted from 18px */
    font-weight: 600;
    margin-top: 0; /* No top margin for heading inside box */
    margin-bottom: 1rem; /* Spacing below heading */
    color: var(--apple-dark);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--apple-border);
}
.result-box h5 { /* Specific for subheadings like Capital Flow */
     font-size: 1rem;
     font-weight: 500;
     margin-top: 1rem;
     margin-bottom: 0.5rem;
     color: var(--apple-dark);
     border: none;
     padding: 0;
 }

/* Metric styling inside result-box */
.metric {
    margin-bottom: 0.5rem; /* Spacing between metrics */
    font-size: 0.9rem; /* Adjusted from 0.95rem / 14px */
    line-height: 1.4; /* Better readability */
}

.metric strong {
    color: var(--apple-dark);
    font-weight: 500; /* Standard weight for emphasis */
}


/* ======= Forms ======= */
.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.875rem; /* 14px */
    color: var(--apple-dark); /* Ensure good contrast */
    display: block; /* MERGED: Ensure labels are block-level for consistency */
}

.form-control,
.form-select {
    border-radius: var(--border-radius-small); /* Adjusted from 10px */
    border-color: var(--apple-border);
    padding: 0.625rem 0.875rem; /* 10px 14px */
    font-size: 0.9375rem; /* 15px */
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
    background-color: var(--apple-content-background); /* Ensure bg color */
    color: var(--apple-dark); /* Ensure text color */
}

.form-control:focus,
.form-select:focus {
    border-color: var(--apple-primary);
    box-shadow: 0 0 0 0.2rem rgba(0, 113, 227, 0.25);
    background-color: var(--apple-content-background); /* Maintain background on focus */
}

.form-control::placeholder { /* Style placeholder text */
    color: var(--apple-secondary);
    opacity: 0.8;
}

/* Readonly styles */
.form-control:read-only, .form-control[readonly] {
    background-color: var(--apple-light-gray);
    opacity: 1;
}

.form-control-sm {
    padding: 0.375rem 0.625rem; /* 6px 10px */
    font-size: 0.875rem; /* 14px */
    border-radius: 6px; /* Slightly smaller radius */
}

.form-check-label {
    padding-left: 0.25rem;
    font-size: 0.9375rem; /* Match input size */
    color: var(--apple-dark);
}

.form-check-input {
    border-color: var(--apple-border);
}

.form-check-input:checked {
    background-color: var(--apple-primary);
    border-color: var(--apple-primary);
}

.form-text { /* Helper text below inputs */
    font-size: 0.8rem; /* Smaller text */
    color: var(--apple-secondary);
    margin-top: 0.25rem;
}

/* MERGED: Control group from risk/return page */
.control-group {
    margin-bottom: 1.5rem;
}
.control-group label span {
    font-weight: bold;
    color: var(--apple-primary);
}

/* Multi-select specific styles (Optimization) */
.selected-counter {
    display: inline-block;
    margin-top: 0.5rem; /* 8px */
    margin-bottom: 0.5rem; /* 8px */
    font-weight: 500;
    color: var(--apple-primary);
    font-size: 0.9rem;
}

.select-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 1rem; /* 15px */
    flex-wrap: wrap;
}

.multi-select {
    min-height: 200px;
    max-height: 350px;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    border-radius: var(--border-radius-small); /* Match form controls */
    border: 1px solid var(--apple-border); /* Match form controls */
    padding: 10px;
    font-size: 0.875rem; /* 14px */
    background-color: var(--apple-content-background);
    color: var(--apple-dark);
}

.multi-select:focus {
    border-color: var(--apple-primary);
    box-shadow: 0 0 0 0.2rem rgba(0, 113, 227, 0.25);
    outline: none;
}


.multi-select optgroup {
    font-weight: 600;
    color: var(--apple-dark);
    padding: 0.5rem 0.25rem; /* 8px 4px */
    font-size: 0.95rem;
}

.multi-select option {
    white-space: normal;
    padding: 0.5rem 0.875rem; /* ~8px 14px */
    cursor: pointer;
    border-radius: 4px; /* Slight radius for options */
    margin-bottom: 2px; /* Spacing between options */
}

.multi-select option:hover {
    background-color: var(--apple-light-gray);
}

.multi-select option:checked {
    background-color: var(--apple-primary);
    color: white;
}
.multi-select option:checked:hover {
    background-color: var(--apple-primary-dark);
}

/* Inline Options Layout (Tools) */
.inline-options {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end; /* Align items to bottom */
}

/* Slider Styles (Bootstrap form-range) */
.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.form-range {
    flex-grow: 1;
    accent-color: var(--apple-primary);
    width: 100%; /* MERGED: Ensure it takes full width within its container */
    cursor: pointer; /* MERGED: Add pointer cursor */
}

.slider-value {
    font-weight: 500;
    min-width: 45px;
    text-align: right;
    color: var(--apple-primary);
    font-size: 0.9rem;
}

/* Specific Form Sections (Growth Projection - uses .content-card) */
.form-section { /* Is a .content-card */
    /* Inherits base padding, background, border, shadow */
}

.form-section h2 { /* Heading inside the form card */
    margin-top: 0; /* Remove top margin for first heading */
    margin-bottom: 1.5rem; /* Adjusted from 20px */
    font-size: 1.5rem; /* Adjusted from 24px */
    font-weight: 600;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--apple-border);
}

.form-section h3 { /* Sub-headings within the form card */
    margin: 1.875rem 0 1rem; /* 30px 0 15px */
    font-size: 1.25rem; /* Adjusted from 18px */
    font-weight: 600;
    color: var(--apple-dark);
    border-bottom: 1px solid var(--apple-border);
    padding-bottom: 0.5rem; /* 8px */
}

.form-section h3:first-of-type {
    margin-top: 0; /* No top margin for the very first H3 */
}

/* Style for dynamically added outflow periods */
.outflow-period {
    background-color: var(--apple-light-gray);
    border-radius: var(--border-radius-standard); /* Consistent radius */
    padding: 1rem 1.25rem; /* Adjusted padding */
    margin-bottom: 1rem; /* Spacing */
    border: 1px dashed var(--apple-secondary); /* Retain dashed border from inline style */
}

.outflow-period h5 { /* Heading inside outflow box */
    font-size: 1rem; /* Adjusted from 16px */
    font-weight: 500;
    margin-top: 0;
    margin-bottom: 1rem; /* Spacing below heading */
    color: var(--apple-dark);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--apple-border);
}

.form-buttons { /* Button container at form bottom */
    display: flex;
    gap: 1rem; /* Adjusted from 15px */
    margin-top: 2rem; /* Adjusted from 30px */
    justify-content: flex-start; /* Align buttons left */
    flex-wrap: wrap; /* Allow buttons to wrap on small screens */
}


/* ======= Tables ======= */
/* Data Table (Used in Tools/main) */
.data-table-container {
    margin-top: 1rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--apple-border);
    border-radius: var(--border-radius-small);
    background-color: var(--apple-content-background);
}

.data-table {
    font-size: 0.8rem;
    margin-bottom: 0;
    width: 100%;
    white-space: nowrap;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    background-color: var(--apple-light-gray);
    color: var(--apple-dark);
    font-weight: 500;
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 2px solid var(--apple-border);
}

.data-table td,
.data-table th {
    padding: 0.4rem 0.6rem;
    vertical-align: middle;
    text-align: center;
    border-bottom: 1px solid var(--apple-border);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table td:first-child,
.data-table th:first-child {
    text-align: left;
    padding-left: 1rem;
}

.data-table td:last-child,
.data-table th:last-child {
    text-align: right;
    padding-right: 1rem;
}

/* Allocation Table (Simpler style, from Optimization) */
.allocation-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
    font-size: 0.9rem;
    border: 1px solid var(--apple-border);
    border-radius: var(--border-radius-small);
    overflow: hidden;
    background-color: var(--apple-content-background);
}

.allocation-table th {
    text-align: left;
    padding: 0.625rem 1rem; /* 10px 15px */
    background-color: var(--apple-light-gray);
    border-bottom: 1px solid var(--apple-border);
    font-weight: 500;
    color: var(--apple-dark);
}

.allocation-table th:last-child {
    text-align: right;
}

.allocation-table td {
    padding: 0.625rem 1rem; /* 10px 15px */
    border-bottom: 1px solid var(--apple-border);
    color: var(--apple-dark);
    vertical-align: middle;
}

.allocation-table td:last-child {
    text-align: right;
    font-weight: 500;
    color: var(--apple-primary);
}

.allocation-table tr:last-child td {
    border-bottom: none;
}

.allocation-table tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* MERGED: Education Table (from risk/return page) */
.education-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.9rem;
}
.education-table th, .education-table td {
    padding: 0.625rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--apple-border);
}
.education-table thead th {
    background-color: var(--apple-light-gray);
    font-weight: 500;
    color: var(--apple-dark);
}
.education-table tbody tr:hover {
    background-color: var(--apple-light-gray);
    opacity: 0.7;
}
.education-table td:nth-child(2),
.education-table td:nth-child(3) {
    text-align: center; /* Keep specific alignment */
}

/* ======= Buttons ======= */
/* Base Button Styles */
.btn {
    border-radius: var(--border-radius-small);
    font-weight: 500;
    transition: var(--transition-standard);
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    vertical-align: middle;
    user-select: none;
    border: 1px solid transparent;
    line-height: 1.5; /* Ensure consistent line height */
    position: relative; /* Needed for spinner positioning */
}

/* Button Spinner Styles */
.btn .btn-spinner {
    display: none; /* Hidden by default */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 1.2em; /* Relative to button font size */
    height: 1.2em;
    border: 0.15em solid currentColor; /* Spinner color matches button text color */
    border-right-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.75s linear infinite;
}

.btn.loading {
    pointer-events: none; /* Disable clicks while loading */
    /* Optional: slightly dim the button */
    /* opacity: 0.85; */
}

.btn.loading .btn-text {
    color: transparent !important; /* Hide original text by making it transparent */
    visibility: hidden; /* Further ensure it's not accidentally visible or selectable */
}

.btn.loading .btn-spinner {
    display: inline-block;
}

@keyframes btn-spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}


.btn:hover {
    transform: translateY(-1px);
    filter: brightness(95%); /* Slight darken/lighten effect */
}
.btn:active {
    transform: translateY(0px);
    filter: brightness(90%);
}
.btn:focus-visible { /* Modern focus outline */
    outline: 2px solid var(--apple-primary);
    outline-offset: 2px;
    box-shadow: none; /* Remove Bootstrap's default focus shadow if needed */
}


/* Primary Button */
.btn-primary {
    background-color: var(--apple-primary);
    border-color: var(--apple-primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--apple-primary-dark);
    border-color: var(--apple-primary-dark);
    color: white;
    filter: none; /* Override base hover filter */
}

/* Outline Secondary Button */
.btn-outline-secondary {
    color: var(--apple-secondary);
    border-color: var(--apple-border);
    background-color: transparent;
}

.btn-outline-secondary:hover {
    color: var(--apple-dark);
    background-color: var(--apple-light-gray);
    border-color: var(--apple-border);
    filter: none; /* Override base hover filter */
}

/* Large Button Size */
.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
}

/* Card Button (Landing Page) */
.btn-card {
    width: 100%;
    background-color: var(--apple-primary);
    color: white;
    border: none;
    border-radius: var(--border-radius-standard); /* 12px */
    padding: 0.875rem 1.25rem; /* 14px 20px */
    font-size: 1.125rem; /* 18px */
    font-weight: 500;
    transition: all 0.2s ease;
    text-align: center;
    display: block;
    text-decoration: none;
}

.btn-card:hover {
    background-color: var(--apple-primary-dark);
    transform: translateY(-1px);
    color: white;
    filter: none;
}

/* Copy Button (Optimization) */
.copy-button {
    margin-top: 10px;
    padding: 6px 12px;
    background-color: var(--apple-light-gray);
    border: 1px solid var(--apple-border);
    border-radius: 6px;
    color: var(--apple-dark);
    font-size: 0.8125rem; /* 13px */
    cursor: pointer;
    transition: background-color 0.2s;
}

.copy-button:hover {
    background-color: #e5e5ea; /* Slightly darker gray */
}

.copy-notification {
    display: none; /* Initially hidden */
    margin-left: 10px;
    color: var(--apple-success);
    font-size: 0.8125rem; /* 13px */
}

/* MERGED: Preset Buttons (from risk/return page) */
.presets {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
}
.preset-btn {
    flex: 1;
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
    border: 1px solid var(--apple-primary);
    background-color: transparent;
    color: var(--apple-primary);
    border-radius: var(--border-radius-small);
    cursor: pointer;
    transition: var(--transition-standard);
}
.preset-btn:hover, .preset-btn.active {
    background-color: var(--apple-primary);
    color: white;
}


/* ======= Charts & Plots ======= */
/* General .plotly-chart-container (Refined and Merged) */
.plotly-chart-container {
    background-color: var(--chart-background);
    border-radius: var(--border-radius-standard);
    padding: 0.5rem; /* Keep padding minimal as Plotly handles internal margins */
    margin-bottom: 1.5rem;
    min-height: 450px; /* Default min-height for desktop */
    overflow: hidden; /* Crucial to contain the plot */
    border: 1px solid var(--apple-border);
    width: 100%; /* Take full width of parent */
    position: relative; /* For potential absolute positioned elements inside */
}

/* Ensure the Plotly div itself uses the container's dimensions */
.plotly-chart-container .js-plotly-plot,
.plotly-chart-container .plotly-graph-div {
    width: 100% !important;
    height: 100% !important;
}

/* Selector to ensure Plotly uses the container background (from original, good to keep) */
.plotly-chart-container .plotly .plot-container {
    background-color: var(--chart-background) !important;
}


/* General Chart Container (e.g., for images, Chart.js) */
.chart-container {
    background-color: var(--apple-content-background);
    border-radius: var(--border-radius-large);
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--apple-border);
    position: relative; /* MERGED: Crucial for positioning canvas/title */
    min-height: 400px; /* MERGED: Give a default min height */
}

/* MERGED: Specific styles for Chart.js canvas inside its container */
.chart-container canvas {
    box-sizing: border-box;
    padding: 1.5rem; /* Match the wrapper's padding so chart elements don't hit the edge */
}

.chart-container h3 { /* MERGED: Style for titles inside chart-container */
    text-align: center;
    font-weight: 500;
    margin: 0 0 1.5rem 0;
    color: var(--apple-dark);
    position: relative; /* Ensures title appears ON TOP of the canvas */
    z-index: 10;
}

.chart-img {
    width: 100%;
    height: auto;
    border-radius: var(--border-radius-standard);
    display: block;
    margin: 0 auto;
}

/* Specific Plot Container (Growth Projection - by ID - original) */
#plot-container,
#plot-container-placeholder {
    width: 100%;
    /* height: 450px; -- Height now controlled by .plotly-chart-container's min-height and JS/CSS for responsiveness */
    margin-bottom: 1.5rem;
    border-radius: var(--border-radius-standard); /* Consistent radius */
    border: 1px solid var(--apple-border);
    overflow: hidden;
    background-color: var(--chart-background); /* Consistent light background */
}

#plot-container {
     /* display: none; set by JS */
     /* Used for the actual Plotly chart */
}

#plot-container-placeholder {
    /* display: flex; set by JS */
    align-items: center;
    justify-content: center;
    border-style: dashed; /* Dashed border for placeholder */
    color: var(--apple-secondary);
    min-height: 450px; /* Match .plotly-chart-container default */
}
#plot-container-placeholder p {
     margin-bottom: 0; /* Remove margin from placeholder text */
     padding: 1rem; /* Add some padding to text */
     text-align: center;
}

/* Wrapper for results below the chart (original) */
.results-content {
    margin-top: 1.5rem; /* Spacing below chart/placeholder */
}

/* ======= Chart Maximize Feature (Refined for #chart-wrapper-normalized) ======= */
/* General class for all chart wrappers */
.chart-wrapper {
    position: relative;
}

/* Specific ID for the chart that has maximize functionality */
#chart-wrapper-normalized {
    transition: background-color 0.3s ease-in-out, padding 0.3s ease-in-out;
}

/* Maximize button, when inside a .chart-wrapper */
.chart-wrapper .chart-control-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 30;
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--apple-border);
    border-radius: var(--border-radius-small);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 0.25rem 0.5rem;
    line-height: 1;
}
.chart-wrapper .chart-control-btn:hover {
     background-color: white;
     border-color: var(--apple-secondary);
     box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}
.chart-wrapper .chart-control-btn .icon-minimize { display: none; }

/* When #chart-wrapper-normalized is maximized */
#chart-wrapper-normalized.chart-maximized .chart-control-btn .icon-maximize { display: none; }
#chart-wrapper-normalized.chart-maximized .chart-control-btn .icon-minimize { display: inline-block; }

#chart-wrapper-normalized.chart-maximized {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1050;
    background-color: var(--apple-content-background);
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* The .plotly-chart-container *inside* the maximized #chart-wrapper-normalized */
#chart-wrapper-normalized.chart-maximized .plotly-chart-container {
    flex-grow: 1;
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    overflow: hidden;
}

/* Prevent body scroll when chart is maximized */
body.chart-is-maximized {
    overflow: hidden;
}

/* --- Original #chart-wrapper maximize styles (Kept in case used by other pages) --- */
/* Styles when the chart wrapper is maximized - RESET TO PREVIOUSLY WORKING */
#chart-wrapper.chart-maximized { /* More generic selector */
    position: fixed; /* Make it cover the viewport */
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1050; /* High z-index */
    background-color: var(--apple-content-background); /* Use a background */
    margin: 0;
    padding: 20px; /* Padding around the maximized chart */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Hide potential overflow */
}

#chart-wrapper.chart-maximized .chart-control-btn { /* Adjust button position for generic wrapper */
    position: absolute;
    top: 25px;
    left: 25px;
}

/* Ensure the direct child plot container takes full height for generic wrapper */
#chart-wrapper.chart-maximized > .plotly-chart-container {
    flex-grow: 1;
    height: 100%;
    min-height: 150px;
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    display: block;
}

/* Force ANY Plotly generated div *inside* the container to expand for generic wrapper */
#chart-wrapper.chart-maximized .plotly-chart-container .js-plotly-plot,
#chart-wrapper.chart-maximized .plotly-chart-container .plotly-graph-div {
    width: 100% !important;
    height: 100% !important;
    min-height: 150px; /* Minimum size */
}


/* Also ensure the placeholder fills space if needed for generic wrapper */
#chart-wrapper.chart-maximized #plot-container-placeholder {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    margin-bottom: 0;
}

/* --- Ensure table styles don't interfere unexpectedly --- (Original) */
#recovery-table-wrapper {
    overflow-x: auto;
    margin-bottom: 1.5rem;
    padding: 0;
}
.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}
 .table-controls h5 { margin-bottom: 0; }
 #copyTableImageBtn .spinner-border-sm { display: none; }
 #copyTableImageBtn.loading .spinner-border-sm { display: inline-block; }
 #copyTableImageBtn.loading .btn-text { display: none; }

/* Toggle button icons (Original, specific to a generic #chart-wrapper ) */
#chart-wrapper.chart-maximized .chart-control-btn .icon-maximize {
    display: none;
}
#chart-wrapper.chart-maximized .chart-control-btn .icon-minimize {
    display: inline-block;
}

/* ======= Tabs & Accordions ======= */

/* MERGED: Custom Tabs Component (from risk/return page) */
.tabs {
    font-size: 0.9rem;
    margin-bottom: 2rem; /* Add space below the whole tab component */
}
.tabs input[type="radio"] {
    display: none;
}
.tabs .tab-labels {
    border-bottom: 1px solid var(--apple-border);
    margin-bottom: -1px; /* Overlap with tab content border */
}
.tabs .tab-label {
    display: inline-block;
    padding: 0.75rem 1.25rem;
    margin-right: 0.5rem;
    cursor: pointer;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: var(--border-radius-small) var(--border-radius-small) 0 0;
    background: transparent;
    color: var(--apple-secondary);
    position: relative;
    transition: var(--transition-standard);
}
.tabs .tab-label:hover {
    color: var(--apple-dark);
    background-color: var(--apple-light-gray);
}
.tabs input:checked + .tab-label {
    background: var(--apple-content-background);
    color: var(--apple-primary);
    font-weight: 500;
    border-color: var(--apple-border);
    border-bottom-color: var(--apple-content-background); /* Hide bottom border of active tab */
}
.tab-content {
    display: none;
    padding: 1.5rem;
    border: 1px solid var(--apple-border);
    border-radius: 0 var(--border-radius-small) var(--border-radius-small) var(--border-radius-small);
    background: var(--apple-content-background);
}
#tab1:checked ~ .tab-contents > #content1,
#tab2:checked ~ .tab-contents > #content2,
#tab3:checked ~ .tab-contents > #content3 {
    display: block;
}


/* ======= Information & Explanations ======= */
/* Explanation Section (Tools) */
.explanation-section {
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: var(--apple-light-gray);
    border-radius: var(--border-radius-standard);
    border: 1px solid var(--apple-border);
}

.explanation-section h5 {
    font-weight: 500;
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--apple-dark);
}

/* Info Box (Optimization) */
.info-box {
    background-color: var(--apple-light-gray);
    border-radius: var(--border-radius-standard); /* 16px */
    padding: 1.5rem; /* 24px */
    margin: 1.25rem 0; /* 20px 0 */
    border: 1px solid var(--apple-border);
}

.info-box p,
.info-box li {
    color: var(--apple-secondary);
    font-size: 0.9375rem; /* 15px */
    line-height: 1.5;
}

.info-box ul {
    color: var(--apple-secondary);
    margin-bottom: 1.25rem; /* 20px */
    padding-left: 20px;
}

.info-box h4 {
    margin-top: 0;
    margin-bottom: 1rem; /* 15px */
    font-size: 1.125rem; /* 18px */
    font-weight: 500;
    color: var(--apple-dark);
}

/* Info Section (Landing Page) */
.info-section {
    background-color: var(--apple-content-background);
    border-radius: 20px; /* Specific radius */
    padding: 2.5rem; /* 40px */
    margin-bottom: 3.75rem; /* 60px */
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--apple-border);
}

.info-section h2 {
    margin-top: 0;
    font-size: 2rem; /* 32px */
    font-weight: 600;
    margin-bottom: 1.25rem; /* 20px */
    color: var(--apple-dark);
}

.info-section p,
.info-section li {
    color: var(--apple-secondary);
    font-size: 1.0625rem; /* 17px */
    line-height: 1.6;
}

.info-section ul {
    margin-bottom: 1.25rem; /* 20px */
    padding-left: 20px;
}

/* Info Icon & Tooltip (Optimization) */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: var(--apple-secondary);
    color: white;
    font-size: 12px;
    margin-left: 6px;
    cursor: pointer;
    vertical-align: middle;
}

[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]:after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(29, 29, 31, 0.9); /* Darker background based on --apple-dark */
    color: white;
    padding: 8px 12px;
    border-radius: var(--border-radius-small);
    font-size: 12px;
    width: 250px;
    max-width: 90vw;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    font-weight: 400;
    line-height: 1.4;
    text-align: left;
}

[data-tooltip]:hover:after {
    opacity: 1;
    visibility: visible;
}


/* ======= Specific Layouts ======= */
/* Landing Page Cards Container */
.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 3.75rem; /* 60px */
}

/* Optimization Allocation Grid */
.allocation-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem; /* 24px */
    margin-bottom: 1.5rem; /* 24px */
}

/* MERGED: Dashboard Grid Layout (from risk/return page) */
.dashboard-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
}

/* MERGED: Visualizations Grid Layout (from risk/return page) */
.visualizations-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

/* MERGED: Probability Cards Grid Layout (from risk/return page) */
.probability-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

/* Growth Projection Results Section (uses .content-card) */
.results-section { /* This is a .content-card, inherits its styles */
     height: auto; /* Let content determine height */
}


/* ======= Utility & Misc ======= */
/* Alerts (Using Bootstrap classes assumed) */
.alert {
    border-radius: var(--border-radius-small);
    padding: 1rem 1.25rem;
    /* Customizations */
    border-width: 0; /* Remove default border if using background */
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.alert h4, .alert h5, .alert strong {
     color: inherit; /* Ensure heading/strong text inherits alert color */
     font-weight: 500;
}
.alert-info {
    background-color: #e7f6fd;
    color: #0a58ca; /* Adjusted for better contrast */
}
.alert-danger {
    background-color: #fdecea;
    color: var(--apple-error);
}
.alert-warning {
    background-color: #fffacc;
    color: #664d03;
}
.alert-success {
    background-color: #d1f5d3;
    color: #0f5132;
}
.alert-secondary {
    background-color: var(--apple-light-gray);
    color: var(--apple-secondary);
    box-shadow: none;
    border: 1px solid var(--apple-border);
}

/* Disclaimers */
/* Page Content Disclaimer (e.g., Optimization results) */
.disclaimer-section {
    font-size: 0.875rem; /* 14px */
    color: var(--apple-secondary);
    padding: 1.25rem; /* 20px */
    border-top: 1px solid var(--apple-border);
    margin-top: 2rem; /* 30px */
    background-color: var(--apple-light-gray);
    border-radius: var(--border-radius-standard);
}

.disclaimer-section h4 {
    color: var(--apple-dark);
    font-size: 1rem; /* 16px */
    margin-top: 0;
    margin-bottom: 1rem; /* 15px */
}

.disclaimer-section p {
    margin-bottom: 1rem; /* 15px */
    line-height: 1.5;
}

/* Footer Disclaimer (Defined in Footer section) */

/* Spinners */
/* Bootstrap Spinner Addon (Optimization) */
.spinner-border { /* Assumes Bootstrap's class */
    margin-right: 8px;
    vertical-align: text-bottom;
}

/* Custom Loading Spinner (Growth Projection) */
.loading-spinner {
    display: none; /* Initially hidden - controlled by JS */
    border: 4px solid var(--apple-light-gray);
    border-top: 4px solid var(--apple-primary); /* Use primary color for spinner */
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 1.25rem auto 0; /* 20px auto 0 - Spacing and centering */
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
/* Container for loading spinner and potential text */
#loading-indicator {
    min-height: 54px; /* Height of spinner + margin */
}

/* Hidden Utility */
.hidden {
    display: none !important;
}
/* Visually Hidden (for accessibility) */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}


/* ======= Footer ======= */
.footer {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(18px);
    margin-top: auto;
    border-top: 1px solid rgba(210, 210, 215, 0.55);
    padding: 2.5rem 0;
}

.footer-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.footer-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--apple-dark);
    text-decoration: none;
}

.footer-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

.footer-subtitle {
    margin: 0.1rem 0 0;
    font-size: 0.8rem;
    color: var(--apple-secondary);
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.footer-links a {
    color: var(--apple-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: color 0.2s ease, transform 0.2s ease;
}

.footer-links a:hover {
    color: var(--apple-dark);
    transform: translateY(-1px);
}

.footer-disclaimer {
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.6;
    color: var(--apple-secondary);
    max-width: 900px;
}


/* ==========================================================================
   Styles SPECIFIC to performance_comparison.html (and refinements)
   ========================================================================== */

.chart-section {
    margin-bottom: 2rem;
    padding-top: 1rem;
}
.chart-section:first-child {
    padding-top: 0;
}

.chart-section h5 {
    margin-bottom: 1rem; /* Increased space below title for clarity */
}

/* Metrics Table Styling (for results.metrics_table_html output) */
.metrics-table-wrapper {
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border: 1px solid var(--apple-border);
    border-radius: var(--border-radius-small);
    background-color: var(--apple-content-background);
}

.metrics-table-wrapper table {
    width: 100%;
    min-width: 600px; /* Minimum width before scrollbar appears, adjust as needed */
    white-space: nowrap;
    border-collapse: collapse;
    font-size: 0.825rem;
}

.metrics-table-wrapper th,
.metrics-table-wrapper td {
    padding: 0.6rem 0.8rem;
    text-align: center;
    vertical-align: middle;
    border-bottom: 1px solid var(--apple-border);
    border-right: 1px solid var(--apple-border); /* Cell separation */
}
.metrics-table-wrapper th:last-child,
.metrics-table-wrapper td:last-child {
    border-right: none; /* Remove last right border */
}

.metrics-table-wrapper th {
    background-color: var(--apple-light-gray);
    font-weight: 500;
    color: var(--apple-dark);
    position: sticky; /* Sticky header for vertical scroll in wrapper */
    top: 0;
    z-index: 10; /* Above content but below modals/nav */
}

.metrics-table-wrapper th:first-child,
.metrics-table-wrapper td:first-child {
    text-align: left;
    font-weight: 500; /* Make labels bold */
}

.metrics-table-wrapper tr:last-child td {
    border-bottom: none;
}

.metrics-table-wrapper tr:hover td {
    background-color: var(--apple-light-gray);
}


/* ==========================================================================
   Styles SPECIFIC to growth_projection.html
   NOTE: These highly specific classes are kept separate for clarity.
   ========================================================================== */

.growth-projection-page .card {
    border: 1px solid #e0e0e0;
    transition: box-shadow 0.3s ease-in-out;
}

.growth-projection-page .card:hover {
    box-shadow: 0 0.25rem 0.75rem rgba(0,0,0,0.075);
}

.growth-projection-page .card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.growth-projection-page .form-label {
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
}

.growth-projection-page .form-text {
    font-size: 0.8rem;
    color: #6c757d;
}

.growth-projection-page .accordion-button {
    font-weight: 500;
    font-size: 1.05rem;
    color: #333;
}

.growth-projection-page .accordion-button:not(.collapsed) {
    background-color: #e9ecef;
    color: #0056b3;
    box-shadow: inset 0 -1px 0 rgba(0,0,0,.125);
}

.growth-projection-page .accordion-button:focus {
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.growth-projection-page .accordion-body {
    padding: 1rem 1.25rem;
}

.growth-projection-page .accordion-item {
    border-color: #dee2e6;
}
.growth-projection-page .accordion-item:first-of-type .accordion-button {
    border-top-left-radius: calc(0.25rem - 1px);
    border-top-right-radius: calc(0.25rem - 1px);
}
.growth-projection-page .accordion-item:last-of-type .accordion-button.collapsed {
    border-bottom-right-radius: calc(0.25rem - 1px);
    border-bottom-left-radius: calc(0.25rem - 1px);
}

.growth-projection-page .input-group-text {
    background-color: #e9ecef;
    border-color: #ced4da;
    font-size: 0.9rem;
}

.growth-projection-page .outflow-period-card {
    border: 1px dashed #ced4da;
    padding: 0.75rem;
    background-color: #f8f9fa !important;
}
.growth-projection-page .outflow-period-card .form-label-sm {
    font-size: 0.8rem;
}
.growth-projection-page .outflow-period-card .input-group-sm .form-control-sm,
.growth-projection-page .outflow-period-card .input-group-sm .input-group-text {
    font-size: 0.8rem;
}

.growth-projection-page .form-buttons {
    padding-top: 1.5rem;
    border-top: 1px solid #e9ecef;
}
.growth-projection-page .form-buttons .btn-lg {
    padding: 0.6rem 1.5rem;
}

.growth-projection-page .loading-spinner {
    width: 1.5rem;
    height: 1.5rem;
    border-width: .2em;
    color: var(--apple-primary);
    vertical-align: text-bottom;
}

.growth-projection-page .results-column .card-header .btn-outline-secondary {
    border-color: #adb5bd;
    color: #495057;
}
.growth-projection-page .results-column .card-header .btn-outline-secondary:hover {
    background-color: #e9ecef;
}

.growth-projection-page .chart-placeholder {
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fa;
}

.growth-projection-page #plot-container {
    min-height: 400px;
}

.growth-projection-page .data-summary-box {
    background-color: #fdfdfd;
    height: 100%;
}

.growth-projection-page .data-summary-box .h6 {
    font-weight: 600;
    color: #0d6efd;
    padding-bottom: 0.6rem;
    margin-bottom: 1rem !important;
    border-bottom: 1px solid #e9ecef;
}

.growth-projection-page .data-summary-box .h4.fs-sm {
    font-size: 0.9rem;
    font-weight: 600;
    color: #343a40;
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
}
.growth-projection-page .data-summary-box .dl-metrics + .h4.fs-sm {
    margin-top: 1.5rem;
}

.growth-projection-page .dl-metrics {
    display: grid;
    grid-template-columns: minmax(auto, 45%) 1fr;
    gap: 0.5rem 1rem;
    align-items: baseline;
}
.growth-projection-page .dl-metrics dt {
    grid-column: 1;
    text-align: left;
    font-weight: 400;
    color: #586069;
    font-size: 0.875rem;
    padding: 0.1rem 0;
}
.growth-projection-page .dl-metrics dd {
    grid-column: 2;
    text-align: left;
    font-weight: 600;
    color: #24292e;
    font-size: 0.875rem;
    margin-bottom: 0;
    word-break: break-word;
    padding: 0.1rem 0;
}

.growth-projection-page .dl-metrics dt.metric-group-separator {
    grid-column: 1 / -1;
    border-top: 1px dashed #d8dfe5;
    padding-top: 0.75rem;
    margin-top: 0.75rem;
    color: transparent;
    font-size: 0;
    line-height: 0;
}

.growth-projection-page .dl-metrics dd ul {
    margin: 0.25rem 0 0 0;
    padding-left: 1rem;
    list-style-position: outside;
}
.growth-projection-page .dl-metrics dd ul li {
    color: #454c54;
    font-weight: 400;
    font-size: 0.8rem;
    margin-bottom: 0.1rem;
}

.growth-projection-page .dl-metrics dd:is(:empty)::after,
.growth-projection-page .dl-metrics dd:contains('None') {
    content: var(--dd-empty-content, "None");
    font-style: italic;
    color: #6c757d;
    font-weight: 400;
}

.growth-projection-page #chart-wrapper {
    position: relative;
}

.growth-projection-page #chart-wrapper.chart-maximized {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    padding: 15px;
    z-index: 1060;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
}

.growth-projection-page #chart-wrapper.chart-maximized #plot-container {
    flex-grow: 1;
    min-height: 0;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
}

.growth-projection-page #chart-wrapper.chart-maximized .chart-control-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1061;
}

.growth-projection-page #chart-wrapper.chart-maximized #plot-container .plotly,
.growth-projection-page #chart-wrapper.chart-maximized #plot-container .plotly .main-svg,
.growth-projection-page #chart-wrapper.chart-maximized #plot-container .plotly .main-svg .draglayer {
    width: 100% !important;
    height: 100% !important;
}

.growth-projection-page .results-footer .alert-secondary {
    background-color: #eef2f7;
    border-color: #d1d9e2;
    color: #385069;
}


/* ======= Responsive Adjustments (MERGED) ======= */

/* Tablets & Smaller Desktops */
@media (max-width: 1199.98px) { /* Use .98 suffix for Bootstrap breakpoints */
    .cards-container {
        grid-template-columns: repeat(2, 1fr);
    }
    /* MERGED: Responsive layouts from risk/return */
    .dashboard-grid, .visualizations-grid {
        grid-template-columns: 1fr;
    }
}

/* Tablets */
@media (max-width: 991.98px) {
    /* Typography */
    h1, .page-header h1, .landing-header h1 { font-size: 2rem; }
    h2, .info-section h2 { font-size: 1.75rem; }
    h3, .form-section h3 { font-size: 1.4rem; }
    .subtitle, .page-header .subtitle { font-size: 1.1rem; }

    /* Navigation */
    .nav-wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .nav-actions {
        width: 100%;
        justify-content: space-between;
    }

    /* Landing */
    .landing-hero {
        grid-template-columns: 1fr;
        padding: 3.5rem 0 2.5rem;
    }
    .landing-hero h1 {
        font-size: 2.5rem;
    }
    .hero-visual {
        justify-content: flex-start;
    }
    .hero-visual-card {
        max-width: 420px;
    }

    /* Headers */
    .page-header { padding: 30px 0 15px; }
    .landing-header { padding: 40px 0 30px; }

    /* Cards & Containers */
    .content-card { padding: 1.5rem; }
    .results-container { margin-top: 2rem; margin-bottom: 2rem; }
    .results-header { padding: 1.25rem; }
    .results-body { padding: 1.25rem; }
    .performance-metric { padding: 12px; }
    .performance-metric p { font-size: 1.25rem; }
    .info-box { padding: 1.25rem; }
    .info-section { padding: 2rem; }
    .result-box { padding: 1.25rem; }

    /* Forms */
    .inline-options {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    .content-wrapper .col-lg-6 {
         margin-bottom: 1.5rem;
     }
     .content-wrapper .col-lg-6:last-child {
         margin-bottom: 0;
     }

    /* Chart/Plot Heights */
    .plotly-chart-container, #plot-container-placeholder { min-height: 350px; }
    .chart-container { min-height: 350px; }

    /* Table Font Sizes */
     .metrics-table-wrapper table { font-size: 0.8rem; }
    .metrics-table-wrapper th,
    .metrics-table-wrapper td { padding: 0.5rem 0.6rem; }

    /* MERGED: Responsive layouts from risk/return */
    .probability-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Page-specific responsive */
    .growth-projection-page .form-column,
    .growth-projection-page .results-column {
        margin-bottom: 2rem;
    }
    .growth-projection-page .results-column {
        margin-bottom: 0;
    }
    .growth-projection-page #plot-container {
        min-height: 350px;
    }
}

/* Mobile Devices */
@media (max-width: 767.98px) {
    /* Layout */
    .container, .nav-wrapper, .footer-inner { padding: 0 15px; }

    /* Navigation */
    .nav-wrapper {
        align-items: stretch;
    }
    .nav-actions {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 0.5rem;
    }
    .nav-cta {
        width: 100%;
        justify-content: center;
    }

    /* Landing */
    .landing-hero {
        padding: 3rem 0 2rem;
        gap: 2.5rem;
    }
    .landing-hero h1 {
        font-size: 2.2rem;
    }
    .hero-button {
        width: 100%;
    }
    .hero-stats {
        gap: 1.1rem;
    }
    .hero-visual-card {
        padding: 1.75rem;
    }
    .tool-section-header {
        align-items: flex-start;
    }
    .tool-grid {
        gap: 1.5rem;
    }

    /* Specific Layouts */
    .allocation-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .cards-container {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
    .dashboard-grid, .probability-cards-grid {
        grid-template-columns: 1fr;
    }

    /* Cards & Chart Containers */
    .card-img-container { height: 180px; }
    .chart-container { padding: 1rem; min-height: 350px; }
    .card-content { padding: 1.25rem; }
    .card-title { font-size: 1.5rem; }

    /* Forms & Buttons */
    .select-actions { flex-direction: column; gap: 8px; }
    .select-actions .btn { width: 100%; }
    .form-buttons { flex-direction: column; gap: 0.75rem; }
    .form-buttons .btn { width: 100%; }

    /* Column Stacking */
     .form-section .row.g-3 .col-md-6,
     .results-content .row .col-md-6 {
         width: 100%;
     }
     .form-section .row.g-3,
     .results-content .row {
         gap: 0.75rem 0;
     }
     .result-box { margin-bottom: 1rem; }

    /* Chart/Plot heights */
    .plotly-chart-container, #plot-container-placeholder { min-height: 320px; padding: 0.25rem; }

    /* Form group spacing for performance_comparison page */
    .form-section .row.g-3 > [class*="col-"] { margin-bottom: 0.75rem; }
    .form-section .row.g-3 > [class*="col-"]:last-of-type { margin-bottom: 0; }
    .form-section .row.g-3 .btn-primary.w-100 { margin-top: 0.25rem; }

    /* Tables on Mobile */
    .metrics-table-wrapper { border-radius: 0; border-left: none; border-right: none; }
    .metrics-table-wrapper table { font-size: 0.75rem; min-width: 500px; }
    .metrics-table-wrapper th,
    .metrics-table-wrapper td { padding: 0.4rem 0.5rem; }

    /* MERGED: Tabs on Mobile */
    .tabs .tab-labels { border-bottom: none; }
    .tabs .tab-label {
        display: block;
        width: auto;
        margin-bottom: 5px;
        text-align: center;
    }
    .tabs input:checked + .tab-label {
        border: 1px solid var(--apple-border);
        border-radius: var(--border-radius-small);
    }
    .tab-content { border-radius: var(--border-radius-small); }

    /* Footer */
    .footer-inner { gap: 1.25rem; }
    .footer-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .footer-links { gap: 0.75rem; }
    .footer-disclaimer { font-size: 0.7rem; }

    /* Navigation on Mobile */
    /* Page-specific responsive */
    .growth-projection-page .display-5 { font-size: 2.25rem; }
    .growth-projection-page .lead { font-size: 1rem; }
    .growth-projection-page .form-buttons { flex-direction: column; align-items: stretch !important; }
    .growth-projection-page .form-buttons .btn { width: 100%; }
    .growth-projection-page .form-buttons .btn:not(:last-child) { margin-bottom: 0.75rem !important; margin-right: 0 !important; }
    .growth-projection-page .form-buttons #loading-indicator { margin-left: 0 !important; margin-top: 0.75rem; text-align: center; }
    .growth-projection-page #plot-container { min-height: 300px; }
    .growth-projection-page .dl-metrics dt,
    .growth-projection-page .dl-metrics dd { font-size: 0.85rem; }
}

/* Extra Small Devices (Optional Fine-tuning) */
@media (max-width: 575.98px) {
    h1, .page-header h1, .landing-header h1 { font-size: 1.8rem; }
    h2, .info-section h2 { font-size: 1.6rem; }

    .content-card,
    .results-body,
    .results-header,
    .info-box,
    .info-section,
    .result-box {
        padding: 1rem;
    }
    .form-section h2 { margin-bottom: 1rem; padding-bottom: 0.5rem; }
    .form-section h3 { margin: 1.5rem 0 0.75rem; padding-bottom: 0.4rem; }

    .btn { padding: 0.5rem 1rem; font-size: 0.9rem; }
    .btn-lg { padding: 0.6rem 1.2rem; font-size: 1rem; }
    .btn-card { padding: 0.75rem 1rem; font-size: 1rem; }

    /* Chart/Plot heights */
     .plotly-chart-container, #plot-container-placeholder { min-height: 280px; }
     .chart-container { min-height: 320px; }

    /* Landing */
    .landing-hero h1 {
        font-size: 1.95rem;
    }
    .hero-visual-value {
        font-size: 2rem;
    }
}
