/* Siempre modo oscuro, sin importar el tema del sistema/navegador del visitante */
:root {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --page: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #e66767;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

header.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
}

header.top h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

header.top a {
  color: var(--text-secondary);
  font-size: 14px;
  text-decoration: none;
}
header.top a:hover { color: var(--text-primary); }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.hero-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.hero-value {
  font-size: 48px;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: proportional-nums;
}

.hero-value .unit {
  font-size: 22px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-left: 4px;
}

.hero-meta {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.hero-live .live-frame {
  margin-top: 8px;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
}

.filters {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.filters button {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
.filters button:hover { background: var(--gridline); }
.filters button.active {
  background: var(--series-1);
  border-color: var(--series-1);
  color: white;
}

.chart-title {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .grid { stroke: var(--gridline); stroke-width: 1; }
svg.chart .baseline { stroke: var(--baseline); stroke-width: 1; }
svg.chart .axis-label { fill: var(--text-muted); font-size: 11px; }
svg.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .area { fill: var(--series-1); opacity: 0.10; }
svg.chart .crosshair { stroke: var(--text-muted); stroke-width: 1; opacity: 0; }
svg.chart .dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; opacity: 0; }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  opacity: 0;
  transition: opacity 0.1s;
  white-space: nowrap;
}
.tooltip .value { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.tooltip .time { color: var(--text-secondary); }

.empty-state {
  color: var(--text-muted);
  font-size: 14px;
  padding: 32px 0;
  text-align: center;
}

/* --- Admin --- */

form.admin-form { display: flex; flex-direction: column; gap: 14px; max-width: 360px; }
form.admin-form label { font-size: 13px; color: var(--text-secondary); display: flex; flex-direction: column; gap: 4px; }
form.admin-form input {
  font: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
}
form.admin-form button, a.button {
  font: inherit;
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  background: var(--series-1);
  color: white;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-dot.ok { background: var(--good); }
.status-dot.bad { background: var(--critical); }
.status-dot.stale { background: var(--warning); }

.value-stale { color: var(--text-muted); }

.error-msg { color: var(--critical); font-size: 13px; }

.nav-row { display: flex; gap: 8px; margin-bottom: 20px; }

.live-frame { width: 100%; border-radius: 8px; border: 1px solid var(--border); background: black; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.stats-grid .stat-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 2px; }
.stats-grid .stat-value { font-size: 20px; font-weight: 600; font-variant-numeric: proportional-nums; }

.conditions-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-top: 8px;
}
.conditions-grid .stat-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 2px; }
.conditions-grid .stat-value { font-size: 18px; font-weight: 600; font-variant-numeric: proportional-nums; }
#cond-val-seeing, #cond-val-sqm { font-size: 22px; }
@media (max-width: 860px) {
  .conditions-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 520px) {
  .conditions-grid { grid-template-columns: repeat(2, 1fr); }
}

.aag-events { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.aag-event { display: flex; gap: 12px; align-items: baseline; font-size: 14px; }
.aag-event .time { color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.aag-event .desc { color: var(--text-primary); }
.aag-event.to-unsafe .desc { color: var(--serious); }
.aag-event.to-safe .desc { color: var(--good); }

/* prevision (experimental) */
.fc-badge { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: 11px;
  font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--warning);
  border: 1px solid var(--warning); vertical-align: middle; }
.fc-note { margin: 4px 0 14px; font-size: 13px; color: var(--text-secondary); }
.fc-nights { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.fc-night { background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.fc-verdict { font-size: 18px; font-weight: 600; margin: 2px 0 6px; display: flex; align-items: center; gap: 6px; }
.fc-line { font-size: 13px; color: var(--text-secondary); }
.fc-line.muted { color: var(--text-muted); }
.fc-warn { color: var(--serious); margin-top: 4px; }
.fc-strip { width: 100%; height: 110px; display: block; }
.fc-legend { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
