/* CSS Variables */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --radius-sm: 8px;
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color), #1e40af);
    color: white;
    padding: 40px 0;
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo-img {
    width: 48px;
    height: 48px;
    border-radius: 10px;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
}

.tagline {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Main Content */
main {
    flex: 1;
    padding: 40px 0;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 30px;
    margin-bottom: 30px;
}

.card h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.section-desc {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* Questions & Radio Groups */
.question-group {
    margin-bottom: 24px;
}

.question-group > label {
    display: block;
    font-weight: 600;
    margin-bottom: 12px;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--background);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.radio-group label:hover {
    background: #e2e8f0;
}

.radio-group input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    margin-right: 12px;
    margin-top: 12px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--background);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

/* Risk Result */
.result-box {
    margin-top: 24px;
    padding: 24px;
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--primary-color);
}

.result-box h3 {
    font-size: 1.25rem;
    margin-bottom: 16px;
}

#risk-level {
    color: var(--primary-color);
    font-weight: 700;
}

.risk-meter {
    height: 12px;
    background: #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 16px;
}

.risk-meter-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), var(--warning-color), var(--danger-color));
    width: 0%;
    transition: width 0.5s ease;
}

/* Input Groups */
.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
}

.input-group input {
    width: 100%;
    max-width: 300px;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: border-color 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Allocation Grid */
.allocation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.allocation-item {
    background: var(--background);
    padding: 20px;
    border-radius: var(--radius-sm);
}

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

.asset-name {
    font-weight: 600;
}

.asset-percent {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.allocation-slider {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: #e2e8f0;
    border-radius: 4px;
    outline: none;
}

.allocation-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

.allocation-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.allocation-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.asset-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

.hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.total-allocation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--background);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 20px;
}

.total-value {
    color: var(--success-color);
}

.total-value.invalid {
    color: var(--danger-color);
}

/* Results Section */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.result-panel {
    background: var(--background);
    padding: 24px;
    border-radius: var(--radius-sm);
}

.result-panel.full-width {
    grid-column: 1 / -1;
}

.result-panel h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
}

.chart-container.large {
    height: 350px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.stat-item {
    text-align: center;
    padding: 16px;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Diversification */
.diversification-grid {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.diversification-item {
    text-align: center;
}

.diversification-score {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
}

.diversification-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.diversification-details {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.diversification-details .detail-item {
    padding: 12px 16px;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
}

.diversification-meter {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.diversification-meter-fill {
    height: 100%;
    background: var(--success-color);
    width: 0%;
    transition: width 0.5s ease;
}

/* Simulation Stats */
.simulation-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.sim-stat {
    text-align: center;
    padding: 16px;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
}

.sim-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.sim-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
}

.sim-value.positive {
    color: var(--success-color);
}

.sim-value.negative {
    color: var(--danger-color);
}

/* Table */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

th, td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: var(--card-bg);
    font-weight: 600;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
}

tr:hover {
    background: rgba(37, 99, 235, 0.05);
}

/* Footer */
footer {
    background: var(--text-primary);
    color: white;
    padding: 30px 0;
    text-align: center;
    margin-top: auto;
}

footer a {
    color: #60a5fa;
    text-decoration: none;
    font-weight: 600;
}

footer a:hover {
    text-decoration: underline;
}

.disclaimer {
    margin-top: 12px;
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    header {
        padding: 30px 0;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .logo-img {
        width: 40px;
        height: 40px;
    }

    .tagline {
        font-size: 1rem;
    }

    .card {
        padding: 20px;
    }

    .allocation-grid {
        grid-template-columns: 1fr;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .btn {
        width: 100%;
        margin-right: 0;
        text-align: center;
    }

    .diversification-grid {
        flex-direction: column;
        align-items: flex-start;
    }

    .simulation-stats {
        grid-template-columns: 1fr;
    }

    table {
        font-size: 0.85rem;
    }

    th, td {
        padding: 10px 12px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    header h1 {
        font-size: 1.25rem;
    }

    .card h2 {
        font-size: 1.25rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .diversification-score {
        font-size: 2.5rem;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.3s ease-out;
}

/* Print Styles */
@media print {
    header {
        background: var(--primary-color);
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .btn {
        display: none;
    }

    .card {
        break-inside: avoid;
    }
}
