:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page-plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-indoor: #2a78d6;
  --series-outdoor: #eb6834;
  --status-good: #0ca30c;
  --status-critical: #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page-plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-indoor: #3987e5;
    --series-outdoor: #d95926;
    --status-good: #0ca30c;
    --status-critical: #e66767;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --page-plane: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-indoor: #3987e5;
  --series-outdoor: #d95926;
  --status-good: #0ca30c;
  --status-critical: #e66767;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
}

.page {
  max-width: 1600px;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 48px);
}

.header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: clamp(20px, 3vw, 36px);
}

.header h1 {
  font-size: clamp(1.5rem, 3.2vw, 2.6rem);
  font-weight: 600;
  margin: 0;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: clamp(0.8rem, 1vw, 1.05rem);
  color: var(--text-secondary);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2em;
  height: 2em;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: inherit;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.theme-toggle:hover {
  background: var(--page-plane);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--status-critical);
  flex-shrink: 0;
  transition: background 0.3s ease;
}

.status-dot.live {
  background: var(--status-good);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--status-good) 20%, transparent);
}

body {
  overflow-x: hidden;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: clamp(12px, 1.6vw, 24px);
  margin-bottom: clamp(20px, 3vw, 36px);
}

.stat-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: clamp(16px, 2vw, 28px);
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(0.9rem, 1.1vw, 1.2rem);
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.stat-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stat-value {
  font-size: clamp(2.6rem, 7vw, 5.5rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-value .unit {
  font-size: 0.5em;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 0.15em;
}

.stat-minmax {
  margin-top: 10px;
  font-size: clamp(0.9rem, 1.1vw, 1.25rem);
  color: var(--text-secondary);
}

.stat-minmax b {
  color: var(--text-primary);
  font-weight: 600;
}

.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
  gap: clamp(12px, 1.6vw, 24px);
}

.chart-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: clamp(16px, 2vw, 28px);
  position: relative;
}

.chart-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(1rem, 1.3vw, 1.4rem);
  font-weight: 600;
  margin-bottom: clamp(8px, 1.2vw, 16px);
}

.chart-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chart-svg-wrap {
  position: relative;
}

svg.chart {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.axis-label {
  fill: var(--text-muted);
  font-size: 13px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.gridline {
  stroke: var(--gridline);
  stroke-width: 1;
}

.crosshair-line {
  stroke: var(--axis);
  stroke-width: 1;
  pointer-events: none;
}

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
  color: var(--text-primary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.1s ease;
  transform: translate(-50%, -110%);
}

.tooltip.visible {
  opacity: 1;
}

.tooltip .tt-value {
  font-weight: 600;
}

.empty-state {
  color: var(--text-muted);
  font-size: clamp(0.95rem, 1.1vw, 1.2rem);
  padding: 24px 0;
  text-align: center;
}

.footer {
  margin-top: clamp(20px, 3vw, 36px);
  color: var(--text-muted);
  font-size: clamp(0.8rem, 0.95vw, 1rem);
  text-align: center;
}

/* TV / very large screens: cap line-length growth, lean on the fluid clamps above */
@media (min-width: 1400px) {
  .page {
    padding-top: 40px;
    padding-bottom: 40px;
  }
}
