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

:root {
    --bg-primary: #1e1e1e;
    --bg-secondary: #2c2c2c;
    --bg-tertiary: #3a3a3a;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent-red: #ff4d4d;
    --accent-red-dark: #cc3333;
    --accent-green: #4caf50;
    --accent-blue: #2196f3;
    --border-color: #404040;
}

[data-theme="light"] {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8e8e8;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --accent-red: #e53935;
    --accent-red-dark: #c62828;
    --accent-green: #43a047;
    --accent-blue: #1e88e5;
    --border-color: #d0d0d0;
}

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

header {
    background-color: var(--bg-secondary);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.3s, border-color 0.3s;
}

.title-icon {
    width: 32px;
    height: 32px;
    vertical-align: middle;
    margin-right: 8px;
}

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

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

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

.theme-toggle {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
}

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

[data-theme="dark"] .icon-sun {
    display: block;
}

[data-theme="dark"] .icon-moon {
    display: none;
}

[data-theme="light"] .icon-sun {
    display: none;
}

[data-theme="light"] .icon-moon {
    display: block;
}

.lang-selector {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    height: 38px;
}

.lang-selector:hover {
    border-color: var(--accent-blue);
}

.lang-selector:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.last-updated {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--bg-tertiary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

.update-label {
    color: var(--text-secondary);
}

.update-time {
    color: var(--accent-blue);
    font-weight: 600;
}

.refresh-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.refresh-btn:hover {
    color: var(--accent-blue);
    background-color: rgba(33, 150, 243, 0.1);
}

.update-btn-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

.ticker-tape-container {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 0;
    transition: background-color 0.3s, border-color 0.3s;
}

.dashboard {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem;
}

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

.barometer-card {
    background-color: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s, border-color 0.3s;
}

.card-header {
    padding: 1rem 1.25rem;
    background-color: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.3s, border-color 0.3s;
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

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

.card-body {
    padding: 0.75rem;
}

.stock-group {
    margin-bottom: 1rem;
}

.stock-group:last-child {
    margin-bottom: 0;
}

.group-title {
    font-size: 0.85rem;
    color: var(--accent-blue);
    padding: 0.5rem 0.5rem;
    margin-bottom: 0.25rem;
    border-left: 3px solid var(--accent-blue);
}

.stock-row {
    display: grid;
    grid-template-columns: 70px 80px 1fr 105px;
    gap: 0.75rem;
    align-items: center;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.stock-row:hover {
    background-color: var(--bg-tertiary);
}

.stock-row.has-error {
    opacity: 0.7;
}

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

.stock-ticker {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--accent-blue);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s, text-decoration 0.2s;
}

.stock-ticker:hover {
    color: var(--accent-green);
    text-decoration: underline;
}

.sector-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0.8;
}

.stock-price {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: right;
}

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

.drawdown-bar {
    flex: 0.95;
    height: 8px;
    background-color: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    transition: background-color 0.3s;
}

.drawdown-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-red-dark), var(--accent-red));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.column-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header-ticker {
    min-width: 60px;
}

.header-price {
    min-width: 70px;
}

.header-drawdown {
    flex: 1;
    text-align: center;
}

.header-days {
    min-width: 40px;
    text-align: center;
}

.header-pct {
    min-width: 50px;
    text-align: right;
}

.header-daily {
    min-width: 70px;
    text-align: center;
}

.days-since-high {
    min-width: 40px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background-color: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    margin: 0 6px;
}

.drawdown-value {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--accent-red);
    min-width: 50px;
    text-align: right;
}

