
/* Portfolio Tab Styles */

/* Portfolio Container - Main wrapper */
#portfolioTab .portfolio-container {
    padding: 8px 16px 16px 16px;
    max-width: 1600px;
    margin: 0 auto;
    overflow-y: auto;
    height: 100%;
}

/* Portfolio Header - Title and buttons on same row */
#portfolioTab .portfolio-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

#portfolioTab .portfolio-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

#portfolioTab .portfolio-header-title h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary, #333);
}

#portfolioTab .portfolio-title-actions {
    display: flex;
    gap: 4px;
}

#portfolioTab .portfolio-header .header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Portfolio Statistics Dashboard - Full width cards in single row */
#portfolioTab .portfolio-stats {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: nowrap;
}

#portfolioTab .portfolio-stats .stat-card {
    background: var(--card-bg, #ffffff);
    padding: 8px 10px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
    flex: 1;
    min-width: 0;
}

#portfolioTab .portfolio-stats .stat-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

#portfolioTab .portfolio-stats .stat-label {
    font-size: 11px;
    color: var(--text-secondary, #6c757d);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#portfolioTab .portfolio-stats .stat-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #333);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#portfolioTab .portfolio-stats .stat-icon {
    position: absolute;
    top: 8px;
    right: 10px;
    font-size: 14px;
    opacity: 0.3;
}

/* Portfolio Layout - Sidebar + Main content */
#portfolioTab .portfolio-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 0px !important;
    margin-top: 12px;
}

/* Portfolio Sidebar */
#portfolioTab .portfolio-sidebar {
    width: auto !important;
    background: var(--card-bg, #ffffff);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
    height: calc(100vh - 180px); /* Expand to window height minus header/tabs */
    min-height: 600px;
}

/* Sidebar Portfolio Header */
#portfolioTab .sidebar-portfolio-header {
    padding: 6px 12px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    margin: 0;
}

#portfolioTab .sidebar-portfolio-header h3 {
    margin: 0 0 8px 0;
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
    word-wrap: break-word;
    line-height: 1.4;
}

#portfolioTab .sidebar-portfolio-actions {
    display: flex;
    gap: 6px;
}

#portfolioTab .btn-icon-small {
    padding: 5px 8px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

#portfolioTab .btn-icon-small:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
    transform: scale(1.05);
}

#portfolioTab .sidebar-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 0;
}

#portfolioTab .new-portfolio-btn {
    width: 100%;
    padding: 8px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

#portfolioTab .new-portfolio-btn:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

#portfolioTab .portfolios-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    max-height: 700px;
    overflow-y: auto;
    padding-right: 5px;
}

#portfolioTab .portfolio-item {
    padding: 6px 8px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 6px;
    box-sizing: border-box;
}

#portfolioTab .portfolio-item:hover {
    background: #f8f9fa;
    border-color: #007bff;
    transform: none !important;
}

#portfolioTab .portfolio-item.active {
    background: #e7f3ff;
    border-color: #007bff;
}

#portfolioTab .portfolio-item-info {
    flex: 1;
    min-width: 0;
}

#portfolioTab .portfolio-item-name {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#portfolioTab .portfolio-item-id {
    font-size: 10px;
    color: #999;
    font-family: monospace;
    margin-bottom: 2px;
}

#portfolioTab .portfolio-item-count {
    font-size: 11px;
    color: #666;
}

#portfolioTab .portfolio-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

#portfolioTab .portfolio-delete-btn:hover {
    opacity: 1;
}

#portfolioTab .portfolio-name {
    font-weight: bold;
    margin-bottom: 5px;
}

#portfolioTab .portfolio-value {
    font-size: 14px;
    color: #666;
}

#portfolioTab .portfolio-change {
    font-size: 12px;
    font-weight: bold;
}

#portfolioTab .portfolio-change.positive { color: #28a745; }
#portfolioTab .portfolio-change.negative { color: #dc3545; }

#portfolioTab .empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

#portfolioTab .empty-hint {
    font-size: 12px;
    margin-top: 10px;
}

/* Portfolio Main Content */
#portfolioTab .portfolio-main {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    margin: 0;
}

#portfolioTab .portfolio-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

#portfolioTab .empty-icon {
    font-size: 80px;
    margin-bottom: 20px;
}

#portfolioTab .portfolio-empty h2 {
    font-size: 32px;
    margin-bottom: 10px;
}

#portfolioTab .portfolio-empty p {
    font-size: 18px;
    color: #6c757d;
    margin-bottom: 30px;
}

#portfolioTab .create-first-btn {
    padding: 12px 24px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

#portfolioTab .create-first-btn:hover {
    background: #0056b3;
}

#portfolioTab .portfolio-viewer {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#portfolioTab .portfolio-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 2px solid #dee2e6;
}

#portfolioTab .portfolio-header h3 {
    font-size: 24px;
    margin: 0;
}

