/*
 * LNet v2 — uklad strony.
 * Tokeny i komponenty bazowe: theme.css
 */

* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; }

/* --- Nawigacja --- */
.nav-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
    font-weight: 900;
    font-size: 16px;
    letter-spacing: 1px;
    color: var(--brand);
}
.brand-tag {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: var(--muted);
    background: var(--active);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
}
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-user { text-align: right; line-height: 1.3; }
.nav-user-name { font-size: 12px; font-weight: 700; }
.nav-user-mail { font-size: 11px; color: var(--muted); }
.role-badge {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--brand);
    background: var(--brand-soft);
    border-radius: 4px;
    padding: 2px 6px;
    margin-left: 4px;
}

/* --- Strona --- */
.page { max-width: 1440px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.page-title { margin: 10px 0 4px; }
.page-desc { margin: 0; }
.title-count {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--muted);
    vertical-align: super;
}
.page-badge { text-decoration: none; }

/* --- Karty KPI --- */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin: 20px 0;
}
.unit { font-size: 13px; font-weight: 700; color: var(--muted); }

/* --- Filtry --- */
.filters { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filters .input { max-width: 420px; }
.pills { display: flex; gap: 8px; }

/* --- Tabela --- */
.table-card { padding: 0; overflow: hidden; }
.table th.right, .table td.right { text-align: right; }
.table tbody tr { cursor: pointer; }
.table tbody tr:last-child td { border-bottom: none; }
.table .empty { text-align: center; color: var(--muted); padding: 32px; }
.table.compact td { border-bottom: 1px solid var(--border); font-size: 12px; }
.table.compact tr:last-child td { border-bottom: none; }
.lkd-id { text-decoration: none; font-weight: 700; }

/* --- Wykres --- */
.chart-card { margin: 20px 0; }
.chart { width: 100%; height: 360px; }
.chart-head { display: flex; gap: 24px; margin-bottom: 12px; flex-wrap: wrap; }
.input.inline { width: auto; min-width: 170px; margin-top: 4px; }

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

/* --- Logowanie --- */
.login-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 380px; padding: 28px; }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.login-title { font-size: 20px; font-weight: 800; margin: 0 0 4px; }
.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.login-submit { width: 100%; }
.alert {
    background: var(--brand-soft);
    color: var(--brand);
    border: 1px solid var(--brand);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 700;
    margin-top: 16px;
}

.footer {
    text-align: center;
    color: var(--muted);
    font-size: 11px;
    padding: 24px;
}

@media (max-width: 720px) {
    .nav-inner { flex-wrap: wrap; gap: 12px; }
    .page { padding: 16px; }
    .table-card { overflow-x: auto; }
}

/* --- Zakladki --- */
.tabs {
    display: flex;
    gap: 4px;
    margin: 20px 0 16px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 14px;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    cursor: pointer;
    margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-sub {
    display: block;
    font-size: 9px;
    font-weight: 400;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    opacity: 0.75;
}

.panel { display: none; }
.panel.active { display: block; }
.panel-head { display: flex; justify-content: space-between; margin-bottom: 12px; }
.panel-time { font-size: 12px; color: var(--muted); }

/* --- Wskazniki --- */
.gauges {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
}
.gauge { height: 210px; }

/* --- Paski faz --- */
.phase-bars { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.phase-row { display: flex; align-items: center; gap: 10px; }
.phase-name { font-size: 11px; font-weight: 700; color: var(--muted); width: 22px; }
.phase-track {
    flex: 1;
    height: 10px;
    background: var(--active);
    border-radius: 5px;
    overflow: hidden;
}
.phase-fill { display: block; height: 100%; background: var(--brand); border-radius: 5px; }
.phase-val { font-size: 12px; font-weight: 700; width: 92px; text-align: right; }

/* --- Bilans mocy --- */
.balance {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.balance-col { flex: 1; min-width: 150px; }
.balance-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--muted);
}
.balance-value { font-size: 20px; font-weight: 900; margin-top: 4px; }
.balance-sub { font-size: 12px; color: var(--muted); }
.balance-arrow { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* Przekroczony prog rozliczeniowy */
.over { color: var(--brand); }

/* --- Flagi statusu --- */
.flags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.flag {
    font-family: var(--font-mono);
    font-size: 10px;
    background: var(--active);
    border-radius: 4px;
    padding: 4px 8px;
}
.all-clear {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 12px;
    font-weight: 700;
}

/* --- Siatka trojkolumnowa --- */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

/* --- Slupki pionowe --- */
.bars { height: 190px; margin-top: 8px; }

/* --- Zegary male: wykorzystanie per faza --- */
.gauges-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.gauge-sm { height: 160px; }

/* --- Wybor zakresu dat --- */
.dates { display: flex; flex-direction: column; gap: 4px; }
.dates .input.inline { min-width: 140px; }
.hidden { display: none; }

/* --- Wykresy slupkowe zuzycia i oszczednosci --- */
.chart-tall { height: 340px; }
.tariff-line {
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--active);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--muted);
}
.tariff-line b { color: var(--text); font-family: var(--font-mono); }
.ok-text { color: var(--ok); }

