/* Modern Portfolio Review Page - Mobile-First Design */
/* Matching the quality of index.html, symbol.html, and portfolio_detail.html */
/*
 * Screen breakpoints (matches breakpoints.css, same as portfolio list page):
 * - Mobile: ≤639px   → 1 column
 * - Tablet: 640-1023px → 2 columns
 * - Full: ≥1024px   → 3 columns
 */

/* Review page header: sticky on scroll, sits on top of nav */
#review-header-container {
    position: sticky;
    top: 0;
    z-index: 150;
    background: var(--bg-secondary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Header action buttons - Try Again + Keep This Portfolio */
.review-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.review-header-try-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: var(--bg-glass);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}

.review-header-try-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
    border-color: var(--primary);
}

.review-header-try-btn:disabled,
.review-header-keep-btn:disabled,
.review-header-try-btn.is-disabled,
.review-header-keep-btn.is-disabled,
#try-again-portfolio-btn.is-disabled {
    opacity: 0.6;
    pointer-events: none;
    transform: none;
}

/* Header Keep Portfolio Button - right-aligned in page header */
.review-header-keep-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
    white-space: nowrap;
}

.review-header-keep-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
    color: white;
}

/* Mobile / small tablet: cap review sub-header at 100px; one line each (matches review.html @767px padding) */
@media (max-width: 767px) {
    #review-header-container.watchlist-app-header {
        max-height: 120px;
        min-height: 54px;
        padding: 10px 0;
        box-sizing: border-box;
        overflow: hidden;
        align-items: center;
    }

    #review-header-container .watchlist-app-header-inner {
        padding: 4px 10px;
        gap: 8px;
        align-items: center;
        min-height: 54px;
        box-sizing: border-box;
    }

    #review-header-container .header-title-section {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 4px;
        overflow: hidden;
    }

    #review-header-container .watchlist-header-title {
        font-size: 14px;
        font-weight: 700;
        line-height: 1.25;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #review-header-container .watchlist-header-subtitle {
        font-size: 11px;
        line-height: 1.25;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #review-header-container .header-actions {
        flex-shrink: 0;
    }

    #review-header-container .review-header-actions {
        gap: 6px;
    }

    #review-header-container .review-header-try-btn {
        width: 40px;
        min-width: 40px;
        max-width: 40px;
        height: 40px;
        min-height: 40px;
        box-sizing: border-box;
        padding: 0;
        justify-content: center;
        font-size: 12px;
        gap: 0;
    }

    #review-header-container .review-header-try-btn .review-header-try-label {
        display: none;
    }

    #review-header-container .review-header-keep-btn {
        width: 148px;
        min-width: 148px;
        max-width: 148px;
        height: 40px;
        min-height: 40px;
        box-sizing: border-box;
        padding: 0 6px;
        justify-content: center;
        font-size: 12px;
        font-weight: 600;
        gap: 4px;
        box-shadow: var(--shadow-sm);
        overflow: hidden;
    }

    #review-header-container .review-header-keep-btn .review-header-keep-label {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #review-header-container .review-header-keep-btn i {
        font-size: 11px;
        flex-shrink: 0;
    }

    #review-header-container .review-header-keep-btn:hover {
        transform: none;
    }
}

/* Loading Container */
.loading-container-modern {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 40px 20px;
}

.loading-spinner-modern {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
}

