/* Modern Dark Theme CSS */
:root {
    --bg-primary: #0a0e27;
    --bg-secondary: #141b2d;
    --bg-tertiary: #1a2332;
    --bg-card: #1e2a3a;
    --text-primary: #e4e7eb;
    --text-secondary: #9ca3af;
    --accent-primary: #3b82f6;
    --accent-secondary: #8b5cf6;
    --accent-success: #10b981;
    --accent-danger: #ef4444;
    --accent-warning: #f59e0b;
    --border-color: #2d3748;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-lg: rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Global responsive fixes */
html {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    position: relative;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, 
        #0a0e27 0%, 
        #141b2d 25%, 
        #1a2332 50%, 
        #141b2d 75%, 
        #0a0e27 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    min-height: -webkit-fill-available; /* iOS Safari fix */
    padding: 20px;
    line-height: 1.6;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Prevent text size adjustment on orientation change */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at top, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
                radial-gradient(ellipse at bottom, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

body > * {
    position: relative;
    z-index: 1;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding: 0 20px;
    box-sizing: border-box;
}

header {
    margin-bottom: 40px;
    padding: 30px 0;
}

header > div {
    text-align: center;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    word-wrap: break-word;
}

/* Header responsive wrapper */
.header-content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.header-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    width: 100%;
    position: relative;
    min-width: 0;
}

.header-title-row > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
}

.header-title-row > div:last-child {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
}

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

/* User profile indicator base styles */
#userProfileIndicator {
    display: none;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 100%;
    min-width: 0;
}

#userProfileIndicator.mobile-layout {
    width: 100%;
    margin-left: 0;
    margin-top: 15px;
    flex-direction: column;
    align-items: stretch;
}

/* User info container */
#userInfo {
    display: none;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
}

#userEmail {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#storageModeIndicator {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Portfolio Selector Compact */
.portfolio-selector-compact {
    margin-bottom: 20px;
}

.portfolio-selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 0;
    margin-bottom: 0;
}

.portfolio-selector-header:hover {
    opacity: 0.9;
}

.selector-header-content {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.portfolio-selector-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.portfolio-badge {
    margin-left: auto;
    margin-right: 0;
}

.toggle-icon {
    font-size: 1.2rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
    user-select: none;
}

.collapsible-header {
    user-select: none;
}

.collapsible-header:hover {
    opacity: 0.9;
}

.portfolio-manager-content {
    margin-top: 20px;
}

.portfolio-summary-content {
    margin-top: 20px;
}

.portfolio-category-container {
    margin-bottom: 20px;
}

.portfolio-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 10px;
    transition: background 0.2s ease;
}

.portfolio-category-header:hover {
    background: var(--bg-card);
}

.portfolio-category-header h4 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
}

.category-toggle {
    font-size: 1rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
    user-select: none;
}

.portfolio-category-content {
    display: block;
    padding-left: 10px;
}