/* --- Logo --- */
.brand-logo { height: 26px; width: auto; display: block; }
.login-logo { height: 42px; width: auto; display: block; margin-bottom: 8px; }
.login-sub {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: var(--muted);
    margin-bottom: 18px;
}

/* --- Komunikat po przekierowaniu --- */
.notice {
    background: var(--surface);
    border: 1px solid var(--brand);
    border-left-width: 3px;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 16px;
}

/* --- Formularze --- */
.register-card { width: 100%; max-width: 560px; padding: 28px; }
.register-form { margin-top: 8px; }
.form-section {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--muted);
    border-top: 1px solid var(--border);
    padding-top: 14px;
    margin: 18px 0 10px;
}
.form-section:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.optional { font-weight: 400; text-transform: none; letter-spacing: 0; opacity: 0.8; }
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.form-grid .span-2 { grid-column: span 2; }
.register-form .btn { margin-top: 18px; }

.login-alt {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
}
.login-alt a { color: var(--brand); font-weight: 700; text-decoration: none; }
.login-note { margin-top: 8px; }

.inline-form { display: inline; }
.btn.sm { padding: 5px 10px; font-size: 11px; border-radius: var(--radius-sm); }
.input.inline.sm { min-width: 150px; padding: 5px 8px; font-size: 11px; }

/* --- Pasek akcji nad tabela --- */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

@media (max-width: 620px) {
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: span 1; }
}

