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

:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --card-bg: #ffffff;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

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

/* ── Header ── */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header h1 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.last-updated {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.back-link {
  font-size: 0.875rem;
  color: var(--accent);
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

/* ── Current conditions cards ── */

.current-conditions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  padding: 1rem;
}

@media (min-width: 640px) {
  .current-conditions {
    grid-template-columns: repeat(4, 1fr);
    padding: 1.25rem;
  }
}

@media (min-width: 1024px) {
  .current-conditions {
    grid-template-columns: repeat(7, 1fr);
  }
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.card-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

.card-value {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  letter-spacing: -0.02em;
}

.card-unit {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.card-minmax {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  min-height: 1rem;
}

/* ── Chart section ── */

.chart-section {
  padding: 0 1rem 1.5rem;
}

@media (min-width: 640px) {
  .chart-section {
    padding: 0 1.25rem 2rem;
  }
}

.period-controls {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.period-btn {
  padding: 0.375rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

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

.period-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.period-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.loading-bar {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
}

.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chart-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.625rem;
}

.chart-container {
  width: 100%;
  height: 260px;
}

@media (min-width: 768px) {
  .chart-container {
    height: 360px;
  }
}

.sensor-na {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0.5rem 0;
}

/* ── Admin page ── */

.admin-section {
  padding: 1.25rem;
  max-width: 960px;
}

.admin-section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.status-timestamp {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.status-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: 0.8rem;
  line-height: 1.8;
  color: var(--text);
  overflow-x: auto;
}

/* ── Wind card ── */

.card-wind .card-value {
  font-size: 1.75rem;
}

.wind-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  margin-top: 0.25rem;
}

.wind-arrow {
  width: 28px;
  height: 38px;
  color: var(--accent);
  flex-shrink: 0;
  transition: transform 0.6s ease;
  transform-origin: center center;
}

.admin-chart-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.75rem;
  padding: 1.25rem 1.25rem 0;
}

/* Override Dygraphs default font to match site */
.dygraph-legend {
  font-size: 0.75rem !important;
  background: rgba(255,255,255,0.9) !important;
  border: 1px solid var(--border) !important;
  border-radius: 6px !important;
  padding: 4px 8px !important;
}