#portfolioTab .portfolio-actions {
    display: flex;
    gap: 10px;
}

#portfolioTab .action-btn {
    padding: 8px 16px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

#portfolioTab .action-btn:hover {
    background: #0056b3;
}

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

#portfolioTab .summary-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

#portfolioTab .summary-label {
    font-size: 14px;
    color: #6c757d;
    margin-bottom: 10px;
}

#portfolioTab .summary-value {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

#portfolioTab .coming-soon-note {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

#portfolioTab .coming-soon-note p {
    margin: 5px 0;
    color: #856404;
}

@media (max-width: 768px) {
    .portfolio-container {
        flex-direction: column;
    }

    .portfolio-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #dee2e6;
    }

    .portfolio-actions {
        flex-wrap: wrap;
    }
}

/* Tools Tabs Styles */
#portfolioTab .tools-container {
    padding: 40px;
    max-width: 1200px;
    margin: 0 auto;
}

#portfolioTab .tools-header-section {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
}

#portfolioTab .tools-action-btn {
    padding: 12px 24px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

#portfolioTab .tools-action-btn:hover {
    background: #0056b3;
}

#portfolioTab .tools-empty {
    text-align: center;
    padding: 80px 20px;
}

#portfolioTab .tools-empty .empty-icon {
    font-size: 80px;
    margin-bottom: 20px;
}

#portfolioTab .tools-empty h3 {
    font-size: 28px;
    margin-bottom: 10px;
}

#portfolioTab .tools-empty p {
    font-size: 18px;
    color: #6c757d;
    margin-bottom: 30px;
}

/* Scanners Grid */
#portfolioTab .scanners-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, auto);
    gap: 20px;
    margin-bottom: 20px;
    max-width: 1200px;
}

#portfolioTab .scanner-card {
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 12px;
    padding: 30px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
    text-align: center;
}

#portfolioTab .scanner-card:hover {
    border-color: #007bff;
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

#portfolioTab .scanner-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

#portfolioTab .scanner-title {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
}

#portfolioTab .scanner-desc {
    font-size: 14px;
    color: #6c757d;
    margin-bottom: 15px;
}

#portfolioTab .scanner-preview {
    width: 100%;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
}

#portfolioTab .preview-row {
    display: grid;
    grid-template-columns: 60px 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 6px 0;
    font-size: 12px;
}

#portfolioTab .preview-symbol {
    font-weight: 600;
    color: #333;
}

#portfolioTab .preview-price {
    color: #495057;
    text-align: right;
}

#portfolioTab .preview-change {
    font-weight: 600;
    text-align: right;
}

#portfolioTab .preview-change.positive {
    color: #28a745;
}

#portfolioTab .preview-change.negative {
    color: #dc3545;
}


@media (max-width: 768px) {
    .tools-container {
        padding: 20px;
    }

    .tools-header-section {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .scanners-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, auto);
    }
}

/* Learning Tab - iframe */
#portfolioTab #learningTab {
    padding: 0 !important;
}

#portfolioTab .learning-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Focus styles for accessibility */
#portfolioTab .quick-action-btn:focus,
#portfolioTab .popular-query-card:focus,
#portfolioTab .scanner-card:focus,
#portfolioTab .portfolio-card:focus,
#portfolioTab .step-card:focus {
    outline: 2px solid #4a9eff;
    outline-offset: 2px;
}

button:focus,
a:focus {
    outline: 2px solid #4a9eff;
    outline-offset: 2px;
}

/* Toast notifications */
@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Scanner Results */
#portfolioTab .scanner-results {
    margin-top: 30px;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* All Scanners Grid View */
#portfolioTab .all-scanners-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
}

#portfolioTab .scanner-mini-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

#portfolioTab .scanner-mini-card h4 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #333;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
}

#portfolioTab .mini-table table {
    width: 100%;
    border-collapse: collapse;
}

#portfolioTab .mini-table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
    padding: 8px 4px;
    border-bottom: 1px solid #e9ecef;
}

#portfolioTab .mini-table td {
    font-size: 13px;
    padding: 8px 4px;
    border-bottom: 1px solid #f8f9fa;
}

#portfolioTab .mini-table .symbol {
    font-weight: 600;
    color: #333;
}

#portfolioTab .mini-table .change.positive {
    color: #28a745;
    font-weight: 600;
}

#portfolioTab .mini-table .change.negative {
    color: #dc3545;
    font-weight: 600;
}


#portfolioTab .scanner-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

#portfolioTab .scanner-results-header h3 {
    font-size: 20px;
    color: #333;
    margin: 0;
}

#portfolioTab .close-results-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

#portfolioTab .close-results-btn:hover {
    background: #f8f9fa;
    color: #333;
}

#portfolioTab .scanner-results-table {
    overflow-x: auto;
}

#portfolioTab .scanner-results-table table {
    width: 100%;
    border-collapse: collapse;
}

#portfolioTab .scanner-results-table thead {
    background: #f8f9fa;
}

