/* ====== Stat Cards ====== */
.stats-row {
    display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 22px;
    transition: opacity 0.3s ease;
}
.stat-card {
    background: rgba(24,24,27,0.8); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid #27272a; border-radius: 14px; padding: 18px 16px;
    position: relative; overflow: hidden; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 0 1px rgba(59,130,246,0.05), 0 4px 24px rgba(0,0,0,0.2);
}
.stat-card::before {
    content: ''; position: absolute; inset: 0; border-radius: 14px; padding: 1px;
    background: linear-gradient(135deg, transparent, transparent);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor; mask-composite: exclude; opacity: 0; transition: opacity 0.3s ease; pointer-events: none;
}
.stat-card:hover::before { opacity: 1; }
.stat-card.card-blue::before { background: linear-gradient(135deg, rgba(59,130,246,0.4), rgba(59,130,246,0.1), transparent); }
.stat-card.card-green::before { background: linear-gradient(135deg, rgba(34,197,94,0.4), rgba(34,197,94,0.1), transparent); }
.stat-card.card-orange::before { background: linear-gradient(135deg, rgba(245,158,11,0.4), rgba(245,158,11,0.1), transparent); }
.stat-card.card-red::before { background: linear-gradient(135deg, rgba(239,68,68,0.4), rgba(239,68,68,0.1), transparent); }
.stat-card.card-purple::before { background: linear-gradient(135deg, rgba(168,85,247,0.4), rgba(168,85,247,0.1), transparent); }
.stat-card:hover { border-color: #3f3f46; box-shadow: 0 0 0 1px rgba(59,130,246,0.1), 0 8px 32px rgba(0,0,0,0.3); transform: translateY(-2px); }
.stat-card-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; position: relative; z-index: 1; }
.stat-card-icon svg { width: 18px; height: 18px; }
.stat-card-icon.blue { background: rgba(59,130,246,0.12); color: #3b82f6; }
.stat-card-icon.green { background: rgba(34,197,94,0.12); color: #22c55e; }
.stat-card-icon.orange { background: rgba(245,158,11,0.12); color: #f59e0b; }
.stat-card-icon.red { background: rgba(239,68,68,0.12); color: #ef4444; }
.stat-card-icon.purple { background: rgba(168,85,247,0.12); color: #a855f7; }
.stat-card .label { font-size: 11px; text-transform: uppercase; color: #71717a; letter-spacing: 0.5px; font-weight: 600; margin-bottom: 4px; }
.stat-card .value { font-family: 'JetBrains Mono', monospace; font-size: 26px; font-weight: 600; color: #fafafa; line-height: 1.2; }
.stat-card .unit { font-family: 'Inter', sans-serif; font-size: 12px; color: #71717a; font-weight: 400; margin-left: 3px; }
.stat-card::after {
    content: ''; position: absolute; top: -20px; right: -20px; width: 80px; height: 80px;
    border-radius: 50%; opacity: 0.04; transition: opacity 0.2s; pointer-events: none;
}
.stat-card:hover::after { opacity: 0.08; }
.stat-card.card-blue::after { background: #3b82f6; }
.stat-card.card-green::after { background: #22c55e; }
.stat-card.card-orange::after { background: #f59e0b; }
.stat-card.card-red::after { background: #ef4444; }
.stat-card.card-purple::after { background: #a855f7; }

/* ====== Charts ====== */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.chart-card {
    background: #18181b; border: 1px solid #27272a; border-radius: 14px; padding: 20px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); position: relative;
}
.chart-card:hover { border-color: #3f3f46; box-shadow: 0 0 0 1px rgba(59,130,246,0.05), 0 4px 20px rgba(0,0,0,0.2); }
.chart-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.chart-card-header h3 {
    font-size: 13px; color: #71717a; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
    margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chart-card canvas { width: 100% !important; }

/* Chart gear & popover */
.chart-gear-btn {
    background: none; border: none; color: #52525b; cursor: pointer; padding: 4px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center; transition: all 0.15s; flex-shrink: 0; position: relative;
}
.chart-gear-btn:hover { background: #27272a; color: #a1a1aa; }
.chart-gear-btn.active { background: #27272a; color: #3b82f6; }
.chart-gear-btn svg { width: 16px; height: 16px; }

.chart-config-popover {
    display: none; position: absolute; top: 44px; right: 16px;
    background: #18181b; border: 1px solid #3f3f46; border-radius: 12px; padding: 8px 0;
    z-index: 80; min-width: 220px; box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    animation: popoverIn 0.15s cubic-bezier(0.4, 0, 0.2, 1); max-height: 300px; overflow-y: auto;
}
.chart-config-popover.show { display: block; }
@keyframes popoverIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.chart-config-popover .popover-title {
    padding: 6px 14px 8px; font-size: 11px; color: #52525b; text-transform: uppercase;
    letter-spacing: 0.5px; font-weight: 600; border-bottom: 1px solid #27272a; margin-bottom: 4px;
}
.chart-config-row { display: flex; align-items: center; gap: 8px; padding: 6px 14px; cursor: pointer; transition: background 0.1s; user-select: none; }
.chart-config-row:hover { background: rgba(59,130,246,0.05); }
.chart-config-row.disabled { opacity: 0.35; cursor: not-allowed; }
.chart-config-row.disabled:hover { background: transparent; }
.chart-config-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.chart-config-row input[type="checkbox"] { accent-color: #3b82f6; width: 14px; height: 14px; cursor: pointer; flex-shrink: 0; }
.chart-config-row.disabled input[type="checkbox"] { cursor: not-allowed; }
.chart-config-label { font-size: 12px; color: #e4e4e7; font-weight: 500; flex: 1; }
.chart-config-unit { font-size: 11px; color: #52525b; font-family: 'JetBrains Mono', monospace; }
.chart-config-max { padding: 6px 14px 8px; font-size: 10px; color: #52525b; text-align: center; border-top: 1px solid #27272a; margin-top: 4px; }

/* Chart header action buttons */
.chart-header-actions { display: flex; align-items: center; gap: 4px; }
.chart-action-btn { background: none; border: none; color: #52525b; cursor: pointer; padding: 4px; border-radius: 6px; transition: all 0.2s; display: flex; align-items: center; }
.chart-action-btn:hover { color: #a1a1aa; background: #27272a; }
.chart-action-btn svg { width: 16px; height: 16px; }

/* ====== Empty State ====== */
.empty-state { text-align: center; padding: 80px 20px; color: #71717a; }
.empty-state-icon {
    width: 64px; height: 64px; border-radius: 16px; background: #18181b; border: 1px solid #27272a;
    display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; position: relative;
}
.empty-state-icon svg { width: 28px; height: 28px; color: #3f3f46; }
.empty-state-icon::after {
    content: ''; position: absolute; inset: -4px; border-radius: 20px;
    border: 2px solid rgba(59,130,246,0.15); animation: emptyPulse 2.5s ease-in-out infinite;
}
@keyframes emptyPulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.08); }
}
.empty-state h3 { font-size: 16px; color: #a1a1aa; font-weight: 500; margin-bottom: 6px; }
.empty-state p { font-size: 13px; line-height: 1.6; }

/* ====== Compare Bar ====== */
.compare-bar { display: flex; align-items: center; justify-content: space-between; background: #18181b; border: 1px solid #3b82f6; border-radius: 10px; padding: 10px 16px; margin-bottom: 16px; }
.compare-bar-info { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.compare-label-a { color: #3b82f6; font-weight: 600; }
.compare-label-b { color: #f59e0b; font-weight: 600; }
.compare-vs { color: #52525b; font-size: 11px; text-transform: uppercase; }

/* ====== Anomaly Panel ====== */
.anomaly-panel { background: #18181b; border: 1px solid #27272a; border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; }
.anomaly-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.anomaly-header h3 { font-size: 13px; color: #a1a1aa; font-weight: 500; }
.anomaly-count { font-size: 12px; padding: 2px 10px; border-radius: 12px; font-weight: 500; }
.anomaly-count.has-anomalies { background: rgba(239,68,68,0.15); color: #ef4444; }
.anomaly-count.clean { background: rgba(34,197,94,0.15); color: #22c55e; }
.anomaly-list { display: flex; flex-wrap: wrap; gap: 8px; max-height: 120px; overflow-y: auto; }
.anomaly-item { display: flex; align-items: center; gap: 6px; background: #27272a; padding: 4px 10px; border-radius: 6px; font-size: 11px; color: #a1a1aa; cursor: pointer; transition: all 0.2s; }
.anomaly-item:hover { background: #3f3f46; color: #fafafa; }
.anomaly-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.anomaly-dot.temp_spike { background: #ef4444; }
.anomaly-dot.voltage_drop { background: #f59e0b; }
.anomaly-dot.high_current { background: #eab308; }
.anomaly-dot.fault_code { background: #f43f5e; }
.anomaly-dot.duty_saturation { background: #06b6d4; }
