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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #73003A;
  color: #fccada;
  min-height: 100vh;
  padding: 20px;
}

h1 {
  text-align: center;
  margin-bottom: 30px;
  font-weight: 300;
  font-size: 2rem;
  color: #F3B3FF;
}

h2 {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 15px;
  color: #F3B3FF;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.dashboard {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 900px;
  margin: 0 auto;
}

.panel {
  background: rgba(60, 21, 78, 0.4);
  border: 1px solid rgba(243, 179, 255, 0.2);
  border-radius: 12px;
  padding: 20px;
  backdrop-filter: blur(10px);
}

/* Live Reading: 3-column axes grid */
.axes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.axis-card {
  background: rgba(115, 0, 58, 0.4);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.axis-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #CED1B6;
  margin-bottom: 8px;
}

.axis-number {
  font-size: 2.2rem;
  font-weight: 300;
  color: #F3B3FF;
  line-height: 1;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.axis-unit {
  font-size: 0.7rem;
  color: #CED1B6;
  margin-bottom: 12px;
}

/* Axis bar: centered, extends left for negative / right for positive */
.bar-track {
  position: relative;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.bar-center {
  position: absolute;
  left: 50%;
  top: 0;
  width: 1px;
  height: 100%;
  background: rgba(255, 255, 255, 0.25);
}

.bar-fill {
  position: absolute;
  top: 0;
  height: 100%;
  background: #F3B3FF;
  border-radius: 3px;
  transition: width 0.4s ease, left 0.4s ease, right 0.4s ease;
  width: 0%;
}

/* Magnitude */
.magnitude {
  text-align: center;
  font-size: 1rem;
  color: #CED1B6;
  font-variant-numeric: tabular-nums;
}

/* History panel */
#raw-data {
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  overflow-y: auto;
  max-height: 280px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#raw-data .data-entry {
  padding: 6px 10px;
  background: rgba(115, 0, 58, 0.5);
  border-radius: 6px;
  border-left: 3px solid #F3B3FF;
}

#raw-data .data-entry.old {
  border-left-color: #A63382;
  opacity: 0.7;
}

#raw-data .timestamp {
  font-size: 0.65rem;
  color: #CED1B6;
  margin-bottom: 2px;
}

#raw-data .values {
  color: #F3B3FF;
}

#raw-data .values span {
  margin-right: 12px;
}

/* PIR panel */
.pir-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.pir-card {
  background: rgba(115, 0, 58, 0.4);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.pir-status {
  font-size: 2rem;
  font-weight: 300;
  line-height: 1;
  margin-top: 8px;
}

.motion-yes {
  color: #ffb3c6;
}

.motion-no {
  color: #CED1B6;
}

/* Network panel */
.network-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.network-label {
  font-size: 2rem;
  font-weight: 300;
  line-height: 1;
  margin-top: 8px;
}

.network-home {
  color: #4ADE80;
}

.network-sandbox {
  color: #FBBF24;
}

/* Chart panel */
.chart-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.chart-legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.time-range {
  display: flex;
  gap: 4px;
}

.range-btn {
  background: rgba(115, 0, 58, 0.4);
  border: 1px solid rgba(243, 179, 255, 0.3);
  border-radius: 6px;
  color: #CED1B6;
  padding: 4px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.range-btn.active {
  background: rgba(243, 179, 255, 0.2);
  border-color: #F3B3FF;
  color: #F3B3FF;
}

.legend-btn {
  background: rgba(115, 0, 58, 0.4);
  border: 2px solid var(--color);
  border-radius: 6px;
  color: var(--color);
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, background 0.2s;
}

.legend-btn.active {
  background: rgba(115, 0, 58, 0.8);
}

.legend-btn:not(.active) {
  opacity: 0.3;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 280px;
}

#chart-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-tooltip {
  display: none;
  position: absolute;
  background: rgba(40, 0, 20, 0.95);
  border: 1px solid rgba(243, 179, 255, 0.4);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.75rem;
  color: #F3B3FF;
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
  font-family: 'Monaco', 'Menlo', monospace;
  line-height: 1.6;
}

@media (max-width: 600px) {
  body {
    padding: 15px;
  }

  h1 {
    font-size: 1.5rem;
    margin-bottom: 20px;
  }

  .panel {
    padding: 15px;
  }

  .axis-number {
    font-size: 1.6rem;
  }
}