#portfolioTab .scanner-results-table th {
    padding: 12px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
}

#portfolioTab .scanner-results-table td {
    padding: 12px;
    font-size: 14px;
    border-bottom: 1px solid #f8f9fa;
}

#portfolioTab .stock-row {
    cursor: pointer;
    transition: background 0.2s;
}

#portfolioTab .stock-row:hover {
    background: #f8f9fa;
}

#portfolioTab .stock-row .symbol {
    font-weight: 600;
    color: #333;
}

#portfolioTab .stock-row .price {
    color: #495057;
}

#portfolioTab .stock-row .change.positive {
    color: #28a745;
    font-weight: 600;
}

#portfolioTab .stock-row .change.negative {
    color: #dc3545;
    font-weight: 600;
}

#portfolioTab .stock-row .volume {
    color: #6c757d;
}

#portfolioTab .scanner-loading {
    text-align: center;
    padding: 40px;
}

#portfolioTab .loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #28a745;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#portfolioTab .scanner-error {
    text-align: center;
    padding: 40px;
}

#portfolioTab .scanner-error p {
    font-size: 16px;
    color: #dc3545;
    margin-bottom: 10px;
}

#portfolioTab .scanner-error .error-message {
    font-size: 14px;
    color: #6c757d;
}

#portfolioTab .scanner-error button {
    margin-top: 20px;
    padding: 10px 20px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

#portfolioTab .scanner-error button:hover {
    background: #5568d3;
}


/* Signal Badge Styles */
#portfolioTab .signal-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}

#portfolioTab .signal-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#portfolioTab .signal-badge-buy {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

#portfolioTab .signal-badge-hold {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

#portfolioTab .signal-badge-sell {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Allocation & Risk Analysis Grid */
#portfolioTab .allocation-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    margin-top: 15px;
}

#portfolioTab .allocation-chart-container,
#portfolioTab .volatility-chart-container {
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

#portfolioTab .allocation-chart-container h4,
#portfolioTab .volatility-chart-container h4 {
    margin: 0 0 15px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

/* Volatility Chart Styles */
#portfolioTab .volatility-bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#portfolioTab .volatility-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

#portfolioTab .volatility-symbol {
    font-weight: 600;
    min-width: 60px;
    font-size: 13px;
}

#portfolioTab .volatility-bar-container {
    flex: 1;
    height: 24px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
}

#portfolioTab .volatility-bar {
    height: 100%;
    transition: width 0.3s ease;
}

#portfolioTab .volatility-low {
    background: linear-gradient(90deg, #28a745, #5cb85c);
}

#portfolioTab .volatility-medium {
    background: linear-gradient(90deg, #ffc107, #ffdb4d);
}

#portfolioTab .volatility-high {
    background: linear-gradient(90deg, #dc3545, #e74c3c);
}

#portfolioTab .volatility-unknown {
    background: #999;
}

#portfolioTab .volatility-value {
    font-weight: 600;
    min-width: 50px;
    text-align: right;
    font-size: 13px;
}

#portfolioTab .volatility-average {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #e0e0e0;
    font-size: 14px;
    text-align: center;
}

#portfolioTab .signal-summary {
    margin-top: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
}

/* Signal Details Modal */
#portfolioTab .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

/* News & Sentiment Section */
#portfolioTab .collapsible {
    cursor: pointer;
    user-select: none;
}

#portfolioTab .collapsible:hover {
    background: #f8f9fa;
}

#portfolioTab .toggle-icon {
    float: right;
    font-size: 14px;
    color: #666;
}

#portfolioTab .portfolio-sentiment-summary {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 16px;
    text-align: center;
}

#portfolioTab .news-stocks-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#portfolioTab .stock-news-section {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    background: #fff;
}

#portfolioTab .stock-news-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

#portfolioTab .stock-news-header strong {
    font-size: 16px;
    color: #333;
}

#portfolioTab .sentiment-badge {
    font-size: 13px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    background: #f0f0f0;
}

#portfolioTab .news-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#portfolioTab .news-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    transition: background 0.2s;
}

#portfolioTab .news-item:hover {
    background: #e9ecef;
}

#portfolioTab .news-sentiment {
    font-size: 16px;
    flex-shrink: 0;
}

#portfolioTab .news-title {
    flex: 1;
    color: #007bff;
    text-decoration: none;
    font-size: 14px;
    line-height: 1.4;
}

#portfolioTab .news-title:hover {
    text-decoration: underline;
}

#portfolioTab .news-title-nolink {
    flex: 1;
    color: #333;
    font-size: 14px;
    line-height: 1.4;
}

#portfolioTab .news-time {
    font-size: 12px;
    color: #999;
    flex-shrink: 0;
}

/* Signal Details Modal */
#portfolioTab .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

#portfolioTab .signal-modal {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

#portfolioTab .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

#portfolioTab .modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

