/* ==================== DASHBOARD LAYOUT ==================== */

.dashboard-container {
    display: flex;
    min-height: 100vh;
    height: auto; /* Allow content to expand beyond viewport */
    background: var(--bg-primary);
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

/* When dashboard is active, mainContent should be inside dashboard-main */
.dashboard-container ~ .container .main-content {
    display: none !important;
}

.dashboard-container .main-content {
    margin-left: 0;
    padding: 0;
    display: none;
}

.dashboard-container .main-content.show {
    display: grid;
}

/* ==================== SIDEBAR ==================== */

.sidebar {
    width: 280px;
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar.hidden {
    transform: translateX(-100%);
}

/* Hamburger Menu Button */
.sidebar-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001; /* Higher than sidebar */
    width: 48px;
    height: 48px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.sidebar-toggle:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.sidebar-toggle:active {
    transform: scale(0.95);
}

.sidebar-toggle.active {
    left: 1rem; /* Keep in same position when open */
}

/* Mobile Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-logo i {
    color: var(--primary-color);
    font-size: 1.75rem;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
    margin: 0.25rem 0;
}

.nav-item i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.nav-item span {
    font-size: 0.95rem;
    font-weight: 500;
}

.nav-item .badge {
    margin-left: auto;
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.1) 0%, transparent 100%);
    color: var(--primary-color);
    border-left: 3px solid var(--primary-color);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-color);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    margin-bottom: 0.75rem;
}

.user-card-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1rem;
}

.user-card-info {
    flex: 1;
    min-width: 0;
}

.user-card-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card-plan {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-logout {
    width: 100%;
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    color: #ef4444;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.sidebar-logout:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
}

/* ==================== DASHBOARD MAIN ==================== */

.dashboard-main {
    margin-left: 280px;
    flex: 1;
    min-height: 100vh;
    height: auto; /* Allow content to expand */
    padding: 2rem;
    transition: margin-left 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

.dashboard-main.sidebar-hidden {
    margin-left: 0;
}

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

.header-left h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.header-left p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ==================== DASHBOARD VIEWS ==================== */

.dashboard-content {
    position: relative;
    width: 100%;
    min-height: 100%;
}

.dashboard-view {
    display: none;
    animation: fadeIn 0.3s ease;
    width: 100%;
    overflow-x: hidden;
}

.dashboard-view.active {
    display: block;
}

/* ==================== STATS GRID ==================== */

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

.stat-card {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    gap: 1rem;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-icon.blue {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(99, 102, 241, 0.05));
    color: var(--primary-color);
}

.stat-icon.purple {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(168, 85, 247, 0.05));
    color: #a855f7;
}

.stat-icon.gold {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(251, 191, 36, 0.05));
    color: #fbbf24;
}

.stat-icon.green {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(34, 197, 94, 0.05));
    color: #22c55e;
}

.stat-info {
    flex: 1;
    min-width: 0;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.stat-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.stat-progress {
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.75rem;
}

.stat-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 3px;
    transition: width 0.5s ease;
}