/* --- Wynik sprawdzenia numerow --- */
.check-result {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 700;
}
.check-result:empty { display: none; }
.check-result.good { background: rgba(22,163,74,0.08);  color: var(--ok); }
.check-result.warn { background: rgba(234,179,8,0.10);  color: #A16207; }
.check-result.bad  { background: var(--brand-soft);     color: var(--brand); }

/* ================= Pulpit ================= */
.table th.center, .table td.center { text-align: center; }

.status-pill {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 26px; border-radius: 13px; color: #fff;
}
.status-pill.on  { background: #6CC08B; }
.status-pill.off { background: var(--error); }

.leds { display: inline-flex; gap: 5px; }
.led {
    width: 14px; height: 14px; border-radius: 50%;
    background: #9CA3AF; box-shadow: inset 0 -2px 0 rgba(0,0,0,.12);
}
.led-green  { background: #22A33A; }
.led-yellow { background: #F2B705; }
.led-red    { background: var(--error); }

.comp {
    display: inline-block; font-size: 11px; font-weight: 700;
    padding: 3px 8px; border-radius: 6px;
}
.comp-ok    { background: rgba(22,163,74,.10); color: var(--ok); }
.comp-under { background: var(--brand-soft);   color: var(--brand); }
.comp-none  { background: var(--active);       color: var(--muted); }
.comp-big   { font-size: 18px; font-family: var(--font-sans); background: none !important; padding: 0; }

.usage { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.usage-track { flex: 1; height: 8px; border-radius: 4px; background: #EEF1F4; overflow: hidden; }
.usage-fill  { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.usage-val   { font-size: 11px; font-weight: 700; width: 38px; text-align: right; }

/* ================= Widok urządzenia: Live ================= */
.live-time { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.live-grid {
    display: grid; gap: 16px; margin-bottom: 16px;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.widget { padding: 20px; }
.widget-title { font-size: 15px; font-weight: 800; margin-bottom: 14px; color: var(--text); }
.unit-tag {
    font-family: var(--font-mono); font-size: 10px; font-weight: 700; color: var(--muted);
    background: var(--active); border-radius: 4px; padding: 2px 6px; margin-left: 4px;
    vertical-align: middle;
}

/* Paski obciazenia: kreskowane tlo, wypelnienie od dolu */
.hbars { display: flex; justify-content: space-around; gap: 14px; height: 170px; }
.hbar  { flex: 1; max-width: 72px; display: flex; flex-direction: column; align-items: center; }
.hbar-track {
    flex: 1; width: 100%; border-radius: 12px; position: relative; overflow: hidden;
    background: repeating-linear-gradient(135deg, #EEF1F4 0 6px, #F7F8FA 6px 12px);
}
.hbar-fill {
    position: absolute; left: 0; right: 0; bottom: 0; min-height: 30px;
    background: linear-gradient(180deg, #DA2C36, #A3141D); border-radius: 12px;
    display: flex; align-items: flex-start; justify-content: center;
}
.hbar-val {
    font-size: 13px; font-weight: 800; color: var(--text);
    background: rgba(255,255,255,.85); border-radius: 6px; padding: 1px 5px; margin-top: -22px;
}
.hbar-lbl { font-size: 11px; color: var(--muted); margin-top: 6px; font-weight: 700; }

/* Stan urzadzenia */
.state { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: stretch; }
.state-pills { display: flex; flex-direction: column; gap: 8px; }
.state-pill {
    display: flex; align-items: baseline; gap: 10px;
    border: 1px solid var(--border); border-radius: 20px; padding: 9px 14px;
}
.state-pill span { font-size: 11px; color: var(--muted); }
.state-pill b    { font-size: 14px; }
.temp-card {
    background: var(--navy); color: #fff; border-radius: var(--radius);
    padding: 14px; display: flex; flex-direction: column; justify-content: space-between;
}
.temp-title { font-size: 12px; opacity: .85; }
.temp-body  { display: flex; align-items: center; gap: 10px; }
.temp-val   { font-size: 34px; font-weight: 800; }
.temp-unit  { font-size: 14px; opacity: .85; }

/* Napiecia */
.volts { display: flex; justify-content: space-around; gap: 8px; padding-top: 6px; }
.volt  { display: flex; flex-direction: column; align-items: center; color: var(--accent); }
.volt-bad { color: var(--error); }
.volt-val { font-size: 18px; font-weight: 800; color: var(--text); margin-top: 6px; }
.volt-val small { font-size: 12px; color: var(--muted); }
.volt-lbl { font-size: 11px; color: var(--muted); margin-top: 10px; font-weight: 700; }

.gauge { height: 180px; }

/* ================= Zakładki z wykresami ================= */
.range-bar { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.charts-grid {
    display: grid; gap: 16px; margin-bottom: 16px;
    grid-template-columns: repeat(auto-fit, minmax(520px, 1fr));
}
.charts-grid .chart { height: 300px; }
.chart-card { padding: 18px 20px; }

.tab-alert {
    display: inline-block; min-width: 16px; height: 16px; line-height: 16px;
    font-size: 10px; font-weight: 800; text-align: center; color: #fff;
    background: var(--error); border-radius: 8px; margin-left: 4px; padding: 0 4px;
}
.flag-ok   { background: rgba(22,163,74,.10); color: var(--ok); }
.flag-warn { background: rgba(234,179,8,.14); color: #A16207; }
.tariff-line { margin-bottom: 16px; }

@media (max-width: 620px) {
    .charts-grid { grid-template-columns: 1fr; }
    .state { grid-template-columns: 1fr; }
}

/* --- Naglowek strony logowania: logo wysrodkowane i wieksze --- */
.login-head {
    display: flex; flex-direction: column; align-items: center;
    padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--border);
}
.login-head .login-logo { height: 64px; margin: 4px 0 10px; }
.login-head .login-sub  { margin-bottom: 0; }

/* ================= Poprawki: wyrownanie i uklad ================= */

/* Pulpit: wszystkie kolumny wysrodkowane */
.table-card .table th,
.table-card .table td { text-align: center; vertical-align: middle; }
.table-card .table .usage { justify-content: center; margin: 0 auto; max-width: 180px; }
.table-card .table .comp { margin: 0 auto; }

/* Pasek stanu online w barwach sygnalizacyjnych - to wskaznik, nie dane */
.status-pill.on { background: var(--ok); }

/* Wykresy w zakladkach: pelna szerokosc, jeden pod drugim */
.charts-grid { grid-template-columns: 1fr; }
.charts-grid .chart { height: 320px; }

/* Napiecia jako zegary - trzy obok siebie */
.volt-gauges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.volt-gauge  { height: 150px; }
.volt-gauge-lbl { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); margin-top: -6px; }

/* Temperatura - granat LOPI zamiast grafitu */
.temp-card { background: var(--navy); }

.range-bar .input.inline { min-width: 190px; }
.range-note { font-size: 11px; color: var(--muted); align-self: center; }
#panel-savings .chart-card, #panel-meters .chart-card { margin-bottom: 16px; }

/* --- Ustawienia urzadzenia --- */
.form-grid-4 { grid-template-columns: repeat(4, 1fr); }
.settings-foot { display: flex; align-items: center; gap: 16px; margin: 4px 0 16px; }
#panel-settings .card { margin-bottom: 16px; }
@media (max-width: 900px) { .form-grid-4 { grid-template-columns: 1fr 1fr; } }

/* --- Atrybut hidden wygrywa z display ustawionym w klasach (.field, .card) --- */
[hidden] { display: none !important; }

/* --- Organizacje i instalatorzy --- */
.nowrap { white-space: nowrap; }
.company-devices .input.inline.sm { min-width: 0; max-width: 190px; }
.company-devices .kw-input { width: 80px; }
.edit-row td { background: var(--active); text-align: left !important; }
.user-edit { padding: 8px 4px; }
.user-edit-actions { display: flex; gap: 8px; margin-top: 12px; }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { filter: brightness(0.92); }

/* --- Konfiguracja OSD --- */
.osd-pills { flex-wrap: wrap; margin: 0 0 16px; }
.osd-block { margin-bottom: 16px; }
.osd-table td { vertical-align: top; }
.zone-inputs { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.zone-input { display: flex; flex-direction: column; gap: 2px; }
.input.inline.sm.rate-input { min-width: 0; width: 96px; }
.input.changed { border-color: var(--brand); background: rgba(200, 25, 36, .05); }
.row-changed td:first-child { box-shadow: inset 3px 0 0 var(--brand); }

/* --- Wykres kombinowany: wybor dodatkowych danych --- */
.chart-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.combo-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.combo-panel {
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg);
    padding: 12px 14px; margin-bottom: 14px; max-height: 340px; overflow-y: auto;
}
.combo-tab + .combo-tab { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.combo-tab-label {
    font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); margin-bottom: 6px;
}
.combo-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 4px 0; }
.combo-group-label { font-size: 13px; font-weight: 700; color: var(--text); min-width: 300px; }
.combo-series { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.combo-check {
    font-size: 12px; font-weight: 500; color: var(--text);
    display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
}
.combo-foot { margin-top: 10px; text-align: right; }
@media (max-width: 620px) { .combo-group-label { min-width: 0; width: 100%; } }

/* --- Optymalizacja taryfy i mocy umownej --- */
.optim-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.optim-tile { border-left: 4px solid var(--border); }
.optim-tile.optim-yes { border-left-color: var(--brand); background: rgba(200, 25, 36, .04); }
.optim-tile.optim-ok { border-left-color: var(--ok); }
.optim-value { font-size: 22px; font-weight: 800; font-family: var(--font-mono); margin: 6px 0; }
.optim-value b { color: var(--brand); }
.optim-yes .kpi-caption b { color: var(--text); }
.row-current td { background: var(--active); }
.row-best td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.optim-badge {
    display: inline-block; margin-top: 4px; padding: 2px 8px; border-radius: 10px;
    font-size: 10px; font-weight: 700; text-decoration: none;
    color: var(--brand); background: rgba(200, 25, 36, .08);
}
@media (max-width: 620px) { .optim-row { grid-template-columns: 1fr; } }

/* --- Dzwonek powiadomien --- */
.bell { position: relative; margin-right: 8px; }
.bell-btn {
    position: relative; background: none; border: 1px solid var(--border); border-radius: 50%;
    width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer; color: var(--text);
}
.bell-btn:hover { background: var(--active); }
.bell-count {
    position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; line-height: 18px;
    padding: 0 5px; border-radius: 9px; background: var(--brand); color: #fff;
    font-size: 10px; font-weight: 800; text-align: center;
}
.bell-panel {
    display: none; position: absolute; right: 0; top: 46px; width: 360px; max-width: calc(100vw - 32px);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: 0 12px 32px rgba(20, 28, 58, .12); z-index: 50; max-height: 70vh; overflow-y: auto;
}
.bell.open .bell-panel { display: block; }
.bell-head {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 12px;
}
.bell-link { background: none; border: none; color: var(--brand); font-size: 11px; font-weight: 700; cursor: pointer; padding: 0; }
.bell-item {
    display: flex; flex-direction: column; gap: 3px; padding: 10px 14px;
    border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); font-size: 12px;
}
.bell-item:hover { background: var(--active); }
.bell-item.unread { box-shadow: inset 3px 0 0 var(--brand); }
.bell-item.unread .bell-title { font-weight: 800; }
.bell-body { color: var(--muted); line-height: 1.4; }
.bell-time { font-size: 10px; color: var(--muted); }
.bell-empty { padding: 16px 14px; font-size: 12px; color: var(--muted); }

/* --- Rekordy pod wykresami zakladki --- */
.records-card { margin-bottom: 16px; }
.records-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.records-head .widget-title { margin-bottom: 0; }
.records-info { font-size: 12px; font-weight: 500; color: var(--muted); }
.records-actions { display: flex; align-items: center; gap: 6px; }
.records-actions .kpi-label { margin: 0 4px 0 0; }
.records-scroll { overflow: auto; max-height: 560px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.records-table { font-variant-numeric: tabular-nums; }
.records-table th, .records-table td { white-space: nowrap; padding: 5px 10px; font-size: 12px; }
.records-table thead th { position: sticky; top: 0; z-index: 1; }
.records-table thead tr + tr th { top: 29px; }
.records-table th.grp, .records-table td.grp { border-left: 1px solid var(--border); }
.records-table tbody tr { cursor: default; }
.records-table tbody tr:hover td { background: var(--active); }
.records-table td:first-child, .records-table th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 2; }
.records-table thead th:first-child { background: var(--bg); z-index: 3; }
.records-pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.records-pager:empty { display: none; }
.records-table th .unit-tag { text-transform: none; }

/* --- Opłaty dystrybucyjne: miesiace i poziom analizy --- */
.month-bar { margin-bottom: 16px; }
.month-pills { flex-wrap: wrap; margin-top: 8px; }
.section-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 12px; }
.level-badge { font-size: 10px; font-weight: 700; padding: 3px 9px; border-radius: 10px; letter-spacing: .3px; }
.level-badge.lvl-pre { background: rgba(234, 179, 8, .16); color: #A16207; }
.level-badge.lvl-normal { background: var(--active); color: var(--text); }
.level-badge.lvl-full { background: rgba(22, 163, 74, .12); color: var(--ok); }
.optim-row-3 { grid-template-columns: repeat(3, 1fr); }
#dist-year, #dist-charts, #dist-compare-card { margin-bottom: 16px; }
#dist-charts .chart-card { margin-bottom: 0; }
@media (max-width: 900px) { .optim-row-3 { grid-template-columns: 1fr; } }

/* Lista urzadzen: lokalizacja do lewej (naglowek zostaje wysrodkowany) */
.table-card .table td.left { text-align: left; }
.filters .pills { flex-wrap: wrap; align-items: center; }
.pills-label { margin: 0 4px 0 0; }
a.pill { text-decoration: none; color: inherit; }
a.pill.active { color: #fff; }

.pager {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; margin-top: 14px;
}
.pager .pills { align-items: center; }

.assign-dialog { width: min(440px, calc(100vw - 32px)); border: none; padding: 22px; }
.assign-dialog::backdrop { background: rgba(20, 28, 58, 0.55); }
.assign-dialog .field { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Lista urzadzen na cala szerokosc ekranu - przy 10 kolumnach 1440 px
   zawijalo date ostatniego sygnalu. */
.page.page-wide, .nav-inner.page-wide { max-width: none; }
.nowrap { white-space: nowrap; }
.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.sort-link:hover, .sort-link.active { color: var(--text); }
.sort-arrow { font-size: 9px; opacity: 0.6; }
.sort-link.active .sort-arrow { opacity: 1; color: var(--brand); }

/* Limity alarmowe: macierz kwadrant x okres w Ustawieniach */
.limits-table .input { width: 110px; padding: 5px 8px; text-align: right; }

/* Lista urzadzen: zwarte wiersze - wszystko w jednej linii */
.devices-table td { padding: 5px 10px; white-space: nowrap; }
.devices-table td.left { white-space: normal; }
.devices-table .status-pill { width: 32px; height: 20px; border-radius: 10px; }
.devices-table .status-pill svg { width: 13px; height: 13px; }
.devices-table .led { width: 12px; height: 12px; }
.devices-table .comp { padding: 2px 6px; margin: 0 4px 0 0; }
.devices-table .optim-badge { margin: 0 0 0 6px; padding: 1px 6px; }
.devices-table .btn.sm { padding: 3px 9px; }

.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .form-grid-3 { grid-template-columns: 1fr; } }

.rules-apply { margin-top: 12px; }

/* Stan urzadzenia: cztery kafelki 2x2 (temperatura jako kafelek, bez czarnej karty) */
.state { grid-template-columns: 1fr; }
.state-pills { display: grid; grid-template-columns: 1fr 1fr; }

/* --- Live: kropka w tytule w barwie slupkow kafelka --- */
.widget-title[class*="mark-"]::before {
    content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px;
    margin-right: 8px; vertical-align: 1px; background: var(--mark);
}
.mark-red   { --mark: linear-gradient(180deg, #DA2C36, #A3141D); }
.mark-navy  { --mark: linear-gradient(180deg, #34406A, #141C3A); }
.mark-slate { --mark: linear-gradient(180deg, #8A94A6, #5A6472); }
.mark-rose  { --mark: linear-gradient(180deg, #EDA1A5, #D66A70); }

/* ================= Wyglad z makiet strony WWW ================= */

/* --- Tlo aplikacji: jasny szary z delikatna poswiata i pasmem rombow LOPI
   w prawym dolnym rogu. Wzor (static/diamonds.svg) jest maska, kolor daje
   token - karty zostaja czyste, wzor widac tylko w marginesach. --- */
body { min-height: 100vh; display: flex; flex-direction: column; position: relative; isolation: isolate; }
body > main { flex: 1 0 auto; width: 100%; }
body::before {
    content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none;
    background:
        radial-gradient(900px 520px at 100% 0%, rgba(20, 28, 58, .07), transparent 70%),
        radial-gradient(700px 480px at 0% 100%, rgba(200, 25, 36, .05), transparent 70%);
}
body::after {
    content: ""; position: fixed; right: 0; bottom: 0; z-index: -1; pointer-events: none;
    width: min(1100px, 100vw); height: 420px;
    background: var(--navy); opacity: .07;
    /* Dwie maski: wzor rombow i wygaszenie ku lewej gorze */
    -webkit-mask-image: url(/static/diamonds.svg), linear-gradient(120deg, transparent 25%, #000 80%);
            mask-image: url(/static/diamonds.svg), linear-gradient(120deg, transparent 25%, #000 80%);
    -webkit-mask-size: 240px 140px, 100% 100%;
            mask-size: 240px 140px, 100% 100%;
    -webkit-mask-repeat: repeat, no-repeat;
            mask-repeat: repeat, no-repeat;
    -webkit-mask-position: right bottom, 0 0;
            mask-position: right bottom, 0 0;
    -webkit-mask-composite: source-in;
            mask-composite: intersect;
}

/* --- Nawigacja: biala, polprzezroczysta nad tlem, czerwona kreska pod aktywna --- */
.nav {
    background: rgba(255, 255, 255, .92);
    -webkit-backdrop-filter: saturate(1.4) blur(8px);
            backdrop-filter: saturate(1.4) blur(8px);
    border-bottom: none;
    box-shadow: 0 1px 0 var(--border), 0 6px 20px rgba(20, 28, 58, .04);
}
.nav a { color: var(--navy); position: relative; }
.nav-links a:hover { background: var(--active); }
.nav a.active { background: none; color: var(--brand); }
.nav-links a.active::after {
    content: ""; position: absolute; left: 12px; right: 12px; bottom: -10px;
    height: 3px; border-radius: 3px 3px 0 0; background: var(--brand);
}
.brand-tag { color: var(--navy); }
.nav-user-name { color: var(--navy); }

.footer { color: var(--muted-2); }

/* Naglowki sekcji z kreska jak na stronie WWW ("— Produkty") */
span.page-badge::before { content: "— "; }

.table th { color: var(--navy); }
.widget-title, .login-title { color: var(--navy); }

/* ================= Logowanie i rejestracja: granatowa scena ================= */
body.auth { background: var(--navy); }
body.auth::before {
    background:
        radial-gradient(900px 600px at 88% 8%, rgba(200, 25, 36, .24), transparent 60%),
        radial-gradient(800px 700px at 0% 100%, rgba(58, 74, 120, .55), transparent 65%),
        linear-gradient(160deg, var(--navy-3) 0%, var(--navy) 45%, #0D1330 100%);
}
body.auth::after {
    left: 0; width: auto; height: 65vh;
    background: #fff; opacity: .08;
    -webkit-mask-image: url(/static/diamonds.svg), linear-gradient(180deg, transparent 0%, #000 75%);
            mask-image: url(/static/diamonds.svg), linear-gradient(180deg, transparent 0%, #000 75%);
    -webkit-mask-size: 300px 175px, 100% 100%;
            mask-size: 300px 175px, 100% 100%;
    -webkit-mask-position: center bottom, 0 0;
            mask-position: center bottom, 0 0;
}
body.auth .footer { color: rgba(255, 255, 255, .45); }

.auth-stage {
    min-height: calc(100vh - 120px);
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 72px;
    align-items: center; max-width: 1120px; margin: 0 auto; padding: 24px 0;
}
.auth-hero { color: #fff; max-width: 520px; }
.auth-hero-logo { height: 64px; width: auto; display: block; margin: 0 0 32px -17px; }
.auth-eyebrow {
    font-size: 12px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase;
    color: #F0525B;
}
.auth-eyebrow::before { content: "— "; }
.auth-hero h2 {
    font-size: 40px; line-height: 1.12; font-weight: 800; letter-spacing: -0.6px;
    margin: 12px 0 16px;
}
.auth-hero h2 em { font-style: normal; color: #F0525B; }
.auth-hero p { font-size: 15px; line-height: 1.6; color: rgba(255, 255, 255, .72); margin: 0; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.auth-points li {
    display: flex; align-items: center; gap: 12px;
    font-size: 14px; font-weight: 600; color: rgba(255, 255, 255, .9);
}
.auth-points li::before {
    content: ""; flex: none; width: 8px; height: 8px;
    border: 2px solid var(--brand); transform: rotate(45deg);
}

body.auth .login-wrap { min-height: 0; }
body.auth .page > .login-wrap { min-height: calc(100vh - 120px); }
body.auth .login-card, body.auth .register-card {
    border: none; border-top: 4px solid var(--brand);
    box-shadow: 0 30px 80px rgba(5, 8, 25, .45), 0 2px 6px rgba(5, 8, 25, .2);
}
body.auth .login-card { max-width: 400px; padding: 32px; }

@media (max-width: 960px) {
    .auth-stage { grid-template-columns: 1fr; gap: 24px; justify-items: center; min-height: 0; }
    .auth-hero { text-align: center; }
    .auth-hero-logo { margin: 0 auto 16px; height: 52px; }
    .auth-hero h2 { font-size: 26px; margin-bottom: 0; }
    .auth-hero p, .auth-points { display: none; }
}
@media (max-width: 720px) {
    .nav-links a.active::after { display: none; }
}


/* --- Stan kompensacji: co konkretnie jest poza norma --- */
.comp-why { color: var(--brand); font-weight: 600; }
