/* Inverter Review — reviewer dashboard styles.
   Tokens on :root; dark mode is a selected set of its own values, not an
   automatic inversion. No framework. Series colors are read from these
   variables by review.js so charts follow the colour scheme. */

:root {
  color-scheme: light;

  --bg: #fcfcfb;
  --card: #ffffff;
  --text: #0b0b0b;
  --text-muted: #52514e;
  --border: #e5e4df;
  --shadow: 0 1px 2px rgba(11, 11, 11, .05), 0 4px 16px rgba(11, 11, 11, .06);

  --accent: #2a78d6;
  --accent-hover: #2264b4;
  --danger: #b3402f;

  --seg-bg: #efeeea;
  --seg-active: #ffffff;
  --pre-bg: #f4f3ef;

  /* Chart series (light mode) */
  --series-power: #2a78d6;
  --series-irradiance: #eb6834;
  --series-energy: #1baf7a;
  --chart-grid: rgba(11, 11, 11, .08);
  --chart-text: #52514e;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg: #1a1a19;
    --card: #232322;
    --text: #f0efec;
    --text-muted: #c3c2b7;
    --border: #37362f;
    --shadow: none;

    --accent: #3987e5;
    --accent-hover: #4d97f0;
    --danger: #e0705f;

    --seg-bg: #1a1a19;
    --seg-active: #37362f;
    --pre-bg: #1a1a19;

    /* Chart series (dark mode) */
    --series-power: #3987e5;
    --series-irradiance: #d95926;
    --series-energy: #199e70;
    --chart-grid: rgba(240, 239, 236, .10);
    --chart-text: #c3c2b7;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

code, pre { font-family: 'JetBrains Mono', ui-monospace, monospace; }

h1, h2 { margin: 0; font-weight: 600; line-height: 1.3; }

p { margin: 0; }

button { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.error { color: var(--danger); font-size: 13.5px; margin-top: 10px; }

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.card.loading {
  opacity: .55;
  pointer-events: none;
  animation: card-pulse 1.4s ease-in-out infinite;
}

@keyframes card-pulse {
  50% { opacity: .35; }
}

/* ---------- Gate ---------- */

.gate {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.gate-card {
  width: 100%;
  max-width: 400px;
  padding: 32px;
}

.gate-card h1 {
  font-size: 22px;
  margin-bottom: 8px;
}

.gate-card .muted { margin-bottom: 20px; }

.gate-card label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}

.gate-card input {
  display: block;
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
}

.gate-card input:focus { border-color: var(--accent); }

.gate-card button[type="submit"] {
  width: 100%;
  margin-top: 4px;
  padding: 11px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.gate-card button[type="submit"]:hover:not(:disabled) { background: var(--accent-hover); }
.gate-card button[type="submit"]:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Buttons ---------- */

.btn {
  font: inherit;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn.secondary:hover { background: var(--seg-bg); }

.btn.ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn.ghost:hover { background: var(--seg-bg); color: var(--text); }

.btn.small { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }

/* ---------- App layout ---------- */

#app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 0;
}

.topbar h1 { font-size: 20px; }
.topbar .muted { font-size: 13px; }

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ---------- Controls ---------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.controls #range-label { margin: 0; flex-basis: 100%; }

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  background: var(--seg-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  max-width: 100%;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 500;
  font-size: 13.5px;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.segmented button:hover:not(:disabled):not(.active) { color: var(--text); }

.segmented button.active {
  background: var(--seg-active);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(11, 11, 11, .16);
}

.segmented button:disabled { opacity: .4; cursor: not-allowed; }

.segmented.small button { font-size: 12.5px; padding: 4px 12px; }

.custom-range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  flex-basis: 100%;
}

.custom-range label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.custom-range input[type="date"] {
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
}

.custom-range .btn { padding: 7px 14px; }

/* ---------- KPIs ---------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-label { font-size: 13px; color: var(--text-muted); }

.kpi-value {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.kpi-unit {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Charts ---------- */

.chart-card h2 {
  font-size: 15px;
  margin-bottom: 12px;
}

.chart-card h2 .unit { color: var(--text-muted); font-weight: 400; }

.chart-wrap {
  position: relative;
  height: 320px;
}

.chart-wrap.short { height: 200px; }

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

/* ---------- Weather + API grid ---------- */

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.grid-2 h2 { font-size: 15px; margin-bottom: 12px; }

.weather-body {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}

.weather-icon img { display: block; }

.weather-head strong { font-size: 16px; font-weight: 600; }

.weather-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  width: 100%;
}

.weather-cell { display: flex; flex-direction: column; gap: 2px; }

.weather-cell-label { font-size: 12px; color: var(--text-muted); }

.weather-cell-value {
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.warning {
  width: 100%;
  color: var(--danger);
  font-size: 13px;
}

.api pre {
  background: var(--pre-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0 12px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.55;
}

dl.endpoints {
  display: grid;
  grid-template-columns: minmax(0, max-content) 1fr;
  gap: 6px 16px;
  margin: 12px 0;
}

dl.endpoints dt code {
  font-size: 12px;
  background: var(--pre-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  white-space: nowrap;
}

dl.endpoints dd {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.curl {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 12px;
  overflow: hidden;
}

.curl-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px 6px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.curl pre {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------- Footer ---------- */

footer { padding: 4px 4px 24px; text-align: center; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .25);
}

.toast.error { background: var(--danger); color: #fff; }

.toast button {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 6px;
  color: inherit;
  padding: 3px 10px;
  cursor: pointer;
  white-space: nowrap;
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .chart-wrap { height: 260px; }
}

@media (max-width: 420px) {
  .kpis { grid-template-columns: 1fr; }
  .topbar-actions { width: 100%; }
  .topbar-actions .btn { flex: 1; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