.portfolio-selector-content {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Merged Portfolio Manager */
.portfolio-manager-merged {
    margin-bottom: 30px;
}

.workflow-step {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 2px solid var(--border-color);
}

.workflow-step:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.step-title {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.step-title::before {
    content: '';
    width: 4px;
    height: 20px;
    background: var(--accent-primary);
    border-radius: 2px;
}

.current-asset-display {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

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

.current-asset-badge-inline {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(139, 92, 246, 0.2));
    border: 2px solid var(--accent-primary);
    border-radius: 8px;
    color: var(--accent-primary);
    font-weight: 700;
    font-size: 0.95rem;
}

.portfolio-manager-merged .asset-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    align-items: flex-end;
}

.portfolio-manager-merged .form-grid {
    margin-top: 20px;
}

/* Main Workspace - Two Column Layout */
.main-workspace {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
    align-items: stretch;
}

.workspace-left,
.workspace-right {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.workspace-left {
    justify-content: flex-start;
}

.workspace-right {
    justify-content: flex-start;
}

/* Make cards fill available space in their columns */
.workspace-left .card {
    flex: 0 1 auto;
}

.workspace-right .card {
    flex: 0 1 auto;
}

/* When profit section has results, make it expand */
.profit-section .profit-results[style*="display: block"] {
    flex: 1 1 auto;
}

/* Make charts section fill space when visible */
.charts-section:not([style*="display: none"]) {
    flex: 1 1 auto;
}

.full-width-section {
    grid-column: 1 / -1;
}

/* Better balance - make stats section expand to fill space */
.stats-section:not([style*="display: none"]) {
    flex: 1 1 auto;
    min-height: 0;
}

/* Ensure input section doesn't grow too much */
.input-section {
    flex: 0 0 auto;
}

/* Better alignment for columns */
.main-workspace {
    align-items: stretch;
}

.workspace-left {
    justify-content: flex-start;
}

.workspace-right {
    justify-content: flex-start;
}

/* Make charts section fill available space when profit is shown */
.charts-section:not([style*="display: none"]) {
    flex: 1 1 auto;
}

.profit-section:not([style*="display: none"]) {
    flex: 1 1 auto;
}

/* Large Desktop (1400px+) - Default styles apply */

/* Desktop (1200px - 1400px) */
@media (max-width: 1400px) {
    .container {
        max-width: 1200px;
    }
}

/* Medium Desktop / Large Tablet (1024px - 1200px) */
@media (max-width: 1200px) {
    .main-workspace {
        grid-template-columns: 1fr;
    }
    
    .workspace-left,
    .workspace-right {
        grid-column: 1 / -1;
    }
    
    .portfolio-summary-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

.card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 10px 30px var(--shadow);
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px var(--shadow-lg);
}

.card h2 {
    font-size: 1.8rem;
    margin-bottom: 20px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

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

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

.form-group label {
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input {
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.form-group input::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

/* Button Styles */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(59, 130, 246, 0.4);
}

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

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

.btn-danger {
    background: var(--accent-danger);
    color: white;
    padding: 6px 12px;
    font-size: 0.85rem;
}

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

/* Statistics Section */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-tertiary);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    text-align: center;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: scale(1.05);
}

.stat-card.highlight {
    border: 2px solid var(--accent-primary);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1));
}

.stat-card.danger {
    border: 2px solid var(--accent-danger);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(220, 38, 38, 0.1));
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 8px;
    font-weight: 500;
}

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

.stat-subvalue {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 4px;
}

.stat-card.highlight .stat-value {
    color: var(--accent-primary);
}

.stat-card.danger .stat-value {
    color: var(--accent-danger);
}

.safety-margin {
    padding: 15px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-color);
}

/* Share Modal Styles */
.share-options {
    margin-bottom: 20px;
}

.share-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.share-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.share-checkbox:hover {
    background: var(--bg-card);
    border-color: var(--accent-primary);
}

.share-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-primary);
}

.share-checkbox span {
    color: var(--text-primary);
    font-size: 0.9rem;
    user-select: none;
}

.share-preview {
    font-family: 'Courier New', monospace;
}

.share-buttons .btn-social {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-size: 0.9rem;
}

.share-buttons .btn-social svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.share-buttons .btn-social span {
    white-space: nowrap;
}

.share-buttons .btn-social:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0.9;
}

.share-buttons .btn-social:active {
    transform: translateY(0);
}

.share-buttons .btn-copy {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.share-buttons .btn-copy svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

/* Auth Modal Styles */
.btn-tab {
    transition: all 0.2s ease;
}

.btn-tab:hover {
    background: var(--bg-tertiary) !important;
}

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

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

.safety-label {
    color: var(--text-secondary);
    margin-right: 10px;
}

.safety-value {
    color: var(--accent-success);
    font-size: 1.2rem;
    font-weight: 700;
}

/* Charts Section */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
}

.chart-container {
    background: var(--bg-tertiary);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.chart-container h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
    font-size: 1.2rem;
}

.chart-container canvas {
    max-height: 300px;
}

/* Table Styles */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--bg-tertiary);
}

th {
    padding: 15px;
    text-align: left;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

/* Action buttons container in position history table */
.action-buttons-container {
    display: flex;
    flex-direction: row;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem !important;
    padding: 4px 8px !important;
    white-space: nowrap;
    min-width: auto;
    flex-shrink: 0;
    transition: all 0.2s ease;
    border-radius: 4px;
    font-weight: 500;
}

.action-btn .btn-icon {
    font-size: 0.75rem;
    line-height: 1;
}

.action-btn .btn-text {
    font-size: 0.7rem;
}

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

.action-btn:active {
    transform: translateY(0);
}

tbody tr {
    transition: background 0.2s ease;
}

tbody tr:hover {
    background: var(--bg-tertiary);
}

tbody tr.disabled-row {
    opacity: 0.5;
    background: var(--bg-secondary);
}

tbody tr.disabled-row td {
    color: var(--text-secondary);
}

.btn-toggle {
    padding: 6px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 40px;
}

.btn-toggle.enabled {
    background: var(--accent-success);
    border-color: var(--accent-success);
    color: white;
}

.btn-toggle.disabled {
    background: var(--accent-danger);
    border-color: var(--accent-danger);
    color: white;
}

.btn-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Profit Forecast Section */
.profit-section {
    margin-top: 30px;
}

.section-description {
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-size: 0.95rem;
}

.profit-controls {
    margin-bottom: 30px;
}

.price-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.price-input-group label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
}

