/*
 * Portal Ofertowy LOPI - warstwa wizualna wspolna z LNet2
 *
 * Wzorzec: MQTT_PORTAL/portal/app/static/theme.css + layout.css (LNet2).
 * Paleta z makiet nowej strony WWW Lopi (STRATEGIA/Makiety_Lopi), zeby portal
 * ofertowy, LNet2 i strona WWW wygladaly jak jedna marka.
 *
 * Zasady przeniesione z LNet2:
 * - system plaski, oparty na cienkich ramkach: biale karty na jasnoszarym tle,
 * - drobna typografia: etykiety 10-11 px wersalikami, tresc tabel 12 px,
 * - wszystkie liczby, numery ofert i kwoty w monospace (.num),
 * - czerwien Lopi jako akcent i przycisk glowny, granat w tytulach i aktywnych pigulkach,
 * - zadnych kolorow na sztywno w szablonach - tylko tokeny ponizej.
 *
 * Portal laduje Tailwinda z CDN (preflight + klasy utility). Komponenty ponizej
 * maja zwykle selektory klas; tam, gdzie preflight Tailwinda wygrywa
 * selektorem atrybutu ([type='button'] zeruje tlo przycisku), dopisany jest
 * wariant z [type], zeby tlo przycisku glownego nie znikalo.
 *
 * Kolor wiodacy --brand jest nadpisywany per uzytkownik w base.html (biala
 * etykieta instalatora) - dokladnie tak jak w jego ofertach.
 */

:root {
    /* Kolor wiodacy. Nadpisywany per uzytkownik przy bialej etykiecie. */
    --brand:          #C81924;
    --brand-dark:     #A3141D;
    --brand-soft:     rgba(200, 25, 36, 0.08);
    --brand-tint:     #FBEAEA;

    --bg:             #F6F7FB;
    --surface:        #FFFFFF;
    --text:           #1E2430;
    --text-2:         #3A4250;
    --muted:          #5A6472;
    --muted-2:        #8A94A6;
    --border:         #E3E7EF;
    --border-input:   #C9D0DC;
    --active:         rgba(20, 28, 58, 0.05);

    --navy:           #141C3A;
    --navy-2:         #1B2438;
    --navy-3:         #232D48;

    /* Stany - odpowiedniki statusow ofert */
    --ok:             #3FA34D;
    --warn:           #EAB308;
    --error:          #DC2626;
    --offline:        #8A94A6;
    --info:           #0EA5E9;

    --font-sans: Aptos, Lato, "Segoe UI", Calibri, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
                 "Liberation Mono", "Courier New", monospace;

    /* Zaokraglenia jak w LNet2 */
    --radius:       12px;  /* karty, kafelki KPI, okna, przyciski glowne */
    --radius-sm:     8px;  /* ramki wewnatrz kart, komunikaty, panele */
    --radius-ctl:    8px;  /* pola, pigulki, male przyciski, pozycje nawigacji */

    /* Miekki cien kart - na tle z wzorem sama ramka gubi krawedz */
    --shadow:       0 1px 2px rgba(20, 28, 58, .04), 0 4px 16px rgba(20, 28, 58, .04);
}

