/* Portfolio v2 - Main Styles */

/* ===== LIGHT THEME (default) ===== */
:root {
    --primary: #3498db;
    --primary-dark: #2980b9;
    --primary-light: #5dade2;
    --success: #2ecc71;
    --danger: #e74c3c;
    --warning: #f39c12;
    
    /* Backgrounds */
    --bg-app: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-card: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-header: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: #f5f5f5;
    --bg-modal: #ffffff;
    
    /* Text */
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --text-muted: #95a5a6;
    --text-link: #3498db;
    
    /* Borders */
    --border-color: #e0e0e0;
    --border-light: #f0f0f0;
    
    /* Shadows */
    --shadow: rgba(0,0,0,0.1);
    --shadow-lg: rgba(0,0,0,0.15);
    
    /* Status colors */
    --gain: #27ae60;
    --loss: #c0392b;
    
    /* Tier cards */
    --bg-card-tier: #dce1e8;
    
    /* Insights analysis cards */
    --insights-bg-card: #f8f9fa;
    --insights-bg-card-alt: #eef0f2;
    --insights-bg-narrative: linear-gradient(135deg, #e8f0fe 0%, #dce8f8 100%);
    --insights-bg-rec-narrative: linear-gradient(135deg, #fef7e0 0%, #fdf0d5 100%);
    --insights-border-diagnosis: #3498db;
    --insights-border-rec: #f39c12;
    --insights-text-narrative: #2c3e50;
    --insights-text-card: #2c3e50;
    --insights-text-muted: #64748b;
    --insights-text-title: #1e293b;
    --insights-code-bg: #e2e8f0;
    --insights-code-text: #334155;
}

/* ===== DARK THEME ===== */
[data-theme="dark"] {
    --primary: #5dade2;
    --primary-dark: #3498db;
    --primary-light: #85c1e9;
    
    /* Backgrounds */
    --bg-app: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --bg-card: #1e2a3a;
    --bg-secondary: #161e2a;
    --bg-header: #1e2a3a;
    --bg-input: #2d3748;
    --bg-hover: #2d3748;
    --bg-modal: #1e2a3a;
    
    /* Text */
    --text-primary: #e2e8f0;
    --text-secondary: #a0aec0;
    --text-muted: #718096;
    --text-link: #63b3ed;
    
    /* Borders */
    --border-color: #2d3748;
    --border-light: #3d4a5c;
    
    /* Shadows */
    --shadow: rgba(0,0,0,0.3);
    --shadow-lg: rgba(0,0,0,0.5);
    
    /* Status colors */
    --gain: #48bb78;
    --loss: #fc8181;
    
    /* Tier cards */
    --bg-card-tier: #1a2535;
    
    /* Insights analysis cards */
    --insights-bg-card: #1e2a3a;
    --insights-bg-card-alt: #253548;
    --insights-bg-narrative: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --insights-bg-rec-narrative: linear-gradient(135deg, #1a1a2e 0%, #1e3a5f 100%);
    --insights-border-diagnosis: #3b82f6;
    --insights-border-rec: #f59e0b;
    --insights-text-narrative: #e2e8f0;
    --insights-text-card: #e2e8f0;
    --insights-text-muted: #94a3b8;
    --insights-text-title: #f0f0f0;
    --insights-code-bg: #334155;
    --insights-code-text: #e2e8f0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-app);
    min-height: 100vh;
    color: var(--text-primary);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: var(--bg-header);
    padding: 15px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px var(--shadow);
}

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

.header-row:first-child {
    margin-bottom: 10px;
}

.header-second-row {
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
}

.header h1 {
    color: var(--text-primary);
    font-size: 1.5rem;
    margin: 0;
}

.header-logo-wrapper {
    display: flex;
    align-items: center;
}

.header-logo-img {
    height: 90px;
    width: auto;
    display: block;
}

.header-title-text {
    margin-left: 12px !important;
    font-size: 1.2rem !important;
}

.header-info {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: nowrap;
}

.header-info > * {
    flex-shrink: 0;
    white-space: nowrap;
}

.header-info span {
    font-weight: 600;
    color: var(--text-primary);
    min-width: fit-content;
}

#portfolio-value {
    font-size: 1.4rem;
    color: var(--primary);
}

#last-update {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: normal;
}

/* Account Selector */
.account-selector {
    position: relative;
    z-index: 100;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.account-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.account-selector select {
    padding: 10px 35px 10px 12px;
    border: 2px solid var(--primary);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    min-width: 180px;
    max-width: 250px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%233498db' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
}

.account-selector select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

.account-selector select:hover {
    background-color: var(--bg-hover);
}

.account-selector select option {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 10px;
}

/* Theme Toggle Button */
.theme-toggle {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    color: var(--text-primary);
}

.theme-toggle:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.account-btn {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
    color: var(--text-primary);
}

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

/* Tabs */
.tabs {
    display: flex;
    gap: 5px;
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px var(--shadow);
    flex-wrap: wrap;
    border: 1px solid var(--border-color);
}

.tab {
    padding: 12px 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

/* Tab Content */
.tab-content {
    display: none;
    background: var(--bg-card);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px var(--shadow);
    position: relative;
    overflow: visible;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.tab-content.active {
    display: block;
}

/* Force all tab contents to match positions tab width */
#dividends-tab.tab-content,
#dividends-tab.tab-content,
#positions-tab.tab-content,
#funding-tab.tab-content,
#risks-tab.tab-content,
#account-tab.tab-content,
#earnings-tab.tab-content {
    max-width: 1400px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 auto !important;
    overflow-x: auto !important;
}

/* Prevent child elements from expanding beyond container */
#dividends-tab > *,
#positions-tab > *,
#funding-tab > *,
#risks-tab > *,
#account-tab > *,
#earnings-tab > * {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Table responsive wrapper */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive table {
    width: 100%;
    min-width: 700px;
    white-space: nowrap;
}

/* Fix for tables that might expand */
#positions-tab table,
#funding-tab table,
#risks-tab table,
#account-tab table {
    max-width: 100% !important;
    overflow-x: auto !important;
    display: block !important;
}

/* Container constraint for all tabs */
.container {
    max-width: 1400px !important;
    margin: 0 auto !important;
}

/* Fix for funding and risk tabs - ensure proper background */
#funding-tab, #risk-tab {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    max-width: 100%;
    overflow-x: auto;
}

#funding-tab .tab-content,
#risk-tab .tab-content {
    background: var(--bg-card) !important;
}

#funding-tab .summary-cards,
#risk-tab .summary-cards {
    background: transparent;
}

#funding-tab .dashboard-section,
#risk-tab .dashboard-section {
    background: transparent;
}

/* Force dark theme colors for tabs */
[data-theme="dark"] #funding-tab,
[data-theme="dark"] #risks-tab {
    background: #1f2937 !important;
    color: #f9fafb !important;
}

/* Additional fix for white background issue */
#funding-tab > *,
#risks-tab > * {
    background: transparent !important;
}

#funding-tab .card,
#risks-tab .card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
    color: white !important;
}

/* Fix for dividend calendar sub-tab - ensure text is visible */
#dividends-tab .subtab-buttons {
    margin-bottom: 15px;
}

#dividends-tab .subtab-buttons button {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

#dividends-tab .subtab-buttons button.active {
    background: var(--primary);
    color: white;
}

#dividends-calendar-subtab {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 20px;
    border-radius: 12px;
}

#dividends-calendar-subtab h2,
#dividends-calendar-subtab h3 {
    color: var(--text-primary);
}

#dividends-calendar-subtab .card-value,
#dividends-calendar-subtab .card-detail {
    color: var(--text-primary);
}

#dividends-calendar-subtab .data-table {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

#dividends-calendar-subtab .data-table th {
    background: var(--primary);
    color: white;
}

#dividends-calendar-subtab .data-table td {
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 20px;
    border-radius: 12px;
    color: white;
}

.card:nth-child(2) {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
}

.card:nth-child(3) {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
}

.card:nth-child(4) {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.card-title {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 5px;
}

.card-value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Cash Card */
.cash-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px var(--shadow);
}