.input-with-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.input-with-buttons input {
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    transition: border-color 0.3s ease;
    width: 100%;
}

.input-with-buttons input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.quick-price-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-btn {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 70px;
}

.quick-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.quick-btn.active {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-color: var(--accent-primary);
    color: white;
}

.profit-results {
    margin-top: 30px;
    animation: fadeIn 0.5s ease;
}

.profit-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}

.profit-card {
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    padding: 25px;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    text-align: center;
    transition: transform 0.3s ease;
}

.profit-card.profit {
    border-color: var(--accent-success);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(5, 150, 105, 0.1));
}

.profit-card.loss {
    border-color: var(--accent-danger);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(220, 38, 38, 0.1));
}

.profit-card:hover {
    transform: scale(1.02);
}

.profit-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 10px;
    font-weight: 500;
}

.profit-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    transition: color 0.3s ease;
}

.profit-card.profit .profit-value {
    color: var(--accent-success);
}

.profit-card.loss .profit-value {
    color: var(--accent-danger);
}

.profit-roi {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.profit-card.profit .profit-roi {
    color: var(--accent-success);
}

.profit-card.loss .profit-roi {
    color: var(--accent-danger);
}

.profit-details {
    background: var(--bg-tertiary);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

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

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

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

.profit-breakdown {
    margin-top: 25px;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.profit-breakdown h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
    font-size: 1.2rem;
}

.breakdown-table {
    overflow-x: auto;
}

.breakdown-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
    gap: 15px;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
}

.breakdown-row:first-child {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    border-bottom: 2px solid var(--border-color);
}

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

.breakdown-cell {
    color: var(--text-primary);
    font-size: 0.9rem;
}

.breakdown-cell.profit-positive {
    color: var(--accent-success);
    font-weight: 600;
}

.breakdown-cell.profit-negative {
    color: var(--accent-danger);
    font-weight: 600;
}

.profit-chart-container {
    margin-top: 30px;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.profit-chart-container h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
    font-size: 1.2rem;
}

.profit-chart-container canvas {
    max-height: 400px;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

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

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

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

    .table-container {
        overflow-x: scroll;
    }

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

    .btn-secondary {
        width: 100%;
    }
    
    .profit-summary {
        grid-template-columns: 1fr;
    }
    
    .quick-price-buttons {
        justify-content: center;
    }
    
    .quick-btn {
        min-width: 60px;
        font-size: 0.75rem;
        padding: 6px 12px;
    }
    
    .breakdown-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .breakdown-row:first-child {
        display: none;
    }
    
    .breakdown-cell::before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: var(--text-secondary);
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.5s ease;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-card);
    margin: 2% auto;
    padding: 0;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    animation: slideDown 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

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

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

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    transform: rotate(90deg);
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

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

.modal-body .form-group:last-child {
    margin-bottom: 0;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: var(--bg-tertiary);
}

.modal-footer .btn {
    min-width: 100px;
}

/* Responsive Modal */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 15px;
    }
}

/* Savings Plan Section */
.savings-plan-section {
    margin-bottom: 30px;
}

.asset-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    align-items: flex-end;
    margin-bottom: 25px;
}

.asset-selector label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 8px;
    display: block;
}

.asset-dropdown {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.asset-dropdown:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.asset-dropdown option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.current-asset-badge {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 20px;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

.portfolio-badge {
    margin-left: auto;
}

/* Portfolio category styles are now in the collapsible section above */

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

/* Portfolio Summary Section */
.portfolio-summary-section {
    margin-bottom: 20px;
    overflow: visible;
}

.portfolio-summary-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 20px;
    flex-wrap: wrap;
    overflow: visible;
}

.portfolio-summary-section .section-header > div {
    flex: 1;
    min-width: 200px;
}

.portfolio-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure responsive grid on all screen sizes */
@media (min-width: 1400px) {
    .portfolio-summary-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

.summary-card {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 15px;
    text-align: center;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 110px;
    overflow: visible;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
    border-color: var(--accent-primary);
}

.summary-card.highlight {
    border-color: var(--accent-primary);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1));
}