#portfolioTab .modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 1;
}

#portfolioTab .modal-close:hover {
    color: #333;
}

#portfolioTab .modal-body {
    padding: 20px;
}

#portfolioTab .signal-main {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

#portfolioTab .signal-strength {
    font-size: 14px;
    line-height: 1.6;
}

#portfolioTab .indicator-section,
#portfolioTab .recommendation-section {
    margin-top: 20px;
}

#portfolioTab .indicator-section h4,
#portfolioTab .recommendation-section h4 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #333;
}

#portfolioTab .indicator-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#portfolioTab .indicator-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
}

#portfolioTab .indicator-label {
    font-weight: 600;
    color: #666;
}

#portfolioTab .indicator-value {
    font-weight: 600;
    color: #333;
}

#portfolioTab .indicator-signal {
    font-size: 13px;
}

#portfolioTab .recommendation-section p {
    line-height: 1.6;
    color: #555;
}

/* Analysis History Section */
#portfolioTab .analysis-history-section {
    margin-top: 20px;
    border-top: 1px solid #e0e0e0;
    padding-top: 15px;
}

#portfolioTab .history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    color: #333;
    text-transform: uppercase;
}

#portfolioTab .history-header:hover {
    background: #ebebeb;
}

#portfolioTab .history-toggle {
    font-size: 12px;
}

#portfolioTab .history-content {
    margin-top: 10px;
}

#portfolioTab .history-loading, .history-empty {
    text-align: center;
    padding: 20px;
    color: #999;
    font-size: 13px;
}

#portfolioTab .history-best {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
    text-align: center;
}

#portfolioTab .history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#portfolioTab .history-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px;
    font-size: 12px;
    transition: all 0.2s;
}

#portfolioTab .history-item:hover {
    border-color: #2196F3;
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.1);
}

#portfolioTab .history-item.best {
    border-color: #ffd700;
    background: #fffef0;
}

#portfolioTab .history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

#portfolioTab .history-date {
    color: #666;
    font-size: 11px;
}

#portfolioTab .history-score {
    background: #2196F3;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 12px;
}

#portfolioTab .history-item.best .history-score {
    background: #ffd700;
    color: #333;
}

#portfolioTab .history-item-details {
    color: #999;
    font-size: 11px;
}

#portfolioTab .history-view-all {
    width: 100%;
    margin-top: 10px;
    padding: 8px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: #2196F3;
}

#portfolioTab .history-view-all:hover {
    background: #ebebeb;
}

/* Analysis History Pagination */
#portfolioTab .history-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
    padding: 15px;
    border-top: 1px solid #e0e0e0;
}

#portfolioTab .history-pagination-btn {
    padding: 8px 16px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

#portfolioTab .history-pagination-btn:hover:not(:disabled) {
    background: #1976D2;
}

#portfolioTab .history-pagination-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

#portfolioTab .history-pagination-info {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}


/* Analysis Detail Modal */
#portfolioTab .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

#portfolioTab .modal-content {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

#portfolioTab .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

#portfolioTab .modal-header h3 {
    margin: 0;
    font-size: 18px;
}

#portfolioTab .modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 1;
}

#portfolioTab .modal-close:hover {
    color: #333;
}

#portfolioTab .modal-body {
    padding: 20px;
}

#portfolioTab .analysis-detail-section {
    margin-bottom: 20px;
}

#portfolioTab .analysis-detail-section h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #2196F3;
}

#portfolioTab .analysis-metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

#portfolioTab .metric {
    background: #f5f5f5;
    padding: 10px;
    border-radius: 6px;
}

#portfolioTab .metric-label {
    display: block;
    font-size: 11px;
    color: #999;
    margin-bottom: 4px;
}

#portfolioTab .metric-value {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

#portfolioTab .holdings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

#portfolioTab .holdings-table th {
    background: #f5f5f5;
    padding: 8px;
    text-align: left;
    font-weight: 600;
}

#portfolioTab .holdings-table td {
    padding: 8px;
    border-bottom: 1px solid #e0e0e0;
}

#portfolioTab .analysis-detail-section ul {
    margin: 0;
    padding-left: 20px;
}

#portfolioTab .analysis-detail-section li {
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.5;
}

#portfolioTab .analysis-detail-section p {
    margin: 0;
    font-size: 13px;
    line-height: 1.6;
    color: #666;
}


/* Portfolio title */
#portfolioTab #current-portfolio-name {
    font-size: 20px;
    margin-bottom: 12px;
}

#portfolioTab .portfolio-summary-grid {
    margin-top: 0;
}


/* ============================================
   INVESTOR ANALYSIS MODAL STYLES
   ============================================ */

#portfolioTab .investor-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    background: #f9fafb;
    border-radius: 8px;
}

#portfolioTab .investor-checkbox {
    display: flex;
    flex-direction: column;
    padding: 15px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

#portfolioTab .investor-checkbox:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