.cash-card-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.cash-icon {
    font-size: 2rem;
}

.cash-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

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

.cash-card-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cash-card-right input {
    width: 120px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    text-align: right;
}

.cash-card-right input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

@media (max-width: 600px) {
    .cash-card {
        flex-direction: column;
        gap: 16px;
    }
    .cash-card-right {
        width: 100%;
        justify-content: space-between;
    }
    .cash-card-right input {
        flex: 1;
    }
}

/* Dark theme cash card */
[data-theme="dark"] .cash-card {
    background: var(--bg-card);
    border-color: var(--border-color);
}

[data-theme="dark"] .cash-card-right input {
    background: var(--bg-primary);
}

/* Actions */
.actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar input[type="text"] {
    flex: 1;
    min-width: 200px;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.filter-bar input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

.filter-bar select {
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    min-width: 140px;
}

.filter-bar select:focus {
    outline: none;
    border-color: var(--primary);
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

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

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

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

.btn-danger:hover {
    background: #c0392b;
}

/* Data Table */
.hidden { display: none !important; }

/* ============ DATA TABLE ============ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

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

.data-table tr:hover {
    background: var(--bg-hover);
}

.data-table td {
    color: var(--text-primary);
}
    text-align: left;
    border-bottom: 1px solid var(--light);
}

.data-table th {
    background: var(--light);
    font-weight: 600;
    color: var(--dark);
}

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

.data-table .positive {
    color: var(--success);
}

.data-table .negative {
    color: var(--danger);
}

/* Price flash animation for auto-updates */
.data-table .price-flash {
    animation: price-flash 2s ease-out;
}

@keyframes price-flash {
    0% {
        background-color: var(--primary);
        color: white;
        transform: scale(1.05);
    }
    30% {
        background-color: var(--primary-light);
        color: white;
    }
    100% {
        background-color: transparent;
        color: inherit;
        transform: scale(1);
    }
}

[data-theme="dark"] .data-table .price-flash {
    animation: price-flash-dark 2s ease-out;
}

@keyframes price-flash-dark {
    0% {
        background-color: var(--primary);
        color: white;
        transform: scale(1.05);
    }
    30% {
        background-color: #1e3a5f;
        color: white;
    }
    100% {
        background-color: transparent;
        color: inherit;
        transform: scale(1);
    }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-modal);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px var(--shadow-lg);
    border: 1px solid var(--border-color);
    margin: 20px;
}

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

.modal-header h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-close:hover {
    color: var(--text-primary);
}

#modal-body {
    padding: 20px;
}

/* Form */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-input);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Action buttons in table */
.action-btn {
    padding: 5px 10px;
    font-size: 0.8rem;
    margin-right: 5px;
}

/* Mobile: hide less important columns in dividends table */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        text-align: center;
    }

    .header-info {
        flex-direction: column;
        gap: 10px;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab {
        flex: 1;
        min-width: 100px;
    }

    .data-table {
        font-size: 0.8rem;
    }

    .data-table th,
    .data-table td {
        padding: 8px;
    }

}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    position: relative;
    padding: 16px 20px;
    padding-left: 45px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: toastSlideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast::before {
    position: absolute;
    left: 15px;
    font-size: 18px;
}

.toast.success {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    border-left: 4px solid #1a7a3c;
}
.toast.success::before { content: '✓'; }

.toast.error {
    background: linear-gradient(135deg, #c0392b 0%, #e74c3c 100%);
    border-left: 4px solid #922b21;
}
.toast.error::before { content: '✕'; }

.toast.warning {
    background: linear-gradient(135deg, #d68910 0%, #f39c12 100%);
    border-left: 4px solid #b9770e;
    color: #1a1a2e;
}
.toast.warning::before { content: '⚠'; }

.toast.info {
    background: linear-gradient(135deg, #2980b9 0%, #3498db 100%);
    border-left: 4px solid #1a5276;
}
.toast.info::before { content: 'ℹ'; }

.toast-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.7;
    font-size: 18px;
    padding: 0 5px;
}

.toast-close:hover {
    opacity: 1;
}

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastSlideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* Push notification button */
.push-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.push-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.push-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
}

/* Push notifications panel */
.push-panel {
    position: fixed;
    top: 70px;
    right: 20px;
    width: 400px;
    max-height: 500px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    animation: slideDown 0.2s ease;
}

.push-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

.push-panel-header h3 {
    margin: 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.push-panel-body {
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
}

.push-item {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background 0.2s;
}

.push-item:hover {
    background: var(--bg-hover);
}

.push-item.unread {
    background: rgba(52, 152, 219, 0.1);
    border-left: 3px solid var(--primary);
}

.push-item-title {
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.push-item-message {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.push-item-time {
    font-size: 11px;
    color: var(--text-muted);
}

.push-item-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Badge for currency display */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--primary);
    color: white;
}

.badge.mxn {
    background: #e67e22;
}

/* Ticker validation styles */
#ticker-validation {
    display: block;
    margin-top: 4px;
    font-size: 0.85rem;
}

.validation-pending {
    color: #f39c12;
}

.validation-success {
    color: #27ae60;
}

.validation-error {
    color: #e74c3c;
}

/* Auth styles */
.auth-container {
    padding: 20px;
}

.auth-container h2 {
    margin-bottom: 20px;
    text-align: center;
}

.auth-container .form-group {
    margin-bottom: 15px;
}

.auth-container .form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.auth-container .form-actions .btn {
    flex: 1;
}

.auth-note {
    margin-top: 15px;
    text-align: center;
    color: var(--gray);
    font-size: 0.85rem;
}

/* User info in header */
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info span {
    color: var(--dark);
}

.user-info .btn-logout {
    padding: 5px 15px;
    font-size: 0.85rem;
}

/* Account Tab */
.account-container {
    display: grid;
    gap: 20px;
    max-width: 100%;
    width: 100%;
}

.account-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px var(--shadow);
}

.account-card h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
    font-size: 1.1rem;
}

/* Fix for account tab - match other tabs styling */
#account-tab {
    background: var(--bg-card);
    color: var(--text-primary);
    max-width: 100%;
    overflow-x: auto;
}

#account-tab .account-container {
    max-width: 100%;
}

/* Dark theme support */
[data-theme="dark"] #account-tab {
    background: #1f2937 !important;
    color: #f9fafb !important;
}

[data-theme="dark"] .account-card {
    background: #1f2937 !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.profile-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.profile-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #ddd;
}

.profile-row:last-child {
    border-bottom: none;
}

.profile-row label {
    font-weight: 600;
    min-width: 120px;
    color: var(--gray);
}

.profile-row span {
    flex: 1;
    color: var(--dark);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.85rem;
}

.danger-zone {
    border: 1px solid var(--danger);
    background: #fdf2f2;
}

.danger-zone h3 {
    color: var(--danger);
}

.danger-zone .btn {
    width: 100%;
}

/* Chart containers */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    margin: 1rem 0;
}

.gainers-chart-container,
.losers-chart-container {
    height: 200px;
    margin-top: 1rem;
}

/* Risk Cards Row - Mejorado */
.risk-cards-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.risk-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.risk-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.risk-card.gainers {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1) 0%, rgba(34, 197, 94, 0.02) 100%);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.risk-card.gainers h3 {
    color: #22c55e;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.risk-card.losers {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(239, 68, 68, 0.02) 100%);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.risk-card.losers h3 {
    color: #ef4444;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.gain-lose-list {
    margin-bottom: 0.5rem;
}

.gain-lose-list .risk-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin: 4px 0;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
}

.gain-lose-list .risk-item.gain {
    background: rgba(34, 197, 94, 0.15);
}

.gain-lose-list .risk-item.loss {
    background: rgba(239, 68, 68, 0.15);
}

.gain-lose-list .risk-item .ticker {
    font-weight: 700;
    font-size: 0.95rem;
    min-width: 50px;
}

.gain-lose-list .risk-item .name {
    flex: 1;
    color: var(--text-muted);
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0 8px;
}

.gain-lose-list .risk-item .pct {
    font-weight: 700;
    min-width: 60px;
    text-align: right;
}