html { background: var(--bg); }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    isolation: isolate;
}
body > main { flex: 1 0 auto; width: 100%; }
::selection { background: var(--brand); color: #fff; }

/* Tailwind: monospace i krój bezszeryfowy jak w LNet2 */
.font-mono { font-family: var(--font-mono) !important; }
.font-sans { font-family: var(--font-sans) !important; }

/* Liczby, identyfikatory i kwoty zawsze monospace - to decyduje o czytelnosci
   kolumn, nie jest ozdobnikiem. */
.num, td.num, .kpi-value, .offer-id {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* !important: komponenty (.notice, .tag, .field, .modal-backdrop...) maja wlasne display
   o tej samej sile selektora, a JS pokazuje i chowa elementy wylacznie klasa "hidden". */
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

/* ================= Tlo aplikacji =================
   Jasny szary z delikatna poswiata granatu i czerwieni oraz pasmem rombow LOPI
   w prawym dolnym rogu. diamonds.svg jest MASKA - kolor nadaje token, wiec ten
   sam wzor dziala na jasnym i ciemnym tle. Karty zostaja czyste. */
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;
    -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;
}

/* ================= Karta ================= */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.kpi-label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.55px;
    text-transform: uppercase;
}
.kpi-value {
    font-size: 24px;
    font-weight: 900;
    line-height: 1.2;
    color: var(--text);
    margin-top: 2px;
}
.kpi-value.brand { color: var(--brand); }
.kpi-value.positive { color: var(--ok); }
.kpi-caption { color: var(--muted); font-size: 11px; }
.unit { font-size: 13px; font-weight: 700; color: var(--muted); }

.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.widget-title { font-size: 15px; font-weight: 800; margin-bottom: 14px; color: var(--navy); }

/* ================= Strona ================= */
.page { max-width: 1440px; width: 100%; margin: 0 auto; padding: 24px; }
.page.page-wide { max-width: none; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.page-head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.page-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--brand);
    background: var(--brand-tint);
    border-radius: var(--radius-ctl);
    padding: 4px 10px;
    text-decoration: none;
}
/* Naglowek sekcji z kreska jak na stronie WWW ("— Baza ofert") */
span.page-badge::before { content: "— "; }

.page-title { font-size: 28px; font-weight: 800; color: var(--navy); letter-spacing: -0.3px; margin: 10px 0 4px; line-height: 1.2; }
.page-desc  { color: var(--muted); font-size: 13px; margin: 0; }
.title-count {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 400;
    color: var(--muted);
    vertical-align: super;
}

/* ================= Przyciski ================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
    border-radius: var(--radius);
    padding: 10px 16px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.sm { padding: 5px 10px; font-size: 11px; border-radius: var(--radius-ctl); }
/* "block" to klasa Tailwinda (display: block) - stad "full" */
.btn.full { width: 100%; }

.btn-primary, .btn-primary[type] { background: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(200, 25, 36, .22); }
.btn-primary:hover, .btn-primary[type]:hover { background: var(--brand-dark); }

.btn-outline, .btn-outline[type] {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-input);
}
.btn-outline:hover, .btn-outline[type]:hover { background: var(--active); }

.btn-danger, .btn-danger[type] { background: var(--error); color: #fff; }
.btn-danger:hover, .btn-danger[type]:hover { filter: brightness(0.92); }

.btn-navy, .btn-navy[type] { background: var(--navy); color: #fff; }
.btn-navy:hover, .btn-navy[type]:hover { background: var(--navy-2); }

/* Ikona w przycisku akcji tabeli */
.btn-icon, .btn-icon[type] {
    display: inline-grid; place-items: center;
    width: 28px; height: 28px; padding: 0;
    border: 1px solid var(--border-input); border-radius: var(--radius-ctl);
    background: var(--surface); color: var(--navy); cursor: pointer; text-decoration: none;
}
.btn-icon:hover, .btn-icon[type]:hover { background: var(--active); color: var(--brand); border-color: var(--brand); }
.btn-icon.danger:hover { color: var(--error); border-color: var(--error); }
.btn-icon svg { width: 15px; height: 15px; }

/* ================= Pola ================= */
.input {
    background: var(--surface);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-ctl);
    padding: 8px 16px;
    font-size: 12px;
    font-family: var(--font-sans);
    color: var(--text);
    width: 100%;
}
.input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
.input.inline { width: auto; min-width: 170px; }
.input.sm { padding: 5px 8px; font-size: 11px; }
select.input { padding-right: 32px; }
textarea.input { resize: vertical; font: inherit; font-size: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-hint { font-size: 11px; color: var(--muted); }
.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; }
.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; }
@media (max-width: 620px) {
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: span 1; }
}

