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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #0b1020;
    color: #e4e4e7;
    line-height: 1.6;
}

/* Layout */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px;
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    .fractal-card:hover {
        transform: none;
    }

    .fractal-card:active {
        transform: scale(0.98);
    }

    .btn:hover {
        transform: none;
    }

    .btn:active {
        transform: scale(0.95);
    }

    .timeframe-tab:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    .modal-tab:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    .tooltip:hover .tooltiptext {
        visibility: hidden;
    }

    .tooltip:active .tooltiptext {
        visibility: visible;
    }
}

.header {
    text-align: center;
    margin-bottom: 40px;
    padding: 32px 0;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.header p {
    font-size: 1.1rem;
    color: #a1a1aa;
}

/* Main Content Areas */
.current-fractals {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(25px);
    border: 1px solid rgba(59, 130, 246, 0.2);
    padding: 24px;
    border-radius: 16px;
    margin-bottom: 32px;
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.15),
        0 0 40px rgba(59, 130, 246, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.current-fractals h3 {
    font-size: 1.25rem;
    margin-bottom: 20px;
    color: #f4f4f5;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Tabs */
.timeframe-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
}

.timeframe-tab {
    padding: 9px 18px;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.85) 0%, rgba(30, 41, 59, 0.75) 100%);
    border: 1px solid rgba(71, 85, 105, 0.3);
    color: #64748b;
    cursor: pointer;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.8125rem;
    transition: all 0.2s ease;
    letter-spacing: 0.02em;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.timeframe-tab.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.25) 0%, rgba(37, 99, 235, 0.2) 100%);
    color: #e2e8f0;
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.3), 0 2px 4px rgba(0, 0, 0, 0.3);
}

.timeframe-tab:hover:not(.active) {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(51, 65, 85, 0.8) 100%);
    border-color: rgba(71, 85, 105, 0.4);
    color: #94a3b8;
}

/* Fractal Grid */
.fractal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.fractal-card {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.fractal-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.fractal-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.25);
}

.fractal-card:hover::before {
    opacity: 1;
}

.fractal-pair {
    font-size: 1.25rem;
    font-weight: 700;
    color: #3b82f6;
    margin-bottom: 12px;
}

.fractal-price {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: #f4f4f5;
}

.fractal-levels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.fractal-level {
    background: rgba(255, 255, 255, 0.05);
    padding: 16px;
    border-radius: 8px;
    text-align: center;
    border-left: 3px solid transparent;
}

.fractal-high {
    border-left-color: #10b981;
}

.fractal-low {
    border-left-color: #ef4444;
}

.distance {
    font-size: 0.875rem;
    color: #a1a1aa;
    margin-top: 4px;
}

.distance.close {
    color: #f59e0b;
    font-weight: 600;
}

.distance.very-close {
    color: #ef4444;
    font-weight: 700;
    animation: pulse 2s infinite;
}

.distance.broken {
    color: #6b7280;
    text-decoration: line-through;
}

/* Animations */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

@keyframes newsGlow {

    0%,
    100% {
        box-shadow: 0 0 15px rgba(245, 158, 11, 0.5);
    }

    50% {
        box-shadow: 0 0 25px rgba(245, 158, 11, 0.8);
    }
}

@keyframes highImpactGlow {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(239, 68, 68, 0.7);
    }

    50% {
        box-shadow: 0 0 30px rgba(239, 68, 68, 1);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* News Impact Styles */
.fractal-card.news-impact {
    border: 2px solid #f59e0b;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.5);
    animation: newsGlow 2s infinite;
}

.fractal-card.high-impact {
    border: 2px solid #ef4444;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.7);
    animation: highImpactGlow 1.5s infinite;
}

.news-indicator {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #f59e0b;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
}

.news-indicator.high {
    background: #ef4444;
}

.news-details {
    margin-top: 12px;
    padding: 8px;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 4px;
    font-size: 0.75rem;
}

.news-details.high {
    background: rgba(239, 68, 68, 0.1);
}

/* Fractal Status */
.fractal-status {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 12px;
    margin-left: 6px;
    font-weight: 600;
}

.fractal-status.active {
    background: #10b981;
    color: white;
}

.fractal-status.broken {
    background: #6b7280;
    color: #d1d5db;
}

/* Multi-level Fractals */
.multi-levels {
    margin-top: 12px;
    font-size: 0.75rem;
}

.multi-level {
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 8px;
    margin: 2px 0;
    border-radius: 4px;
}

.multi-level.broken {
    opacity: 0.6;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 3px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.8125rem;
    transition: all 0.15s ease;
    letter-spacing: 0.01em;
}

.btn:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: rgba(59, 130, 246, 0.5);
}