.gain-lose-list .risk-item .value {
    color: var(--text-muted);
    font-size: 0.8rem;
    min-width: 70px;
    text-align: right;
}

.risk-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.25rem;
    margin: 1rem 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.risk-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

[data-theme="dark"] .risk-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-light) 100%);
}

[data-theme="dark"] .risk-card.gainers {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15) 0%, rgba(34, 197, 94, 0.05) 100%);
}

[data-theme="dark"] .risk-card.losers {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, rgba(239, 68, 68, 0.05) 100%);
}

@media (max-width: 768px) {
    .risk-cards-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* Chart buttons for temporal evolution */
.chart-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

.btn-small {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-small:hover {
    background: var(--bg-hover);
}

.btn-small.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

/* No data message */
.no-data {
    text-align: center;
    color: var(--gray);
    padding: 2rem;
    font-style: italic;
}

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.dashboard-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-lg);
}

.dashboard-card.main-card {
    grid-column: span 2;
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.dashboard-card.main-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.dashboard-card h3 {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.dashboard-card.main-card h2 {
    margin: 0;
    font-size: 1rem;
    opacity: 0.9;
    font-weight: 500;
}

.big-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-detail {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* TWR Section */
.collapsible-section {
    margin-top: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-card);
}

.collapsible-header {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-hover);
    cursor: pointer;
    user-select: none;
}

.collapsible-header:hover {
    background: var(--border-light);
}

.collapsible-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
    flex: 1;
}

.collapse-icon {
    margin-right: 0.75rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    transition: transform 0.2s;
}

.twr-summary {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.twr-cards {
    padding: 0.75rem;
    background: var(--bg-card);
}

.twr-card {
    min-width: 120px;
    background: var(--bg-card);
}

.twr-card h4 {
    margin: 0 0 0.25rem 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.gain-loss {
    font-size: 1rem;
}

.gain-loss .gain-value { 
    color: var(--gain); 
    font-weight: 600; 
}

.gain-loss .loss-value { 
    color: var(--loss); 
    font-weight: 600; 
}

.gain-loss.negative .gain-value {
    color: var(--loss);
}

.gain-loss.negative .gain-pct {
    color: var(--loss);
}

.mini-chart-container { 
    height: 100px; 
    position: relative;
}

.sector-mini-list {
    margin-top: 0.5rem;
    font-size: 0.75rem;
}

.sector-mini-item {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border-light);
}

.sector-mini-item:last-child {
    border-bottom: none;
}

.sector-mini-item .sector-name {
    color: var(--text-secondary);
}

.sector-mini-item .sector-pct {
    color: var(--text-muted);
    font-weight: 500;
}

.dashboard-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow);
    margin-bottom: 1rem;
}

.dashboard-section h3 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.activity-list { 
    max-height: 300px; 
    overflow-y: auto; 
}

.activity-item { 
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem; 
    border-bottom: 1px solid var(--border-light);
    transition: background 0.2s;
}

.activity-item:hover {
    background: var(--bg-hover);
}

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

.activity-icon {
    font-size: 1.25rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
    border-radius: 8px;
}

.activity-details {
    flex: 1;
}

.activity-title {
    font-weight: 500;
    color: var(--text-primary);
}

.activity-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.activity-amount {
    font-weight: 600;
    font-size: 0.9rem;
}

.activity-amount.positive {
    color: #10b981;
}

.activity-amount.negative {
    color: #ef4444;
}

/* Responsive adjustments for dashboard */
@media (max-width: 768px) {
    .dashboard-card.main-card {
        grid-column: span 1;
    }
    
    .big-value {
        font-size: 2rem;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-charts {
        grid-template-columns: 1fr;
    }
}

/* Dashboard Charts */
.dashboard-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.chart-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow);
}

.chart-card h3 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.chart-card .chart-container {
    height: 250px;
    position: relative;
}
/* ============ IA INSIGHTS TAB ============ */
.insights-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
}

.credits-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.credits-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.credits-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gain);
}

.credits-limit {
    color: var(--text-muted);
    font-size: 1rem;
}

.credits-month {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-left: 0.5rem;
}

.insights-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--gain);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

.insights-content {
    margin-top: 1rem;
}

.insights-empty {
    text-align: center;
    padding: 3rem;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    color: var(--text-muted);
}

/* Account Tab - Theme Preferences */
.preference-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
}

.preference-row label {
    font-weight: 500;
    color: var(--text-primary);
}

.theme-options {
    display: flex;
    gap: 10px;
}

.theme-btn {
    padding: 10px 20px;
    border: 2px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.theme-btn:hover {
    border-color: var(--primary);
}

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

/* Broker badge */
.broker-badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--bg-hover);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

/* Accounts List */
.accounts-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.account-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg-hover);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.account-item.default {
    border-color: var(--primary);
    background: rgba(52, 152, 219, 0.1);
}

.account-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.account-item-name {
    font-weight: 600;
    color: var(--text-primary);
}

.account-item-details {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.account-item-actions {
    display: flex;
    gap: 8px;
}

.account-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.account-badge.default {
    background: var(--primary);
    color: white;
}

.account-badge.currency {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.insights-empty p:first-child {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.insights-card {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    overflow: hidden;
}

.insights-meta {
    background: var(--bg-hover);
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.insights-text {
    padding: 1.5rem;
    line-height: 1.6;
}

.insights-text h2 {
    color: var(--text-primary);
    margin: 1.25rem 0 0.75rem;
    font-size: 1.5rem;
}

.insights-text h3 {
    color: var(--text-primary);
    margin: 1rem 0 0.5rem;
    font-size: 1.25rem;
}

.insights-text h4 {
    color: var(--text-secondary);
    margin: 0.75rem 0 0.5rem;
    font-size: 1.1rem;
}

.insights-text p {
    margin: 0 0 0.75rem 0;
    color: var(--text-secondary);
}

.insights-text ul {
    margin: 0.5rem 0 0.75rem 1.5rem;
}

.insights-text li {
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
}

.insights-text strong {
    color: var(--text-primary);
}

/* ============ INSIGHTS HISTORY DROPDOWN ============ */
.insights-history-dropdown {
    margin-bottom: 1.5rem;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    overflow: hidden;
}

.history-dropdown-header {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.history-dropdown-header:hover {
    background: var(--bg-hover);
}

.history-dropdown-header .history-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.history-dropdown-header .history-count {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

.history-dropdown-header .history-arrow {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.8rem;
    transition: transform 0.2s;
}

.history-dropdown-header.expanded .history-arrow {
    transform: rotate(180deg);
}

.history-dropdown-content {
    display: none;
    padding: 0 1.25rem 1.25rem;
    border-top: 1px solid var(--border-color);
}

.history-dropdown-content.show {
    display: block;
}

#insights-history-select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    cursor: pointer;
    margin-top: 1rem;
}

#insights-history-select:focus {
    outline: none;
    border-color: var(--primary);
}

#insights-history-select option {
    padding: 0.5rem;
}

/* History item styling in dropdown */
#insights-history-select option[value]:not([value=""]) {
    font-weight: 500;
}

/* Dark mode adjustments */
[data-theme="dark"] .insights-history-dropdown {
    background: var(--bg-hover);
}

[data-theme="dark"] #insights-history-select {
    background: var(--bg-card);
}

/* Legacy list styles (kept for compatibility) */
.insights-history-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.insights-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.insight-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.insight-history-item:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.15);
    transform: translateY(-1px);
}

.insight-history-item.current {
    border-color: var(--primary);
    background: rgba(52, 152, 219, 0.08);
}

.insight-history-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.insight-history-date {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.insight-history-summary {
    color: var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    gap: 1rem;
}

.insight-history-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.insight-history-value {
    font-weight: 600;
    font-size: 0.95rem;
}

.insight-history-value.positive {
    color: var(--gain-color);
}

.insight-history-value.negative {
    color: var(--loss-color);
}

.insight-history-pct {
    font-size: 0.85rem;
    padding: 2px 8px;
    border-radius: 6px;
}

.insight-history-pct.positive {
    background: rgba(16, 185, 129, 0.15);
    color: var(--gain-color);
}

.insight-history-pct.negative {
    background: rgba(239, 68, 68, 0.15);
    color: var(--loss-color);
}

.insight-history-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: 1rem;
}