.stat-progress-bar.purple {
    background: linear-gradient(90deg, #a855f7, #ec4899);
}

.stat-action {
    margin-top: 0.75rem;
    padding: 0.5rem 1rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 8px;
    color: var(--primary-color);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stat-action:hover {
    background: rgba(99, 102, 241, 0.15);
    transform: translateX(2px);
}

/* ==================== RECENT ACTIVITY ==================== */

.recent-activity {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
}

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

.activity-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.view-all {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.view-all:hover {
    color: var(--secondary-color);
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.activity-item:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateX(4px);
}

.activity-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(99, 102, 241, 0.05));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 1.25rem;
    flex-shrink: 0;
}

.activity-details {
    flex: 1;
    min-width: 0;
}

.activity-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.activity-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.activity-value {
    font-size: 1.1rem;
    font-weight: 700;
    text-align: right;
}

.activity-value.positive {
    color: #22c55e;
}

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

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

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

.empty-state p {
    margin-bottom: 1.5rem;
}

/* ==================== HISTORY VIEW ==================== */

.history-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-box input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 2.75rem;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

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

.filter-buttons {
    display: flex;
    gap: 0.5rem;
}

.filter-btn {
    padding: 0.875rem 1.25rem;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

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

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.history-card {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.history-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

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

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

.history-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.history-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.history-stat {
    text-align: center;
}

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

.history-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.history-return {
    text-align: center;
    padding: 0.75rem;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 10px;
}

.history-return.negative {
    background: rgba(239, 68, 68, 0.1);
}

.history-return-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.history-return-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #22c55e;
}

.history-return.negative .history-return-value {
    color: #ef4444;
}

/* ==================== SUBSCRIPTION VIEW ==================== */

.subscription-info {
    margin-bottom: 3rem;
}

.current-plan-card {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 2px solid var(--primary-color);
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
}

.plan-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
}

.current-plan-card h2 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.plan-price {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.plan-features {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    text-align: left;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
}

.feature-item i {
    color: #22c55e;
    font-size: 1.1rem;
}

.feature-item.disabled i {
    color: #ef4444;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.upgrade-section h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* ==================== SETTINGS VIEW ==================== */

.settings-sections {
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.settings-section {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
}

.settings-section h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.settings-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.settings-form label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.settings-form .form-control {
    padding: 0.875rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.settings-form .form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

.settings-form .form-control:read-only {
    opacity: 0.6;
    cursor: not-allowed;
}

.danger-zone {
    border-color: rgba(239, 68, 68, 0.3) !important;
}

.danger-zone h3 {
    color: #ef4444;
}

.danger-zone p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.btn-danger {
    padding: 0.875rem 1.5rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 10px;
    color: #ef4444;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
}

/* ==================== RESPONSIVE ==================== */

/* Tablets and below */
@media (max-width: 1024px) {
    .dashboard-main {
        padding: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile Landscape and below */
@media (max-width: 768px) {
    /* Show hamburger menu */
    .sidebar-toggle {
        display: flex;
    }
    
    /* Hide sidebar by default on mobile */
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    /* Dashboard adjustments */
    .dashboard-main {
        margin-left: 0;
        padding: 1rem;
        padding-top: 5rem;
        min-height: 100vh;
        height: auto !important; /* Critical: allow content to expand */
        overflow-y: visible !important; /* Don't clip content */
        overflow-x: hidden;
        max-height: none !important;
    }
    
    /* Ensure views can scroll independently if needed */
    .dashboard-view {
        height: auto !important;
        min-height: auto !important;
        overflow: visible !important;
    }
    
    /* Main content should expand */
    .main-content {
        height: auto !important;
        min-height: auto !important;
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .dashboard-title {
        font-size: 1.5rem;
    }
    
    /* Stats grid single column */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* History adjustments */
    .history-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .search-box {
        width: 100%;
    }
    
    .filter-buttons {
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .history-grid {
        grid-template-columns: 1fr;
    }
    
    /* Backtest form adjustments */
    .form-row {
        grid-template-columns: 1fr;
    }
    
    /* Calculator adjustments */
    .calculator-container {
        grid-template-columns: 1fr;
    }
    
    /* Modal adjustments */
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 1rem;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* Subscription plans */
    .plans-grid {
        grid-template-columns: 1fr;
    }
    
    /* Chart container */
    .chart-container {
        min-height: 250px;
    }
}

/* Mobile Portrait */
@media (max-width: 480px) {
    /* Reduce overall scale */
    html {
        font-size: 14px; /* Reduce base font size */
    }
    
    .dashboard-main {
        padding: 0.5rem;
        padding-top: 4rem;
        min-height: 100vh;
        height: auto !important;
        padding-bottom: 3rem; /* Extra space at bottom */
        max-height: none !important;
        overflow-y: visible !important;
    }
    
    /* Ensure body and html don't limit height */
    body.dashboard-active {
        height: auto !important;
        min-height: 100vh;
    }
    
    .dashboard-title {
        font-size: 1.1rem;
    }
    
    .dashboard-subtitle {
        font-size: 0.8rem;
    }
    
    .dashboard-header {
        margin-bottom: 1rem;
    }
    
    /* Stat cards more compact */
    .stat-card {
        padding: 0.75rem;
    }
    
    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
    
    /* Buttons more compact */
    .btn-primary,
    .btn-outline {
        width: 100%;
        justify-content: center;
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }
    
    /* Form inputs */
    .form-control {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.625rem 0.75rem;
    }
    
    .form-section {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .section-title {
        font-size: 0.85rem;
        margin-bottom: 0.5rem;
    }
    
    /* Glass panels more compact */
    .glass-panel {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .panel-header {
        margin-bottom: 0.75rem;
    }
    
    .panel-header h2,
    .panel-header h3 {
        font-size: 1rem;
    }
    
    .panel-header p {
        font-size: 0.75rem;
    }
    
    /* Result cards */
    .result-card {
        padding: 0.75rem;
    }
    
    .result-metrics {
        gap: 0.75rem;
        grid-template-columns: 1fr;
    }
    
    .result-value-primary {
        font-size: 1.5rem;
    }
    
    .result-value-secondary {
        font-size: 0.85rem;
    }
    
    /* Calculator results */
    .calculator-result-hero {
        margin-bottom: 0.75rem;
    }
    
    .detail-grid {
        gap: 0.5rem;
    }
    
    .detail-item {
        font-size: 0.85rem;
    }
    
    /* Backtest config panel */
    .config-panel {
        padding: 0.75rem;
    }
    
    /* Footer spacing */
    .site-footer {
        margin-top: 1.5rem;
    }
    
    /* Touch-friendly improvements */
    .nav-item {
        padding: 0.875rem 1.25rem;
        min-height: 44px;
    }
    
    .nav-item span {
        font-size: 0.875rem;
    }
    
    button,
    .btn,
    .btn-primary,
    .btn-outline {
        min-height: 44px;
        touch-action: manipulation;
    }
    
    /* Sidebar adjustments */
    .sidebar-header {
        padding: 1.5rem 1rem;
    }
    
    .sidebar-logo {
        font-size: 1.25rem;
    }
    
    .user-card {
        padding: 0.625rem;
    }
    
    .user-card-name {
        font-size: 0.85rem;
    }
    
    /* Improve tap targets */
    a, button, input, select, textarea {
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.2);
    }
    
    /* Ensure all content is visible and scrollable */
    .dashboard-content {
        min-height: auto;
        height: auto;
        overflow: visible;
    }
    
    /* Fix any fixed heights that might cut content */
    .view-header,
    .calculator-container,
    .settings-sections {
        height: auto;
        min-height: auto;
    }
    
    /* Ensure forms don't get cut off */
    form {
        margin-bottom: 1rem;
    }
    
    /* Chart containers should be responsive */
    .chart-container {
        max-height: 250px !important;
        height: 250px !important;
        min-height: 250px;
    }
    
    canvas {
        max-height: 250px !important;
    }
    
    /* Metrics grid more compact */
    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .metrics-hero {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }
    
    .metric-hero-card {
        padding: 0.75rem;
    }
    
    .metric-hero-value {
        font-size: 1.25rem;
    }
    
    .metric-hero-label {
        font-size: 0.75rem;
    }
    
    /* Charts grid */
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .chart-card {
        padding: 0.75rem;
    }
    
    .chart-header h3 {
        font-size: 0.9rem;
    }
    
    /* Metrics detailed */
    .metrics-detailed {
        margin-top: 1rem;
    }
    
    .metrics-section h3 {
        font-size: 0.95rem;
        margin-bottom: 0.75rem;
    }
    
    /* Results panel specific */
    .results-panel {
        padding: 0.75rem !important;
        margin-bottom: 2rem;
    }
    
    .results-panel .panel-header {
        flex-direction: column;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }
    
    .header-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .header-actions button {
        flex: 1 1 calc(50% - 0.25rem);
        min-width: 120px;
        font-size: 0.75rem;
        padding: 0.5rem;
    }
    
    /* Trades table mobile adjustments */
    .trades-table-section {
        padding: 0.75rem;
        margin-bottom: 1rem;
        overflow-x: auto;
    }
    
    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .table-controls {
        width: 100%;
        flex-direction: column;
    }
    
    .search-input,
    .filter-select {
        width: 100%;
        font-size: 14px; /* Prevent iOS zoom */
    }
    
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }
    
    .trades-table {
        font-size: 0.7rem;
        min-width: 800px; /* Force horizontal scroll for full table */
    }
    
    .trades-table th,
    .trades-table td {
        padding: 0.5rem;
        white-space: nowrap;
    }
    
    .trades-table th {
        font-size: 0.65rem;
    }
    
    /* Pagination controls */
    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
        justify-content: center;
    }
    
    .pagination button {
        min-width: 36px;
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* ==================== TOUCH IMPROVEMENTS (ALL DEVICES) ==================== */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .nav-item:hover {
        background: none;
    }
    
    .nav-item:active {
        background: rgba(255, 255, 255, 0.1);
    }
    
    button:hover {
        transform: none;
    }
    
    button:active {
        transform: scale(0.98);
    }
}

/* ==================== ANIMATIONS ==================== */

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