/* WindSolar Studio — layout & theme. Series colours = validated reference palette (light/dark steps). */
:root {
  color-scheme: light;
  --bg: #f4f5f7; --surface-1: #fcfcfb; --surface-2: #f0f1f3; --line: #e2e4e8; --grid: #eceef1;
  --text-primary: #0b0b0b; --text-secondary: #52514e; --text-muted: #77766f;
  --brand: #184f95; --brand-ink: #ffffff; --accent: #2a78d6; --focus: #2a78d6;
  --good: #008300; --warn: #b26b00; --bad: #c83232;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #111110; --surface-1: #1a1a19; --surface-2: #232322; --line: #31312f; --grid: #2a2a28;
    --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #9a998f;
    --brand: #3987e5; --accent: #3987e5; --focus: #86b6ef;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface-1: #1a1a19; --surface-2: #232322; --line: #31312f; --grid: #2a2a28;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #9a998f;
  --brand: #3987e5; --accent: #3987e5; --focus: #86b6ef;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--text-primary); font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
a { color: var(--accent); }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; gap: 16px; padding: 10px 20px;
  background: var(--surface-1); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--brand); }
.brand svg { width: 32px; height: 32px; }
.brand strong { display: block; color: var(--text-primary); font-size: 16px; letter-spacing: -.01em; }
.brand span { display: block; color: var(--text-muted); font-size: 12px; }
.site-chip { margin-left: auto; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--text-secondary);
  max-width: 46vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--surface-2); }
