/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* Modern CSS Reset and Base Styles */
* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    color: #1e293b;
    line-height: 1.5;
    font-weight: 400;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Modern Navigation Bar */
.menubar {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    min-height: 56px;
    position: relative;
    z-index: 1001;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.navbar-brand {
    display: flex;
    align-items: center;
    position: absolute;
    left: 20px;
}

.brand-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: white;
    padding: 12px 16px;
    height: 100%;
    line-height: 1;
    border-radius: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand-link:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.brand-logo {
    width: 28px;
    height: 28px;
    margin-right: 10px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.brand-link:hover .brand-logo {
    transform: scale(1.05);
}

.brand-text {
    font-size: 15px;
    font-weight: 600;
    color: white;
    letter-spacing: -0.025em;
}

.navbar-menu {
    display: flex;
    align-items: center;
    position: relative;
    gap: 6px;
}

.menubar a {
    display: block;
    color: white;
    text-align: center;
    padding: 12px 16px;
    text-decoration: none;
    border-radius: 10px;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.menubar a::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.menubar a:hover::before {
    left: 100%;
}

.menubar a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Modern Dropdown Styles */
.dropbtn {
    background: transparent;
    color: white;
    padding: 12px 16px;
    font-size: 14px;
    border: none;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.dropbtn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.dropbtn:hover::before {
    left: 100%;
}

.dropbtn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    min-width: 160px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    z-index: 1002;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
    transform: translateY(-10px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* Add a small negative margin to eliminate any gap */
    margin-top: -1px;
}

.dropdown-content a {
    float: none;
    color: #1e293b;
    padding: 10px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
    font-weight: 500;
    font-size: 13px;
    border-radius: 0;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.dropdown-content a:last-child {
    border-bottom: none;
}

.dropdown-content a:hover {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: #1e293b;
    transform: translateX(4px);
    padding-left: 20px;
}

.dropdown:hover .dropdown-content {
    display: block;
    transform: translateY(0);
    opacity: 1;
}

/* Ensure the dropdown content itself can maintain hover state */
.dropdown-content:hover {
    display: block;
    transform: translateY(0);
    opacity: 1;
}

/* Content Area */
.content {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Modern Chart Container */
.chart-container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    background: transparent;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    border: none;
    transition: none;
    overflow: visible; /* Allow chart overflow */
    position: relative;
    box-sizing: border-box;
}

.chart-container:hover {
    transform: none;
    box-shadow: none;
}

/* Dashboard Styles */
.dashboard-flex-container {
    display: flex;
    justify-content: center;
    width: 100%;
}

.dashboard-container {
    max-width: 1200px;
    width: 100%;
    padding: 1rem;
}

.dashboard-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.two-cols {
    grid-template-columns: repeat(2, 1fr);
}

.three-cols {
    grid-template-columns: repeat(3, 1fr);
}

.metric-container {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1.3;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    grid-template-columns: 100%;
}

.metric-container:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
}

.section-header {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 1rem 0;
    color: #1e293b;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

.metric-title {
    font-size: 0.75rem;
    color: #64748b;
    margin: 0;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-value {
    font-size: 24px;
    margin: 4px 0;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.02em;
}

.metric-delta {
    font-size: 0.75rem;
    margin: 0;
    font-weight: 600;
}

.positive {
    color: #059669;
}

.negative {
    color: #dc2626;
}

/* Modern Progress Bar */
.progress-bar-container {
    margin-top: 0.5rem;
}

.progress-bar {
    width: 100%;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border-radius: 6px;
    height: 8px;
    margin-top: 6px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-bar-inner {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    height: 100%;
    border-radius: 6px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.progress-label {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    color: #64748b;
    font-weight: 500;
}

/* Enhanced Tooltip */
.tooltip-container {
    position: relative;
    display: inline-block;
    cursor: help;
}

.tooltip-content {
    visibility: hidden;
    width: 280px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(20px);
    color: #f8fafc;
    text-align: left;
    border-radius: 10px;
    padding: 12px;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    margin-left: -140px;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 12px;
    line-height: 1.4;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transform: translateY(10px);
}

.tooltip-content::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: rgba(30, 41, 59, 0.95) transparent transparent transparent;
}

.tooltip-container:hover .tooltip-content {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.info-icon {
    font-style: normal;
    display: inline-block;
    vertical-align: middle;
    margin-left: 4px;
    color: #64748b;
    transition: color 0.2s ease;
}

.tooltip-container:hover .info-icon {
    color: #3b82f6;
}

/* Chart Description Styles */
.chart-description {
    margin: 1.5rem 0;
    padding: 1rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-left: 4px solid #3b82f6;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}

.chart-description p {
    margin: 0;
    color: #475569;
    line-height: 1.5;
    font-weight: 500;
    font-size: 13px;
}

/* Model Info Styles */
.model-info {
    margin: 2rem 0;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

.model-info h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: #1e293b;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

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

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.stat-label {
    font-weight: 600;
    color: #64748b;
    font-size: 0.8rem;
}

.stat-value {
    font-weight: 700;
    color: #1e293b;
    font-size: 1rem;
}

.error {
    color: #dc2626;
    text-align: center;
    padding: 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    background: rgba(220, 38, 38, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(220, 38, 38, 0.2);
}

/* Risk Metrics Styles */
.risk-metrics-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.risk-metric-container {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.risk-metric-container:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
}

.risk-metric-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.risk-metric-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    letter-spacing: -0.025em;
}

.info-link {
    text-decoration: none;
    color: #64748b;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.external-link-icon {
    width: 18px;
    height: 18px;
    filter: invert(40%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(0%) contrast(100%);
    transition: all 0.3s ease;
}

.info-link:hover {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: #3b82f6;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.info-link:hover .external-link-icon {
    filter: invert(59%) sepia(94%) saturate(7482%) hue-rotate(217deg) brightness(97%) contrast(96%);
}

.risk-metric-content {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1rem;
    align-items: center;
}

.risk-metric-value-container {
    text-align: center;
}

.risk-metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 0.5rem 0;
    letter-spacing: -0.02em;
}

.risk-metric-delta {
    font-size: 0.9rem;
    margin: 0;
    font-weight: 600;
}

.risk-metric-chart {
    height: 80px;
    width: 100%;
}

/* Legend Styles */
.legend-container {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.3);
    margin-top: 1rem;
}

.legend-title {
    text-align: center;
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.025em;
}

.legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    align-items: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.legend-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.legend-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #1e293b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.current-value-icon {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

.prior-value-icon {
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.legend-bar {
    width: 80px;
    height: 16px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.range-bar {
    background: linear-gradient(to right, #10b981, #fbbf24, #ef4444);
}

.max-range-bar {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

/* ===== RESPONSIVE DESIGN (SIMPLIFIED) ===== */

/* Tablet (max-width: 1024px) */
@media (max-width: 1024px) {
    .three-cols {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .risk-metric-content {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .legend-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile (max-width: 768px) */
@media (max-width: 768px) {
    body {
        font-size: 13px;
    }
    
    /* Navigation adjustments */
    .menubar {
        padding: 0 12px;
        min-height: 48px;
    }
    
    .navbar-brand {
        left: 12px;
    }
    
    .brand-text {
        display: none;
    }
    
    .brand-logo {
        width: 24px;
        height: 24px;
        margin-right: 0;
    }
    
    .brand-link {
        padding: 8px;
    }
    
    .menubar a,
    .dropbtn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .dropdown-content {
        min-width: 140px;
        padding: 4px 0;
    }
    
    .dropdown-content a {
        padding: 12px 16px;
    }
    
    /* Layout adjustments */
    .content {
        padding: 12px;
    }
    
    /* Grid adjustments */
    .two-cols,
    .three-cols {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .legend-grid {
        grid-template-columns: 1fr;
    }
    
    /* Typography adjustments */
    .section-header {
        font-size: 1.2rem;
    }
    
    .metric-value {
        font-size: 20px;
    }
    
    .risk-metric-value {
        font-size: 1.6rem;
    }
    
    .tooltip-content {
        font-size: 11px;
        width: 240px;
        margin-left: -120px;
    }
}

/* Small Mobile (max-width: 480px) */
@media (max-width: 480px) {
    body {
        font-size: 12px;
    }
    
    /* Navigation adjustments */
    .menubar {
        padding: 0 8px;
        min-height: 44px;
    }
    
    .brand-logo {
        width: 20px;
        height: 20px;
    }
    
    .brand-link {
        padding: 6px;
    }
    
    .menubar a,
    .dropbtn {
        padding: 6px 8px;
        font-size: 12px;
    }
    
    .dropdown-content {
        min-width: 120px;
    }
    
    .dropdown-content a {
        padding: 14px 16px;
    }
    
    /* Layout adjustments */
    .content {
        padding: 8px;
    }
    
    /* Typography adjustments */
    .section-header {
        font-size: 1.1rem;
    }
    
    .metric-value {
        font-size: 18px;
    }
    
    .risk-metric-value {
        font-size: 1.4rem;
    }
    
    .tooltip-content {
        font-size: 10px;
        width: 200px;
        margin-left: -100px;
    }
    
    /* Grid adjustments */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

/* ===== CHART STYLES (SIMPLIFIED & RESPONSIVE) ===== */

/* Base chart styles */
.chart,
.cashflow-chart,
.growth-model-chart,
.projection-chart {
    width: 100%;
    min-width: 0; /* Allow charts to shrink properly */
    height: 400px;
    border-radius: 0;
    overflow: hidden;
    background: transparent;
    border: none;
    position: relative;
    box-shadow: none;
    transition: none;
    margin: 0;
    padding: 0;
}

.chart:hover,
.cashflow-chart:hover,
.growth-model-chart:hover,
.projection-chart:hover {
    box-shadow: none;
    transform: none;
}

.growth-model-chart {
    height: 350px;
}

.risk-metric-chart {
    height: 80px;
    box-shadow: none;
}

/* Plotly responsive containers */
.chart .js-plotly-plot,
.cashflow-chart .js-plotly-plot,
.growth-model-chart .js-plotly-plot,
.projection-chart .js-plotly-plot {
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Ensure Plotly chart elements are visible */
.js-plotly-plot .xtick,
.js-plotly-plot .ytick {
    display: block !important;
    visibility: visible !important;
}

.js-plotly-plot .xtick text,
.js-plotly-plot .ytick text {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Chart page specific styles - only for chart pages, not tools */
.chart-container .chart {
    width: 100% !important;
    height: 500px !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
    overflow: visible !important;
}

/* Mobile responsive adjustments for chart pages */
@media (max-width: 768px) {
    .chart-container .chart {
        height: 350px !important;
    }
    
    .chart-container {
        gap: 15px !important;
    }
    
    .chart-container .chart-description {
        margin-top: 15px !important;
    }
    
    .chart-container .model-info {
        margin-top: 15px !important;
    }
}

@media (max-width: 480px) {
    .chart-container .chart {
        height: 300px !important;
    }
    
    .chart-container {
        gap: 10px !important;
    }
    
    .chart-container .chart-description {
        margin-top: 10px !important;
    }
    
    .chart-container .model-info {
        margin-top: 10px !important;
    }
}

.chart-container .chart .js-plotly-plot {
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
}

/* Ensure legend is visible and positioned correctly */
.chart-container .js-plotly-plot .legend {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 1000 !important;
}

/* Fix chart container spacing for chart pages */
.chart-container {
    display: flex !important;
    flex-direction: column !important;
    gap: 30px !important;
}

.chart-container .chart {
    flex-shrink: 0 !important;
}

.chart-container .chart-description {
    flex-shrink: 0 !important;
    margin-top: 20px !important;
}

.chart-container .model-info {
    flex-shrink: 0 !important;
    margin-top: 20px !important;
}

/* 
 * PLOTLY RESPONSIVE SOLUTION:
 * For optimal mobile responsiveness, ensure your JavaScript includes:
 * 
 * const config = {
 *   responsive: true,
 *   displayModeBar: false, // Hides toolbar on mobile
 *   autosize: true
 * };
 * 
 * Plotly.newPlot('chart-id', data, layout, config);
 * 
 * And for window resize handling:
 * window.addEventListener('resize', () => {
 *   Plotly.Plots.resize('chart-id');
 * });
 */

/* Mobile responsive charts */
@media (max-width: 768px) {
    .chart,
    .cashflow-chart,
    .growth-model-chart,
    .projection-chart {
        height: 400px; /* Maintain good height on mobile */
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 0;
        min-width: 0;
    }
    

    
    /* Hide Plotly modebar on mobile */
    .modebar {
        display: none !important;
    }
    
    /* Improve legend on mobile */
    .legend {
        font-size: 11px !important;
    }
    
    /* Ensure Plotly charts scale properly */
    .chart .js-plotly-plot,
    .cashflow-chart .js-plotly-plot,
    .growth-model-chart .js-plotly-plot,
    .projection-chart .js-plotly-plot {
        width: 100% !important;
        height: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
}

@media (max-width: 480px) {
    .chart,
    .cashflow-chart,
    .growth-model-chart,
    .projection-chart {
        height: 350px; /* Good mobile height */
    }
    
    .risk-metric-chart {
        height: 60px;
    }
}

@media (max-width: 360px) {
    .chart,
    .cashflow-chart,
    .growth-model-chart,
    .projection-chart {
        height: 300px; /* Minimum viable height */
    }
}

/* Tools Page Styles */
.tools-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Cashflow Management Specific Styles */
.balance-setup {
    display: grid;
    gap: 30px;
}

.balance-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.input-hint {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 4px;
    font-style: italic;
}

.balance-display {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
}

.balance-card {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #bae6fd;
}

.balance-card h3 {
    font-size: 0.7rem;
    font-weight: 600;
    color: #0369a1;
    margin: 0 0 4px 0;
}

.balance-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #0c4a6e;
    margin: 0;
}

.strategy-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.btn-secondary {
    background: #fafafa;
    color: #374151;
    border: none;
    padding: 16px 24px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: none;
}

.btn-secondary:hover {
    background: #f5f5f5;
    transform: none;
    box-shadow: none;
}

.btn-secondary:active {
    transform: none;
    background: #f0f0f0;
}

.btn-icon {
    font-size: 1.2rem;
    font-weight: bold;
}

.strategies-container {
    display: grid;
    gap: 20px;
}

.strategy-card {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    position: relative;
}

.strategy-card::before {
    content: none;
}

.strategy-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.1);
}

.dca-card {
    border-color: #f59e0b;
}

.dca-card::before {
    content: none;
}

.dca-card:hover {
    border-color: #d97706;
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.1);
}

.strategy-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e2e8f0;
    cursor: pointer;
}

.strategy-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
}

.toggle-strategy {
    background: transparent;
    border: none;
    color: #6b7280;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toggle-strategy:hover {
    background: #f5f5f5;
    color: #374151;
}

.toggle-strategy:active {
    background: #f0f0f0;
}

/* Hide collapse button since clicking card header toggles */
.toggle-strategy {
    display: none !important;
}

.remove-strategy {
    background: transparent;
    color: #ef4444;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.remove-strategy:hover {
    background: #fef2f2;
    color: #dc2626;
    transform: none;
}

/* ===== TOOLS PAGE MOBILE STYLES ===== */
@media (max-width: 768px) {
    .tools-container {
        padding: 15px;
    }
    
    .tools-header-content {
        flex-direction: column;
        gap: 15px;
    }
    
    .version-info {
        position: static;
        margin-top: 10px;
        align-self: center;
        padding: 6px 10px;
        background: rgba(255, 255, 255, 0.95);
        border: 1px solid #e2e8f0;
        border-radius: 4px;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    }
    
    .version-number {
        font-size: 0.75rem;
    }
    
    .bitcoin-logo {
        width: 50px;
        height: 50px;
        font-size: 2rem;
    }
    
    .tools-title {
        font-size: 2rem;
    }
    
    .tools-subtitle {
        font-size: 1rem;
    }
    
    .tool-section {
        padding: 20px;
    }
    
    .tool-section > .strategy-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    /* Keep card controls (close/collapse) in a row on mobile */
    .strategy-header .strategy-controls {
        flex-direction: row;
        gap: 8px;
    }
    

    
    .btn-secondary {
        width: 100%;
        justify-content: center;
        padding: 12px 16px;
    }
    
    .form-input,
    .form-select {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px 16px;
    }
    
    .balance-display {
        grid-template-columns: repeat(2, 1fr);
        gap: 7px;
    }
    
    .analysis-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 7px;
    }
    
    .strategy-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .input-group {
        width: 100%;
    }
    
    /* Reduce card sizes for mobile */
    .balance-card {
        padding: 8px !important;
    }
    
    .balance-card h3 {
        font-size: 0.6rem !important;
        margin: 0 0 3px 0 !important;
    }
    
    .balance-value {
        font-size: 1rem !important;
    }
    
    .analysis-card {
        padding: 8px !important;
    }
    
    .analysis-card h3 {
        font-size: 0.6rem !important;
        margin: 0 0 3px 0 !important;
    }
    
    .analysis-value {
        font-size: 1rem !important;
        margin: 0 0 2px 0 !important;
    }
    
    .analysis-description {
        font-size: 0.5rem !important;
    }
}

@media (max-width: 480px) {
    .tools-container {
        padding: 10px;
    }
    
    .tool-section {
        padding: 15px;
    }
    
    .bitcoin-logo {
        width: 45px;
        height: 45px;
        font-size: 1.8rem;
    }
    
    .tools-title {
        font-size: 1.8rem;
    }
    
    .balance-display {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        gap: 8px;
    }
    
    .analysis-grid {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        gap: 8px;
    }
    
    /* Further reduce card sizes for smaller mobile */
    .balance-card {
        padding: 6px !important;
    }
    
    .balance-card h3 {
        font-size: 0.55rem !important;
        margin: 0 0 2px 0 !important;
    }
    
    .balance-value {
        font-size: 0.9rem !important;
    }
    
    .analysis-card {
        padding: 6px !important;
    }
    
    .analysis-card h3 {
        font-size: 0.55rem !important;
        margin: 0 0 2px 0 !important;
    }
    
    .analysis-value {
        font-size: 0.9rem !important;
        margin: 0 0 1px 0 !important;
    }
    
    .analysis-description {
        font-size: 0.45rem !important;
    }
    
    .form-input,
    .form-select {
        padding: 10px 12px;
    }
}

.remove-strategy:active {
    background: #fee2e2;
}

.toggle-strategy:focus {
    outline: none;
    box-shadow: none;
}



.strategy-card.collapsed .strategy-content {
    display: none !important;
    max-height: 0;
    overflow: hidden;
}

.strategy-card.collapsed {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.strategy-card.collapsed .strategy-header {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.strategy-card.collapsed .strategy-title {
    color: #64748b;
}

.collapsed-summary {
    font-size: 0.85rem;
    font-weight: 400;
    color: #94a3b8;
    margin-left: 8px;
}

.strategy-title-input {
    background: transparent;
    border: none;
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    width: auto;
    min-width: 120px;
}

.strategy-title-input:hover {
    background-color: #f1f5f9;
}

.strategy-title-input:focus {
    background-color: #e2e8f0;
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.strategy-title-display {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    cursor: default;
}

.strategy-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.remove-strategy {
    background: transparent;
    color: #ef4444;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
}

.remove-strategy:hover {
    background: #fef2f2;
    color: #dc2626;
}

.remove-strategy:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.strategy-content {
    display: grid;
    gap: 20px;
    transition: all 0.3s ease;
    overflow: hidden;
}

.strategy-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.amount-hint {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 4px;
    font-style: italic;
}

.visualization-controls {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.date-range-selector {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.chart-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.date-range-selector label {
    font-weight: 600;
    color: #374151;
    font-size: 0.9rem;
}



.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
}

.analysis-card {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #e2e8f0;
}

.analysis-card h3 {
    font-size: 0.7rem;
    font-weight: 600;
    color: #64748b;
    margin: 0 0 4px 0;
}

.analysis-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 2px 0;
}

.analysis-description {
    font-size: 0.6rem;
    color: #94a3b8;
    margin: 0;
}

.strategy-summary {
    min-height: 100px;
}

.empty-state {
    text-align: center;
    color: #64748b;
    font-style: italic;
    margin: 40px 0;
}

.summary-list {
    display: grid;
    gap: 15px;
}

.summary-item {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.summary-amount {
    font-weight: 700;
    font-size: 1.1rem;
}

.summary-amount.positive {
    color: #059669;
}

.summary-amount.negative {
    color: #dc2626;
}

.summary-frequency {
    font-size: 0.8rem;
    color: #64748b;
    background: #e2e8f0;
    padding: 2px 8px;
    border-radius: 4px;
}

.summary-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.summary-description {
    font-size: 0.9rem;
    color: #374151;
    font-weight: 500;
}

.summary-dates {
    font-size: 0.8rem;
    color: #64748b;
}

.summary-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    margin: 20px 0 10px 0;
    padding-bottom: 5px;
    border-bottom: 1px solid #e2e8f0;
}

.cashflow-item {
    border-left: 3px solid #3b82f6;
}

.dca-item {
    border-left: 3px solid #f59e0b;
}

/* Actions Table Styles */
/* Ensure parent containers don't expand beyond viewport */
.tool-section,
.strategy-card,
.balance-card {
    max-width: 100vw;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Ensure the strategy summary container doesn't overflow */
.strategy-summary {
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Custom scrollbar styles for better visibility */
.actions-table-container::-webkit-scrollbar {
    height: 12px;
    -webkit-appearance: none;
}

.actions-table-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.actions-table-container::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 6px;
    border: 1px solid #64748b;
}

.actions-table-container::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Force scrollbar to be visible */
.actions-table-container {
    scrollbar-width: auto !important;
    overflow-x: scroll !important;
}

/* Simple chart constraints */
.cashflow-chart,
.growth-model-chart {
    max-width: 100%;
    box-sizing: border-box;
}







.actions-table-container {
    overflow-x: auto;
    overflow-y: hidden;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    /* Ensure smooth scrolling on mobile */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    /* Strictly constrain the container width */
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    /* Prevent any overflow beyond container */
    position: relative;
    /* Force scrollbar to always show */
    scrollbar-width: auto;
    /* Ensure container doesn't expand beyond parent */
    min-width: 0;
    flex-shrink: 1;
}

.actions-table {
    width: 100%;
    min-width: 800px; /* Minimum width to accommodate all 7 columns with proper spacing */
    border-collapse: collapse;
    font-size: 0.9rem;
    table-layout: fixed; /* Use fixed layout for better control */
    /* Prevent table from expanding container */
    max-width: none;
}

.actions-table th {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e2e8f0;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.actions-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: #374151;
}

/* Style specific columns */
.actions-table th:nth-child(1),
.actions-table td:nth-child(1) {
    min-width: 100px; /* Date column */
}

.actions-table th:nth-child(2),
.actions-table td:nth-child(2) {
    min-width: 120px; /* Title column */
    font-weight: 500;
}

.actions-table th:nth-child(4),
.actions-table td:nth-child(4) {
    text-align: right; /* Amount column */
    font-weight: 600;
}

.actions-table th:nth-child(5),
.actions-table td:nth-child(5),
.actions-table th:nth-child(6),
.actions-table td:nth-child(6),
.actions-table th:nth-child(7),
.actions-table td:nth-child(7) {
    text-align: right; /* Balance columns */
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    background-color: #f8fafc;
}

.actions-table td:nth-child(5),
.actions-table td:nth-child(6),
.actions-table td:nth-child(7) {
    background-color: #f8fafc;
    border-left: 1px solid #e2e8f0;
}

.actions-table tr:hover {
    background-color: #f8fafc;
}

.actions-table tr.positive-action {
    border-left: 3px solid #059669;
}

.actions-table tr.negative-action {
    border-left: 3px solid #dc2626;
}

.actions-table tr.positive-action:hover {
    background-color: #f0fdf4;
}

.actions-table tr.negative-action:hover {
    background-color: #fef2f2;
}

.summary-row {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%) !important;
    color: white !important;
    font-weight: 600;
}

.summary-row td {
    border-top: 2px solid #475569;
    color: white !important;
    text-align: right;
}

.summary-row td:first-child {
    text-align: left;
}

.summary-row:hover {
    background: linear-gradient(135deg, #334155 0%, #475569 100%) !important;
}

/* Responsive table */
@media (max-width: 1200px) {
    .actions-table {
        font-size: 0.8rem;
    }
    
    .actions-table th,
    .actions-table td {
        padding: 6px 8px;
    }
}

@media (max-width: 768px) {
    .actions-table-container {
        /* Strictly constrain container to viewport width */
        max-width: 100%;
        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        /* Ensure container clips content properly */
        position: relative;
        box-sizing: border-box;
        /* Force horizontal scrollbar */
        scrollbar-width: thin;
        scrollbar-color: #cbd5e1 #f1f5f9;
        /* Prevent container from expanding */
        min-width: 0;
        flex-shrink: 1;
    }
    
    .actions-table {
        font-size: 0.7rem;
        min-width: 800px; /* Ensure table maintains minimum width for all 7 columns */
        width: 800px; /* Fixed width to force horizontal scroll */
        /* Ensure table doesn't expand container */
        max-width: none;
        /* Prevent table from affecting container width */
        table-layout: fixed;
    }
    
    .actions-table th,
    .actions-table td {
        padding: 4px 6px;
        white-space: nowrap; /* Prevent text wrapping */
    }
    
    /* Ensure all columns are visible on mobile */
    .actions-table th,
    .actions-table td {
        display: table-cell !important; /* Force all columns to be visible */
    }
}

.tools-header {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
}

.tools-header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.version-info {
    position: absolute;
    top: 0;
    right: 0;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.version-number {
    font-size: 0.8rem;
    font-weight: 500;
    color: #64748b;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    letter-spacing: 0.5px;
}

.bitcoin-logo {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: linear-gradient(135deg, #f7931a 0%, #ff9500 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: bold;
    color: white;
    box-shadow: 0 4px 20px rgba(247, 147, 26, 0.3);
    transition: transform 0.3s ease;
    font-family: 'Arial', sans-serif;
}

.bitcoin-logo:hover {
    transform: scale(1.05);
}

.tools-text {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tools-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #f7931a 0%, #ff9500 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tools-subtitle {
    font-size: 1.1rem;
    color: #64748b;
    margin: 0;
}

/* Experimental Tool Disclaimer */
.experimental-disclaimer {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 25px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.disclaimer-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.disclaimer-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    margin-top: 1px;
    opacity: 0.7;
}

.disclaimer-text {
    flex: 1;
}

.disclaimer-text strong {
    display: block;
    color: #475569;
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.disclaimer-text p {
    color: #64748b;
    margin: 0;
    line-height: 1.5;
    font-size: 0.9rem;
}

/* Mobile optimization for disclaimer */
@media (max-width: 768px) {
    .disclaimer-text p {
        display: none;
    }
    
    .disclaimer-content {
        gap: 8px;
    }
    
    .disclaimer-text strong {
        margin-bottom: 0;
    }
}

.tools-grid {
    display: grid;
    gap: 30px;
}

.tool-section {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
}

.strategy-builder {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

    .input-group {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

.input-group label {
    font-weight: 600;
    color: #374151;
    font-size: 0.9rem;
}

.form-input, .form-select {
    padding: 16px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.15s ease;
    background: #fafafa;
    color: #374151;
    width: 100%;
    box-sizing: border-box;
}

.form-input:focus, .form-select:focus {
    outline: none;
    background: white;
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
    color: #1f2937;
}

.form-input:hover, .form-select:hover {
    background: #f5f5f5;
}

.btn-primary {
    background: #8b5cf6;
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: none;
}

.btn-primary:hover {
    background: #7c3aed;
    transform: none;
    box-shadow: none;
}

.btn-primary:active {
    transform: none;
    background: #6d28d9;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.results-container {
    display: grid;
    gap: 30px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.metric-card {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #e2e8f0;
}

.metric-card .metric-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 8px;
}

.metric-card .metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 4px 0;
}

.metric-card .metric-description {
    font-size: 0.8rem;
    color: #94a3b8;
    margin: 0;
}



.projection-chart {
    width: 100%;
    height: 400px;
    margin: 0;
    padding: 0;
}

.risk-analysis {
    display: grid;
    gap: 30px;
}

.risk-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
}

.risk-metric {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #fecaca;
}

.risk-metric h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #991b1b;
    margin: 0 0 8px 0;
}

.risk-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #dc2626;
    margin: 0;
}

.scenario-analysis h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 15px;
}

.scenario-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.scenario {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    padding: 15px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #bae6fd;
}

.scenario-label {
    font-weight: 600;
    color: #0369a1;
}

.scenario-value {
    font-weight: 700;
    color: #0c4a6e;
}

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

.recommendation-card {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #bbf7d0;
}

.recommendation-card h4 {
    font-size: 1rem;
    font-weight: 600;
    color: #166534;
    margin: 0 0 10px 0;
}

.recommendation-card p {
    font-size: 0.9rem;
    color: #15803d;
    margin: 0;
    line-height: 1.5;
}

/* Comprehensive Mobile Responsive Styles for Tools */

/* Tablet and smaller desktop */
@media (max-width: 1024px) {
    .tools-container {
        padding: 20px;
        max-width: 100%;
    }
    
    .tools-grid {
        gap: 25px;
    }
    
    .tool-section {
        padding: 25px;
    }
    
    .balance-inputs {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 18px;
    }
    
    .balance-display {
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
        gap: 9px;
    }
    
    .strategy-controls {
        gap: 12px;
    }
    
    .btn-secondary {
        padding: 10px 16px;
        font-size: 0.85rem;
    }
    
    .analysis-grid {
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
        gap: 9px;
    }
    
    .model-controls {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 18px;
    }
}





@media (max-width: 360px) {
    .tools-container {
        padding: 8px;
    }
    
    .tools-title {
        font-size: 1.6rem;
    }
    
    .tools-subtitle {
        font-size: 0.85rem;
    }
    
    .bitcoin-logo {
        width: 40px;
        height: 40px;
        font-size: 1.6rem;
    }
    
    .tool-section {
        padding: 12px;
    }
    
    .section-header {
        font-size: 1.1rem;
    }
    
    .strategy-card {
        padding: 10px;
    }
    
    .balance-display {
        grid-template-columns: repeat(auto-fit, minmax(45px, 1fr));
        gap: 4px;
    }
    
    .analysis-grid {
        grid-template-columns: repeat(auto-fit, minmax(45px, 1fr));
        gap: 4px;
    }
    
    .balance-card {
        padding: 4px 3px !important;
    }
    
    .balance-card h3 {
        font-size: 0.5rem !important;
        margin: 0 0 1px 0 !important;
    }
    
    .balance-value {
        font-size: 0.7rem !important;
    }
    
    .analysis-card {
        padding: 4px 3px !important;
    }
    
    .analysis-card h3 {
        font-size: 0.5rem !important;
        margin: 0 0 1px 0 !important;
    }
    
    .analysis-value {
        font-size: 0.7rem !important;
        margin: 0 0 0px 0 !important;
    }
    
    .analysis-description {
        font-size: 0.45rem !important;
    }
    
    .cashflow-chart {
        height: 250px;
        width: 100%;
        max-width: 100%;
        overflow: visible;
        box-sizing: border-box;
        min-width: 0;
        margin: 0;
        padding: 0;
    }
    
    .growth-model-chart {
        height: 180px;
        width: 100%;
        max-width: 100%;
        overflow: visible;
        box-sizing: border-box;
        min-width: 0;
        margin: 0;
        padding: 0;
    }
    

    
    /* Minimal table for very small screens */
    .actions-table-container {
        /* Strictly constrain container to viewport width */
        max-width: 100%;
        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        /* Ensure container clips content properly */
        position: relative;
        box-sizing: border-box;
        /* Force horizontal scrollbar */
        scrollbar-width: thin;
        scrollbar-color: #cbd5e1 #f1f5f9;
        /* Prevent container from expanding */
        min-width: 0;
        flex-shrink: 1;
    }
    
    .actions-table {
        min-width: 800px; /* Ensure table maintains minimum width for all 7 columns */
        width: 800px; /* Fixed width to force horizontal scroll */
        font-size: 0.7rem;
        /* Ensure table doesn't expand container */
        max-width: none;
        /* Prevent table from affecting container width */
        table-layout: fixed;
        margin: 0;
        padding: 0;
    }
    
    .actions-table th:nth-child(4),
    .actions-table td:nth-child(4) {
        display: table-cell; /* Show all columns */
    }
}

/* Tablet-specific optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
    .tools-container {
        padding: 25px;
    }
    
    .tools-grid {
        gap: 28px;
    }
    
    .tool-section {
        padding: 28px;
    }
    
    .balance-inputs {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .balance-display {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .strategy-controls {
        flex-direction: row;
        gap: 15px;
    }
    
    .btn-secondary {
        flex: 1;
        max-width: 200px;
    }
    
    .analysis-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .model-controls {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Landscape mobile optimizations */
@media (max-width: 768px) and (orientation: landscape) {
    .tools-header-content {
        flex-direction: row;
        gap: 20px;
    }
    
    .tools-title {
        font-size: 1.8rem;
    }
    
    .balance-display {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .analysis-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .strategy-controls {
        flex-direction: row;
        gap: 12px;
    }
    
    .btn-secondary {
        width: auto;
        flex: 1;
    }
    
    .cashflow-chart {
        height: 280px;
    }
    
    .growth-model-chart {
        height: 220px;
    }
}

/* ===== TOGGLE SECTIONS & GROWTH MODEL ===== */

.section-header-with-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.section-header-with-toggle .section-header {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.toggle-section {
    background: transparent;
    border: none;
    font-size: 1rem;
    color: #6b7280;
    cursor: pointer;
    padding: 10px 12px;
    border-radius: 8px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    font-weight: 500;
}

.toggle-section:hover {
    background: #f5f5f5;
    color: #374151;
}

.toggle-section:focus {
    outline: none;
}

.toggle-section.collapsed,
.toggle-strategy.collapsed {
    transform: rotate(180deg);
}

.growth-model-setup {
    display: grid;
    gap: 20px;
}

.model-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.model-visualization {
    margin-top: 20px;
    width: 100%;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .model-controls {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .toggle-section {
        min-width: 36px;
        height: 36px;
        font-size: 0.9rem;
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    .toggle-section {
        min-width: 32px;
        height: 32px;
        font-size: 0.8rem;
        padding: 6px 8px;
    }
}

/* ===== EXPORT BUTTON STYLES ===== */

.section-header-with-export {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.section-header-with-export .section-header {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.export-btn {
    background: #10b981;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 100px;
    justify-content: center;
}

.export-btn:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.export-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.export-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.export-btn .btn-icon {
    font-size: 1rem;
}

/* Mobile responsive adjustments for export button */
@media (max-width: 768px) {
    .section-header-with-export {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .section-header-with-export .section-header {
        margin-bottom: 0;
    }
    
    .export-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
        min-width: 80px;
        align-self: flex-end;
    }
    
    .export-btn .btn-icon {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .section-header-with-export {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .section-header-with-export .section-header {
        margin-bottom: 0;
        font-size: 1.1rem;
    }
    
    .export-btn {
        padding: 5px 10px;
        font-size: 0.75rem;
        min-width: 70px;
        align-self: flex-end;
    }
    
    .export-btn .btn-icon {
        font-size: 0.8rem;
    }
}







/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .tools-container {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    .strategy-card,
    .balance-card,
    .analysis-card {
        border-width: 0.5px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn-secondary,
    .btn-primary,
    .toggle-strategy,
    .toggle-section,
    .remove-strategy {
        min-height: 44px;
        min-width: 44px;
    }
    
    .form-input,
    .form-select {
        min-height: 44px;
    }
    
    .strategy-header {
        min-height: 44px;
    }
    
    /* Increase touch targets */
    .toggle-strategy {
        width: 44px;
        height: 44px;
    }
    
    .remove-strategy {
        width: 44px;
        height: 44px;
    }
    
    .toggle-section {
        min-width: 44px;
        height: 44px;
    }
    
    /* Improve touch scrolling */
    .actions-table-container {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    /* Better touch feedback */
    .btn-secondary:active,
    .btn-primary:active {
        transform: scale(0.95);
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .btn-secondary,
    .btn-primary,
    .toggle-strategy,
    .toggle-section,
    .remove-strategy,
    .strategy-card,
    .balance-card,
    .analysis-card {
        transition: none;
    }
    
    .btn-secondary:hover,
    .btn-primary:hover {
        transform: none;
    }
}

/* Focus styles for better accessibility */
.btn-secondary:focus,
.btn-primary:focus,
.form-input:focus,
.form-select:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Minimal focus styles for toggle and remove buttons */
.toggle-strategy:focus,
.remove-strategy:focus {
    outline: none;
    box-shadow: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .strategy-card,
    .balance-card,
    .analysis-card {
        border-width: 2px;
        border-color: #000;
    }
    
    .btn-secondary,
    .btn-primary {
        border: 2px solid #000;
    }
}

/* Use browser default dropdown styling */
.form-select {
    /* Remove all custom styling */
    -webkit-appearance: auto;
    -moz-appearance: auto;
    appearance: auto;
    background-image: none;
    padding-right: 16px;
}

/* Mobile-specific dropdown fixes */
@media (max-width: 768px) {
    .form-select {
        /* Use browser defaults on mobile */
        -webkit-appearance: auto;
        -moz-appearance: auto;
        appearance: auto;
        background-image: none;
        padding-right: 16px;
        /* Prevent zoom on iOS */
        font-size: 16px;
        /* Ensure proper touch target */
        min-height: 44px;
    }
}