.loading-spinner-modern i {
    font-size: 28px;
    color: var(--primary);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.loading-text-modern {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 500;
    margin: 0;
}

/* Review Hero Section */
.review-hero-modern {
    text-align: center;
    padding: 40px 20px;
    margin-bottom: 32px;
}

.review-hero-icon-modern {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: white;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.6s ease-out;
}

.review-hero-title-modern {
    font-size: clamp(28px, 5vw, 40px);
    font-weight: 800;
    margin-bottom: 16px;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.review-hero-description-modern {
    font-size: clamp(16px, 2vw, 18px);
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.7;
}

/* Summary Cards Grid */
.portfolio-summary-modern {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 32px;
}

@media (min-width: 640px) {
    .portfolio-summary-modern {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .portfolio-summary-modern {
        grid-template-columns: repeat(3, 1fr);
    }
}

.summary-card-modern {
    display: flex;
    flex-direction: column !important; /* header above, stats below - never side-by-side */
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.summary-card-modern:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Risk Profile / quiz / analytics grid: stat tiles lift like portfolio metric cells */
.portfolio-summary-modern .summary-stats-modern > .summary-stat-modern {
    transition: var(--transition);
}

.portfolio-summary-modern .summary-stats-modern > .summary-stat-modern:hover {
    background: var(--bg-glass);
    transform: translateY(-2px);
}

/* Hovering a stat tile should not also lift the whole summary card */
.portfolio-summary-modern .summary-card-modern:has(.summary-stat-modern:hover) {
    box-shadow: var(--shadow-md);
    transform: none;
}

.summary-card-header-modern {
    display: flex;
    flex-direction: column !important;
    align-items: center;
    text-align: center;
    width: 100%;
    flex-shrink: 0;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.summary-card-icon-modern {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(22px, 2.5vw, 24px);
    color: white;
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
}

.summary-card-title-modern {
    font-size: clamp(20px, 2.5vw, 24px);
    font-weight: 700;
    margin: 0 0 4px 0;
    color: var(--text-primary);
}

.summary-card-subtitle-modern {
    font-size: clamp(15px, 1.5vw, 17px);
    color: var(--text-secondary);
    margin: 0;
}

.summary-stats-modern {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    width: 100%;
}

.summary-stat-modern {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.summary-stat-modern:last-child {
    /* no special treatment - grid handles layout */
}

.summary-stat-label-modern {
    font-size: clamp(12px, 1.2vw, 14px);
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 6px;
}

.summary-stat-value-modern {
    font-size: clamp(16px, 1.6vw, 18px);
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

/* Badge Styles */
.badge-modern {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 12px;
    font-size: clamp(13px, 1.3vw, 15px);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-modern.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.badge-modern.warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.badge-modern.danger {
    background: rgba(239, 71, 111, 0.15);
    color: var(--danger);
}

/* Allocations Section */
.allocations-section-modern {
    margin-bottom: 40px;
}

.section-header-modern {
    text-align: center;
    margin-bottom: 24px;
}

.section-header-modern i {
    font-size: 32px;
    color: var(--primary);
    margin-top: 60px;
    margin-bottom: 12px;
    display: block;
}

/* Review preview allocations header: icon above title (wins over other sheets; SW may cache ?v= until restart) */
#review-container-modern #review-preview .allocations-section-modern .section-header-modern > i:first-child {
    margin-top: 40px !important;
}

.section-header-modern h2 {
    font-size: clamp(24px, 4vw, 32px);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 12px 0;
}

.section-description-modern {
    font-size: 18px;
    color: var(--text-secondary);
    text-align: center;
    max-width: 800px;
    margin: 0 auto 32px;
    line-height: 1.7;
}

#review-container-modern .review-allocations-count-note {
    font-size: 16px;
}

/* Review page sector-allocation pie chart (rendered as first allocations grid cell) */
.review-sector-allocation-cell {
    min-width: 0;
    display: flex;
    flex-direction: column;
    /* Do not stretch to row height (tallest allocation card); avoids donut floating mid-card */
    align-self: start;
}

.review-sector-allocation-chart {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-md);
    padding: 18px 20px 20px;
    display: grid;
    gap: 16px;
    height: auto;
    margin: 0;
}

#review-container-modern .sector-allocation-chart-header-modern {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 4px;
}

.sector-allocation-chart-title-modern {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}

#review-container-modern .sector-allocation-chart-subtitle-modern {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: none;
    letter-spacing: 0.02em;
    line-height: 1.35;
}

.sector-allocation-chart-body-modern {
    display: grid;
    grid-template-columns: minmax(168px, 40%) minmax(0, 1fr);
    gap: 20px 28px;
    align-items: start;
    min-width: 0;
}

.sector-allocation-ring-wrap-modern {
    display: flex;
    align-items: center;
    justify-content: center;
}

#review-container-modern .sector-allocation-ring-modern {
    width: 168px;
    height: 168px;
    border-radius: 50%;
    background: var(--sector-chart-gradient, #6b7280 0deg 360deg);
    position: relative;
}

#review-container-modern .sector-allocation-ring-modern::after {
    content: "";
    position: absolute;
    inset: 22px;
    border-radius: 50%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
}

.sector-allocation-legend-modern {
    display: grid;
    gap: 8px;
    max-height: none;
    overflow: visible;
    padding-right: 4px;
    align-self: start;
}

/*
 * Review legend: flex rows — table-cell on the swatch stretched it to row height (tall ovals).
 * Reserves min-width for % so values stay inside the card; name flexes with ellipsis.
 */
#review-container-modern .sector-allocation-legend-modern {
    display: flex;
    flex-direction: column;
    gap: 7px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    margin: 0;
    padding-right: 0;
}

#review-container-modern .sector-allocation-legend-item-modern {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

#review-container-modern .sector-allocation-color-modern {
    flex: 0 0 10px;
    width: 10px;
    height: 10px;
    min-width: 10px;
    min-height: 10px;
    align-self: center;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-sizing: border-box;
}