/* Alerts */
.alert-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1000;
    max-width: 400px;
}

.alert-item {
    background: rgba(239, 68, 68, 0.95);
    backdrop-filter: blur(10px);
    color: white;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 12px;
    animation: slideIn 0.5s ease-out;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.alert-proximity {
    background: rgba(245, 158, 11, 0.95);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: linear-gradient(135deg, #010205 0%, #1e293b 50%, #0f172a 100%);
    backdrop-filter: blur(24px);
    margin: 2% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 1400px;
    max-height: 95vh;
    overflow: hidden;
    border: 1px solid rgba(59, 130, 246, 0.25);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(59, 130, 246, 0.1) inset;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.98) 0%, rgba(30, 41, 59, 0.95) 100%);
    border-bottom: 1px solid rgba(59, 130, 246, 0.2);
    backdrop-filter: blur(12px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.modal-title {
    color: #f1f5f9;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.close-btn {
    color: #64748b;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.close-btn:hover {
    color: #f1f5f9;
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    transform: scale(1.05);
}

.modal-tabs {
    display: flex;
    gap: 0;
    padding: 0 24px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.8) 0%, rgba(15, 23, 42, 0.6) 100%);
    border-bottom: 1px solid rgba(59, 130, 246, 0.15);
}

.modal-tab {
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    color: #64748b;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    position: relative;
    background: transparent;
}

.modal-tab.active {
    border-bottom-color: #3b82f6;
    color: #f1f5f9;
    background: rgba(59, 130, 246, 0.08);
}

.modal-tab:hover:not(.active) {
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.03);
}

.tab-content {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(95vh - 140px);
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.4) 0%, rgba(15, 23, 42, 0.2) 100%);
}

.tab-content::-webkit-scrollbar {
    width: 8px;
}

.tab-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.tab-content::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.5);
    border-radius: 4px;
}

.tab-content::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.7);
}

/* Daily Analysis Modal specific styles */
#dailyAnalysisModal .modal-content {
    padding: 0;
}

#dailyAnalysisModal .modal-header {
    padding: 16px 24px;
    margin-bottom: 0;
}

/* Loading States */
.loading {
    color: #a1a1aa;
    font-style: italic;
    text-align: center;
    padding: 40px;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #a1a1aa;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* Refresh button hover effect */
button[onclick^="refreshEconomicEvents"]:hover {
    background: rgba(245, 158, 11, 0.3) !important;
    transform: scale(1.05);
    transition: all 0.2s ease;
}

/* Clear cache button hover effect */
button[onclick^="clearAnalysisCache"]:hover {
    background: rgba(239, 68, 68, 0.3) !important;
    transform: scale(1.05);
    transition: all 0.2s ease;
}

/* Forex Calendar */
.forex-calendar {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 24px;
    border-radius: 16px;
    margin-bottom: 32px;
}

.forex-calendar h3 {
    text-align: center;
    margin-bottom: 20px;
    color: #8391b7;
}

.calendar-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.todays-events,
.upcoming-events {
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 12px;
}

.event-item {
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 12px;
    padding: 16px;
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
}

.event-high {
    border-left-color: #ef4444;
}

.event-medium {
    border-left-color: #f59e0b;
}

.event-low {
    border-left-color: #10b981;
}

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

.event-title {
    font-weight: 600;
    color: #f4f4f5;
}

.event-impact {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
}

.impact-high {
    background: #ef4444;
    color: white;
}

.impact-medium {
    background: #f59e0b;
    color: white;
}

.impact-low {
    background: #10b981;
    color: white;
}

.event-details {
    font-size: 0.875rem;
    color: #a1a1aa;
}

.event-time {
    color: #3b82f6;
    font-weight: 600;
}

.event-currency {
    background: #6b7280;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
}

/* Reactions List */
.reactions-list {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 24px;
    border-radius: 16px;
    margin-bottom: 32px;
}

.reactions-list h3 {
    text-align: center;
    margin-bottom: 20px;
    color: #3b82f6;
    font-size: 1.125rem;
}

.reaction-item {
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 21px;
    padding: 16px;
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
}

.reaction-item.yesterday-low {
    background: rgba(255, 165, 0, 0.1);
    border-left-color: #ffa500;
    box-shadow: 0 0 10px rgba(255, 165, 0, 0.3);
}

.reaction-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.reaction-pair {
    font-weight: 700;
    color: #3b82f6;
}

.reaction-type {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.type-high {
    background: #10b981;
}

.type-low {
    background: #ef4444;
}

.yesterday-low-badge {
    background: #ffa500;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-left: 8px;
}

.reaction-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    font-size: 0.875rem;
}

.metric {
    text-align: center;
}

.metric-label {
    color: #a1a1aa;
    font-size: 0.75rem;
    margin-left: 0.2rem;
}

.metric-value {
    font-weight: 700;
}

/* Trade Journal Styles */
.journal-container {
    display: none;
}

.journal-container.active {
    display: block;
}

/* VTD Analysis Styles */
#vtdContainer {
    display: none;
}