/* Pole wyszukiwania z ikona lupy */
.search { position: relative; flex: 1 1 320px; max-width: 420px; }
.search .input { padding-left: 36px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted-2); pointer-events: none; }

/* ================= Filtry i pigulki ================= */
.filters { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.pill, .pill[type] {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    border-radius: var(--radius-ctl);
    padding: 6px 12px;
    border: 1px solid var(--border-input);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
}
.pill:hover, .pill[type]:hover { background: var(--active); }
.pill.active, .pill.active[type] { background: var(--navy); color: #fff; border-color: var(--navy); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pill .count { font-family: var(--font-mono); font-weight: 400; opacity: .8; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot-ok      { background: var(--ok); }
.dot-warn    { background: var(--warn); }
.dot-error   { background: var(--error); }
.dot-offline { background: var(--offline); }
.dot-info    { background: var(--info); }
.dot-brand   { background: var(--brand); }

/* Plakietka statusu w tabeli: kropka + nazwa, bez kolorowego tla */
.status-tag {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 700; color: var(--text);
    border: 1px solid var(--border-input); border-radius: var(--radius-ctl);
    padding: 3px 9px; background: var(--surface); white-space: nowrap;
}
/* Statusy ofert - kolor kropki z data-status (pigulki filtrow, plakietki, lista wyboru).
   Odpowiedniki stanow urzadzen z LNet2: przygotowana szara, wyslana bursztynowa,
   akceptacja zielona, odrzucona czerwona, nieoplacalna blekitna. */
[data-status="draft"]      { --status: var(--offline); }
[data-status="sent"]       { --status: var(--warn); }
[data-status="accepted"]   { --status: var(--ok); }
[data-status="rejected"]   { --status: var(--error); }
[data-status="not_viable"] { --status: var(--info); }
[data-status] > .dot, [data-status] .status-dot { background: var(--status, var(--offline)); }

.status-wrap { position: relative; display: inline-flex; align-items: center; }
.status-wrap > .dot { position: absolute; left: 9px; pointer-events: none; }
.status-select {
    -webkit-appearance: none; appearance: none;
    font-family: var(--font-sans); font-size: 11px; font-weight: 700; color: var(--text);
    padding: 4px 26px 4px 23px; cursor: pointer;
    border: 1px solid var(--border-input); border-radius: var(--radius-ctl);
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235A6472' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 7px center / 11px;
}
.status-select:hover { border-color: var(--muted-2); }
.status-select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* Wyslane przypomnienie mailowe - pulsujaca kropka */
.reminder {
    display: inline-flex; align-items: center; gap: 5px; cursor: help;
    font-size: 10px; font-weight: 700; color: var(--brand);
    background: var(--brand-soft); border-radius: 4px; padding: 2px 6px;
}
.reminder .dot { background: var(--brand); position: relative; width: 7px; height: 7px; }
.reminder .dot::after {
    content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--brand);
    animation: reminder-ping 1.4s cubic-bezier(0, 0, .2, 1) infinite;
}
@keyframes reminder-ping { 75%, 100% { transform: scale(2.4); opacity: 0; } }

.link-action, .link-action[type] {
    background: none; border: none; padding: 0; cursor: pointer; font-family: inherit;
    font-size: 11px; font-weight: 700; color: var(--brand); text-decoration: none;
}
.link-action:hover { text-decoration: underline; }

/* Lista zmian w oknie "Co nowego?" */
.changelog-list { display: flex; flex-direction: column; gap: 10px; }
.changelog-item {
    border: 1px solid var(--border); border-left: 3px solid var(--brand);
    border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12px; line-height: 1.5; color: var(--text-2);
}
.changelog-item b:first-child { display: block; color: var(--navy); font-size: 12px; margin-bottom: 2px; }
.changelog-item.navy { border-left-color: var(--navy); }

/* Etykieta modelu / znacznika (monospace, szare tlo) */
.tag {
    display: inline-flex; align-items: center; gap: 4px;
    font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--navy);
    background: var(--active); border-radius: 4px; padding: 2px 7px; white-space: nowrap;
}
.tag.warn { background: rgba(234, 179, 8, .12); color: #8A6100; }
.tag.ok { background: rgba(63, 163, 77, .12); color: var(--ok); }
.tag.brand { background: var(--brand-soft); color: var(--brand); }

.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;
    white-space: nowrap;
}