#review-container-modern .sector-allocation-name-modern {
    flex: 1 1 auto;
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 4px;
}

#review-container-modern .sector-allocation-pct-modern {
    flex: 0 0 auto;
    min-width: 3.65rem;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    padding-left: 0;
}

.sector-allocation-color-modern {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.sector-allocation-name-modern {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sector-allocation-pct-modern {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 700;
}

@media (max-width: 767px) {
    #review-container-modern .sector-allocation-chart-body-modern {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
        gap: 18px;
    }

    #review-container-modern .sector-allocation-ring-modern {
        width: 156px;
        height: 156px;
    }

    #review-container-modern .sector-allocation-legend-modern {
        width: 100%;
        text-align: left;
    }

    .sector-allocation-chart-body-modern {
        grid-template-columns: 1fr;
    }
}

/* Mobile "Show more positions" — full width, 44px+ tap target, high visibility */
#review-container-modern .review-allocations-show-more-wrap {
    width: 100%;
    margin-top: 24px;
    box-sizing: border-box;
}

#review-container-modern #review-allocations-show-more-btn {
    width: 100%;
    max-width: none;
    min-height: 44px;
    flex: none;
    box-sizing: border-box;
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.25;
    border: 2px solid var(--primary);
    color: var(--text-primary);
    background: rgba(96, 165, 250, 0.16);
    box-shadow: 0 2px 12px rgba(96, 165, 250, 0.2);
}

#review-container-modern #review-allocations-show-more-btn:hover {
    background: rgba(96, 165, 250, 0.26);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(96, 165, 250, 0.3);
}

/* Review page: sector/industry spans full container width */
#review-container-modern .allocation-symbol-modern .symbol-info-modern {
    flex: 1;
    min-width: 0;
}
#review-container-modern .symbol-sector-industry-modern {
    display: block;
    width: 100%;
}

/* Review page: metric cells are tappable to show info modals (like symbol page) */
#review-container-modern .allocation-metric-info-trigger {
    cursor: pointer;
}
#review-container-modern .allocation-metric-info-trigger:hover {
    background: color-mix(in srgb, var(--primary) 12%, var(--bg-secondary));
}

/* Summary cards: suppress card hover when hovering summary stats (each stat has its own hover) */
#review-container-modern .summary-card-modern:has(.summary-stats-modern:hover):hover {
    transform: none;
    box-shadow: var(--shadow-md);
    border-color: var(--border-color);
}

/* Suppress whole-card hover when hovering metrics—each metric has its own hover above */
#review-container-modern .allocation-card-modern:has(.allocation-metrics-modern:hover):hover {
    transform: none;
    box-shadow: var(--shadow-md);
    border-color: var(--border-color);
}
#review-container-modern .allocation-card-modern:has(.allocation-metrics-modern:hover):hover::before {
    opacity: 0;
}

/* Review page: symbol and current price - consistent, eye-catching header */
/* Price and options button top-right aligned in header */
#review-container-modern .allocation-card-wrapper-review .allocation-card-header-modern {
    align-items: stretch;
}
#review-container-modern .allocation-card-wrapper-review .allocation-options-wrap {
    align-items: flex-start;
}
#review-container-modern .allocation-card-wrapper-review .allocation-header-quote-wrap {
    gap: 2px;
}
#review-container-modern .allocation-card-wrapper-review .symbol-name-modern {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}
#review-container-modern .allocation-card-wrapper-review .allocation-current-price-value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--primary);
}

/* Review page: options button 44x44 square (matches portfolio allocation cards) */
#review-container-modern .allocation-card-wrapper-review .allocation-options-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    box-sizing: border-box;
}

/* Review page typography bump: +2pt across target allocation labels/values */
#review-container-modern .allocation-card-wrapper-review .symbol-company-modern {
    font-size: calc(15px + 2pt);
}

#review-container-modern .allocation-card-wrapper-review .analysis-signal-badge-modern,
#review-container-modern .allocation-card-wrapper-review .stage-badge-modern,
#review-container-modern .allocation-card-wrapper-review .strength-badge-modern {
    font-size: calc(12px + 2pt);
}