#vtdContainer.active {
    display: block;
}

#vtdPredictions,
#vtdProfileChart,
#vtdZones {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    margin-bottom: 20px;
}

#vtdPredictions h4,
#vtdProfileChart h4,
#vtdZones h4 {
    color: #3b82f6;
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.journal-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 32px;
    gap: 12px;
}

.journal-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 32px;
}

.stat-card {
    background: rgba(15, 23, 42, 0.6);
    padding: 24px 20px;
    border-radius: 4px;
    text-align: center;
    border: 1px solid rgba(71, 85, 105, 0.3);
    transition: all 0.15s ease;
    position: relative;
}

.stat-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(59, 130, 246, 0.4);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.stat-card:hover {
    border-color: rgba(100, 116, 139, 0.5);
    background: rgba(15, 23, 42, 0.8);
}

.stat-card:hover::after {
    opacity: 1;
}

.stat-value {
    font-size: 2rem;
    font-weight: 600;
    color: #e2e8f0;
    letter-spacing: -0.02em;
    line-height: 1;
    margin-bottom: 8px;
}

.stat-label {
    color: #64748b;
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.journal-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 32px;
    border-bottom: 1px solid rgba(71, 85, 105, 0.3);
    background: transparent;
}

.journal-tab {
    padding: 12px 24px;
    cursor: pointer;
    color: #64748b;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
    position: relative;
}

.journal-tab:hover {
    color: #94a3b8;
}

.journal-tab.active {
    color: #e2e8f0;
    border-bottom-color: #3b82f6;
}

.trade-form {
    background: rgba(255, 255, 255, 0.05);
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 24px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-weight: 600;
    color: #f4f4f5;
    font-size: 0.875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: #f4f4f5;
    border-radius: 6px;
    font-size: 0.875rem;
}

/* Tables */
.trades-table,
.events-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(71, 85, 105, 0.3);
    border-radius: 4px;
    overflow: hidden;
}

.trades-table th,
.trades-table td,
.events-table th,
.events-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(51, 65, 85, 0.5);
    font-size: 0.8125rem;
}

.trades-table tbody tr,
.events-table tbody tr {
    transition: background 0.15s ease;
}

.trades-table tbody tr:nth-child(even) {
    background: rgba(15, 23, 42, 0.3);
}

.trades-table tbody tr:hover,
.events-table tbody tr:hover {
    background: rgba(30, 41, 59, 0.6);
}

.trades-table th,
.events-table th {
    background: rgba(15, 23, 42, 0.8);
    color: #94a3b8;
    font-weight: 600;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    position: sticky;
    top: 0;
    z-index: 10;
}

.trades-table td {
    color: #cbd5e1;
}

.trades-table td:nth-child(n+4) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.events-table th {
    background: rgba(15, 23, 42, 0.8);
    color: #94a3b8;
}