#portfolioTab .investor-checkbox input[type="checkbox"] {
    margin-right: 10px;
}

#portfolioTab .investor-checkbox input[type="checkbox"]:checked + span {
    color: #3b82f6;
    font-weight: 600;
}

#portfolioTab .investor-checkbox small {
    color: #666;
    font-size: 11px;
    margin-top: 5px;
    margin-left: 30px;
}

/* Investor Results */
#portfolioTab .investor-results {
    margin-top: 30px;
}

#portfolioTab .investor-result-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
}

#portfolioTab .investor-result-card h3 {
    margin: 0 0 15px 0;
    color: #1f2937;
}

#portfolioTab .investor-analysis-content {
    background: #f9fafb;
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
}

#portfolioTab .investor-analysis-content pre {
    margin: 0;
    font-size: 12px;
    white-space: pre-wrap;
    word-wrap: break-word;
}


/* Responsive Design for Portfolio Layout */
@media (max-width: 1200px) {
    .portfolio-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .portfolio-container {
        padding: 10px;
        gap: 15px;
    }

    .portfolio-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .portfolio-header .header-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

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

    .portfolio-layout {
        grid-template-columns: 1fr;
    }

    .portfolio-sidebar {
        max-height: 300px;
    }
}


/* ========================================
   INVESTOR OPINIONS SECTION STYLES
   ======================================== */

.investor-opinions-content {
    padding: 15px;
}

.investor-controls-section {
    background: #f9fafb;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.investor-controls-grid {
    display: grid;
    gap: 15px;
    margin-bottom: 15px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-label {
    font-weight: 600;
    color: #374151;
    font-size: 0.85em;
}

/* Period Selector Buttons */
.period-selector-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.period-btn {
    padding: 6px 12px;
    border: 2px solid #e5e7eb;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    color: #6b7280;
    transition: all 0.2s;
    font-size: 0.85em;
}

.period-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.period-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
}

/* Investor Checkboxes */
.investor-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}

.investor-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85em;
}

.investor-checkbox:hover {
    border-color: #667eea;
    background: #f5f7fa;
}

.investor-checkbox input[type="checkbox"] {
    cursor: pointer;
}

.investor-checkbox span {
    color: #374151;
}

/* Action Section */
.investor-action-section {
    display: flex;
    justify-content: center;
    padding-top: 5px;
}

.btn-large {
    padding: 10px 24px;
    font-size: 1em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-icon {
    font-size: 1.1em;
}

/* Analysis Results */
.investor-analysis-results {
    margin-top: 15px;
}

.investor-analysis-report {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.report-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 15px;
}

.report-header h3 {
    margin: 0 0 3px 0;
    font-size: 1em;
    font-weight: 600;
}

.report-subtitle {
    margin: 0;
    opacity: 0.9;
    font-size: 0.75em;
}

/* Stock Summary Cards */
.stock-summary-cards {
    display: flex;
    gap: 8px;
    padding: 12px;
    overflow-x: auto;
    background: #fafbfc;
    border-bottom: 1px solid #e5e7eb;
}

.stock-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px 12px;
    min-width: 160px;
    flex: 1;
}

.stock-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.stock-symbol {
    font-weight: bold;
    color: #1f2937;
}

.stock-price {
    font-weight: bold;
    color: #10b981;
}

.stock-card-metrics {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.75em;
}

.stock-card-metrics .metric {
    display: flex;
    gap: 4px;
    color: #6b7280;
}

.stock-card-metrics .metric-label::after {
    content: ':';
}

.stock-card-metrics .metric-value {
    font-weight: 600;
    color: #1f2937;
}

/* Consensus Section */
.consensus-section {
    padding: 10px 12px;
}

.consensus-section h4 {
    margin: 0 0 6px 0;
    color: #1f2937;
    font-size: 0.85em;
    font-weight: 600;
}

/* Consensus Grid - Modern Card Layout */
.consensus-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    margin-top: 10px;
}

.stock-consensus-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.stock-consensus-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.stock-consensus-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f3f4f6;
}

.stock-symbol-large {
    font-size: 1.1em;
    font-weight: 700;
    color: #1f2937;
}

.stock-price-small {
    font-size: 0.9em;
    font-weight: 600;
    color: #6b7280;
}

.consensus-badge-large {
    text-align: center;
    padding: 8px;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
}

.investor-signals-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.investor-signal-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    background: #f9fafb;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.investor-signal-item:hover {
    background: #f3f4f6;
}

.investor-signal-name {
    font-size: 0.8em;
    color: #4b5563;
    font-weight: 500;
}

.investor-signal-value {
    font-size: 0.75em;
    font-weight: 600;
    white-space: nowrap;
}

/* Old Consensus Table (kept for backward compatibility) */
.consensus-table-wrapper {
    overflow-x: auto;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.consensus-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8em;
    background: white;
    table-layout: auto;
}

