/* ── CSS Custom Properties ──────────────────────────────────────────────── */
:root {
  --bg-primary:    #0f172a;
  --bg-card:       #1e293b;
  --bg-hover:      #334155;
  --bg-toolbar:    #172033;
  --text-primary:  #f1f5f9;
  --text-muted:    #94a3b8;
  --accent-red:    #ef4444;
  --accent-blue:   #3b82f6;
  --accent-green:  #22c55e;
  --accent-yellow: #eab308;
  --border:        #334155;
  --radius:        10px;
}

/* ── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

/* ── Header ─────────────────────────────────────────────────────────────── */
header {
  background: #0b1120;
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.icon { font-size: 1.4rem; }

h1 {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.header-time {
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ── Tab Nav ─────────────────────────────────────────────────────────────── */
.tab-nav {
  background: #0b1120;
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  overflow-x: auto;
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 0.25rem;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.75rem 1.1rem;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-blue);
}

/* ── Main / Tab Content ─────────────────────────────────────────────────── */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  border-top: 3px solid var(--border);
  position: relative;
}

.card--red   { border-top-color: var(--accent-red); }
.card--blue  { border-top-color: var(--accent-blue); }
.card--green { border-top-color: var(--accent-green); }

.card-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.4rem; }
.card-value { font-size: 2.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }

.card-value-temp {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.trend-arrow {
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1;
  transition: color 0.3s;
}
.trend-arrow.up     { color: var(--accent-red); }
.trend-arrow.down   { color: var(--accent-blue); }
.trend-arrow.steady { color: var(--text-muted); }
.card-value-unit { font-size: 1.1rem; color: var(--text-muted); align-self: flex-end; padding-bottom: 0.15rem; }
.card-value-row { display: flex; align-items: baseline; gap: 0.4rem; font-size: 1.8rem; font-weight: 700; }
.sep { color: var(--text-muted); font-weight: 300; }

/* ── Accent colors ───────────────────────────────────────────────────────── */
.accent-red   { color: var(--accent-red); }
.accent-blue  { color: var(--accent-blue); }
.accent-green { color: var(--accent-green); }

/* ── Last update ─────────────────────────────────────────────────────────── */
.last-update {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

/* ── Stats bar ───────────────────────────────────────────────────────────── */
.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  min-width: 140px;
  flex: 1;
}

.stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 1.15rem; font-weight: 600; margin-top: 0.1rem; }
.stat-sub   { font-size: 0.75rem; color: var(--text-muted); }

/* ── Charts ──────────────────────────────────────────────────────────────── */
.chart-section { margin-bottom: 2rem; }

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

.chart-wrap {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem;
  height: 280px;
  position: relative;
}

.chart-wrap--half { height: 200px; }
.chart-wrap--historical { height: 320px; }

.chart-wrap canvas { width: 100% !important; height: 100% !important; }

.zoom-reset-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  background: #1e3a5f;
  color: #94a3b8;
  border: 1px solid #334155;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s;
  z-index: 10;
}
.zoom-reset-btn:hover { opacity: 1; color: #f1f5f9; }

/* ── Toolbar ─────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.toolbar label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.toolbar input[type="date"],
.toolbar select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.toolbar select option { background: var(--bg-card); }

/* ── Table ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1.1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: #172033;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-hover); }

.loading { color: var(--text-muted); font-style: italic; }

/* ── Clickable stat item ─────────────────────────────────────────────────── */
.stat-item--link {
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
  padding: 0.35rem 0.5rem;
  margin: -0.35rem -0.5rem;
}
.stat-item--link:hover { background: var(--bg-hover); }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 460px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text-primary); }

.modal-body {
  overflow-y: auto;
  padding: 0;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  main { padding: 1rem; }
  .cards-row { grid-template-columns: 1fr; }
  .card-value { font-size: 2rem; }
  .stats-bar { flex-direction: column; gap: 0.75rem; }
}
