/* PROmeter – style interfejsu, motyw jasny i ciemny */
:root, [data-theme="light"] {
  --bg: #F4F7FB; --sf: #FFFFFF; --sf2: #EEF3FA; --bd: #D5DEEB; --tx: #0F1B2D; --mu: #4F5F78;
  --pr: #1D4ED8; --onp: #FFFFFF; --nav: #0B2A5B; --navt: #D6E2F5; --navh: #9FB4D6; --nava: #1D4ED8;
  --grid: #E4E9F1; --ok: #15803D; --okbg: #E6F4EA; --warn: #92400E; --warnbg: #FDF3E1; --crit: #B91C1C; --critbg: #FDECEC;
  --el: #1D4ED8; --wo: #0F766E; --ga: #7C3AED; --kl: #C2410C;
  --tel: #E4EDFD; --two: #E2F3F1; --tga: #EFE9FD; --tkl: #FDEEE3;
  --shadow: 0 6px 18px rgba(15, 27, 45, 0.12);
}
[data-theme="dark"] {
  --bg: #0B1220; --sf: #111B2E; --sf2: #16233A; --bd: #2A3B5C; --tx: #E6EDF7; --mu: #A3B3CA;
  --pr: #5B9BFF; --onp: #0B1220; --nav: #070E1A; --navt: #C3CFE2; --navh: #8FA3C2; --nava: #1E4FBF;
  --grid: #22314D; --ok: #4ADE80; --okbg: #12301F; --warn: #FBBF24; --warnbg: #3A2A0B; --crit: #F87171; --critbg: #3A1518;
  --el: #5B9BFF; --wo: #2DD4BF; --ga: #C4B5FD; --kl: #F59E0B;
  --tel: #17294A; --two: #0F2E2C; --tga: #251D45; --tkl: #33260D;
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--tx); font-size: 14px; }
a { color: var(--pr); }
button, input, select { font: inherit; color: inherit; }
.app { min-height: 100vh; display: flex; flex-wrap: wrap; }

/* menu */
.nav { flex: 1 1 232px; max-width: 280px; background: var(--nav); color: var(--navt); padding: 24px 16px; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 16px; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; background: var(--nava); display: flex; align-items: center; justify-content: center; }
.brand b { color: #fff; font-size: 15px; display: block; }
.brand small { font-size: 12px; }
.nav-h { padding: 14px 12px 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--navh); }
.nav a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px; border-radius: 9px; text-decoration: none; color: var(--navt); font-weight: 500; }
.nav a.active { background: var(--nava); color: #fff; font-weight: 600; }
.nav a:hover:not(.active) { background: rgba(255, 255, 255, .08); }
.nav-user { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid rgba(255, 255, 255, .12); font-size: 13px; }
.nav-user b { color: #fff; display: block; }
.nav-user button { background: none; border: 0; color: var(--navt); text-decoration: underline; padding: 6px 0; cursor: pointer; }

/* treść */
.main { flex: 999 1 560px; min-width: 0; padding: 28px 32px 40px; display: flex; flex-direction: column; gap: 22px; }
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.head h1 { margin: 0; font-size: 26px; }
.head .sub { margin-top: 4px; color: var(--mu); }
.head-icon { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; flex: none; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.card { background: var(--sf); border: 1px solid var(--bd); border-radius: 14px; padding: 20px 24px; }
.card h2 { margin: 0 0 12px; font-size: 17px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.muted { color: var(--mu); }
.small { font-size: 12px; }

.btn { min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--bd); background: var(--sf); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.btn.primary { background: var(--pr); color: var(--onp); border-color: var(--pr); font-weight: 600; }
.btn.danger { color: var(--crit); }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--pr); outline-offset: 2px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: var(--sf2); border: 1px solid var(--bd); }
.seg button { min-height: 38px; padding: 0 14px; border-radius: 9px; border: 0; background: transparent; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.seg button[aria-pressed="true"] { background: var(--pr); color: var(--onp); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--bd); }
.tabs button { min-height: 44px; padding: 0 16px; border: 0; border-bottom: 3px solid transparent; background: none; cursor: pointer; font-weight: 600; color: var(--mu); display: inline-flex; gap: 8px; align-items: center; }
.tabs button[aria-selected="true"] { color: var(--pr); border-bottom-color: var(--pr); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; }
.field input, .field select, input.inp, select.inp { min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--bd); background: var(--bg); }

.kpi { background: var(--sf); border: 1px solid var(--bd); border-top: 4px solid var(--acc, var(--pr)); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--tx); }
.kpi .lbl { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--mu); font-weight: 600; }
.kpi .ico { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex: none; }
.kpi .val { font-size: 26px; font-weight: 700; }
.kpi .val small { font-size: 14px; color: var(--mu); font-weight: 400; margin-left: 4px; }
.kpi .note { font-size: 12px; color: var(--mu); font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 13px; color: var(--mu); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--bd); }
td { padding: 10px 12px; border-bottom: 1px solid var(--bd); }
td.num, th.num { text-align: right; }
.scroll { overflow-x: auto; }
.badge { display: inline-flex; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--sf2); color: var(--mu); }
.badge.ok { background: var(--okbg); color: var(--ok); }
.badge.warn { background: var(--warnbg); color: var(--warn); }
.badge.crit { background: var(--critbg); color: var(--crit); }
.alert { display: flex; gap: 12px; padding: 14px 18px; border-radius: 12px; border: 1px solid var(--warn); background: var(--warnbg); }
.chart { width: 100%; height: 320px; }
.chart.tall { height: 380px; }
.chart.small { height: 240px; }

