:root {
    --bg-primary: #0f0f14;
    --bg-secondary: #1a1a24;
    --bg-tertiary: #252532;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #6b6b7b;
    --accent-blue: #4a9eff;
    --accent-purple: #a855f7;
    --accent-green: #22c55e;
    --accent-orange: #f97316;
    --accent-pink: #ec4899;
    --accent-cyan: #06b6d4;
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-flash: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    --gradient-pro: linear-gradient(135deg, #4a9eff 0%, #3b82f6 100%);
    --gradient-research: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
    --gradient-video: linear-gradient(135deg, #ec4899 0%, #d946ef 100%);
    --gradient-image: linear-gradient(135deg, #22c55e 0%, #10b981 100%);
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --radius: 16px;
    --radius-sm: 8px;
}

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

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

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

/* Header */
header {
    margin-bottom: 32px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-icon {
    font-size: 2.5rem;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-orange);
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background: var(--accent-green);
    animation: none;
}

.status-dot.error {
    background: #ef4444;
    animation: none;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Filters */
.filters {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 32px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

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

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

select,
input[type="date"] {
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

select:hover,
input[type="date"]:hover {
    border-color: var(--accent-blue);
}

select:focus,
input[type="date"]:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.custom-date {
    gap: 12px;
}

.custom-date span {
    color: var(--text-muted);
}

.btn-apply,
.btn-refresh {
    padding: 10px 20px;
    background: var(--gradient-1);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-apply:hover,
.btn-refresh:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-refresh {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.refresh-icon {
    font-size: 1.1rem;
    transition: transform 0.3s;
}

.btn-refresh:hover .refresh-icon {
    transform: rotate(180deg);
}

.filter-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: auto;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

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

.stat-card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-1);
}

.stat-card.flash::before {
    background: var(--gradient-flash);
}

.stat-card.pro::before {
    background: var(--gradient-pro);
}

.stat-card.deep-research::before {
    background: var(--gradient-research);
}

.stat-card.video::before {
    background: var(--gradient-video);
}

.stat-card.image::before {
    background: var(--gradient-image);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.stat-icon {
    font-size: 2.5rem;
    opacity: 0.9;
}

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

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card.flash .stat-value {
    background: var(--gradient-flash);
    -webkit-background-clip: text;
    background-clip: text;
}

.stat-card.pro .stat-value {
    background: var(--gradient-pro);
    -webkit-background-clip: text;
    background-clip: text;
}

.stat-card.deep-research .stat-value {
    background: var(--gradient-research);
    -webkit-background-clip: text;
    background-clip: text;
}

.stat-card.video .stat-value {
    background: var(--gradient-video);
    -webkit-background-clip: text;
    background-clip: text;
}

.stat-card.image .stat-value {
    background: var(--gradient-image);
    -webkit-background-clip: text;
    background-clip: text;
}

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

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

.chart-container h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.chart {
    min-height: 250px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 16px 0;
}

.chart-placeholder {
    color: var(--text-muted);
    text-align: center;
    width: 100%;
    padding: 60px;
}

/* Bar Chart */
.bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 40px;
}

.bar {
    width: 100%;
    max-width: 40px;
    background: var(--gradient-1);
    border-radius: 4px 4px 0 0;
    transition: height 0.5s ease;
    position: relative;
}

.bar:hover::after {
    content: attr(data-value);
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tertiary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
}

.bar-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 8px;
    text-align: center;
}

/* Mode Distribution */
.mode-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.mode-bar:last-child {
    border-bottom: none;
}

.mode-bar .mode-icon {
    font-size: 1.5rem;
}

.mode-bar .mode-info {
    flex: 1;
}

.mode-bar .mode-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.mode-bar .mode-progress {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.mode-bar .mode-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.mode-bar .mode-count {
    font-weight: 600;
    min-width: 60px;
    text-align: right;
}

/* Recent Activity */
.recent-activity {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border-color);
}

.recent-activity h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.activity-item:hover {
    background: rgba(74, 158, 255, 0.1);
}

.activity-icon {
    font-size: 1.5rem;
}

.activity-content {
    flex: 1;
}

.activity-mode {
    font-weight: 500;
    margin-bottom: 2px;
}

.activity-device {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--accent-blue);
    margin-left: 8px;
}

.activity-details {
    font-size: 0.85rem;
    color: var(--text-muted);
}

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

.activity-placeholder {
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

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

    h1 {
        font-size: 1.5rem;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .filters {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-refresh {
        margin-left: 0;
        justify-content: center;
    }

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

    .stat-card {
        padding: 16px;
    }

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

/* Section Title */
.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 24px 0 16px;
}

/* Export Button */
.btn-export {
    padding: 10px 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

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

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 400px;
    transform: translateY(-20px);
    transition: transform 0.3s;
}

.modal-overlay.show .modal {
    transform: translateY(0);
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

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

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

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 16px;
}

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

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

.form-group select,
.form-group input {
    width: 100%;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.btn-cancel {
    flex: 1;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-weight: 500;
    cursor: pointer;
}

.btn-primary {
    flex: 1;
    padding: 12px;
    background: var(--gradient-1);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
}

/* Stacked Bar Charts */
.bar-group.stacked {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.bar-stack {
    display: flex;
    flex-direction: column-reverse;
    width: 100%;
    max-width: 40px;
}

.bar-stack .bar {
    max-width: 100%;
    border-radius: 0;
}

.bar-stack .bar:first-child {
    border-radius: 0 0 4px 4px;
}

.bar-stack .bar:last-child {
    border-radius: 4px 4px 0 0;
}

.bar-stack .bar.flash {
    background: var(--gradient-flash);
}

.bar-stack .bar.pro {
    background: var(--gradient-pro);
}

.bar-value {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

/* Model Mode Chart */
.model-mode-group {
    margin-bottom: 20px;
}

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

.model-mode-header {
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.model-mode-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mini-bar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mini-bar-label {
    width: 120px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.mini-bar-track {
    flex: 1;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.mini-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.mini-bar-value {
    min-width: 40px;
    text-align: right;
    font-weight: 600;
    font-size: 0.9rem;
}

.mode-count small {
    color: var(--text-muted);
    font-weight: 400;
}