.consensus-table th {
    background: #f9fafb;
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    font-size: 0.85em;
    white-space: nowrap;
}

.consensus-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #f3f4f6;
    white-space: nowrap;
    vertical-align: middle;
    display: table-cell !important;
}

.consensus-table th {
    display: table-cell !important;
}

.consensus-table tr {
    display: table-row !important;
}

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

.investor-name {
    font-weight: 500;
    color: #1f2937;
    white-space: nowrap;
}

.signal-cell {
    font-size: 0.9em;
    white-space: nowrap;
}

.signal-bullish {
    color: #10b981;
}

.signal-bearish {
    color: #ef4444;
}

.signal-neutral {
    color: #6b7280;
}

.consensus-row {
    background: #fffbeb;
    font-weight: 600;
}

.consensus-row td {
    border-top: 2px solid #fbbf24;
}

.consensus-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-weight: 600;
    font-size: 0.9em;
}

.consensus-bullish {
    color: #065f46;
}

.consensus-bearish {
    color: #991b1b;
}

.consensus-mixed {
    color: #374151;
}

/* Detailed Analysis Section */
.detailed-analysis-section {
    padding: 12px;
    background: #fafbfc;
    border-top: 1px solid #e5e7eb;
}

.detailed-analysis-section h4 {
    margin: 0 0 6px 0;
    color: #1f2937;
    font-size: 0.85em;
    font-weight: 600;
}

.stock-detail-card {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-bottom: 8px;
    overflow: hidden;
    background: white;
}

.stock-detail-header {
    background: #f9fafb;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.stock-detail-header:hover {
    background: #f3f4f6;
}

.expand-icon {
    transition: transform 0.3s;
    color: #9ca3af;
    font-size: 0.8em;
}

.stock-detail-card.expanded .expand-icon {
    transform: rotate(90deg);
}

.stock-symbol-large {
    font-weight: bold;
    font-size: 0.9em;
    color: #1f2937;
}

.stock-price-large {
    margin-left: auto;
    font-size: 1em;
    font-weight: bold;
    color: #10b981;
}

.stock-detail-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.stock-detail-card.expanded .stock-detail-content {
    max-height: 3000px;
    padding: 12px;
}

/* Risk Metrics Section */
.risk-metrics-section {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f3f4f6;
}

.risk-metrics-section h5 {
    margin: 0 0 8px 0;
    color: #374151;
    font-size: 0.85em;
}

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