#review-container-modern .allocation-card-wrapper-review .metric-label-modern {
    font-size: calc(13px + 2pt);
}

#review-container-modern .allocation-card-wrapper-review .metric-value-modern {
    font-size: calc(18px + 2pt);
}

#review-container-modern .allocation-card-wrapper-review .allocation-metric-classification-cell .metric-value-modern {
    font-size: calc(15px + 2pt);
}

#review-container-modern .allocation-card-wrapper-review .show-more-text {
    font-size: calc(15px + 2pt);
}

/* Spacing between each cell's Show more button and the next cell */
#review-container-modern .reasoning-toggle-btn-modern {
    margin-bottom: 20px;
}

/* Allocations grid: reuse allocation-card.css (.allocations-grid-modern, .allocations-cards-grid-modern)
 * Mobile 1 col, in-between 2 cols, full 3 cols via 640px / 1024px breakpoints (breakpoints.css)
 */

/* Action Section */
.action-section-modern {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 32px 24px;
    text-align: center;
    margin-top: 100px;
    margin-bottom: 80px;
    box-shadow: var(--shadow-lg);
}

.action-header-modern {
    margin-bottom: 24px;
}

.action-header-modern h2 {
    font-size: clamp(24px, 4vw, 28px);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.action-header-modern p {
    font-size: 18px;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.7;
}

.action-buttons-modern {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    width: 100%;
}

@media (min-width: 640px) {
    .action-buttons-modern {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        flex-wrap: wrap;
    }
}

.action-btn-modern {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 32px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    flex: 1;
    max-width: 300px;
    height: 44px;
    min-height: 44px;
}

@media (min-width: 640px) {
    .action-btn-modern {
        flex: 0 1 auto;
    }
}

.action-btn-primary-modern {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(96, 165, 250, 0.4);
}

.action-btn-primary-modern:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(96, 165, 250, 0.5);
}