.summary-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-bottom: 6px;
    font-weight: 500;
    line-height: 1.2;
    overflow: visible;
    position: relative;
}

.summary-value {
    color: var(--text-primary);
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.2;
    margin: 4px 0;
}

.summary-subvalue {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 3px;
    line-height: 1.2;
}

.summary-card .summary-description {
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.2;
    opacity: 0.8;
}

.portfolio-breakdown {
    margin-top: 25px;
    padding-top: 25px;
    border-top: 2px solid var(--border-color);
}

.portfolio-breakdown h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 1.3rem;
}

.breakdown-table {
    overflow-x: auto;
}

.breakdown-table table {
    width: 100%;
    border-collapse: collapse;
}

.breakdown-table th {
    text-align: left;
    padding: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 2px solid var(--border-color);
}

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

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

/* Portfolio History Section */
.portfolio-history-section {
    margin-bottom: 20px;
}

.portfolio-history-content {
    padding-top: 20px;
}

.timeframe-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.timeframe-btn {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 60px;
}

.timeframe-btn:hover {
    background: var(--bg-card);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.timeframe-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.portfolio-history-content .chart-container {
    background: var(--bg-tertiary);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    min-height: 300px;
    position: relative;
}

.portfolio-history-content .chart-container canvas {
    max-height: 400px;
}

.loading-indicator {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 1rem;
}

.loading-indicator span {
    display: inline-block;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Portfolio Overview */
.portfolio-overview {
    margin-top: 25px;
}

.portfolio-overview h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 1.3rem;
}

.portfolio-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.portfolio-category-content {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    margin-top: 10px;
}

.portfolio-card {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.portfolio-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px var(--shadow);
    border-color: var(--accent-primary);
}

.portfolio-card.active {
    border-color: var(--accent-primary);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1));
    box-shadow: 0 5px 15px rgba(59, 130, 246, 0.3);
}

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

.asset-icon {
    font-size: 1.8rem;
    margin-right: 10px;
}

.asset-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.active-badge {
    background: var(--accent-primary);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

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

.portfolio-stat {
    display: flex;
    flex-direction: column;
}

.portfolio-stat .stat-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 4px;
}

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

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

/* Base mobile styles (applies to all mobile devices) */

/* Header responsive fixes for all screen sizes */
@media (max-width: 1200px) {
    .header-title-row {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .header-title-row > div:first-child {
        flex: 1 1 100%;
        text-align: center;
    }
    
    .header-title-row > div:last-child {
        flex: 1 1 100%;
        justify-content: center;
        margin-top: 10px;
    }
    
    #userProfileIndicator {
        width: 100%;
        justify-content: center;
        margin-left: 0;
        flex-wrap: wrap;
    }
}