.metric-item {
    background: #f9fafb;
    padding: 6px 8px;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.metric-item .metric-label {
    font-size: 0.7em;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-item .metric-value {
    font-size: 0.95em;
    font-weight: 600;
    color: #1f2937;
}

/* Investor Opinions Section */
.investor-opinions-section h5 {
    margin: 0 0 8px 0;
    color: #374151;
    font-size: 0.85em;
}

.investor-opinion {
    border-left: 3px solid #e5e7eb;
    padding: 8px 10px;
    margin-bottom: 8px;
    background: #f9fafb;
    border-radius: 3px;
}

.investor-opinion.opinion-bullish {
    border-left-color: #10b981;
    background: #f0fdf4;
}

.investor-opinion.opinion-bearish {
    border-left-color: #ef4444;
    background: #fef2f2;
}

.investor-opinion.opinion-neutral {
    border-left-color: #6b7280;
    background: #f9fafb;
}

.opinion-item {
    border-left: 3px solid #e5e7eb;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: #fafbfc;
    border-radius: 4px;
}

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

.opinion-header strong {
    font-size: 0.9em;
    color: #1f2937;
}

.opinion-metrics {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85em;
}

.opinion-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.85em;
}

.opinion-action.signal-bullish {
    background: #d1fae5;
    color: #065f46;
}

.opinion-action.signal-bearish {
    background: #fee2e2;
    color: #991b1b;
}

.opinion-action.signal-neutral {
    background: #f3f4f6;
    color: #4b5563;
}

.opinion-confidence {
    color: #6b7280;
    font-weight: 500;
}

.opinion-quantity {
    color: #6b7280;
    font-weight: 500;
}

.opinion-reasoning {
    font-size: 0.85em;
    line-height: 1.6;
    color: #374151;
    margin: 0;
}

.opinion-icon {
    font-size: 1em;
}

.opinion-investor {
    font-weight: 600;
    color: #1f2937;
    font-size: 0.85em;
}

.opinion-signal {
    font-size: 0.65em;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 3px;
    background: #e5e7eb;
    color: #374151;
    text-transform: uppercase;
}

.opinion-confidence {
    margin-left: auto;
    font-weight: 600;
    color: #6b7280;
    font-size: 0.8em;
}

.opinion-reasoning {
    font-size: 0.8em;
    line-height: 1.4;
    color: #4b5563;
    font-style: italic;
}

/* Loading and Error States */
.loading-spinner {
    border: 3px solid #f3f4f6;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message {
    background: #fee2e2;
    border: 1px solid #ef4444;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    color: #991b1b;
    font-size: 0.9em;
}

/* Responsive Design */
@media (max-width: 768px) {
    .stock-summary-cards {
        flex-direction: column;
    }

    .stock-card {
        min-width: auto;
    }

    .investor-checkboxes {
        grid-template-columns: 1fr;
    }

    .period-selector-buttons {
        flex-direction: column;
    }

    .period-btn {
        width: 100%;
    }

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

    .consensus-table {
        font-size: 0.75em;
    }

    .consensus-table th,
    .consensus-table td {
        padding: 6px 4px;
    }
}


/* Markdown Rendered Content Styling */
.recommendations-section {
    margin-bottom: 20px;
    background: white;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.recommendations-section h4 {
    margin: 0 0 12px 0;
    font-size: 1.1em;
    color: #1f2937;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 8px;
}

.rule-based-recommendations,
.ai-recommendations {
    font-size: 0.95em;
    line-height: 1.6;
    color: #374151;
}

.md-h1, .md-h2, .md-h3, .md-h4 {
    margin: 16px 0 8px 0;
    color: #111827;
    font-weight: 600;
}

.md-h1 { font-size: 1.5em; }
.md-h2 { font-size: 1.3em; }
.md-h3 { font-size: 1.15em; }
.md-h4 { font-size: 1.05em; }

.md-p {
    margin: 8px 0;
    line-height: 1.6;
}

.md-ul, .md-ol {
    margin: 8px 0;
    padding-left: 24px;
}

.md-li, .md-li-num {
    margin: 4px 0;
    line-height: 1.5;
}

.md-ul .md-li {
    list-style-type: disc;
}

.md-ol .md-li-num {
    list-style-type: decimal;
}

strong {
    font-weight: 600;
    color: #111827;
}

/* Structured reasoning for analysts */
.structured-reasoning {
    margin-top: 8px;
}

.signal-item {
    margin-bottom: 8px;
    padding: 8px;
    background: white;
    border-radius: 4px;
    border-left: 2px solid #007bff;
}

.signal-item strong {
    display: block;
    margin-bottom: 4px;
    color: #333;
}

/* Collapsible stock sections */
.stock-detail-card.collapsed .collapsible-content {
    display: none;
}

.stock-detail-card .collapsible-content {
    display: block;
}

.stock-detail-header.collapsible {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 10px;
}

.stock-detail-card.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.collapse-icon {
    transition: transform 0.3s ease;
    font-size: 0.8em;
    color: #666;
}

/* Investor reasoning formatting */
.opinion-item p {
    margin: 0.8em 0;
    line-height: 1.6;
}

.opinion-item strong {
    color: #2c3e50;
    font-weight: 600;
}

.opinion-item ol,
.opinion-item ul {
    margin: 1em 0;
    padding-left: 1.5em;
}

.opinion-item li {
    margin: 0.5em 0;
    line-height: 1.6;
}

.opinion-item ol {
    list-style-type: decimal;
}

.opinion-item ul {
    list-style-type: disc;
}

/* Specialist Analysis Compact Layout */
.consensus-summary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.consensus-summary h5 {
    margin: 0 0 10px 0;
    font-size: 18px;
    font-weight: 600;
}

.consensus-stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.consensus-stat {
    font-size: 14px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.2);
    padding: 5px 12px;
    border-radius: 4px;
}

.specialist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin: 10px 0;
}

.symbol-analysis-card {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
}

.symbol-header {
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 5px;
}