.action-btn-secondary-modern {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.action-btn-secondary-modern:hover {
    background: var(--bg-tertiary);
    transform: translateY(-2px);
}

.action-footer-modern {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.action-footer-modern p {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

.action-footer-modern i {
    color: var(--primary);
    margin-right: 6px;
}

/* Optimization Overlay */
.optimization-overlay-modern {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.optimization-overlay-modern.show {
    display: flex;
    opacity: 1;
    visibility: visible;
}

.optimization-modal-modern {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 40px 32px;
    max-width: 500px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-xl);
}

.optimization-icon-modern {
    width: 64px;
    height: 64px;
    margin: 0 auto 24px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
    animation: spin 2s linear infinite;
}

.optimization-title-modern {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.optimization-message-modern {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.6;
}

.optimization-progress-modern {
    width: 100%;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}

.optimization-progress-bar-modern {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Try Again symbol selection modal */
.try-again-symbol-modal {
    max-width: 520px;
    text-align: left;
}

.try-again-symbol-message {
    margin-bottom: 16px;
}

.try-again-symbol-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 14px;
}

.try-again-symbol-link-btn {
    background: none;
    border: none;
    color: var(--accent-primary, #6366f1);
    cursor: pointer;
    padding: 0;
    font-size: 14px;
    font-weight: 600;
}

.try-again-symbol-link-btn:hover {
    text-decoration: underline;
}

.try-again-symbol-toolbar-sep {
    color: var(--text-secondary);
}

.try-again-symbol-list {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md, 12px);
    padding: 8px 12px;
    margin-bottom: 20px;
    background: var(--bg-secondary, rgba(0, 0, 0, 0.15));
}

.try-again-symbol-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
    cursor: pointer;
    font-size: 15px;
    color: var(--text-primary);
}

.try-again-symbol-row + .try-again-symbol-row {
    border-top: 1px solid var(--border-color);
}

.try-again-symbol-checkbox {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    accent-color: var(--accent-primary, #6366f1);
}

.try-again-symbol-label {
    font-weight: 600;
    letter-spacing: 0.02em;
}

.try-again-symbol-empty {
    margin: 0;
    padding: 12px 4px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.try-again-symbol-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.try-again-symbol-actions .action-btn-modern {
    flex: 1;
    max-width: none;
}

@media (max-width: 480px) {
    .try-again-symbol-actions {
        flex-direction: column-reverse;
    }
}

/* Stage Badges */
.badge-stage-1 {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-secondary);
}

.badge-stage-2 {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.badge-stage-3 {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.badge-stage-4 {
    background: rgba(239, 71, 111, 0.15);
    color: var(--danger);
}

.badge-buy {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.badge-hold {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.badge-sell {
    background: rgba(239, 71, 111, 0.15);
    color: var(--danger);
}

/* Strength and Confidence Colors */
.strength-very-strong {
    color: var(--success);
    font-weight: 700;
}

.strength-strong {
    color: #22c55e;
    font-weight: 600;
}

.strength-moderate {
    color: var(--warning);
    font-weight: 600;
}

.strength-weak {
    color: #f97316;
    font-weight: 600;
}

.strength-very-weak {
    color: var(--danger);
    font-weight: 700;
}

.confidence-very-high {
    color: var(--success);
    font-weight: 700;
}

.confidence-high {
    color: #22c55e;
    font-weight: 600;
}

.confidence-medium {
    color: var(--warning);
    font-weight: 600;
}

.confidence-low {
    color: #f97316;
    font-weight: 600;
}

.confidence-very-low {
    color: var(--danger);
    font-weight: 700;
}

/* Responsive Adjustments (mobile: ≤639px, matches breakpoints.css) */
@media (max-width: 639px) {
    .review-hero-modern {
        padding: 32px 16px;
    }

    /*
     * Review summary strip (Portfolio Details, Risk Profile, Analytics): full width, no
     * glass card chrome on mobile. Scoped to #review-preview so tablet/desktop and other
     * pages stay unchanged.
     */
    #review-container-modern.review-container #review-preview .portfolio-summary-modern {
        box-sizing: border-box;
        width: calc(100% + 32px);
        max-width: none;
        margin-left: -16px;
        margin-right: -16px;
        margin-bottom: 24px;
        gap: 0;
        padding: 0 16px;
    }

    #review-container-modern #review-preview .portfolio-summary-modern .summary-card-modern.glass-card {
        border: none;
        border-radius: 0;
        padding: 0;
        margin: 0 0 40px 0;
        box-shadow: none;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    #review-container-modern #review-preview .portfolio-summary-modern .summary-card-modern.glass-card:last-child {
        margin-bottom: 0;
    }

    #review-container-modern #review-preview .portfolio-summary-modern .summary-card-modern.glass-card:hover {
        transform: none;
        box-shadow: none;
    }

    #review-container-modern #review-preview .portfolio-summary-modern .summary-card-modern:has(
        .summary-stat-modern:hover
    ) {
        box-shadow: none;
    }

    #review-container-modern #review-preview .portfolio-summary-modern .summary-card-header-modern {
        margin-bottom: 16px;
        padding-bottom: 16px;
    }

    #review-container-modern #review-preview .portfolio-summary-modern .summary-card-modern:has(
        .summary-stats-modern:hover
    ):hover {
        transform: none;
        box-shadow: none;
        border-color: transparent;
    }
    
    .summary-card-title-modern {
        font-size: 20px;
    }
    
    .summary-card-subtitle-modern {
        font-size: 16px;
    }
    
    .summary-stat-label-modern {
        font-size: 16px;
    }
    
    .summary-stat-value-modern {
        font-size: 18px;
    }
    
    .badge-modern {
        font-size: 14px;
    }
    
    .action-section-modern {
        padding: 24px 16px;
    }
}

/* Keep Portfolio Success Overlay - reuses trade execution success animation */
.review-keep-success-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.review-keep-success-overlay.show {
    opacity: 1;
    visibility: visible;
}

.review-keep-success-overlay .success-content {
    text-align: center;
    background: var(--bg-primary);
    padding: 40px 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    max-width: 90%;
}

/* Paper-trading disclaimer below Portfolio Analytics (overview + review); prefs shared via localStorage */
.overview-paper-disclaimer-root {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.overview-paper-disclaimer-inline.disclaimer-modern {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.1) 0%, rgba(96, 165, 250, 0.05) 100%);
    border: 2px solid rgba(96, 165, 250, 0.3);
    border-radius: var(--radius-lg);
    padding: 20px 24px 24px;
    margin: 0;
    text-align: center;
    position: relative;
}

.overview-paper-disclaimer-inline.disclaimer-modern:not([hidden]) {
    margin-top: 20px;
    margin-bottom: 20px;
}

/* Mobile: extra allocation cards sit in this wrapper; display:contents exposes children to the parent grid */
#review-allocations-more.review-allocations-more {
    display: contents;
}

