:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e3e1dc;
  --grid: #e9e7e2;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #75746f;
  --accent: #2a78d6;
  --accent-wash: #e3eefb;
  --good: #0a7a0a;
  --bad: #c43535;
  /* paliwa: kolejność warstw od dołu, sprawdzona skryptem pod kątem daltonizmu */
  --c-brunatny: #a8652a;
  --c-kamienny: #4a4e8f;
  --c-gaz: #eb6834;
  --c-pozostale: #b04fb0;
  --c-biomasa: #008300;
  --c-woda: #2a78d6;
  --c-wiatr: #1baf7a;
  --c-slonce: #eda100;
  --c-oze: #008300;
  --c-cena: #2a78d6;
  --c-linia: #0b0b0b;
  --c-prognoza: #75746f;
  --c-import: #2a78d6;
  --c-eksport: #e34948;
  --mid: #e9e7e2;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #2f2f2c;
    --grid: #2a2a28;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #93928a;
    --accent: #3987e5;
    --accent-wash: #1c2a3d;
    --good: #2fbf2f;
    --bad: #e66767;
    --c-brunatny: #b8743a;
    --c-kamienny: #7a7fd0;
    --c-gaz: #d95926;
    --c-pozostale: #c05ec0;
    --c-biomasa: #0ca30c;
    --c-woda: #3987e5;
    --c-wiatr: #199e70;
    --c-slonce: #c98500;
    --c-oze: #0ca30c;
    --c-cena: #3987e5;
    --c-linia: #f0efec;
    --c-prognoza: #93928a;
    --c-import: #3987e5;
    --c-eksport: #e66767;
    --mid: #383835;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #2f2f2c; --grid: #2a2a28;
  --text: #f0efec; --text-2: #c3c2b7; --text-3: #93928a; --accent: #3987e5; --accent-wash: #1c2a3d;
  --good: #2fbf2f; --bad: #e66767;
  --c-brunatny: #b8743a; --c-kamienny: #7a7fd0; --c-gaz: #d95926; --c-pozostale: #c05ec0; --c-biomasa: #0ca30c;
  --c-woda: #3987e5; --c-wiatr: #199e70; --c-slonce: #c98500; --c-oze: #0ca30c; --c-cena: #3987e5;
  --c-linia: #f0efec; --c-prognoza: #93928a; --c-import: #3987e5; --c-eksport: #e66767; --mid: #383835;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- nagłówek */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; font-size: 17px; }