.analyst-signals-compact {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.analyst-row {
    display: flex;
    flex-direction: column;
    padding: 6px 8px;
    background: white;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.analyst-row:hover {
    background: #f8f9fa;
}

.analyst-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.analyst-label {
    font-weight: 500;
    color: #34495e;
}

.signal-summary {
    font-size: 12px;
    color: #7f8c8d;
    font-weight: 600;
}

.expand-arrow {
    display: inline-block;
    transition: transform 0.2s ease;
    margin-left: 5px;
}

.collapsible-analyst.expanded .expand-arrow {
    transform: rotate(180deg);
}

.analyst-details {
    display: none;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

.collapsible-analyst.expanded .analyst-details {
    display: block;
}

.signal-detail {
    margin: 8px 0;
    padding: 6px 10px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.5;
}

.signal-detail strong {
    color: #2c3e50;
}

.detail-text {
    color: #7f8c8d;
    font-size: 11px;
    display: block;
    margin-top: 4px;
}

/* Enhanced Rule-Based Analysis */
.rule-based-enhanced {
    font-size: 13px;
}

.metrics-section {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.metrics-section h5 {
    margin: 0 0 12px 0;
    font-size: 15px;
    font-weight: 600;
    color: #2c3e50;
}

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

.metric-item {
    padding: 8px 12px;
    background: white;
    border-radius: 4px;
    border-left: 3px solid #3498db;
}

.metric-item strong {
    color: #2c3e50;
    margin-right: 5px;
}

.target {
    font-size: 11px;
    color: #7f8c8d;
}

.risk-high {
    color: #e74c3c;
    font-weight: 600;
}

.risk-medium {
    color: #f39c12;
    font-weight: 600;
}

.risk-low {
    color: #27ae60;
    font-weight: 600;
}

.positions-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    background: white;
}

.positions-table th,
.positions-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.positions-table th {
    background: #34495e;
    color: white;
    font-weight: 600;
}

.positions-table tr:hover {
    background: #f8f9fa;
}

.critical-issues {
    background: #fee;
    border-left: 4px solid #e74c3c;
}

.critical-issues h5 {
    color: #e74c3c;
}

.critical-issues ul {
    margin: 10px 0 0 0;
    padding-left: 20px;
}

.critical-issues li {
    margin: 5px 0;
    color: #c0392b;
}

/* Portfolio Strategy Backtest & Optimization */
.strategy-step {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

.strategy-step h4 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 16px;
}

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

.strategy-controls label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 13px;
    font-weight: 500;
}

.strategy-controls select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.strategy-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    background: white;
    font-size: 13px;
}

.strategy-table th,
.strategy-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.strategy-table th {
    background: #34495e;
    color: white;
    font-weight: 600;
}

.strategy-table tr.best-strategy {
    background: #e8f5e9;
    font-weight: 600;
}

.strategy-table tr:hover {
    background: #f8f9fa;
}

.strategy-table .positive {
    color: #27ae60;
    font-weight: 600;
}

.strategy-table .negative {
    color: #e74c3c;
    font-weight: 600;
}

.recommendation-box {
    margin-top: 15px;
    padding: 15px;
    background: #e8f5e9;
    border-left: 4px solid #27ae60;
    border-radius: 4px;
}

.recommendation-box h5 {
    margin: 0 0 8px 0;
    color: #27ae60;
}

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

.parameter-item {
    padding: 10px;
    background: white;
    border-radius: 4px;
    border-left: 3px solid #3498db;
}

.improvement-note {
    margin-top: 15px;
    padding: 10px;
    background: #fff3cd;
    border-radius: 4px;
    font-size: 14px;
}

.metrics-summary {
    margin: 20px 0;
}

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

.metric-card {
    padding: 15px;
    background: white;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.metric-card strong {
    display: block;
    margin-bottom: 8px;
    color: #7f8c8d;
    font-size: 12px;
}

.metric-card span {
    font-size: 20px;
    font-weight: 600;
}

.trade-history {
    margin: 20px 0;
}

.trades-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 13px;
}

.trades-table th,
.trades-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.trades-table th {
    background: #34495e;
    color: white !important;
    font-weight: 600;
}

.loading {
    padding: 20px;
    text-align: center;
    color: #7f8c8d;
    font-size: 14px;
}

.error-message {
    padding: 15px;
    background: #fee;
    border-left: 4px solid #e74c3c;
    border-radius: 4px;
    color: #c0392b;
}

/* Add Holding Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
    color: #2c3e50;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #2c3e50;
    font-size: 14px;
}

.form-group input[type="text"],
.form-group input[type="number"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

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

.input-with-button {
    display: flex;
    gap: 10px;
}

.input-with-button input {
    flex: 1;
}

.input-with-button button {
    white-space: nowrap;
}

.total-cost-display {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    text-align: center;
    font-size: 16px;
    margin-top: 10px;
}

.total-cost-display span {
    color: #27ae60;
    font-size: 20px;
}

.search-dropdown {
    margin-top: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    max-height: 300px;
    overflow-y: auto;
}

.search-dropdown input {
    width: 100%;
    padding: 10px;
    border: none;
    border-bottom: 1px solid #ddd;
    font-size: 14px;
    box-sizing: border-box;
}

.search-dropdown input:focus {
    outline: none;
    border-bottom-color: #3498db;
}

#search-results {
    max-height: 250px;
    overflow-y: auto;
}

.search-result-item {
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.search-result-item:hover {
    background: #f8f9fa;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-symbol {
    font-weight: 600;
    color: #2c3e50;
}

.search-result-name {
    color: #666;
    font-size: 13px;
    margin-top: 2px;
}

.search-result-price {
    color: #27ae60;
    font-size: 13px;
    margin-top: 2px;
}

.btn-primary, .btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #ecf0f1;
    color: #2c3e50;
}

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


/* Correlation Heatmap Table */
.correlation-heatmap {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 14px;
}

.correlation-heatmap th,
.correlation-heatmap td {
    padding: 12px;
    text-align: center;
    border: 1px solid #e5e7eb;
}

.correlation-heatmap th {
    background-color: #f3f4f6;
    font-weight: 600;
    color: #374151;
}

.correlation-heatmap td {
    font-weight: 500;
    transition: transform 0.2s;
}

.correlation-heatmap td:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    cursor: pointer;
}