/* ================= Tabela ================= */
.table { width: 100%; border-collapse: collapse; }
.table th {
    background: var(--bg);
    color: var(--navy);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
/* Wiersze gesto, jak lista urzadzen w LNet2: interlinia 1,3 zamiast 1,5 z preflightu
   Tailwinda i 6 px odstepu - komorka z nazwa i adresem pod spodem ma ok. 42 px, nie 56. */
.table td {
    font-size: 12px;
    line-height: 1.3;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr { background: var(--surface); }
.table tbody tr:hover { background: var(--active); }
.table tbody tr:last-child td { border-bottom: none; }
.table th.right, .table td.right { text-align: right; }
.table th.center, .table td.center { text-align: center; }
.table .empty { text-align: center; color: var(--muted); padding: 32px; }
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }

.offer-id { color: var(--brand); font-size: 12px; font-weight: 700; text-decoration: none; }
a.offer-id:hover { text-decoration: underline; }
.cell-title { font-weight: 700; font-size: 12px; color: var(--navy); }
.cell-sub   { color: var(--muted); font-size: 11px; }
.row-actions { display: inline-flex; gap: 4px; justify-content: flex-end; }

/* Pasek nad tabela w karcie (wyszukiwarka, filtry) */
.table-toolbar {
    display: flex; gap: 12px 16px; align-items: center; justify-content: space-between; flex-wrap: wrap;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
}

.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); }

/* ================= Zakladki ================= */
.tabs {
    display: flex;
    gap: 4px;
    margin: 20px 0 16px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.tab, .tab[type] {
    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;
    text-decoration: none;
    display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--brand);
             color: #fff; font-size: 10px; line-height: 18px; text-align: center; font-family: var(--font-mono); }

/* ================= Komunikaty ================= */
.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;
    color: var(--text);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.notice.ok { border-color: var(--ok); }
.notice.warn { border-color: #EAB308; background: rgba(234,179,8,.08); color: #8A6100; font-weight: 600; }
.notice-close { background: none; border: none; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; }

.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;
}
.alert.ok { background: rgba(63, 163, 77, .08); color: var(--ok); border-color: var(--ok); }

.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); }