.ver { color: var(--text-3); font-weight: 400; font-size: 12px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a {
  padding: 6px 12px; border-radius: 6px; text-decoration: none; color: var(--text-2);
}
nav a:hover { background: var(--surface-2); color: var(--text); }
nav a.active { background: var(--accent-wash); color: var(--text); font-weight: 600; }
.stan { margin-left: auto; color: var(--text-3); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.kropka { width: 8px; height: 8px; border-radius: 50%; background: var(--good); display: inline-block; }
.kropka.stara { background: var(--text-3); }
.kropka.blad { background: var(--bad); }

main { max-width: 1320px; margin: 0 auto; padding: 20px 24px 60px; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 2px; font-weight: 600; }
.pod { color: var(--text-2); margin: 0 0 16px; }
.male { color: var(--text-3); font-size: 12px; }
.blad-box { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); border: 1px solid var(--bad);
  padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }

/* ---------------------------------------------------------------- karty i siatka */
.karta {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px; min-width: 0;
}
.karta .naglowek { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.karta .opis { color: var(--text-3); font-size: 12px; }
.siatka { display: grid; gap: 16px; margin-bottom: 16px; }
.s2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.s-hero { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.s-mapa { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
@media (max-width: 900px) {
  .s2, .s-hero, .s-mapa { grid-template-columns: minmax(0, 1fr); }
  main { padding: 16px; }
  .top { padding: 10px 16px; gap: 12px; }
}

/* ---------------------------------------------------------------- liczby */
.kafelki { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.kafelek { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.kafelek .l { color: var(--text-2); font-size: 12px; }
.kafelek .w { font-size: 22px; font-weight: 600; margin-top: 2px; white-space: nowrap; }
.kafelek .j { font-size: 13px; font-weight: 400; color: var(--text-2); margin-left: 3px; }
.kafelek .d { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.hero { font-size: 64px; font-weight: 650; line-height: 1; letter-spacing: -1px; }
.hero .j { font-size: 28px; font-weight: 500; color: var(--text-2); margin-left: 2px; }
.hero-wiersz { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin: 6px 0 14px; }
.hero-opis { color: var(--text-2); padding-bottom: 6px; }
.hero-opis b { color: var(--text); }

/* segmentowany pasek miksu */
.pasek { display: flex; gap: 2px; height: 28px; margin: 4px 0 10px; }
.pasek div { border-radius: 4px; min-width: 0; color: #fff; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; padding-left: 6px; overflow: hidden; white-space: nowrap; }
.pasek div.ciemny-tekst { color: #0b0b0b; }

/* legenda */
.legenda { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); }
.legenda span { display: inline-flex; align-items: center; gap: 6px; }
.legenda i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legenda i.linia { height: 2px; width: 14px; border-radius: 1px; }
.legenda i.przerywana { height: 0; width: 14px; border-top: 2px dashed var(--c-prognoza); background: none !important; }
.legenda b { color: var(--text); font-weight: 600; }

.lista-mix { display: grid; grid-template-columns: auto 1fr auto auto; gap: 6px 10px; align-items: center; font-size: 13px; }
.lista-mix i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.lista-mix .liczba { text-align: right; font-variant-numeric: tabular-nums; }
.lista-mix .proc { color: var(--text-3); }

/* ---------------------------------------------------------------- wykresy */
.wykres { position: relative; width: 100%; }
.wykres svg { display: block; width: 100%; overflow: visible; }
.wykres .os text, .os text { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.wykres .siatka-linia { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.wykres .zero { stroke: var(--text-3); stroke-width: 1; shape-rendering: crispEdges; }
.wykres .kursor { stroke: var(--text-2); stroke-width: 1; shape-rendering: crispEdges; pointer-events: none; }
.wykres .teraz-linia { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 2 3; }
.wykres .warstwa { stroke: var(--surface); stroke-width: 1.5; stroke-linejoin: round; }
.wykres .linia { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.wykres .pusty { fill: var(--text-3); font-size: 13px; }
.wykres .slupek:hover, .wykres .slupek.on { filter: brightness(1.12); }
.wykres .komorka:hover { stroke: var(--text); stroke-width: 1.5; }
.mini-siatka { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 18px; }
@media (max-width: 700px) { .mini-siatka { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mini h3 { margin: 0; font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; }
.mini h3 span { font-weight: 400; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* podpowiedź */
.tip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,.14);
  padding: 8px 10px; font-size: 12px; min-width: 160px; max-width: 300px;
}
.tip .t { color: var(--text-2); margin-bottom: 4px; font-weight: 600; }
.tip .r { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; align-items: center; line-height: 1.6; }
.tip .r i { height: 2px; width: 12px; border-radius: 1px; display: inline-block; }
.tip .r i.k { height: 10px; width: 10px; border-radius: 3px; }
.tip .r .n { color: var(--text-2); }
.tip .r b { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.tip .suma { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }

/* ---------------------------------------------------------------- sterowanie */
.pasek-filtrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.btn {
  border: 1px solid var(--border); background: var(--surface); padding: 6px 12px; border-radius: 8px;
  cursor: pointer; color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn.on { background: var(--accent-wash); border-color: var(--accent); font-weight: 600; }
.btn.glowny { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.grupa-btn { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.grupa-btn button { border: 0; background: var(--surface); padding: 6px 12px; cursor: pointer; border-right: 1px solid var(--border); }
.grupa-btn button:last-child { border-right: 0; }
.grupa-btn button.on { background: var(--accent-wash); font-weight: 600; }
input[type=date], select {
  border: 1px solid var(--border); background: var(--surface); padding: 5px 8px; border-radius: 8px;
}
.postep { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; min-width: 160px; flex: 1; max-width: 320px; }
.postep div { height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s; }

/* ---------------------------------------------------------------- tabele */
.tabela-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
th { color: var(--text-2); font-weight: 600; font-size: 12px; position: sticky; top: 0; background: var(--surface); }
td { font-variant-numeric: tabular-nums; }
th:first-child, td:first-child, th.txt, td.txt { text-align: left; }
tr.wybrany td { background: var(--accent-wash); }
tbody tr { cursor: default; }
details summary { cursor: pointer; color: var(--accent); margin-top: 8px; }

/* ---------------------------------------------------------------- mapa */
.mapa svg { display: block; width: 100%; height: auto; }
.mapa .woj { stroke: var(--surface); stroke-width: 14; stroke-linejoin: round; cursor: pointer; }
.mapa .woj:hover { filter: brightness(1.08); }
.mapa .woj.wybrane { stroke: var(--text); stroke-width: 22; }
.mapa .kraj-tlo { fill: var(--surface-2); stroke: var(--surface); stroke-width: 14; }
.mapa .el { stroke: var(--surface); stroke-width: 10; cursor: pointer; }
.mapa .el:hover { stroke: var(--text); }
.mapa .strzalka { stroke-linecap: round; fill: none; }
.mapa .etykieta { font-size: 230px; fill: var(--text); font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 40px; }
.mapa .etykieta-mala { font-size: 190px; fill: var(--text-2); paint-order: stroke; stroke: var(--surface); stroke-width: 34px; }
.skala { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.skala .gradient { height: 10px; flex: 1; max-width: 260px; border-radius: 3px; }

.ranking { display: grid; grid-template-columns: auto 1fr auto; gap: 5px 10px; align-items: center; font-size: 13px; }
.ranking .nazwa { white-space: nowrap; cursor: pointer; }
.ranking .nazwa.on { font-weight: 650; }
.ranking .bar { height: 12px; background: var(--accent); border-radius: 0 4px 4px 0; min-width: 1px; }
.ranking .bar.ujemny { background: var(--c-eksport); }
.ranking .liczba { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.szczegoly dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 8px 0 12px; font-size: 13px; }
.szczegoly dt { color: var(--text-2); }
.szczegoly dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.elektrownie-lista { display: grid; grid-template-columns: 10px minmax(0, 1fr) minmax(60px, 1.2fr) auto; gap: 6px 10px; align-items: center; font-size: 13px; }
.elektrownie-lista i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.elektrownie-lista .nazwa { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.elektrownie-lista .bar { height: 10px; border-radius: 0 4px 4px 0; min-width: 1px; }
.elektrownie-lista .liczba { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.tekst { max-width: 820px; }
.tekst h2 { margin-top: 22px; }
.tekst table td, .tekst table th { white-space: normal; text-align: left; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---------------------------------------------------------------- mapa powiatów */
.mapa-pow path, .mapa-pow circle { vector-effect: non-scaling-stroke; }
.mapa .pow { stroke: var(--surface); stroke-width: 0.6px; cursor: pointer; }
.mapa .pow:hover { filter: brightness(1.1); }
.mapa .granica-woj { fill: none; stroke: var(--text-2); stroke-width: 1px; pointer-events: none; }
.mapa .kontur { fill: none; stroke: var(--text); stroke-width: 1.6px; pointer-events: none; }
.mapa .pow-wybrany { fill: none; stroke: var(--text); stroke-width: 2.5px; pointer-events: none; }
.mapa-pow .el { stroke-width: 1.5px; }
.okruszki { font-size: 13px; margin-bottom: 8px; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
button.link:hover { text-decoration: underline; }
.ranking-przewijany { max-height: 460px; overflow: auto; padding-right: 4px; }

tr.suma-wiersz td { font-weight: 650; border-top: 1px solid var(--text-3); }