/* logowanie */
.login { min-height: 100vh; display: flex; flex-wrap: wrap; width: 100%; }
.login-side { flex: 1 1 420px; background: var(--nav); color: var(--navt); padding: 56px 64px; display: flex; flex-direction: column; justify-content: center; gap: 24px; }
.login-side h1 { color: #fff; font-size: 34px; margin: 0; }
.login-main { flex: 999 1 480px; display: flex; align-items: center; justify-content: center; padding: 32px; }
.login-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 16px; }
.error { color: var(--crit); font-weight: 600; min-height: 20px; }

.toast { position: fixed; right: 20px; bottom: 20px; background: var(--tx); color: var(--bg); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (max-width: 700px) {
  .nav { max-width: none; }
  .main { padding: 20px 16px; }
}

/* --- strony zakładek, okna dialogowe, import --- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
h3 { font-size: 15px; margin: 18px 0 8px; }
.ico.big { width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; }
.ico { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 9px; flex: none; }
.kpi .note.bad { color: var(--crit); } .kpi .note.good { color: var(--ok); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
@media (min-width: 1001px) { .split { align-items: stretch; } .split > .chart.tall { height: auto; min-height: 380px; } }
.legend-panel { border: 1px solid var(--bd); border-radius: 12px; padding: 12px; background: var(--sf2); font-size: 13px; }
.lg-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 40px 80px; gap: 8px; align-items: center; padding: 4px 0; }
.lg-row .lg-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-row span:last-child, .lg-row b { text-align: right; }
.lg-row.total { border-top: 1px solid var(--bd); margin-top: 6px; padding-top: 8px; font-weight: 700; }
/* Pełna nazwa odbiornika w pierwszej linii, wartości (kWh, %, zł) w drugiej – nazwy nie są ucinane */
.lg-row { grid-template-columns: 12px minmax(0, 1fr) 44px auto; row-gap: 1px; padding: 4px 0; }
.lg-row .lg-name { grid-column: 2 / -1; white-space: normal; overflow: visible; line-height: 1.25; }
.lg-row b { grid-column: 2; grid-row: 2; text-align: left; }
.lg-row b + span { grid-column: 3; grid-row: 2; text-align: right; }
.lg-row span:last-child { grid-column: 4; grid-row: 2; }
@media (max-width: 700px) {
  .lg-row { padding: 6px 0; border-bottom: 1px solid var(--bd); }
  .lg-row:last-child { border-bottom: 0; }
  .chart.tall { height: 300px; }
}
.sw { width: 12px; height: 12px; border-radius: 3px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip { min-height: 34px; padding: 4px 14px; border-radius: 999px; border: 1px solid var(--bd); background: var(--sf); color: var(--tx); cursor: pointer; font: inherit; }
.chip[aria-pressed="true"] { background: var(--pr); border-color: var(--pr); color: var(--onp); }
.dialog { border: 1px solid var(--bd); border-radius: 16px; background: var(--sf); color: var(--tx); padding: 22px 24px; width: min(980px, 96vw); max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.dialog::backdrop { background: rgba(4, 12, 28, .55); }
.dialog h2 { margin: 0; }
.table.sticky thead th { position: sticky; top: 0; background: var(--sf); z-index: 1; }
.table tr.row-on td { background: color-mix(in srgb, var(--pr) 8%, transparent); }
.table td .inp { min-height: 36px; }

/* --- ustawienia --- */
.tabs a.tab-link { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; min-height: 44px; color: var(--mu); text-decoration: none; border-bottom: 3px solid transparent; font-weight: 600; white-space: nowrap; }
.tabs a.tab-link[aria-selected="true"] { color: var(--pr); border-bottom-color: var(--pr); }
.tabs { overflow-x: auto; }
.dot { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--crit); color: #fff; font-size: 11px; font-weight: 700; margin-left: 6px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.cols fieldset { border: 1px solid var(--bd); border-radius: 12px; padding: 10px 14px; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.cols legend { font-weight: 700; padding: 0 6px; }
label.check { display: flex; gap: 10px; align-items: center; min-height: 32px; cursor: pointer; }
.proc { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.proc ol { margin: 6px 0 0; padding-left: 20px; line-height: 1.6; }
.module-row { border: 1px solid var(--bd); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
details summary { cursor: pointer; padding: 8px 0; }

/* --- pulpit: edytor i siatka wykresów --- */
.dash-editor { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .dash-editor { grid-template-columns: 1fr; } }
.dash-group { border: 1px solid var(--bd); border-radius: 12px; padding: 8px 14px; }
.dash-group summary { display: flex; align-items: center; gap: 10px; font-weight: 700; min-height: 40px; }
.dash-group .ico { width: 28px; height: 28px; }
.dash-point { padding: 6px 0; border-top: 1px dashed var(--bd); }
.chips-inline { display: flex; flex-wrap: wrap; gap: 0 18px; }
.dash-order { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; max-height: 70vh; overflow: auto; }
.dash-order li { display: flex; align-items: center; gap: 8px; border: 1px solid var(--bd); border-radius: 10px; padding: 6px 8px; background: var(--sf2); }
.dash-order .grow { flex: 1; min-width: 0; }
.icon-btn { min-width: 36px; min-height: 36px; padding: 0 8px; justify-content: center; }
.dash-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 20px; }
.dash-chart { min-width: 0; }
.dash-chart.wide { grid-column: span 2; }
@media (max-width: 1100px) { .dash-chart.wide { grid-column: auto; } }
.demo-box { margin-top: 16px; display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 12px 14px; border: 1px dashed var(--pr); border-radius: 12px; background: color-mix(in srgb, var(--pr) 6%, transparent); }