.daily-change {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.daily-change.positive {
    background-color: rgba(76, 175, 80, 0.15);
    color: var(--accent-green);
}

.daily-change.negative {
    background-color: rgba(255, 77, 77, 0.15);
    color: var(--accent-red);
}

.daily-change.neutral {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
}

.change-arrow {
    font-size: 0.9rem;
}

.change-pct {
    font-size: 0.7rem;
    opacity: 0.85;
}

.error-indicator {
    color: #ff9800;
    font-size: 0.9rem;
    cursor: help;
}

.widgets-section {
    margin-top: 2rem;
}

.widget-row {
    margin-bottom: 1.5rem;
}

.widget-card {
    background-color: var(--bg-secondary);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s, border-color 0.3s;
}

.widget-card h3 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.widget-card.wide {
    width: 100%;
}

.commodities-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.widget-card.small {
    min-height: 280px;
}

.heatmap-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.widget-card.heatmap {
    min-height: 550px;
}

footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
    margin-top: 2rem;
    transition: border-color 0.3s;
}

.footer-links {
    margin-bottom: 0.75rem;
}

.footer-links a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    text-decoration: underline;
}

.footer-divider {
    margin: 0 0.5rem;
    color: var(--text-secondary);
    opacity: 0.5;
}

.copyright {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    opacity: 0.7;
}

.ad-placeholder {
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin: 1.5rem 0;
    text-align: center;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    opacity: 0.5;
}

@media (max-width: 1200px) {
    .commodities-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    header {
        padding: 1rem;
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .header-controls {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }
    
    .control-group {
        width: 100%;
        justify-content: space-between;
    }
    
    .lang-selector {
        flex: 1;
    }
    
    .last-updated {
        width: 100%;
        justify-content: space-between;
    }
    
    .dashboard {
        padding: 1rem;
    }
    
    .barometer-section {
        grid-template-columns: 1fr;
    }
    
    .stock-row {
        grid-template-columns: 60px 70px 1fr 90px;
        gap: 0.5rem;
        padding: 0.5rem;
    }
    
    .commodities-row,
    .heatmap-row {
        grid-template-columns: 1fr;
    }
    
    .widget-card.heatmap {
        min-height: 400px;
    }
}

@media (max-width: 480px) {
    .stock-row {
        grid-template-columns: 55px 1fr 75px;
    }
    
    .stock-price {
        display: none;
    }
    
    .drawdown-value {
        min-width: 45px;
        font-size: 0.75rem;
    }
    
    .days-since-high {
        min-width: 35px;
        font-size: 0.7rem;
        padding: 1px 4px;
    }
}

.tradingview-widget-container {
    width: 100%;
}

.guide-section {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--bg-secondary);
    border-radius: 12px;
}

.guide-section h2 {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    font-size: 1.4rem;
    text-align: center;
    border-bottom: 2px solid var(--accent-blue);
    padding-bottom: 0.75rem;
}

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

.guide-item {
    background: var(--bg-primary);
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid var(--accent-blue);
}

.guide-item h3 {
    color: var(--accent-blue);
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.guide-item p {
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    .guide-section {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .guide-content {
        grid-template-columns: 1fr;
    }
}

.fab-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--accent-blue);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.fab-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.fab-button:active {
    transform: scale(0.95);
}

.feedback-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1001;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.feedback-modal-overlay.active {
    display: flex;
}

.feedback-modal {
    background-color: var(--bg-secondary);
    border-radius: 12px;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
}

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

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

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

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

#feedbackForm {
    padding: 1.25rem;
}

#feedbackForm .form-group {
    margin-bottom: 1rem;
}

#feedbackForm label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

#feedbackForm select,
#feedbackForm input,
#feedbackForm textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

#feedbackForm select:focus,
#feedbackForm input:focus,
#feedbackForm textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
}

#feedbackForm textarea {
    resize: vertical;
    min-height: 100px;
}

#feedbackForm .submit-btn {
    width: 100%;
    padding: 0.875rem;
    background-color: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, opacity 0.2s;
}

#feedbackForm .submit-btn:hover {
    opacity: 0.9;
}

#feedbackForm .submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .fab-button {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
    }
    
    .fab-button svg {
        width: 20px;
        height: 20px;
    }
}