/* ================= Okna dialogowe ================= */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 200;
    display: flex; align-items: center; justify-content: center; padding: 16px;
    background: rgba(20, 28, 58, 0.55);
}
.modal-backdrop.hidden { display: none; }
.modal-card {
    width: min(520px, calc(100vw - 32px)); max-height: 92vh; overflow-y: auto;
    background: var(--surface); border-radius: var(--radius); padding: 20px;
    box-shadow: 0 30px 80px rgba(5, 8, 25, .30), 0 2px 6px rgba(5, 8, 25, .12);
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.modal-head .widget-title { margin-bottom: 0; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px; }
.modal-close:hover { color: var(--brand); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ================= Nawigacja =================
   Pasek na cala szerokosc: logo z nazwa portalu, zakladki, dzwonek,
   zgloszenie bledu, uzytkownik i wylogowanie - jak w LNet2. */
.nav {
    /* backdrop-filter tworzy wlasny kontekst nakladania - bez z-index
       wykresy z tresci strony rysowaly sie nad lista powiadomien. */
    position: relative; z-index: 100;
    background: rgba(255, 255, 255, .92);
    -webkit-backdrop-filter: saturate(1.4) blur(8px);
            backdrop-filter: saturate(1.4) blur(8px);
    box-shadow: 0 1px 0 var(--border), 0 6px 20px rgba(20, 28, 58, .04);
}
.nav-inner {
    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-logo { height: 32px; width: auto; display: block; }
/* Nazwa portalu obok logo i pod spodem podpis. */
.brand-tag {
    display: flex; flex-direction: column; justify-content: center; line-height: 1.15;
    padding-left: 10px; border-left: 1px solid var(--border); white-space: nowrap;
}
.brand-tag b { font-size: 15px; font-weight: 800; letter-spacing: .2px; color: var(--navy); }
.brand-tag small { font-size: 10px; font-weight: 600; letter-spacing: .3px; color: var(--muted); }

.nav-links { display: flex; gap: 4px; flex: 1; justify-content: center; }
.nav a { color: var(--navy); position: relative; text-decoration: none; }
.nav-links a {
    font-size: 12px;
    font-weight: 700;
    border-radius: var(--radius-ctl);
    padding: 8px 12px;
    white-space: nowrap;
}
.nav-links a:hover { background: var(--active); }
.nav-links a.active { 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);
}

.nav-feedback { display: flex; gap: 6px; }
.nav-user { text-align: right; line-height: 1.3; }
a.nav-user { color: inherit; border-radius: var(--radius-ctl); padding: 4px 6px; }
a.nav-user:hover { background: var(--active); }
.nav-user-name { font-size: 12px; font-weight: 700; color: var(--navy); white-space: nowrap; }
.nav-user-mail { font-size: 11px; color: var(--muted); }
.nav-logout { margin: 0; display: flex; gap: 8px; }
.nav-logout .btn { white-space: nowrap; }

.nav-toggle, .nav-toggle[type] {
    display: none; background: none; border: 1px solid var(--border); border-radius: var(--radius-ctl);
    width: 40px; height: 38px; place-items: center; cursor: pointer; color: var(--navy); padding: 0;
}

/* Analiza faktur w tle - pigulka w pasku */
.nav-job {
    display: none; align-items: center; gap: 8px;
    font-family: var(--font-mono); font-size: 11px; font-weight: 700; white-space: nowrap;
    color: var(--brand); background: var(--brand-tint); border: 1px solid var(--brand-soft);
    border-radius: var(--radius-ctl); padding: 6px 10px; cursor: pointer;
}
.nav-job.show { display: inline-flex; }
.nav-job .spin {
    width: 10px; height: 10px; border-radius: 50%; flex: none;
    border: 2px solid currentColor; border-right-color: transparent;
    animation: nav-spin .8s linear infinite;
}
@keyframes nav-spin { to { transform: rotate(360deg); } }

/* Elementy paska nie kurcza sie - inaczej przy braku miejsca nachodzily na siebie
   zamiast zwinac menu. Zakladki maja flex: 1, ale nie zejda ponizej swojej tresci. */
.nav-inner > * { flex-shrink: 0; }

/* Gdy pasek przestaje sie miescic, decyduje skrypt fitNav() w base.html (liczba
   zakladek zalezy od roli: instalator 4, administrator 7). Kolejne kroki:
   .tight  - chowa podpis pod nazwa portalu,
   .split  - zakladki schodza do drugiego wiersza pod logo, na cala szerokosc
             (zostaja widoczne - menu z trzema kreskami bylo na komputerze niewygodne),
   .slim   - w pierwszym wierszu znika blok z nazwiskiem i e-mailem,
   .compact - dopiero telefon: menu, uzytkownik i wylogowanie w panelu rozwijanym
             spod paska (przycisk z trzema kreskami), jak w LNet2.
   Media query ponizej 760 px to zabezpieczenie bez JS. */
.nav.tight .brand-tag small { display: none; }

.nav.split .nav-inner { flex-wrap: wrap; row-gap: 0; column-gap: 16px; padding-bottom: 0; }
.nav.split .brand { margin-right: auto; }
.nav.split .nav-links {
    order: 10; flex-basis: 100%; justify-content: center; gap: 4px;
    margin: 10px 0 0; padding: 4px 0 6px; border-top: 1px solid var(--border);
}
.nav.split .nav-links > a.active::after { bottom: -6px; }
.nav.slim .nav-user { display: none; }

.nav.compact .nav-inner { flex-wrap: wrap; row-gap: 0; column-gap: 12px; padding-bottom: 10px; }
.nav.compact .nav-toggle { display: grid; order: 3; }
.nav.compact .bell { order: 2; margin-left: auto; }
.nav.compact .nav-job { order: 1; margin-left: auto; }
.nav.compact .nav-job.show ~ .bell { margin-left: 0; }
.nav.compact .nav-links, .nav.compact .nav-user,
.nav.compact .nav-logout, .nav.compact .nav-feedback { display: none; order: 10; flex-basis: 100%; }
.nav.compact.open .nav-feedback { display: flex; padding: 4px 12px 10px; }
.nav.compact.open .nav-links { display: flex; flex-direction: column; gap: 2px; padding: 10px 0 6px; margin: 10px 0 0; border-top: 1px solid var(--border); }
.nav.compact.open .nav-links a { padding: 12px; font-size: 14px; }
.nav.compact.open .nav-links a.active { background: var(--active); }
.nav.compact.open .nav-user { display: block; text-align: left; padding: 10px 12px; border-top: 1px solid var(--border); }
.nav.compact.open .nav-logout { display: flex; padding: 0 12px 12px; }
.nav.compact.open .nav-logout .btn { flex: 1; text-align: center; }
.nav.compact .nav-links > a.active::after { display: none; }
@media (max-width: 760px) {
    .nav-inner { flex-wrap: wrap; row-gap: 0; column-gap: 12px; }
    .nav-toggle, .nav-toggle[type] { display: grid; order: 3; }
    .bell { order: 2; margin-left: auto; }
    .nav-links, .nav-user, .nav-logout, .nav-feedback { display: none; order: 10; flex-basis: 100%; }
    .nav.open .nav-feedback { display: flex; padding: 4px 12px 10px; }
    .nav.open .nav-links { display: flex; flex-direction: column; gap: 2px; padding: 10px 0 6px; border-top: 1px solid var(--border); margin-top: 10px; }
    .nav.open .nav-links a { padding: 12px; font-size: 14px; }
    .nav.open .nav-user { display: block; text-align: left; padding: 10px 12px; border-top: 1px solid var(--border); }
    .nav.open .nav-logout { display: flex; padding: 0 12px 12px; }
    .nav.open .nav-logout .btn { flex: 1; text-align: center; }
    .nav-links > a.active::after { display: none; }
}
@media (max-width: 480px) {
    .brand-tag small { display: none; }
    /* "Portal Ofertowy" jest dluzsze niz "LNet2" - na telefonie mniejsze logo i nazwa,
       zeby dzwonek i menu zostaly w jednym wierszu z logo */
    .nav-inner { padding: 10px 16px; }
    .nav.compact .nav-inner, .nav-inner { column-gap: 10px; }
    .brand { gap: 8px; }
    .brand-logo { height: 26px; }
    .brand-tag { padding-left: 8px; }
    .brand-tag b { font-size: 13px; }
    .bell { margin-right: 0; }
    .bell-panel { position: fixed; left: 16px; right: 16px; top: 64px; width: auto; }
}

/* ================= Dzwonek powiadomien ================= */
.bell { position: relative; margin-right: 8px; }
.bell-btn, .bell-btn[type] {
    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, .bell-btn[type]: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 {
    position: sticky; top: 0; z-index: 1; background: var(--surface);
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--navy);
}
.bell-link, .bell-link[type] { background: none; border: none; color: var(--brand); font-size: 11px; font-weight: 700; cursor: pointer; padding: 0; font-family: inherit; }
.bell-item { display: flex; border-bottom: 1px solid var(--border); }
.bell-open {
    flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding: 10px 14px 10px 4px;
    text-decoration: none; color: var(--text); font-size: 12px;
}
a.bell-open:hover { background: var(--active); }
/* Lewa krawedz: pasek = nieprzeczytane; klik oznacza jako przeczytane */
.bell-mark, .bell-mark[type] {
    flex: 0 0 14px; position: relative; padding: 0; border: none; background: none; cursor: pointer;
}
.bell-mark::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: transparent;
    transition: width .12s, background .12s;
}
.bell-item.unread .bell-mark::before { background: var(--brand); }
.bell-item.unread .bell-mark:hover::before { width: 6px; opacity: .6; }
.bell-item.unread .bell-title { font-weight: 800; }
.bell-title { color: var(--navy); font-weight: 600; }
.bell-del, .bell-del[type] {
    flex: 0 0 28px; align-self: flex-start; margin: 6px 6px 0 0; height: 28px; padding: 0;
    border: none; border-radius: 50%; background: none; cursor: pointer;
    color: var(--muted); font-size: 18px; line-height: 28px; opacity: .45;
}
.bell-item:hover .bell-del { opacity: 1; }
.bell-del:hover, .bell-del[type]:hover { background: var(--active); color: var(--brand); }
.bell-body { color: var(--muted); line-height: 1.4; overflow-wrap: anywhere; }
.bell-time { font-size: 10px; color: var(--muted); font-family: var(--font-mono); }
.bell-empty { padding: 16px 14px; font-size: 12px; color: var(--muted); }

/* ================= Powiadomienie (toast) ================= */
.toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
    pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; max-width: 380px;
    background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--ok);
    border-radius: var(--radius-sm); padding: 12px 14px; box-shadow: 0 12px 32px rgba(20, 28, 58, .16);
    font-size: 12px; color: var(--text);
}
.toast b { color: var(--navy); }
.toast p { margin: 2px 0 0; color: var(--muted); }
.toast a { color: var(--brand); font-weight: 700; text-decoration: none; }
.toast-close, .toast-close[type] { background: none; border: none; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; padding: 0; }

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