.top-links { display: flex; align-items: center; gap: 12px; }
.top-links a { text-decoration: none; font-weight: 500; }
.icon-btn { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-1); cursor: pointer; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; padding: 20px; max-width: 1560px; margin: 0 auto; }
@media (max-width: 1000px) { .layout { grid-template-columns: 1fr; } }
.sidebar { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 72px; align-self: start; max-height: calc(100vh - 92px); overflow: auto; padding-right: 4px; }
@media (max-width: 1000px) { .sidebar { position: static; max-height: none; } }
.panel { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; }
details.panel summary { cursor: pointer; list-style: none; }
details.panel summary h3 { display: inline; margin: 0; }
details.panel summary::after { content: '▾'; float: right; color: var(--text-muted); }
details.panel:not([open]) summary::after { content: '▸'; }
details.panel[open] summary { margin-bottom: 10px; }
label { display: block; font-size: 12px; color: var(--text-secondary); margin: 6px 0 0; }
input, select, textarea { width: 100%; margin-top: 3px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-1); }
textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.checks label, label.check { display: flex; align-items: center; gap: 8px; color: var(--text-primary); font-size: 13px; }
.checks input, label.check input { width: auto; margin: 0; }
.hint { font-size: 12px; color: var(--text-muted); margin: 6px 0 0; }
.meta { font-size: 12px; color: var(--text-secondary); margin-top: 8px; }
.map { height: 210px; border-radius: 10px; border: 1px solid var(--line); margin-top: 10px; z-index: 0; }
.search { position: relative; }
.dropdown { position: absolute; left: 0; right: 0; top: 100%; z-index: 1100; margin: 4px 0 0; padding: 4px; list-style: none;
  background: var(--surface-1); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.dropdown li { padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.dropdown li:hover, .dropdown li.sel { background: var(--surface-2); }
.dropdown small { color: var(--text-muted); }

/* ---------- buttons & chips ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--surface-2); border-color: var(--line); margin-top: 8px; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.sm { padding: 4px 10px; font-size: 12px; margin-left: auto; }
.btn.block { width: 100%; }
.btn.big { padding: 12px; font-size: 15px; }
.btn:disabled { opacity: .6; cursor: progress; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.chip { padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-1); cursor: pointer; font-size: 12px; }
.chip.active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.status { font-size: 12px; color: var(--text-secondary); min-height: 16px; margin-top: 8px; }
.status.error { color: var(--bad); } .status.ok { color: var(--good); }

/* ---------- tabs ---------- */
.main { min-width: 0; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { padding: 10px 14px; background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer; color: var(--text-secondary); font-weight: 600; white-space: nowrap; }
.tab.active { color: var(--text-primary); border-bottom-color: var(--brand); }
.tabpane { display: none; flex-direction: column; gap: 16px; }
.tabpane.active { display: flex; }

/* ---------- cards & KPIs ---------- */
.card { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.card h2 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.card .sub, p.sub { color: var(--text-muted); font-size: 12px; }
.card.intro p { color: var(--text-secondary); margin: 6px 0 10px; max-width: 980px; }
.chart { position: relative; height: 320px; }
.chart.sm { height: 250px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1200px) { .row2 { grid-template-columns: 1fr; } }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpis:empty { display: none; }
.kpi { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .l { font-size: 12px; color: var(--text-muted); }
.kpi .v { font-size: 24px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .r { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.kpi .v .u { font-size: 13px; font-weight: 500; color: var(--text-muted); margin-left: 3px; }
.controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; }
.controls label { margin: 0; min-width: 130px; }
.grid-controls { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
label.inline select { width: auto; margin: 0; }
label.file input { padding: 5px; }
.tablewrap { overflow: auto; max-height: 360px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { position: sticky; top: 0; background: var(--surface-1); color: var(--text-muted); font-weight: 600; font-size: 12px; }
td.best { font-weight: 700; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid var(--line); }
.tag.ch { color: var(--series-1); } .tag.dis { color: var(--series-2); } .tag.idle { color: var(--text-muted); }
.empty { text-align: center; padding: 40px 20px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface-1); }
.empty h2 { margin: 0 0 8px; font-size: 18px; } .empty p { color: var(--text-secondary); max-width: 640px; margin: 0 auto; }
.prose { max-width: 980px; } .prose h3 { margin: 18px 0 6px; font-size: 14px; } .prose li { margin: 4px 0; color: var(--text-secondary); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 2000; }
.toast { padding: 10px 14px; border-radius: 10px; background: var(--surface-1); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.15); max-width: 420px; }
.toast.error { border-left: 4px solid var(--bad); } .toast.warn { border-left: 4px solid var(--warn); } .toast.info { border-left: 4px solid var(--accent); }
.leaflet-container { background: var(--surface-2); font: inherit; }

/* ---------- status (fixed palette, always with icon + label) ---------- */
:root { --st-good: #0ca30c; --st-warning: #fab219; --st-serious: #ec835a; --st-critical: #d03b3b; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #1b1b1b; background: var(--surface-2); }
.badge.lv-good { background: var(--st-good); color: #fff; } .badge.lv-warning { background: var(--st-warning); }
.badge.lv-serious { background: var(--st-serious); } .badge.lv-critical { background: var(--st-critical); color: #fff; }
.tabbadge:empty { display: none; }
.tabbadge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; font-size: 11px; line-height: 18px; text-align: center; background: var(--surface-2); color: var(--text-primary); }
.tabbadge.lv-warning { background: var(--st-warning); color: #1b1b1b; } .tabbadge.lv-serious { background: var(--st-serious); color: #1b1b1b; } .tabbadge.lv-critical { background: var(--st-critical); color: #fff; }
.tlwrap { overflow-x: auto; }
.tl { display: grid; gap: 1px; min-width: 700px; align-items: stretch; }
.tl-h { font-size: 10px; color: var(--text-muted); white-space: nowrap; overflow: visible; height: 16px; }
.tl-name { font-size: 12px; color: var(--text-secondary); padding: 4px 6px 4px 0; white-space: nowrap; }
.tl-c { background: var(--surface-2); min-height: 22px; border-radius: 2px; }
.tl-c.lv-warning { background: var(--st-warning); } .tl-c.lv-serious { background: var(--st-serious); } .tl-c.lv-critical { background: var(--st-critical); }
.alerts { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow: auto; }
.alert { border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.alert.lv-warning { border-left-color: var(--st-warning); } .alert.lv-serious { border-left-color: var(--st-serious); } .alert.lv-critical { border-left-color: var(--st-critical); } .alert.lv-good { border-left-color: var(--st-good); }
.alert-h { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; } .alert-b { margin-top: 6px; color: var(--text-secondary); font-size: 13px; }
textarea#wnReport { font-size: 12px; line-height: 1.5; }
.sliders label { display: grid; grid-template-columns: 140px 40px 1fr; align-items: center; gap: 8px; color: var(--text-primary); font-size: 13px; }
.sliders input[type=range] { padding: 0; border: 0; accent-color: var(--brand); }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; } @media (max-width: 1200px) { .row3 { grid-template-columns: 1fr; } }
.row3 .card h2 { margin-bottom: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 8px; }
table.edit td { padding: 4px; } table.edit input, table.edit select { margin: 0; padding: 5px 6px; font-size: 12px; }

.chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 20px;
  color: var(--text-muted); font-size: 14px; border: 1px dashed var(--line); border-radius: 10px; background: var(--surface-1); }
.chart-empty[hidden] { display: none; }
.steps { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.step { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); font-size: 12px; color: var(--text-secondary); }
.step.done { border-color: var(--st-good); color: var(--text-primary); } .step.done::before { content: '✓'; color: var(--st-good); font-weight: 700; }
.step.todo::before { content: '○'; color: var(--text-muted); } .step.busy::before { content: '…'; color: var(--accent); font-weight: 700; }

.site-footer { text-align: center; font-size: 12px; color: var(--text-muted); padding: 8px 20px 24px; } .site-footer a { color: var(--text-secondary); }
