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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f7fa;
    color: #1a1a2e;
    line-height: 1.6;
}

.dashboard-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px;
}

/* Header */
.dashboard-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.2);
}

.dashboard-header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Filter Section */
.filter-section {
    background: white;
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.06);
    margin-bottom: 32px;
    display: flex;
    gap: 24px;
    align-items: center;
    flex-wrap: wrap;
    border: 1px solid #e2e8f0;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.filter-group label {
    font-weight: 500;
    color: #4a5568;
    font-size: 14px;
}

.filter-group input,
.filter-group select {
    padding: 10px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    background-color: #f8fafc;
    color: #1a1a2e;
    font-weight: 500;
}

.filter-group input:focus,
.filter-group select:focus {
    border-color: #667eea;
    background-color: white;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#apply-filter {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 14px;
    margin-left: auto;
}

#apply-filter:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* KPI Section */
.kpi-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.kpi-card {
    background: white;
    padding: 32px;
    border-radius: 16px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.06);
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid #e2e8f0;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}

.kpi-card h3 {
    font-size: 14px;
    color: #718096;
    margin-bottom: 16px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 2.75rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 12px;
    letter-spacing: -1px;
}

.kpi-change {
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 20px;
}

.kpi-change.positive {
    color: #059669;
    background-color: #d1fae5;
}

.kpi-change.negative {
    color: #dc2626;
    background-color: #fee2e2;
}

/* Chart Section */
.chart-section {
    margin-bottom: 32px;
}

.chart-container {
    background: white;
    padding: 32px;
    border-radius: 16px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.06);
    border: 1px solid #e2e8f0;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    flex-wrap: wrap;
    gap: 24px;
}

.chart-header h2 {
    color: #1a1a2e;
    font-weight: 600;
    font-size: 1.5rem;
    letter-spacing: -0.5px;
}

.chart-wrapper {
    position: relative;
    padding-top: 40px;
}

#salesChart {
    max-height: 500px;
}

/* New Legend Style */
.chart-legend {
    display: flex;
    gap: 32px;
    align-items: center;
    flex-wrap: wrap;
}

.legend-group {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background-color: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.legend-title {
    font-weight: 600;
    color: #4a5568;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 4px;
    padding-right: 12px;
    border-right: 2px solid #e2e8f0;
}

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

.legend-item span:not(.legend-color):not(.legend-line):not(.event-icon) {
    font-size: 13px;
    color: #1a1a2e;
    font-weight: 500;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex-shrink: 0;
}

.legend-color.amazon {
    background-color: #ff9f40;
}

.legend-color.rakuten {
    background-color: #ff5252;
}

.legend-color.qoo10 {
    background-color: #448aff;
}

.legend-line {
    width: 20px;
    height: 3px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-line.mall-ads {
    background-color: #4caf50;
}

.legend-line.x-ads {
    background-color: #212121;
}

.legend-line.tiktok-ads {
    background-color: #e91e63;
}

.event-icon {
    font-size: 16px;
}

/* Event Markers */
.event-marker {
    position: absolute;
    top: 0;
    width: 2px;
    height: 100%;
    background-color: rgba(156, 39, 176, 0.3);
    pointer-events: none;
}

.event-label {
    position: absolute;
    top: -30px;
    background: #9c27b0;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    transform: translateX(-50%);
    box-shadow: 0 2px 8px rgba(156, 39, 176, 0.3);
}

.event-label::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #9c27b0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .dashboard-container {
        padding: 16px;
    }
    
    .dashboard-header h1 {
        font-size: 1.75rem;
    }
    
    .filter-section {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        justify-content: space-between;
    }
    
    #apply-filter {
        width: 100%;
        margin-left: 0;
        margin-top: 8px;
    }
    
    .kpi-section {
        grid-template-columns: 1fr;
    }
    
    .chart-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .chart-legend {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .legend-group {
        justify-content: flex-start;
    }
}

/* Enhanced Shadow and Depth */
.dashboard-container > * {
    animation: fadeInUp 0.6s ease-out;
}

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

/* Notification Toast */
.notification {
    position: fixed;
    top: 24px;
    right: 24px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
    font-weight: 500;
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

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

/* Smooth Transitions */
* {
    transition: background-color 0.3s ease, border-color 0.3s ease;
}