@media (max-width: 720px) {
    .page { padding: 16px; }
    .table-card { overflow-x: auto; }
}

/* ================= Logowanie: 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; right: 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;
}
.auth-stage.single { grid-template-columns: minmax(0, 1fr); justify-items: center; }
.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);
}
/* Romb z motywu graficznego LOPI zamiast punktora */
.auth-points li::before {
    content: ""; flex: none; width: 8px; height: 8px;
    border: 2px solid var(--brand); transform: rotate(45deg);
}

.auth-card {
    width: 100%; max-width: 400px; padding: 32px;
    background: var(--surface);
    border: none; border-top: 4px solid var(--brand);
    border-radius: var(--radius);
    box-shadow: 0 30px 80px rgba(5, 8, 25, .45), 0 2px 6px rgba(5, 8, 25, .2);
}
.auth-card.wide { max-width: 480px; }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.login-title { font-size: 20px; font-weight: 800; margin: 0 0 4px; color: var(--navy); }
.login-sub { font-size: 13px; color: var(--muted); margin: 0; }
.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.login-form .btn { width: 100%; }
.login-alt {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}
.login-alt a, .link-muted { color: var(--brand); font-weight: 700; text-decoration: none; }
.link-muted { color: var(--muted-2); font-weight: 400; font-size: 11px; }
.link-muted:hover { color: var(--brand); }

/* Ponizej 960 px scena zwija sie do jednej kolumny - sekcja hasla znika,
   bo na telefonie liczy sie samo pole logowania. */
@media (max-width: 960px) {
    .auth-stage { grid-template-columns: minmax(0, 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; }
}
