:root {
  --accent:       #2563eb;
  --accent-dark:  #1e40af;
  --accent-light: #eff6ff;
  --bg:           #eaf0fb;
  --border:       #c5d5ec;
  --label:        #4f72a6;
  --text:         #1e293b;
  --text-muted:   #64748b;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, #152a4e 0%, #1a56bb 65%, #3b82f6 100%);
  color: #fff;
  padding: 15px 24px;
  display: flex;
  align-items: center;
  gap: 0;
  box-shadow: 0 2px 14px rgba(20, 50, 110, 0.3);
}

header h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

header .subtitle {
  font-size: 12px;
  opacity: 0.65;
  margin-left: 16px;
  padding-left: 16px;
  border-left: 1px solid rgba(255,255,255,0.3);
}

/* ── Filter bar ── */
#filter-bar {
  background: #fff;
  box-shadow: 0 2px 10px rgba(20, 50, 110, 0.07);
  padding: 12px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.filter-group label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--label);
}

.filter-group select {
  height: 34px;
  padding: 0 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  min-width: 180px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.filter-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13);
}

.filter-group select:disabled {
  background: #f8fafc;
  color: #94a3b8;
  cursor: not-allowed;
}

/* ── Multi-select dropdown ── */
.multi-select-wrapper {
  position: relative;
  min-width: 180px;
}

.multi-select-btn {
  width: 100%;
  height: 34px;
  padding: 0 28px 0 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.multi-select-btn::after {
  content: '▾';
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--label);
  pointer-events: none;
}

.multi-select-btn.has-selection {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent-dark);
  font-weight: 500;
}

.multi-select-panel {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  min-width: 260px;
  max-width: 340px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(20, 50, 110, 0.14);
  z-index: 1000;
  overflow: hidden;
}

.multi-select-panel.open {
  display: block;
}

.multi-select-search {
  padding: 8px;
  border-bottom: 1px solid #e8f0fb;
}

.multi-select-search input {
  width: 100%;
  height: 30px;
  padding: 0 10px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  font-size: 12px;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.multi-select-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13);
}

.multi-select-actions {
  padding: 5px 10px;
  border-bottom: 1px solid #e8f0fb;
  display: flex;
  gap: 8px;
}

.multi-select-actions button {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 0;
}

.multi-select-actions button:hover {
  text-decoration: underline;
}

.multi-select-list {
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 0;
}

.multi-select-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  cursor: pointer;
  user-select: none;
}

.multi-select-item:hover {
  background: var(--accent-light);
}

.multi-select-item input[type="checkbox"] {
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

.multi-select-item label {
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.multi-select-empty {
  padding: 12px;
  text-align: center;
  color: #94a3b8;
  font-size: 12px;
}

/* ── Main content ── */
#main {
  padding: 20px 24px;
  position: relative;
}

/* ── Chart ── */
#chart-container {
  background: #fff;
  border-radius: 12px;
  border: none;
  box-shadow: 0 4px 24px rgba(20, 50, 110, 0.09), 0 1px 4px rgba(20, 50, 110, 0.04);
  padding: 20px;
  min-height: 500px;
  position: relative;
}

#chart {
  width: 100%;
  min-height: 480px;
}

/* ── Loading overlay ── */
#loading {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.82);
  align-items: center;
  justify-content: center;
  z-index: 100;
  border-radius: 12px;
  font-size: 14px;
  color: var(--text-muted);
  gap: 10px;
}

#loading.active {
  display: flex;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #dde8f8;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Empty state ── */
#empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: #94a3b8;
  gap: 8px;
}

#empty-state.active {
  display: flex;
}

#empty-state .icon {
  font-size: 40px;
}

#empty-state p {
  font-size: 15px;
}

#empty-state small {
  font-size: 12px;
}

/* ── Live button ── */
.filter-group--action {
  justify-content: flex-end;
}

#live-btn {
  height: 34px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
}

#live-btn::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  flex-shrink: 0;
}

#live-btn.active {
  border-color: #e74c3c;
  background: #fff5f5;
  color: #e74c3c;
  font-weight: 500;
}

#live-btn.active::before {
  background: #e74c3c;
  animation: live-pulse 1.2s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

#live-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.live-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

#last-updated {
  font-size: 11px;
  color: #999;
  white-space: nowrap;
}

/* ── Error banner ── */
#error-banner {
  display: none;
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  color: #dc2626;
  font-size: 13px;
}

#error-banner.active {
  display: block;
}