/* Tablet Landscape / Small Desktop (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
    body {
        padding: 15px;
    }
    
    .container {
        max-width: 100%;
        padding: 0;
    }
    
    header {
        padding: 20px 0;
        margin-bottom: 25px;
    }
    
    header h1 {
        font-size: 2.2rem;
    }
    
    .card {
        padding: 20px;
        border-radius: 12px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .card h2 {
        font-size: 1.5rem;
    }
    
    /* Portfolio Summary Grid - optimized for tablets */
    .portfolio-summary-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
        margin-bottom: 20px;
    }
    
    .summary-card {
        padding: 12px 10px;
        min-height: 105px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .summary-label {
        font-size: 0.75rem;
        margin-bottom: 5px;
    }
    
    .summary-value {
        font-size: 1.3rem;
    }
    
    .summary-description {
        font-size: 0.65rem;
        margin-top: 3px;
    }
    
    /* Chart adjustments for tablets */
    .chart-container {
        height: 320px;
        padding: 12px;
    }
    
    .portfolio-value-chart-container .chart-container {
        height: 300px;
    }
    
    /* Chart stats - better layout on tablets */
    #chartStats {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    #chartStats > div {
        flex: 1 1 calc(50% - 5px);
        min-width: 140px;
    }
    
    /* Main workspace */
    .main-workspace {
        gap: 15px;
        grid-template-columns: 1fr;
    }
    
    /* Section headers */
    .section-header {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .section-header h2 {
        font-size: 1.4rem;
    }
    
    /* Forms - better on tablets */
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    /* Tables - better fit */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 100%;
        font-size: 0.9rem;
    }
    
    /* Buttons */
    .btn {
        padding: 10px 16px;
        font-size: 0.95rem;
    }
    
    /* Portfolio breakdown */
    .portfolio-breakdown {
        margin-top: 20px;
    }
    
    /* Stats grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
}

/* Tablet Portrait / Mobile Landscape (481px - 768px) - Additional base styles */
@media (max-width: 1024px) {
    body {
        padding: 15px;
    }
    
    .container {
        max-width: 100%;
        padding: 0;
    }
    
    .card {
        padding: 20px;
        border-radius: 12px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .card h2 {
        font-size: 1.5rem;
    }
    
    /* Ensure no horizontal overflow */
    * {
        max-width: 100%;
    }
    
    img, canvas, video {
        max-width: 100%;
        height: auto;
    }
}

/* Tablet and smaller desktop */
@media (max-width: 768px) {
    /* Header adjustments */
    header {
        padding: 20px 0;
        margin-bottom: 30px;
    }
    
    header h1 {
        font-size: 2rem;
        line-height: 1.2;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    /* Header row - ensure buttons stay on right */
    header > div > div > div {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    /* User profile indicator - responsive on mobile/tablet */
    #userProfileIndicator {
        margin-left: auto;
        margin-top: 0;
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        gap: 6px;
        order: 2;
        max-width: 100%;
        justify-content: flex-end;
    }
    
    #userProfileIndicator #storageModeIndicator {
        display: inline-block;
        font-size: 0.65rem;
        padding: 4px 6px;
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Keep header buttons small and inline on mobile */
    #userProfileIndicator .btn {
        min-height: 32px;
        padding: 6px 10px !important;
        font-size: 0.7rem !important;
        width: auto !important;
        margin-bottom: 0 !important;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    #userInfo {
        flex-direction: row;
        gap: 6px !important;
        flex-wrap: wrap;
        max-width: 100%;
        min-width: 0;
    }
    
    #userInfo span {
        text-align: left;
        flex-shrink: 1;
        min-width: 0;
    }
    
    #userEmail {
        max-width: 100px !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    #userInfo .btn {
        flex-shrink: 0;
    }
    
    /* Main workspace - single column */
    .main-workspace {
        grid-template-columns: 1fr !important;
        gap: 20px;
    }
    
    .workspace-left,
    .workspace-right {
        grid-column: 1 / -1;
    }
    
    /* Form improvements */
    .form-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .form-group label {
        font-size: 0.95rem;
        margin-bottom: 6px;
    }
    
    input[type="number"],
    input[type="text"],
    select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
        min-height: 44px; /* Touch target size */
    }
    
    /* Buttons - larger touch targets */
    .btn {
        min-height: 44px;
        padding: 12px 20px;
        font-size: 1rem;
        touch-action: manipulation; /* Prevents double-tap zoom */
    }
    
    /* Buttons - full width except header buttons */
    .btn-primary:not(#userProfileIndicator .btn),
    .btn-secondary:not(#userProfileIndicator .btn),
    .btn-danger:not(#userProfileIndicator .btn) {
        width: 100%;
        margin-bottom: 10px;
    }
    
    /* Section headers */
    .section-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .collapsible-header {
        padding: 15px;
    }
    
    .portfolio-category-header {
        padding: 10px 12px;
    }
    
    .category-toggle {
        font-size: 0.9rem;
    }
    
    .section-header h2 {
        font-size: 1.4rem;
        margin-bottom: 0;
    }
    
    /* Portfolio Summary Grid - responsive */
    .portfolio-summary-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 12px;
    }
    
    .summary-card {
        padding: 10px 12px;
        min-height: 100px;
    }
    
    .summary-label {
        font-size: 0.7rem;
    }
    
    .summary-value {
        font-size: 1.2rem;
    }
    
    .summary-description {
        font-size: 0.6rem;
    }
    
    /* Chart adjustments */
    .chart-container {
        height: 300px;
        padding: 10px;
    }
    
    .portfolio-value-chart-container .chart-container {
        height: 280px;
    }
    
    /* Stats grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    /* Charts */
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        height: 300px;
    }
    
    /* Tables - horizontal scroll with better styling */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -20px;
        padding: 0 20px;
    }
    
    table {
        min-width: 600px;
        font-size: 0.9rem;
    }
    
    table th,
    table td {
        padding: 12px 8px;
        white-space: nowrap;
    }
    
    /* Action buttons - stack vertically on tablets */
    .action-buttons-container {
        flex-direction: column;
        gap: 6px;
        align-items: stretch;
    }
    
    .action-btn {
        width: 100%;
        justify-content: center;
        font-size: 0.65rem !important;
        padding: 6px 10px !important;
    }
    
    /* Asset selector */
    .asset-selector {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .asset-dropdown {
        width: 100%;
    }
    
    /* Portfolio grid */
    .portfolio-category-content {
        grid-template-columns: 1fr;
    }
    
    /* Profit summary */
    .profit-summary {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Quick price buttons */
    .quick-price-buttons {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    
    .quick-btn {
        min-width: 70px;
        min-height: 40px;
        font-size: 0.8rem;
        padding: 8px 12px;
    }
    
    /* Breakdown rows - card layout on mobile */
    .breakdown-row {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 15px;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        margin-bottom: 10px;
    }
    
    .breakdown-row:first-child {
        display: none;
    }
    
    .breakdown-cell {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
    }
    
    .breakdown-cell::before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: var(--text-secondary);
    }
    
    /* Modals - full screen on mobile */
    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
        height: 100vh;
    }
    
    .modal-header {
        padding: 15px 20px;
    }
    
    .modal-header h3 {
        font-size: 1.3rem;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .modal-footer {
        padding: 15px 20px;
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin: 0;
    }
    
    /* Portfolio groups */
    .portfolio-groups-grid {
        grid-template-columns: 1fr;
    }
    
    .group-card {
        padding: 15px;
    }
    
    /* Workflow steps */
    .workflow-step {
        padding: 15px;
    }
    
    .step-title {
        font-size: 1.1rem;
    }
    
    /* Current asset badge */
    .current-asset-display {
        padding: 10px;
        font-size: 0.9rem;
    }
    
    /* Share modal checkboxes */
    .share-checkboxes {
        grid-template-columns: 1fr;
    }
    
    /* Social share buttons */
    .social-share-buttons {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .social-btn {
        padding: 12px;
        font-size: 0.9rem;
    }
}

/* Small mobile devices (phones) */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    header {
        padding: 15px 0;
        margin-bottom: 20px;
    }
    
    header h1 {
        font-size: 1.6rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    /* Portfolio Summary - single column on very small screens */
    .portfolio-summary-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .summary-card {
        padding: 12px;
        min-height: auto;
    }
    
    .summary-value {
        font-size: 1.1rem;
    }
    
    /* Chart - smaller on mobile */
    .chart-container {
        height: 250px;
        padding: 8px;
    }
    
    .portfolio-value-chart-container .chart-container {
        height: 230px;
    }
    
    /* Chart stats - stack vertically */
    #chartStats {
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }
    
    #chartStats > div {
        width: 100%;
        text-align: center;
    }
    
    /* Form improvements */
    .form-grid {
        gap: 12px;
    }
    
    input[type="number"],
    input[type="text"],
    select {
        font-size: 16px;
        padding: 10px;
    }
    
    /* Section headers - more compact */
    .section-header h2 {
        font-size: 1.2rem;
    }
    
    /* Buttons - full width */
    .btn {
        width: 100%;
        margin-bottom: 8px;
    }
    
    /* Tables - more compact */
    table {
        font-size: 0.8rem;
    }
    
    table th,
    table td {
        padding: 8px 4px;
    }
    
    /* Keep header buttons even smaller on very small screens */
    #userProfileIndicator {
        flex-wrap: wrap !important;
        gap: 4px !important;
        max-width: 100% !important;
        justify-content: center !important;
    }
    
    #userProfileIndicator .btn {
        min-height: 28px;
        padding: 5px 8px !important;
        font-size: 0.65rem !important;
        flex-shrink: 0;
    }
    
    #userProfileIndicator #storageModeIndicator {
        font-size: 0.6rem;
        padding: 3px 5px;
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    #userInfo {
        flex-wrap: wrap !important;
        gap: 4px !important;
        max-width: 100% !important;
        justify-content: center !important;
    }
    
    #userInfo span {
        font-size: 0.65rem;
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    #userEmail {
        max-width: 70px !important;
    }
    
    /* Action buttons on mobile - compact layout */
    .action-buttons-container {
        flex-direction: row;
        gap: 4px;
        flex-wrap: wrap;
    }
    
    .action-btn {
        font-size: 0.65rem !important;
        padding: 4px 6px !important;
        min-width: 50px;
    }
    
    .action-btn .btn-text {
        display: none; /* Hide text on small mobile, show only icons */
    }
    
    .action-btn .btn-icon {
        font-size: 0.85rem;
    }
    
    .card {
        padding: 15px;
        border-radius: 10px;
    }
    
    .card h2 {
        font-size: 1.3rem;
        margin-bottom: 15px;
    }
    
    /* Stats grid - single column on very small screens */
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-label {
        font-size: 0.85rem;
    }
    
    .stat-value {
        font-size: 1.3rem;
    }
    
    /* Charts - smaller height */
    .chart-container {
        height: 250px;
    }
    
    /* Tables - even more compact */
    table {
        font-size: 0.85rem;
        min-width: 500px;
    }
    
    table th,
    table td {
        padding: 10px 6px;
    }
    
    /* Action buttons on very small screens */
    .action-buttons-container {
        flex-direction: column;
        gap: 4px;
    }
    
    .action-btn {
        width: 100%;
        font-size: 0.65rem !important;
        padding: 5px 8px !important;
    }
    
    .action-btn .btn-text {
        display: inline; /* Show text again on very small screens for clarity */
    }
    
    /* Buttons - full width always */
    .btn {
        width: 100%;
        margin-bottom: 10px;
    }
    
    /* Form inputs */
    input[type="number"],
    input[type="text"],
    select {
        font-size: 16px;
        padding: 14px;
    }
    
    /* Modal adjustments */
    .modal-header {
        padding: 12px 15px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .modal-footer {
        padding: 12px 15px;
    }
    
    /* Quick buttons - smaller */
    .quick-btn {
        min-width: 60px;
        min-height: 36px;
        font-size: 0.75rem;
        padding: 6px 10px;
    }
    
    /* Social buttons - 2 columns */
    .social-share-buttons {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Portfolio badge */
    .portfolio-badge {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
    
    /* Reset button positioning */
    #resetAllBtn {
        width: 100%;
        margin-top: 15px;
    }
}

/* Very small devices (iPhone SE, etc.) */
@media (max-width: 320px) {
    header h1 {
        font-size: 1.4rem;
    }
    
    .card {
        padding: 12px;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    .chart-container {
        height: 200px;
    }
    
    table {
        font-size: 0.8rem;
        min-width: 450px;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    body {
        padding: 10px;
    }
    
    header {
        padding: 10px 0;
        margin-bottom: 15px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .modal-content {
        max-height: 95vh;
        height: auto;
    }
    
    .chart-container {
        height: 250px;
    }
    
    .portfolio-value-chart-container .chart-container {
        height: 220px;
    }
    
    .portfolio-summary-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 10px;
    }
    
    .summary-card {
        padding: 8px 10px;
        min-height: 90px;
    }
    
    .summary-value {
        font-size: 1.1rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .card:hover {
        transform: none;
        box-shadow: 0 10px 30px var(--shadow);
    }
    
    .stat-card:hover {
        transform: none;
    }
    
    /* Increase tap targets */
    button,
    .btn,
    a {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Better focus states for touch */
    button:focus,
    .btn:focus,
    input:focus,
    select:focus {
        outline: 2px solid var(--accent-primary);
        outline-offset: 2px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .card {
        border-width: 0.5px;
    }
}

/* Info Tooltip Styles */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: help;
    margin-left: 6px;
    vertical-align: middle;
    position: relative;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.info-icon:hover {
    background: var(--accent-secondary);
    transform: scale(1.1);
}

.info-icon-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    z-index: 1;
}

.info-tooltip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px var(--shadow-lg);
    white-space: normal;
    width: 280px;
    max-width: 90vw;
    font-size: 0.875rem;
    line-height: 1.5;
    z-index: 10000;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    margin-bottom: 8px;
    word-wrap: break-word;
}

.info-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--bg-card);
}

.info-icon-wrapper:hover .info-tooltip,
.info-icon:hover + .info-tooltip {
    visibility: visible !important;
    opacity: 1 !important;
    transform: translateX(-50%) translateY(0) !important;
    display: block !important;
}

.info-tooltip strong {
    color: var(--accent-primary);
    display: block;
    margin-bottom: 4px;
}

/* Tooltip positioning variants */
.info-icon-wrapper.tooltip-right:hover .info-tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.info-icon-wrapper.tooltip-right .info-tooltip {
    left: 100%;
    top: 50%;
    transform: translateY(-50%) translateX(8px);
    margin-left: 8px;
    margin-bottom: 0;
}

.info-icon-wrapper.tooltip-right .info-tooltip::after {
    top: 50%;
    left: 0;
    transform: translateY(-50%) translateX(-100%);
    border-top-color: transparent;
    border-right-color: var(--bg-card);
    border-left: none;
}

.info-icon-wrapper.tooltip-left:hover .info-tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.info-icon-wrapper.tooltip-left .info-tooltip {
    right: 100%;
    left: auto;
    top: 50%;
    transform: translateY(-50%) translateX(-8px);
    margin-right: 8px;
    margin-bottom: 0;
}

.info-icon-wrapper.tooltip-left .info-tooltip::after {
    top: 50%;
    right: 0;
    left: auto;
    transform: translateY(-50%) translateX(100%);
    border-top-color: transparent;
    border-left-color: var(--bg-card);
    border-right: none;
}

/* Mobile tooltip adjustments */
@media (max-width: 768px) {
    .info-tooltip {
        width: 250px;
        font-size: 0.8rem;
        padding: 10px 12px;
    }
    
    .info-icon {
        width: 16px;
        height: 16px;
        font-size: 0.7rem;
    }
}

/* ==================== COMPREHENSIVE RESPONSIVE FIXES ==================== */

/* Ensure all containers respect viewport width */
section, .card, .portfolio-summary-section, .portfolio-summary-content,
.portfolio-summary-grid, .portfolio-value-chart-container, .chart-container {
    max-width: 100%;
    box-sizing: border-box;
}

/* Tablet-specific optimizations (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    body {
        padding: 15px !important;
    }
    
    .container {
        max-width: 100% !important;
        padding: 0 15px !important;
    }
    
    .portfolio-summary-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 12px !important;
    }
    
    .summary-card {
        min-width: 0 !important;
        width: 100% !important;
    }
    
    .chart-container,
    .portfolio-value-chart-container .chart-container {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    #chartStats {
        flex-wrap: wrap !important;
        width: 100% !important;
    }
    
    #chartStats > div {
        flex: 1 1 calc(50% - 5px) !important;
        min-width: 140px !important;
    }
    
    .section-header {
        flex-wrap: wrap !important;
    }
    
    .section-header > div {
        min-width: 0 !important;
        flex: 1 1 100% !important;
    }
    
    table {
        width: 100% !important;
        display: block !important;
        overflow-x: auto !important;
    }
}

/* Prevent horizontal overflow on all screen sizes */
@media (max-width: 1024px) {
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }
    
    * {
        max-width: 100% !important;
    }
    
    img, canvas, video, svg {
        max-width: 100% !important;
        height: auto !important;
    }
    
    .portfolio-summary-grid {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .summary-card {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }
}

/* Print styles */
@media print {
    body {
        background: white;
        color: black;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .btn,
    button {
        display: none;
    }
}

/* FAQ Section Styles */
.faq-section {
    margin: 60px auto;
    padding: 40px 20px;
}

.faq-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.faq-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.faq-item:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
}

.faq-question {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    cursor: pointer;
    background: var(--bg-card);
    transition: background 0.3s ease;
    user-select: none;
}

.faq-question:hover {
    background: var(--bg-tertiary);
}

.faq-question h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
    font-weight: 600;
    flex: 1;
}

.faq-icon {
    font-size: 1rem;
    color: var(--accent-primary);
    transition: transform 0.3s ease;
    margin-left: 15px;
    flex-shrink: 0;
}

.faq-item.active .faq-icon {
    transform: rotate(180deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0 20px;
}

.faq-item.active .faq-answer {
    max-height: 2000px;
    padding: 0 20px 20px 20px;
}

.faq-answer p,
.faq-answer ul {
    margin: 0;
}

/* Responsive FAQ Styles */
@media (max-width: 768px) {
    .faq-section {
        padding: 30px 15px;
    }
    
    .faq-question {
        padding: 15px;
    }
    
    .faq-question h3 {
        font-size: 1.1rem;
    }
    
    .faq-item.active .faq-answer {
        padding: 0 15px 15px 15px;
    }
}

@media (max-width: 480px) {
    .faq-section {
        padding: 20px 10px;
    }
    
    .faq-question {
        padding: 12px;
    }
    
    .faq-question h3 {
        font-size: 1rem;
    }
    
    .faq-icon {
        font-size: 0.9rem;
        margin-left: 10px;
    }
}

/* Feature Card Hover Styles */
.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    border-color: var(--accent-primary);
}

.feature-card a {
    text-decoration: none;
    color: inherit;
}