/* Trade Direction and Outcome Styles */
.trade-direction {
    padding: 4px 10px;
    border-radius: 2px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.direction-long {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.direction-short {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.pnl-positive {
    color: #10b981;
    font-weight: 600;
}

.pnl-negative {
    color: #ef4444;
    font-weight: 600;
}

.trade-outcome {
    padding: 3px 8px;
    border-radius: 2px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.outcome-tp {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.outcome-sl {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.outcome-manual {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.25);
}

/* Pair Stats */
.pair-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.pair-stat-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.pair-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #10b981;
}

.pair-stat-label {
    color: #a1a1aa;
    font-size: 0.875rem;
}

/* Journal Filters */
.journal-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
    padding: 20px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(71, 85, 105, 0.3);
    border-radius: 4px;
}

/* Tab Content */
.tab-content {
    display: none;
}

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

/* Tooltips */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 300px;
    background-color: rgba(0, 0, 0, 0.9);
    color: #fff;
    text-align: left;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    margin-left: -150px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 11px;
    line-height: 1.4;
    pointer-events: none;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

@media (max-width: 768px) {
    .tooltip .tooltiptext {
        width: 250px;
        margin-left: -125px;
        font-size: 10px;
        bottom: auto;
        top: 100%;
        margin-top: 5px;
    }
}

@media (max-width: 480px) {
    .tooltip .tooltiptext {
        width: 200px;
        margin-left: -100px;
        font-size: 9px;
    }
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    .fractal-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .calendar-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .calendar-grid table {
        width: 100%;
        table-layout: fixed;
        font-size: 0.7rem;
    }

    .calendar-grid th,
    .calendar-grid td {
        padding: 4px 1px;
        font-size: 0.65rem;
        height: 45px;
        overflow: hidden;
        text-overflow: ellipsis;
        word-break: break-word;
    }

    /* Fix modal content overflow */
    #pairStatsContent,
    #pairCalendarContent {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Override all inline grid styles */
    .modal-content div[style*="display: grid"],
    .modal-content div[style*="display:grid"] {
        display: flex !important;
        /* flex-direction: column !important; */
        gap: 13px !important;
    }

    /* Fix specific problematic sections */
    .modal-content div[style*="1.2fr 1.2fr 1fr 0.25fr"],
    .modal-content div[style*="repeat(4, 1fr)"],
    .modal-content div[style*="repeat(3, 1fr)"],
    .modal-content div[style*="1fr 1fr 1fr"],
    .modal-content div[style*="1fr 1fr"] {
        display: flex !important;
        /* flex-direction: column !important; */
        gap: 13px !important;
    }

    /* Fix grid layouts in modals */
    #pairStatsContent>div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    /* Fix yield spread analysis */
    div[style*="grid-template-columns: 1.2fr 1.2fr 1fr 0.25fr"] {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    /* Fix news sentiment grid */
    div[style*="grid-template-columns: 1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    /* Fix component breakdown grid */
    div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .header h1 {
        font-size: 1.8rem;
    }

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

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

    .timeframe-tabs {
        flex-wrap: wrap;
        gap: 6px;
    }

    .timeframe-tab {
        padding: 8px 12px;
        font-size: 0.8rem;
        flex: 1;
        min-width: 70px;
        text-align: center;
    }

    .fractal-card {
        padding: 16px;
    }

    .fractal-pair {
        font-size: 1.1rem;
    }

    .fractal-price {
        font-size: 1.4rem;
    }

    .fractal-levels {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 20px;
        max-height: 85%;
    }

    .modal-tabs {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 4px;
        padding-bottom: 4px;
    }

    .modal-tab {
        padding: 8px 12px;
        font-size: 0.8rem;
        flex: 0 0 auto;
        text-align: center;
        white-space: nowrap;
        min-width: 70px;
    }

    .calendar-grid table {
        font-size: 0.65rem;
        width: 100%;
        min-width: 300px;
    }

    .calendar-grid th,
    .calendar-grid td {
        padding: 3px 1px;
        height: 38px;
        vertical-align: top;
        font-size: 0.6rem;
    }

    .pair-stats-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .impact-news {
        padding: 12px;
    }

    .impact-news .tooltip .tooltiptext {
        width: 280px;
        left: -140px;
        margin-left: 0;
    }

    #infoBlock {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }

    .journal-filters {
        grid-template-columns: 1fr;
        gap: 8px;
    }

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

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

    .btn {
        padding: 10px 16px;
        font-size: 0.8rem;
    }

    .current-fractals {
        padding: 16px;
    }

    .forex-calendar {
        padding: 16px;
    }

    .reactions-list {
        padding: 16px;
    }

    .reaction-metrics {
        grid-template-columns: 1fr;
        gap: 8px;
        text-align: left;
    }

    .event-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .pair-stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .journal-header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    #liveQuotesGrid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    #chartSection {
        padding: 12px;
    }

    #fxChart {
        height: 250px;
    }

    .alert-container {
        top: 12px;
        right: 12px;
        left: 12px;
        max-width: none;
    }

    .alert-item {
        padding: 12px;
        font-size: 0.85rem;
    }
}

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

    /* EURUSD Analysis mobile fix */
    .eurusd-analysis,
    #eurusdAnalysisContent,
    #eurusdAnalysisContent2 {
        font-size: 0.75rem !important;
    }

    #eurusdAnalysisContent>div[style*="grid-template-columns: repeat(4, 1fr)"],
    #eurusdAnalysisContent2>div[style*="grid-template-columns: repeat(4, 1fr)"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    #eurusdAnalysisContent div[style*="font-size: 20px"],
    #eurusdAnalysisContent2 div[style*="font-size: 20px"] {
        font-size: 16px !important;
    }

    #eurusdAnalysisContent div[style*="font-size: 16px"],
    #eurusdAnalysisContent2 div[style*="font-size: 16px"] {
        font-size: 14px !important;
    }

    #eurusdAnalysisContent div[style*="font-size: 12px"],
    #eurusdAnalysisContent2 div[style*="font-size: 12px"] {
        font-size: 10px !important;
    }

    /* VTD Analysis mobile fix */
    #modalVTDContent,
    .algorithms-analysis {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    #modalVTDContent>div,
    .algorithms-analysis>div {
        min-width: 280px !important;
    }

    #modalVTDContent div[style*="display: grid"],
    .algorithms-analysis div[style*="display: grid"] {
        display: block !important;
    }

    #modalVTDContent div[style*="display: grid"]>div,
    .algorithms-analysis div[style*="display: grid"]>div {
        margin-bottom: 12px !important;
    }

    /* Institutional Outlook mobile fix */
    #institutional-outlook-section,
    #institutional-outlook-content,
    .institutional-analysis {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    #institutional-outlook-content div[style*="display: grid"],
    .institutional-analysis div[style*="display: grid"] {
        display: block !important;
    }

    #institutional-outlook-content div[style*="display: grid"]>div,
    .institutional-analysis div[style*="display: grid"]>div {
        margin-bottom: 12px !important;
        width: 100% !important;
    }

    #institutional-outlook-content .tooltip,
    .institutional-analysis .tooltip {
        min-width: 100% !important;
        margin-bottom: 8px !important;
    }

    /* Daily Analysis tooltip cards mobile fix */
    #dailyAnalysisContent .tooltip,
    #pairStatsContent .tooltip {
        min-width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 8px !important;
        box-sizing: border-box !important;
    }

    #dailyAnalysisContent>div[style*="display: grid"],
    #dailyAnalysisContent>div>div[style*="display: grid"] {
        display: block !important;
    }

    #dailyAnalysisContent .tooltip>div,
    #pairStatsContent .tooltip>div {
        font-size: 10px !important;
    }

    /* Nuclear option - force everything to single column */
    * {
        max-width: 100% !important;
    }

    /* Override all grid and flex layouts in modals */
    .modal-content [style*="grid-template-columns"] {
        display: block !important;
    }

    .modal-content [style*="display: flex"] {
        flex-direction: column !important;
    }

    /* Force text wrapping */
    .modal-content div,
    .modal-content span,
    .modal-content p {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        white-space: normal !important;
    }

    /* Hide complex tooltips on mobile */
    .tooltip .tooltiptext {
        display: none !important;
    }

    /* Calendar navigation buttons */
    .calendar-grid button,
    #pairCalendarContent button {
        padding: 6px 10px !important;
        font-size: 0.7rem !important;
        min-width: 60px !important;
        white-space: nowrap !important;
    }

    /* Calendar header */
    .calendar-grid h3,
    #pairCalendarContent h3 {
        font-size: 0.8rem !important;
        margin: 0 !important;
        text-align: center !important;
    }

    /* Reactions tab mobile fix */
    .events-table {
        font-size: 0.65rem !important;
        display: block !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .events-table thead,
    .events-table tbody {
        display: block !important;
    }

    .events-table tr {
        display: block !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        margin-bottom: 8px !important;
        padding: 8px !important;
        border-radius: 4px !important;
        background: rgba(255, 255, 255, 0.02) !important;
    }

    .events-table th,
    .events-table td {
        display: block !important;
        padding: 2px 0 !important;
        border: none !important;
        text-align: left !important;
    }

    .events-table th {
        display: none !important;
    }

    .events-table td:before {
        content: attr(data-label) ': ' !important;
        font-weight: bold !important;
        color: #94a3b8 !important;
        display: inline-block !important;
        width: 80px !important;
        font-size: 0.6rem !important;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .header p {
        font-size: 0.95rem;
    }

    .timeframe-tab {
        padding: 6px 8px;
        font-size: 0.75rem;
    }

    .fractal-card {
        padding: 12px;
    }

    .fractal-pair {
        font-size: 1rem;
    }

    .fractal-price {
        font-size: 1.2rem;
    }

    .modal-content {
        width: 98%;
        margin: 2% auto;
        padding: 12px;
        max-height: 95vh;
        overflow-y: auto;
    }

    .calendar-grid {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .calendar-grid table {
        min-width: 280px;
        font-size: 0.55rem;
    }

    .calendar-grid th,
    .calendar-grid td {
        padding: 1px;
        height: 30px;
        font-size: 0.55rem;
        line-height: 1.1;
    }

    .tooltip .tooltiptext {
        width: 200px;
        left: -100px;
        font-size: 9px;
    }

    .impact-news .tooltip .tooltiptext {
        width: 180px;
        left: -90px;
    }

    /* Simplified mobile layout approach */
    .modal-content,
    #pairStatsContent,
    #pairCalendarContent {
        font-size: 0.7rem !important;
    }

    /* Calendar mobile fix */
    .calendar-grid,
    #pairCalendarContent {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .calendar-grid table,
    #pairCalendarContent table {
        width: 100% !important;
        table-layout: fixed !important;
        border-collapse: collapse !important;
    }

    .calendar-grid th,
    .calendar-grid td,
    #pairCalendarContent th,
    #pairCalendarContent td {
        width: 14.28% !important;
        padding: 2px 1px !important;
        font-size: 0.5rem !important;
        height: 28px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        line-height: 1.1 !important;
    }

    /* Overview page readability */
    #pairStatsContent {
        font-size: 0.75rem !important;
        line-height: 1.3 !important;
    }

    #pairStatsContent h4 {
        font-size: 0.9rem !important;
        margin-bottom: 8px !important;
    }

    #pairStatsContent h5 {
        font-size: 0.8rem !important;
        margin-bottom: 6px !important;
    }

    /* Make analysis sections more readable */
    #pairStatsContent>div {
        margin-bottom: 16px !important;
        padding: 12px !important;
        border-radius: 8px !important;
    }

    /* Simplify complex layouts */
    #pairStatsContent div[style*="display: grid"] {
        display: block !important;
    }

    #pairStatsContent div[style*="display: grid"]>div {
        margin-bottom: 8px !important;
        padding: 8px !important;
        background: rgba(255, 255, 255, 0.05) !important;
        border-radius: 4px !important;
    }

    /* Reduce font sizes in modal content */
    #pairStatsContent {
        font-size: 0.8rem;
    }

    #pairStatsContent h4,
    #pairStatsContent h5 {
        font-size: 0.9rem;
    }

    /* Fix calendar navigation buttons */
    .calendar-grid button {
        padding: 4px 8px;
        font-size: 0.7rem;
    }

    .modal-title {
        font-size: 1.2rem;
    }

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

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

    .current-fractals,
    .forex-calendar,
    .reactions-list {
        padding: 12px;
    }

    .btn {
        padding: 8px 12px;
        font-size: 0.75rem;
    }

    .trades-table {
        font-size: 0.7rem;
    }

    .trades-table th,
    .trades-table td {
        padding: 6px 2px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 8px;
        font-size: 0.8rem;
    }

    #fxChart {
        height: 200px;
    }

    .alert-container {
        top: 8px;
        right: 8px;
        left: 8px;
    }

    .close-btn {
        font-size: 24px;
    }
}

/* Beta Pair Styles */
.fractal-card.beta-pair {
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.2);
    opacity: 0.85;
}

.fractal-card.beta-pair:hover {
    opacity: 1;
    border-color: rgba(251, 191, 36, 0.4);
}

/* App Header */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(11, 18, 32, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(59, 130, 246, 0.15);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-logo {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #94a3b8;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.app-status {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: #64748b;
}

.app-status-indicators {
    margin-left: auto;
    padding-right: 1%;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.status-text {
    color: #10b981;
    font-weight: 500;
}

.status-divider {
    color: rgba(100, 116, 139, 0.3);
}

.status-item {
    color: #64748b;
}

body {
    padding-top: 48px;
}

@media (max-width: 768px) {
    .app-status {
        font-size: 9px;
        gap: 8px;
    }

    .status-divider {
        display: none;
    }
}