.insight-history-actions .btn-sm {
    padding: 4px 8px;
    font-size: 0.8rem;
}

.no-history {
    text-align: center;
    padding: 1rem;
    color: var(--text-muted);
}

/* ============ SORTABLE TABLES ============ */
.data-table.sortable th[data-sort] {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.data-table.sortable th[data-sort]:hover {
    background: var(--bg-hover);
}

.sort-arrow {
    font-size: 0.75rem;
    opacity: 0.5;
    margin-left: 4px;
}

.data-table.sortable th.sort-asc .sort-arrow,
.data-table.sortable th.sort-desc .sort-arrow {
    opacity: 1;
    color: var(--primary);
}

.data-table.sortable th.sort-asc,
.data-table.sortable th.sort-desc {
    background: var(--bg-hover);
    font-weight: 600;
}

/* View Toggle Buttons */
.view-toggle {
    margin-bottom: 16px;
}

.btn-toggle {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.btn-toggle:hover {
    background: var(--bg-hover);
}

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

.btn-toggle .badge {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    margin-left: 6px;
    font-size: 0.7rem;
    padding: 2px 6px;
}

.btn-toggle.active .badge {
    background: rgba(255, 255, 255, 0.3);
}

.btn-toggle:not(.active) .badge {
    background: var(--primary);
    color: white;
}

/* Footer */
.app-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 1.5rem 2rem;
    margin-top: auto;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.footer-brand strong {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.footer-version {
    background: var(--primary);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.footer-credits {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    justify-content: center;
}

.credit-line {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.credit-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.credit-name {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
    
    .credit-line {
        align-items: center;
    }
    
    .footer-credits {
        justify-content: center;
    }
}

/* Export Menu */
.export-menu {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    padding: 0.5rem 0;
}

.export-menu .btn-flat {
    background: transparent;
    border: none;
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-size: 0.9rem;
}

.export-menu .btn-flat:hover {
    background: var(--bg-hover);
}

/* Credit name emphasis */
.credit-name em {
    font-style: normal;
    font-size: 0.75em;
    color: var(--text-muted);
    margin-left: 0.25rem;
}

/* Alerts Button and Badge */
.alerts-btn {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 50%;
    position: relative;
    transition: background 0.2s;
}

.alerts-btn:hover {
    background: var(--bg-hover);
}

.alerts-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: bold;
    padding: 0.1rem 0.35rem;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

/* Alerts Modal Tabs */
.alerts-tabs {
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

/* Alert Item */
.alert-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-hover);
    border-radius: 8px;
    margin-bottom: 10px;
}

.alert-item.triggered {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--danger);
}

.alert-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-ticker {
    font-weight: bold;
    font-size: 1.1rem;
}

.alert-condition {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.alert-status {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
}

.alert-status.active {
    background: var(--success);
    color: white;
}

.alert-status.triggered {
    background: var(--danger);
    color: white;
}

.alert-actions {
    display: flex;
    gap: 8px;
}

.alert-actions button {
    padding: 4px 10px;
    font-size: 0.8rem;
}

/* Calendar Tab Styles */
.calendar-section {
    margin: 20px 0;
}

.calendar-section h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

.calendar-upcoming {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

.calendar-upcoming-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.calendar-upcoming-item.ex-soon {
    border-left: 3px solid var(--warning);
}

.calendar-upcoming-item.ex-imminent {
    border-left: 3px solid var(--danger);
}

.calendar-upcoming-item .ticker {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--text-primary);
}

.calendar-upcoming-item .name {
    font-size: 0.85em;
    color: var(--text-muted);
}

.calendar-upcoming-item .date-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
}

.calendar-upcoming-item .ex-date {
    font-size: 0.9em;
    color: var(--text-secondary);
}

.calendar-upcoming-item .days-until {
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85em;
}

.calendar-upcoming-item .days-until.soon {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.calendar-upcoming-item .amount {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--success);
}

.calendar-upcoming-item .yield {
    font-size: 0.85em;
    color: var(--text-muted);
}

/* Calendar table */
#calendar-table {
    margin-top: 15px;
}

#calendar-table th,
#calendar-table td {
    text-align: left;
    padding: 12px;
}

#calendar-table .positive {
    color: var(--success);
}

#calendar-table .negative {
    color: var(--danger);
}

/* Dividend FWD in dashboard */
.stat-detail strong {
    color: var(--success);
    font-weight: 600;
}

/* Analysis Tables */
.analysis-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 0.9rem;
}

.analysis-table th,
.analysis-table td {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.analysis-table th {
    background: var(--bg-hover);
    font-weight: 600;
    color: var(--text-primary);
}

.analysis-table td {
    background: var(--bg-card);
}

.analysis-table tr:nth-child(even) td {
    background: var(--bg-hover);
}

.analysis-table tr:hover td {
    background: rgba(52, 152, 219, 0.1);
}

/* Dark theme for analysis tables */
[data-theme="dark"] .analysis-table th {
    background: var(--bg-hover);
}

[data-theme="dark"] .analysis-table td {
    background: var(--bg-card);
}

[data-theme="dark"] .analysis-table tr:nth-child(even) td {
    background: var(--bg-hover);
}

/* Return on Capital Section */
.return-on-capital-container {
    margin-top: 1rem;
}

.roc-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-hover);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.roc-card {
    text-align: center;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    background: var(--bg-card);
    min-width: 120px;
    border: 1px solid var(--border-light);
}

.roc-card.roc-result {
    background: linear-gradient(135deg, var(--gain) 0%, #059669 100%);
    min-width: 150px;
    border: none;
}

.roc-card.roc-result.negative {
    background: linear-gradient(135deg, var(--loss) 0%, #dc2626 100%);
}

.roc-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.roc-card.roc-result .roc-label {
    color: rgba(255,255,255,0.9);
}

.roc-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.roc-pct {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-top: 0.25rem;
}

.roc-card.roc-result .roc-value,
.roc-card.roc-result .roc-pct {
    color: #fff;
}

.roc-arrow {
    font-size: 1.5rem;
    color: var(--text-muted);
}

.roc-chart-container {
    height: 250px !important;
}

.section-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* ============ REPORTS TAB ============ */
.reports-container {
    max-width: 1200px;
    margin: 0 auto;
}

.reports-header {
    margin-bottom: 1.5rem;
}

.reports-header h2 {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}

.reports-list {
    display: grid;
    gap: 1rem;
}

.report-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border-light);
}

.report-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-lg);
}