#review-allocations-more.review-allocations-more[hidden] {
    display: none !important;
}

.overview-paper-disclaimer-header-row {
    display: flex;
    justify-content: flex-end;
    margin: -4px -4px 8px 0;
}

.overview-paper-disclaimer-inline .disclaimer-icon {
    font-size: 36px;
    color: var(--primary);
    margin-bottom: 12px;
}

.overview-paper-disclaimer-inline .disclaimer-content {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.overview-paper-disclaimer-inline .disclaimer-content strong {
    color: var(--text-primary);
    font-weight: 700;
}

.overview-paper-disclaimer-toggle-btn {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.overview-paper-disclaimer-toggle-btn:hover {
    color: var(--text-primary);
    border-color: var(--primary);
}

.overview-paper-disclaimer-toggle-btn:focus {
    outline: none;
}

.overview-paper-disclaimer-toggle-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.overview-paper-disclaimer-footer {
    margin-top: 0;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    background: linear-gradient(180deg, rgba(96, 165, 250, 0.06) 0%, rgba(96, 165, 250, 0.02) 100%);
    border-radius: var(--radius-lg);
}

.overview-paper-disclaimer-footer-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px 16px;
    max-width: 1160px;
    margin: 0 auto;
}

.overview-paper-disclaimer-footer-icon {
    color: var(--primary);
    font-size: 16px;
    flex-shrink: 0;
}

.overview-paper-disclaimer-footer-text {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    flex: 1 1 200px;
    text-align: center;
}

@media (max-width: 768px) {
    .overview-paper-disclaimer-inline.disclaimer-modern {
        padding: 16px 18px 20px;
    }

    .overview-paper-disclaimer-footer-inner {
        flex-direction: column;
        text-align: center;
    }

    .overview-paper-disclaimer-footer-text {
        font-size: 12px;
    }
}

/* —— Onboarding review: lazy 3M sparklines above “Show more” —— */
.allocation-metrics-modern > .review-allocation-sparkline-wrap {
    grid-column: 1 / -1;
}

/* Full-width company profile (Artemis-style yfinance blurb) inside metrics grid */
.allocation-metrics-modern > .allocation-market-yf-profile {
    grid-column: 1 / -1;
}

.allocation-metrics-modern > .allocation-company-description-tap {
    grid-column: 1 / -1;
}

.allocation-company-description-tap {
    margin-top: 10px;
    margin-bottom: 4px;
    padding: 10px 12px;
    border-radius: var(--radius-md, 10px);
    background: rgba(15, 23, 42, 0.22);
    border: 1px solid rgba(148, 163, 184, 0.1);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.allocation-company-description-tap:hover {
    background: rgba(15, 23, 42, 0.32);
    border-color: rgba(148, 163, 184, 0.18);
}

.allocation-company-description-tap:focus-visible {
    outline: 2px solid rgba(96, 165, 250, 0.55);
    outline-offset: 2px;
}

.allocation-company-description-text {
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text-secondary, rgba(226, 232, 240, 0.82));
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

.review-allocation-sparkline-wrap {
    width: 100%;
    max-width: 100%;
    margin-top: 14px;
    margin-bottom: 2px;
    box-sizing: border-box;
}

.review-allocation-sparkline-inner {
    position: relative;
    width: 100%;
    height: 72px;
    border-radius: var(--radius-md, 10px);
    background: rgba(15, 23, 42, 0.28);
    border: 1px solid rgba(148, 163, 184, 0.12);
    overflow: hidden;
    contain: layout style paint;
}

.review-allocation-sparkline-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 1;
}

.review-sparkline-shimmer {
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(96, 165, 250, 0.14) 45%,
        rgba(96, 165, 250, 0.22) 50%,
        rgba(96, 165, 250, 0.14) 55%,
        transparent 100%
    );
    animation: review-sparkline-shimmer-move 1.35s ease-in-out infinite;
}

.review-sparkline-loading-icon {
    position: relative;
    z-index: 2;
    font-size: 20px;
    color: rgba(148, 163, 184, 0.75);
    animation: review-sparkline-icon-pulse 0.9s ease-in-out infinite;
}

@keyframes review-sparkline-shimmer-move {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

@keyframes review-sparkline-icon-pulse {
    0%,
    100% {
        opacity: 0.45;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.06);
    }
}

.review-allocation-sparkline-canvas {
    display: block;
    width: 100%;
    height: 72px;
    vertical-align: top;
    opacity: 0;
    transition: opacity 0.22s ease;
}