.report-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.report-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.report-card-date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.report-card-preview {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.report-empty {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.report-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Report Modal */
.report-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.report-modal-content {
    background: var(--bg-card);
    border-radius: 16px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.report-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.report-modal-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.report-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 8px;
    transition: background 0.2s;
}

.report-modal-close:hover {
    background: var(--bg-hover);
}

.report-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.report-modal-body iframe {
    width: 100%;
    height: 100%;
    border: none;
    min-height: 60vh;
}

.loading-spinner-container {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

/* ============ ANALYSIS TAB ============ */
.analysis-container {
    max-width: 1200px;
    margin: 0 auto;
}

.analysis-header {
    margin-bottom: 1rem;
}

.analysis-header h2 {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}

.analysis-header .section-hint {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Selector de Ticker */
.analysis-selector {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow);
    border: 1px solid var(--border-light);
}

.analysis-selector-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.analysis-search-wrapper {
    flex: 1;
    min-width: 250px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.analysis-search-wrapper input {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.95rem;
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.analysis-search-wrapper input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.analysis-search-wrapper select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.95rem;
    width: 100%;
    cursor: pointer;
    transition: border-color 0.2s;
    max-height: 300px;
}

.analysis-search-wrapper select:focus {
    outline: none;
    border-color: var(--accent);
}

.analysis-count {
    text-align: center;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Contenido del Análisis */
.analysis-content-wrapper {
    background: var(--bg-card);
    border-radius: 12px;
    min-height: 400px;
    box-shadow: 0 2px 8px var(--shadow);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.analysis-content {
    padding: 1.5rem;
}

.analysis-placeholder,
.analysis-loading,
.analysis-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    text-align: center;
    color: var(--text-muted);
}

.analysis-placeholder-icon,
.analysis-error-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.analysis-loading {
    color: var(--accent);
}

.analysis-error {
    color: var(--loss);
}

.analysis-error-icon {
    opacity: 1;
}

.analysis-html-content {
    line-height: 1.7;
}

.analysis-html-content h1,
.analysis-html-content h2,
.analysis-html-content h3 {
    color: var(--text-primary);
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.analysis-html-content h1:first-child,
.analysis-html-content h2:first-child,
.analysis-html-content h3:first-child {
    margin-top: 0;
}

.analysis-html-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.analysis-html-content th,
.analysis-html-content td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.analysis-html-content th {
    background: var(--bg-secondary);
    font-weight: 600;
}

.analysis-html-content tr:hover td {
    background: var(--bg-hover);
}

/* Dark theme adjustments */
[data-theme="dark"] .analysis-selector,
[data-theme="dark"] .analysis-content-wrapper {
    background: var(--bg-card);
    border-color: var(--border-color);
}

[data-theme="dark"] .analysis-search-wrapper input,
[data-theme="dark"] .analysis-search-wrapper select {
    background: var(--bg-primary);
    border-color: var(--border-color);
}

/* Legacy styles (keeping for backwards compatibility) */

.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.analysis-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border-light);
    text-align: center;
}

.analysis-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px var(--shadow-lg);
}

.analysis-card-ticker {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
}

.analysis-card-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.analysis-card.hidden {
    display: none;
}

.analysis-empty {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
    grid-column: 1 / -1;
}

.analysis-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Analysis Modal */
.analysis-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.analysis-modal-content {
    background: var(--bg-card);
    border-radius: 16px;
    max-width: 1000px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.analysis-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.analysis-modal-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.analysis-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 8px;
    transition: background 0.2s;
}

.analysis-modal-close:hover {
    background: var(--bg-hover);
}

.analysis-modal-body {
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

.analysis-modal-body iframe {
    width: 100%;
    height: 100%;
    border: none;
    min-height: 70vh;
}


/* Legal Content Styles */
.legal-content {
    max-height: 60vh;
    overflow-y: auto;
    padding: 16px;
}

.legal-content h3 {
    margin-top: 0;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

.legal-content h4 {
    margin-top: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 1rem;
}

.legal-content p {
    margin-bottom: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.legal-content ul {
    margin-left: 20px;
    margin-bottom: 16px;
}

.legal-content li {
    margin-bottom: 6px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.legal-footer {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    text-decoration: none;
    font-size: inherit;
    padding: 0;
    font-family: inherit;
}

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

.auth-links {
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}

/* ==================== Thesis Tab Styles ==================== */

.thesis-container {
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
}

.thesis-header {
    text-align: center;
    margin-bottom: 20px;
}

.thesis-header h2 {
    margin: 0 0 8px 0;
    color: var(--text);
}

.thesis-header .section-hint {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Thesis Layout (Main + Sidebar) */
.thesis-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    min-width: 0;
}

.thesis-layout > * {
    min-width: 0;
}

.thesis-main {
    min-width: 0;
    overflow: hidden;
}

.thesis-sidebar {
    position: sticky;
    top: 20px;
    height: fit-content;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

/* History Card */
.thesis-history-card {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.thesis-history-card h3 {
    margin: 0;
    padding: 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    background: var(--bg-light);
}

.thesis-history-list {
    max-height: 500px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--bg-light);
}

.thesis-history-list::-webkit-scrollbar {
    width: 6px;
}

.thesis-history-list::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 3px;
}

.thesis-history-list::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

.thesis-history-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

.thesis-history-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.thesis-history-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.2s;
}

.thesis-history-item:hover {
    background: var(--bg-light);
}

.thesis-history-item:last-child {
    border-bottom: none;
}

.history-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.history-content {
    flex: 1;
    min-width: 0;
}

.history-description {
    font-size: 13px;
    color: var(--text);
    line-height: 1.4;
}

.history-ticker {
    font-weight: 600;
    color: var(--primary);
}

.history-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* History action colors */
.thesis-history-item.action-buy .history-icon { color: var(--success); }
.thesis-history-item.action-sell .history-icon { color: var(--danger); }
.thesis-history-item.action-hold .history-icon { color: var(--warning); }

/* Thesis Controls (Search + Filters) */
.thesis-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    align-items: center;
}

.thesis-search-wrapper {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
}

.thesis-search-wrapper input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--card-bg);
    color: var(--text);
    transition: border-color 0.2s;
}

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

.thesis-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.thesis-filter-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.thesis-filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.thesis-filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.thesis-count {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 8px 16px;
    background: var(--bg-light);
    border-radius: 6px;
}

.thesis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    padding: 0;
}

.thesis-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.thesis-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.thesis-empty-hint {
    font-size: 13px;
    margin-top: 8px;
    color: var(--text-muted);
}

/* Thesis Card */
.thesis-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
}

.thesis-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.thesis-card.action-buy {
    border-left-color: var(--success);
}

.thesis-card.action-sell {
    border-left-color: var(--danger);
}

.thesis-card.action-hold {
    border-left-color: var(--warning);
}

.thesis-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.thesis-ticker-wrapper {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.thesis-ticker {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.thesis-name {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

.thesis-action {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

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

.thesis-action.action-sell {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

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

.thesis-card-body {
    margin-bottom: 12px;
}

.thesis-price-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.thesis-price-current, .thesis-price-fair {
    flex: 1;
}

.thesis-price-fair.valuation-under {
    color: var(--success);
}

.thesis-price-fair.valuation-over {
    color: var(--danger);
}

.thesis-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 2px;
}

.thesis-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.thesis-upside {
    display: block;
    font-size: 12px;
    margin-top: 2px;
}

.thesis-upside[valuation-under],
.thesis-price-fair.valuation-under .thesis-upside {
    color: var(--success);
}

.thesis-entry, .thesis-target, .thesis-stop {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 13px;
}

.thesis-entry {
    background: rgba(59, 130, 246, 0.1);
}

.thesis-target {
    background: rgba(16, 185, 129, 0.1);
}

.thesis-stop {
    background: rgba(239, 68, 68, 0.1);
}

.thesis-entry-price, .thesis-target-price, .thesis-stop-price {
    font-weight: 600;
}

.thesis-entry-pct, .thesis-stop-pct {
    color: var(--danger);
}

.thesis-target-pct {
    color: var(--success);
}

.thesis-confidence {
    font-size: 12px;
    margin-top: 8px;
    color: var(--text-secondary);
}

.thesis-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
    gap: 8px;
}

.thesis-thesis-preview {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    flex: 1;
}

.thesis-updated {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Thesis Modal */
.thesis-modal-content {
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
}

.thesis-detail-ticker {
    font-size: 24px;
    font-weight: 700;
    margin-right: 12px;
}

.thesis-detail-name {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-right: 12px;
}

.thesis-detail-action {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
}

.thesis-detail-section {
    margin-bottom: 20px;
}

.thesis-detail-section h4 {
    margin: 0 0 12px 0;
    color: var(--text);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.thesis-detail-prices {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.thesis-detail-price-item {
    background: var(--bg-light);
    padding: 12px 16px;
    border-radius: 8px;
    min-width: 120px;
}

.thesis-detail-price-item.valuation-under {
    border-left: 3px solid var(--success);
}

.thesis-detail-price-item.valuation-over {
    border-left: 3px solid var(--danger);
}

.thesis-detail-price-item.valuation-fair {
    border-left: 3px solid var(--warning);
}

.thesis-detail-price-item .label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.thesis-detail-price-item .value {
    font-size: 18px;
    font-weight: 600;
}

.valuation-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.valuation-badge.valuation-under {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.valuation-badge.valuation-over {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.valuation-badge.valuation-fair {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.thesis-detail-thesis {
    background: var(--bg-secondary);
    padding: 16px 20px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
}

.thesis-detail-thesis p {
    margin: 0 0 12px 0;
}

.thesis-detail-thesis p:last-child {
    margin-bottom: 0;
}

.thesis-detail-entry-points, .thesis-detail-targets {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.entry-point-item, .target-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    align-items: center;
}

.entry-point-item.now {
    background: rgba(59, 130, 246, 0.1);
}

.entry-point-item.better {
    background: rgba(16, 185,  185, 0.1);
}

.entry-point-item.ideal {
    background: rgba(139, 92, 246, 0.1);
}

.target-item {
    background: rgba(16, 185, 129, 0.1);
}

.target-item.long {
    background: rgba(139, 92, 246, 0.1);
}

.entry-type, .target-horizon {
    font-size: 13px;
    color: var(--text-secondary);
}

.entry-price, .target-price {
    font-weight: 600;
    font-size: 15px;
}

.entry-pct, .target-pct {
    font-size: 13px;
}

.thesis-detail-risk {
    background: var(--bg-light);
    padding: 16px;
    border-radius: 8px;
}

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

.risk-item {
    text-align: center;
    padding: 12px;
    background: var(--card-bg);
    border-radius: 8px;
}

.risk-item .label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 6px;
}

.risk-item .value {
    font-size: 14px;
    font-weight: 600;
}

.risk-item.stop .value {
    color: var(--danger);
}

.risk-item.profit .value {
    color: var(--success);
}

.risk-badge, .confidence-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.risk-badge.high, .confidence-badge.low {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.risk-badge.medium, .confidence-badge.medium {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.risk-badge.low, .confidence-badge.high {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.thesis-swot-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.swot-item {
    padding: 12px;
    border-radius: 8px;
}

.swot-item h5 {
    margin: 0 0 8px 0;
    font-size: 13px;
}

.swot-item ul {
    margin: 0;
    padding-left: 16px;
}

.swot-item li {
    font-size: 12px;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.swot-item.strengths {
    background: rgba(16, 185, 129, 0.1);
}

.swot-item.weaknesses {
    background: rgba(239, 68, 68, 0.1);
}

.swot-item.opportunities {
    background: rgba(59, 130, 246, 0.1);
}

.swot-item.threats {
    background: rgba(245, 158, 11, 0.1);
}

.thesis-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
}

/* Old metric tag fallback */
.metric-tag {
    display: none;
}

/* New Metric Cards */
.metric-card {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 14px;
    transition: transform 0.15s, box-shadow 0.15s;
}

.metric-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.metric-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.metric-card-cat {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.metric-card-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.metric-card-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    background: rgba(0,0,0,0.08);
    border-radius: 6px;
    padding: 4px 10px;
    display: inline-block;
    margin-bottom: 8px;
    font-family: 'SF Mono', 'Cascadia Code', monospace;
}

.metric-card-condition {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    line-height: 1.4;
}

.mc-cond-label {
    font-weight: 600;
    color: var(--warning);
}

.metric-card-action {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.mc-action-label {
    font-weight: 600;
    color: var(--success);
}

/* Fallback plain card when no structure detected */
.metric-card-plain {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 14px;
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
}

.thesis-detail-footer {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
    color: var(--text-muted);
    font-size: 12px;
}

.thesis-analysis-footer {
    margin-top: 24px;
    padding: 16px 20px;
    background: var(--bg-card-alt, rgba(255,255,255,0.03));
    border-radius: 8px;
    border: 1px solid var(--border-light, rgba(255,255,255,0.08));
    text-align: center;
}

.thesis-version {
    display: block;
    font-size: 11px;
    color: var(--text-muted, #888);
    margin-bottom: 8px;
    font-family: monospace;
}

.thesis-disclaimer {
    display: block;
    font-size: 11px;
    color: var(--text-muted, #888);
    line-height: 1.5;
    max-width: 600px;
    margin: 0 auto;
}

.thesis-version-badge {
    position: absolute;
    bottom: 6px;
    right: 8px;
    font-size: 9px;
    color: var(--text-muted, #666);
    background: rgba(255,255,255,0.03);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: monospace;
    opacity: 0.6;
}

.thesis-date-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Justification Section */
.thesis-justification-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
}

.thesis-justification-section h4 {
    margin-bottom: 16px;
    font-size: 15px;
    color: var(--text-primary);
}

.thesis-justification-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px 20px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-primary);
}

.thesis-justification-content strong {
    color: var(--primary);
    font-weight: 600;
}

.thesis-justification-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.thesis-justification-content li {
    margin: 4px 0;
    list-style-type: disc;
}

.thesis-justification-content br {
    margin-bottom: 8px;
}

@media (max-width: 768px) {
    .thesis-grid {
        grid-template-columns: 1fr;
    }
    
    .thesis-swot-grid {
        grid-template-columns: 1fr;
    }
    
    .thesis-detail-prices {
        flex-direction: column;
    }
    
    .thesis-layout {
        grid-template-columns: 1fr;
        display: flex;
        flex-direction: column;
    }
    
    /* Ocultar sidebar de historial en móvil */
    .thesis-sidebar {
        display: none;
    }
}

/* ============================================
   THESIS CHART STYLES
   ============================================ */

.thesis-mini-chart {
    width: 100%;
    height: 80px;
    background: var(--card-bg);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
    position: relative;
}

.thesis-mini-chart .chart-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 24px;
    opacity: 0.5;
}

.thesis-chart-section {
    margin-bottom: 16px;
}

.thesis-chart-container {
    width: 100%;
    height: 350px;
    min-height: 300px;
    background: var(--card-bg);
    border-radius: 8px;
    position: relative;
}

@media (max-width: 768px) {
    .thesis-chart-container {
        height: 300px;
    }
}

@media (max-width: 480px) {
    .thesis-chart-container {
        height: 260px;
    }
}

.chart-loading,
.chart-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    font-size: 14px;
}

.chart-error {
    color: var(--danger);
}

/* Chart legend for entry points */
.thesis-chart-legend {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    font-size: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.legend-dot.now { background: #2196F3; }
.legend-dot.better { background: #FF9800; }
.legend-dot.ideal { Background: #4CAF50; }
.legend-dot.target { background: #9C27B0; }

/* Tab Groups */
.tab-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.tab-group-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 4px 10px;
    margin-right: 8px;
    font-weight: 600;
    background: var(--bg-card);
    border-radius: 6px;
    white-space: nowrap;
    border: 1px solid var(--border-light);
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

@media (max-width: 768px) {
    /* Header */
    .header-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .header h1 {
        font-size: 1.2rem;
    }
    
    .header-info {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    
    .header-actions {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    /* Navigation Tabs */
    .tabs {
        padding: 8px;
        gap: 4px;
    }
    
    .tab-group {
        width: 100%;
        justify-content: center;
    }
    
    .tab-group-title {
        width: 100%;
        text-align: center;
        margin-bottom: 8px;
        margin-right: 0;
    }
    
    .tab {
        padding: 8px 12px;
        font-size: 0.85rem;
        min-width: auto;
    }
    
    /* Account selector */
    .account-selector {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    /* Tables */
    .data-table {
        font-size: 0.75rem;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .data-table th,
    .data-table td {
        padding: 6px 8px;
    }
    
    .data-table .action-btn {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
    
    /* Dashboard */
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-charts {
        grid-template-columns: 1fr;
    }
    
    .big-value {
        font-size: 1.8rem;
    }
    
    /* Cards */
    .card, .dashboard-card {
        padding: 12px;
    }
    
    /* Forms */
    .form-group {
        margin-bottom: 12px;
    }
    
    .form-group label {
        font-size: 0.85rem;
    }
    
    .form-input, .form-select {
        padding: 8px 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Buttons */
    .btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
    
    .btn-sm {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    
    /* Modals */
    .modal-content {
        width: 95%;
        max-width: none;
        max-height: 85vh;
        margin: 10px;
        padding: 15px;
    }
    
    .modal-header {
        padding: 12px;
    }
    
    .modal-header h2 {
        font-size: 1.1rem;
    }
    
    /* Thesis cards */
    .thesis-grid {
        grid-template-columns: 1fr;
    }
    
    .thesis-card {
        padding: 12px;
    }
    
    .thesis-mini-chart {
        height: 60px;
    }
    
    /* Position cards */
    .position-card {
        padding: 10px;
    }
    
    /* Import CSV section */
    .import-info {
        padding: 10px;
    }
    
    .import-actions {
        flex-direction: column;
    }
    
    .import-actions .btn {
        width: 100%;
    }
    
    /* Account cards */
    .account-item {
        padding: 10px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .account-item-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    /* Filter bar */
    .filter-bar {
        flex-direction: column;
        gap: 8px;
    }
    
    .filter-bar input,
    .filter-bar select,
    .filter-bar .btn {
        width: 100%;
    }
    
    /* Summary cards */
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .summary-cards .card {
        padding: 10px;
    }
    
    /* TWR Section */
    .twr-section,
    .twr-cards {
        grid-template-columns: 1fr;
    }
    
    /* Charts */
    .chart-container {
        height: 250px;
    }
    
    /* Footer */
    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .footer-credits {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    /* Alerts panel */
    .alerts-list {
        max-height: 300px;
    }
    
    /* Dividend calendar */
    .calendar-grid {
        grid-template-columns: 1fr;
    }
    
    /* Report options */
    .report-options {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    /* Extra small screens */
    .header h1 {
        font-size: 1rem;
    }
    
    .tab {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
    
    .big-value {
        font-size: 1.5rem;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
    }
    
    .data-table {
        font-size: 0.7rem;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
    
    .modal-content {
        padding: 12px;
    }
    
    .thesis-card-body {
        font-size: 0.85rem;
    }
    
    .report-options {
        grid-template-columns: 1fr;
    }
    
    /* Chart in detail modal */
    .thesis-chart-container {
        height: 200px;
    }
}

/* ===== FUNDAMENTALS PRO TAB ===== */
.fundamentals-pro-container {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.fundamentals-pro-header {
    margin-bottom: 20px;
}

.fundamentals-pro-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.fundamentals-pro-header .section-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

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

.fundamentals-pro-search-wrapper {
    flex: 1;
    min-width: 250px;
}

.fundamentals-pro-search-wrapper input {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    background: var(--bg-input);
    color: var(--text-primary);
}

.fundamentals-pro-count {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 10px 15px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.fundamentals-pro-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.fundamentals-pro-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border-color);
}

.fundamentals-pro-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--shadow-lg);
}

.fundamentals-pro-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.fundamentals-pro-card-header h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin: 0;
}

.fundamentals-pro-sector {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: 4px 8px;
    border-radius: 4px;
}

.fundamentals-pro-section {
    margin-bottom: 15px;
}

.fundamentals-pro-section h4 {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 10px;
    font-weight: 600;
}

.fundamentals-pro-metric-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 0.9rem;
}

.fundamentals-pro-metric-row .metric-label {
    color: var(--text-secondary);
}

.fundamentals-pro-metric-row .metric-value {
    color: var(--text-primary);
    font-weight: 500;
}

.fundamentals-pro-card-footer {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

/* Modal */
.fundamentals-pro-modal-content {
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
}

.fundamentals-pro-detail {
    padding: 10px;
}

.fundamentals-pro-detail-section {
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
}

.fundamentals-pro-detail-section h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary);
}

.fundamentals-pro-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.fundamentals-pro-detail-row {
    display: flex;
    flex-direction: column;
    padding: 10px;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.fundamentals-pro-detail-row .detail-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.fundamentals-pro-detail-row .detail-value {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 5px;
}

.fundamentals-pro-detail-row .detail-sector {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.fundamentals-pro-detail-row .detail-diff {
    font-size: 0.85rem;
    font-weight: 600;
}

.fundamentals-pro-detail-row .detail-diff.positive {
    color: var(--gain);
}

.fundamentals-pro-detail-row .detail-diff.negative {
    color: var(--loss);
}

/* Estimates table */
.estimates-table {
    overflow-x: auto;
}

.estimates-table table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
}

.estimates-table th {
    background: var(--primary);
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: 600;
}

.estimates-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.estimates-table tr:hover {
    background: var(--bg-hover);
}

/* Earnings list */
.earnings-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.earnings-item {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.earnings-date {
    font-weight: 600;
    color: var(--text-primary);
}

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

/* Empty state */
.fundamentals-pro-container .empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 1rem;
}

/* Error message */
.fundamentals-pro-container .error-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--loss);
    font-size: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .fundamentals-pro-grid {
        grid-template-columns: 1fr;
    }
    
    .fundamentals-pro-detail-grid {
        grid-template-columns: 1fr;
    }
    
    .fundamentals-pro-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .fundamentals-pro-search-wrapper {
        min-width: 100%;
    }
}


/* EARNINGS VIEW STYLES */

.earnings-container {
    padding: 20px;
    background: var(--bg-card);
    border-radius: 12px;
}

.earnings-header {
    margin-bottom: 20px;
}

.earnings-header h2 {
    margin-bottom: 5px;
    color: var(--text-primary);
}

.section-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 5px;
}

.earnings-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.earnings-sort {
    display: flex;
    align-items: center;
    gap: 10px;
}

.earnings-sort label {
    font-weight: 600;
    color: var(--text-primary);
}

.earnings-sort select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
}

.earnings-count {
    font-weight: 600;
    color: var(--primary);
}

.earnings-table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

#earnings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

#earnings-table th {
    background: var(--bg-secondary);
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

#earnings-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

#earnings-table tbody tr:hover {
    background: var(--bg-secondary);
}

#earnings-table .ticker-cell {
    font-weight: 600;
    color: var(--primary);
}

#earnings-table .btn-icon {
    margin-right: 5px;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 1.2rem;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

#earnings-table .btn-icon:hover {
    background: var(--bg-secondary);
}

/* SURPRISE % COLOR CODING */

.surprise-dark-green {
    background: #1b5e20;
    color: white;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
}

.surprise-green {
    background: #4caf50;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
}

.surprise-light-green {
    background: #c8e6c9;
    color: #2e7d32;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
    font-weight: 600;
}

.surprise-inline {
    background: #f5f5f5;
    color: #757575;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
}

.surprise-light-red {
    background: #ffcdd2;
    color: #c62828;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
    font-weight: 600;
}

.surprise-red {
    background: #ef5350;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
}

.surprise-dark-red {
    background: #b71c1c;
    color: white;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
}

/* BEAT/MISS INDICATORS */

.beat-miss-beat {
    color: #4caf50;
    font-weight: bold;
}

.beat-miss-miss {
    color: #ef5350;
    font-weight: bold;
}

.beat-miss-inline {
    color: #ff9800;
}

/* EARNINGS MODAL */

.earnings-modal-content {
    max-width: 900px;
    max-height: 80vh;
    overflow-y: auto;
}

.earnings-history h4 {
    margin: 20px 0 10px 0;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.earnings-next {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
}

.earnings-next p {
    margin: 5px 0;
    color: var(--text-primary);
}

/* RESPONSIVE */

@media (max-width: 1200px) {
    #earnings-table {
        font-size: 0.8rem;
    }
    
    #earnings-table th,
    #earnings-table td {
        padding: 8px 4px;
    }
}

@media (max-width: 768px) {
    .earnings-controls {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .earnings-sort {
        flex-direction: column;
        align-items: stretch;
    }
    
    .earnings-sort select {
        width: 100%;
    }
    
    #earnings-table-container {
        overflow-x: scroll;
    }
}

/* User Tiers Styles - v3.0.0 */
#user-tier-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

#user-tier-card h3 {
    color: white !important;
}

.tier-badge-display {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    margin-bottom: 1rem;
}

.tier-icon {
    font-size: 2.5rem;
}

.tier-name {
    font-size: 1.5rem;
    font-weight: 700;
}

.tier-features {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
}

.tier-features h4 {
    color: white;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

.tier-features ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tier-features li {
    color: white;
    font-size: 0.875rem;
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tier-features li::before {
    content: '✓';
    color: #4ade80;
    font-weight: bold;
}

.tier-features li.disabled {
    opacity: 0.5;
    text-decoration: line-through;
}

.tier-features li.disabled::before {
    content: '✗';
    color: #f87171;
}

#upgrade-section {
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    padding-top: 1rem;
}
.surprise-dark-green {
    background: #1b5e20;
    color: white;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
}

.surprise-green {
    background: #4caf50;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
}

.surprise-light-green {
    background: #c8e6c9;
    color: #2e7d32;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
    font-weight: 600;
}

.surprise-inline {
    background: #f5f5f5;
    color: #757575;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
}

.surprise-light-red {
    background: #ffcdd2;
    color: #c62828;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
    font-weight: 600;
}

.surprise-red {
    background: #ef5350;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
}

.surprise-dark-red {
    background: #b71c1c;
    color: white;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
}

/* BEAT/MISS INDICATORS */

.beat-miss-beat {
    color: #4caf50;
    font-weight: bold;
}

.beat-miss-miss {
    color: #ef5350;
    font-weight: bold;
}

.beat-miss-inline {
    color: #ff9800;
}

/* EARNINGS MODAL */

.surprise-dark-green {
    background: #1b5e20;
    color: white;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
}

.surprise-green {
    background: #4caf50;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
}

.surprise-light-green {
    background: #c8e6c9;
    color: #2e7d32;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
    font-weight: 600;
}

.surprise-inline {
    background: #f5f5f5;
    color: #757575;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
}

.surprise-light-red {
    background: #ffcdd2;
    color: #c62828;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
    font-weight: 600;
}

.surprise-red {
    background: #ef5350;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
}

.surprise-dark-red {
    background: #b71c1c;
    color: white;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
}

/* BEAT/MISS INDICATORS */

.beat-miss-beat {
    color: #4caf50;
    font-weight: bold;
}

.beat-miss-miss {
    color: #ef5350;
    font-weight: bold;
}

.beat-miss-inline {
    color: #ff9800;
}

/* EARNINGS MODAL */


/* ============ POSITION CHART MODAL ============ */

.position-chart-modal {
    max-width: 900px;
}

.position-chart-container {
    width: 100%;
    height: 400px;
    background: var(--card-bg, #1a1a2e);
    border-radius: 8px;
    overflow: hidden;
}

.position-chart-legend {
    display: flex;
    gap: 15px;
    padding: 10px 0;
    flex-wrap: wrap;
}

.position-chart-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: var(--text-secondary, #888);
}

.position-chart-legend .avg-price {
    color: #4CAF50;
}

.position-chart-legend .alerts-count {
    color: #9C27B0;
}

/* Modal footer */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.1));
    background: var(--bg-secondary, #12121f);
    border-radius: 0 0 8px 8px;
}

/* Chart loading/error states */
.chart-loading,
.chart-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: var(--text-secondary, #888);
    font-size: 14px;
}

.chart-error {
    color: var(--error, #ef5350);
}

/* Responsive */
@media (max-width: 600px) {
    .position-chart-modal {
        width: 95%;
        margin: 20px auto;
    }
    
    .position-chart-container {
        height: 300px;
    }
}

/* ============================================
   PRINT STYLES - Thesis Export to PDF
   ============================================ */

@media print {
    /* Ocultar todo excepto el modal de tesis */
    body * {
        visibility: hidden;
    }
    
    /* Mostrar solo el modal de tesis y sus hijos */
    #thesis-modal,
    #thesis-modal * {
        visibility: visible;
    }
    
    /* Posicionar el modal al inicio de la página */
    #thesis-modal {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        display: block !important;
        background: white !important;
    }
    
    /* Estilos del contenido del modal para impresión */
    #thesis-modal .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 20px !important;
        border: none !important;
        box-shadow: none !important;
        background: white !important;
    }
    
    /* Ocultar botones en impresión */
    #thesis-modal .modal-header-actions,
    #thesis-modal .modal-close,
    #thesis-modal button {
        display: none !important;
    }
    
    /* Estilos del título para impresión */
    #thesis-modal .modal-header h3 {
        color: black !important;
        font-size: 24px !important;
        border-bottom: 2px solid #333 !important;
        padding-bottom: 10px !important;
    }
    
    /* Asegurar texto negro visible */
    #thesis-modal .modal-body {
        color: black !important;
        background: white !important;
    }
    
    /* Estilos de tablas para impresión */
    #thesis-modal table {
        border-collapse: collapse !important;
        width: 100% !important;
    }
    
    #thesis-modal th,
    #thesis-modal td {
        border: 1px solid #ddd !important;
        padding: 8px !important;
        color: black !important;
    }
    
    /* SWOT grid para impresión */
    #thesis-modal .swot-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 15px !important;
    }
    
    /* Page breaks */
    #thesis-modal .thesis-section {
        page-break-inside: avoid;
    }
}

/* Estilos para el header del modal con acciones */
.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header-actions .btn {
    white-space: nowrap;
}

/* ============================================
   RESPONSIVE - Mobile (< 768px)
   Added 2026-05-22 - does not affect desktop
   ============================================ */

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    .header {
        padding: 10px;
    }
    .header-row {
        flex-wrap: wrap;
        gap: 6px;
    }
    .header h1,
    .header-title-text {
        font-size: 1rem !important;
    }
    .header-logo-img {
        height: 72px;
    }
    .header-info {
        gap: 8px;
        flex-wrap: wrap;
    }
    .header-info span {
        font-size: 0.85rem;
    }
    #portfolio-value {
        font-size: 1.1rem;
    }
    #last-update {
        display: none;
    }
    .alerts-btn, .push-btn {
        padding: 4px 6px;
        font-size: 1em;
    }
    .account-selector select {
        max-width: 160px;
        font-size: 0.8rem;
    }
    .tabs {
        flex-direction: row;
        overflow-x: auto;
        gap: 4px;
        padding: 8px;
        -webkit-overflow-scrolling: touch;
    }
    .tabs::-webkit-scrollbar {
        height: 3px;
    }
    .tabs::-webkit-scrollbar-thumb {
        background: var(--primary);
        border-radius: 3px;
    }
    .tab-group {
        flex-shrink: 0;
    }
    .tab-group-title {
        display: none;
    }
    .tab {
        padding: 6px 10px;
        font-size: 0.78rem;
        white-space: nowrap;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .dashboard-card {
        padding: 15px;
    }
    .dashboard-card h2 {
        font-size: 1rem;
    }
    .big-value {
        font-size: 1.6rem;
    }
    .data-table {
        font-size: 0.75rem;
    }
    .data-table th, .data-table td {
        padding: 6px 4px;
    }
    .modal-content {
        width: 95%;
        margin: 10px auto;
        max-height: 90vh;
    }
    .modal-body {
        padding: 15px;
    }
    .header-second-row .account-selector {
        width: 100%;
        justify-content: flex-start;
    }
    .header-second-row select {
        flex: 1;
        min-width: 0;
    }
    .dashboard-card.main-card {
        grid-column: 1;
    }
    .positions-actions {
        flex-wrap: wrap;
        gap: 6px;
    }
    .positions-actions .btn {
        font-size: 0.78rem;
        padding: 6px 10px;
    }
    .positions-filters {
        flex-wrap: wrap;
    }
    .action-btn {
        padding: 3px 6px;
        font-size: 0.8rem;
    }
    .form-group {
        margin-bottom: 10px;
    }
    .form-input, .form-select {
        font-size: 0.85rem;
        padding: 8px;
    }
    .section-hint {
        font-size: 0.8rem;
    }
    .data-table {
        overflow-x: auto;
        display: block;
    }
    .data-table th, .data-table td {
        white-space: nowrap;
    }
    .tab-content {
        overflow-x: auto;
    }
    .positions-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .header-info .theme-toggle,
    .header-info .account-btn {
        padding: 4px 6px;
        font-size: 1em;
    }
    .header-title-text {
        display: none;
    }
    .data-table {
        font-size: 0.7rem;
    }
    .data-table th, .data-table td {
        padding: 4px 3px;
    }
}
