/* ==========================================================================
   Baza Spawania - warstwa wizualna

   Bez frameworka CSS i bez DevExpressa. Kolor wiodacy #305088 pochodzi z logo
   Verlogic. Wszystkie pary tekst/tlo sprawdzone pod katem WCAG AA:
   bialy na #305088 daje 7,99:1, tekst podstawowy na bieli 15,52:1,
   tekst drugorzedny 6,20:1, tekst pomocniczy 4,83:1.
   ========================================================================== */

:root {
    /* marka */
    --brand:        #305088;
    --brand-dark:   #243E68;
    --brand-light:  #E8EEF7;
    --brand-tint:   #F2F6FC;

    /* tekst */
    --ink:          #1F2430;
    --ink-soft:     #5B6170;
    /* 4,83:1 na bieli i 4,50:1 na tle strony - tekst pomocniczy tez musi spelniac AA */
    --ink-faint:    #6B7280;
    --on-brand:     #FFFFFF;

    /* powierzchnie */
    --bg:           #F5F7FA;
    --surface:      #FFFFFF;
    --line:         #D8DEE8;
    --line-soft:    #E8ECF2;

    /* stany */
    --ok:           #1F7A4D;
    --ok-bg:        #E8F5EE;
    --warn:         #8A5A00;
    --warn-bg:      #FDF4E3;
    --danger:       #B42318;
    --danger-bg:    #FDECEA;

    /* ksztalt i rytm */
    --r-sm: 4px;
    --r:    8px;
    --r-lg: 12px;
    --shadow:    0 1px 2px rgba(31, 36, 48, .06), 0 2px 8px rgba(31, 36, 48, .06);
    --shadow-lg: 0 8px 28px rgba(31, 36, 48, .14);

    --header-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; }

/* atrybut hidden wygrywa z klasami ustawiajacymi display (.toolbar, .grid-form...) -
   inaczej przelaczane grupy pol (np. miejsce wykonania spoiny) bylyby widoczne mimo hidden */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font: 15px/1.55 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 600; color: var(--ink); }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
p { margin: 0 0 1em; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- widoczny focus klawiatury: jedna regula dla calej aplikacji --- */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
    outline: 3px solid var(--brand);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}
.topbar a:focus-visible, .topbar button:focus-visible { outline-color: #FFFFFF; }

/* --- pasek gorny --- */
.topbar {
    position: sticky; top: 0; z-index: 50;
    height: var(--header-h);
    background: var(--brand);
    color: var(--on-brand);
    display: flex; align-items: center; gap: 20px;
    padding: 0 20px;
    box-shadow: var(--shadow);
}
/* brand jest odnosnikiem, wiec regula "a { color: var(--brand) }" wygrywa
   z kolorem dziedziczonym z paska - nazwa systemu znikala wtedy w tle */
.topbar .brand { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; color: var(--on-brand); }
.topbar .brand:hover { color: var(--on-brand); text-decoration: none; }
.topbar .brand img { height: 30px; width: auto; display: block; }
.topbar .brand .sep { width: 1px; height: 26px; background: rgba(255,255,255,.35); }
.topbar .brand .title { font-weight: 600; letter-spacing: .02em; white-space: nowrap; }

.topbar nav { display: flex; gap: 2px; flex: 1 1 auto; }
.topbar nav a {
    color: rgba(255,255,255,.86);
    padding: 8px 13px; border-radius: var(--r-sm);
    font-weight: 500; white-space: nowrap;
}
.topbar nav a:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.topbar nav a.active { background: rgba(255,255,255,.18); color: #fff; }

.topbar .user { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; font-size: 14px; }
.topbar .user .who { color: rgba(255,255,255,.9); }
.topbar .user form { margin: 0; }
.topbar .user button {
    background: transparent; border: 1px solid rgba(255,255,255,.45);
    color: #fff; padding: 6px 12px; border-radius: var(--r-sm);
    font: inherit; cursor: pointer;
}
.topbar .user button:hover { background: rgba(255,255,255,.14); }
/* przejscie do drugiej aplikacji (Baza Spawania / Projekty Inwestycyjne) - ten sam login */
.topbar .user .app-switch {
    color: #fff; padding: 6px 12px; border-radius: var(--r-sm); white-space: nowrap;
    background: rgba(255,255,255,.12); text-decoration: none;
}
.topbar .user .app-switch:hover { background: rgba(255,255,255,.22); color: #fff; text-decoration: none; }

.hamburger { display: none; background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; padding: 6px 8px; }

/* --- układ strony --- */
.page { max-width: 1320px; margin: 0 auto; padding: 22px 20px 60px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .grow { flex: 1 1 260px; min-width: 0; }
.page-head .lead { color: var(--ink-soft); margin: 0; }

.crumbs { font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.crumbs a { color: var(--ink-soft); }
.crumbs span { padding: 0 6px; color: var(--ink-faint); }

/* --- karty --- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.card > header {
    padding: 14px 18px; border-bottom: 1px solid var(--line-soft);
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card > header h2, .card > header h3 { margin: 0; }
.card > header .grow { flex: 1 1 auto; }
.card > .body { padding: 18px; }
.card > .body.tight { padding: 0; }

/* --- kafelki podsumowania --- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 15px 17px; }
.tile .label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); font-weight: 600; }
.tile .value { font-size: 27px; font-weight: 600; color: var(--brand); line-height: 1.2; margin-top: 4px; }
.tile .hint { font-size: 12px; color: var(--ink-faint); }

/* --- przyciski --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    min-height: 38px; padding: 0 16px;
    border: 1px solid transparent; border-radius: var(--r-sm);
    font: inherit; font-weight: 500; cursor: pointer;
    background: var(--brand); color: #fff;
    transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--brand); border-color: var(--line); }
.btn.secondary:hover { background: var(--brand-tint); color: var(--brand-dark); }
.btn.ghost { background: transparent; color: var(--ink-soft); border-color: transparent; }
.btn.ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #8F1B12; }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn-row.end { justify-content: flex-end; }

/* --- formularze --- */
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px 18px; }
.grid-form .span-2 { grid-column: span 2; }
.grid-form .span-all { grid-column: 1 / -1; }
@media (max-width: 640px) { .grid-form .span-2 { grid-column: span 1; } }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field > label .req { color: var(--danger); }
.field .help { font-size: 12px; color: var(--ink-faint); }

/* pola tekstowe wszystkich rodzajow - takze tel/url i pola bez atrybutu type (domyslnie tekst);
   bez nich telefon i pola pisane recznie dostawaly waska szerokosc przegladarki */
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number],
input[type=tel], input[type=url], input[type=date], input[type=time], input[type=datetime-local],
input[type=month], input[type=week], input[type=search], select, textarea {
    width: 100%; min-height: 38px; padding: 7px 10px;
    border: 1px solid var(--line); border-radius: var(--r-sm);
    font: inherit; color: var(--ink); background: var(--surface);
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
input[readonly], input[disabled], select[disabled], textarea[disabled] { background: var(--bg); color: var(--ink-soft); }

.checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.checkbox input { width: 17px; height: 17px; min-height: 0; accent-color: var(--brand); }

.field-error { color: var(--danger); font-size: 13px; }
input.invalid, select.invalid, textarea.invalid { border-color: var(--danger); }

/* --- komunikaty --- */
.alert { border-radius: var(--r); padding: 11px 14px; margin-bottom: 16px; border: 1px solid transparent; font-size: 14px; }
.alert.ok     { background: var(--ok-bg);     border-color: #BFE3CF; color: var(--ok); }
.alert.error  { background: var(--danger-bg); border-color: #F3C7C2; color: var(--danger); }
.alert.warn   { background: var(--warn-bg);   border-color: #EBD4A3; color: var(--warn); }
.alert.info   { background: var(--brand-light); border-color: #C6D5EC; color: var(--brand-dark); }

/* --- tabele --- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data thead th {
    background: var(--brand-tint); color: var(--ink-soft);
    font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600;
    white-space: nowrap; position: sticky; top: 0;
}
table.data tbody tr:hover { background: var(--brand-tint); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data tbody tr.selected { background: var(--brand-light); }

.empty { padding: 40px 20px; text-align: center; color: var(--ink-soft); }
.empty .big { font-size: 17px; color: var(--ink); margin-bottom: 6px; }

/* --- etykiety statusu --- */
.badge {
    display: inline-block; padding: 2px 9px; border-radius: 20px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
    background: var(--line-soft); color: var(--ink-soft);
}
.badge.ok     { background: var(--ok-bg);     color: var(--ok); }
.badge.warn   { background: var(--warn-bg);   color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.brand  { background: var(--brand-light); color: var(--brand-dark); }

/* --- pasek narzedzi nad lista --- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0; }
.toolbar input[type=search] { min-width: 230px; width: auto; }
.toolbar select { min-width: 170px; width: auto; }
.toolbar .grow { flex: 1 1 auto; }

/* --- stronicowanie --- */
.pager { display: flex; gap: 6px; align-items: center; justify-content: space-between; padding: 12px 18px; border-top: 1px solid var(--line-soft); flex-wrap: wrap; }
.pager .info { color: var(--ink-soft); font-size: 13px; }
.pager .links { display: flex; gap: 4px; }
.pager a, .pager span.current {
    min-width: 34px; height: 32px; padding: 0 9px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 14px;
}
.pager span.current { background: var(--brand); color: #fff; border-color: var(--brand); }

/* --- zakladki --- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a {
    padding: 10px 16px; color: var(--ink-soft); font-weight: 500;
    border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a:hover { color: var(--brand); text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* --- strona logowania i rejestracji --- */
.auth { min-height: calc(100vh - var(--header-h)); display: flex; align-items: flex-start; justify-content: center; padding: 48px 20px; }
.auth .box { width: 100%; max-width: 440px; }
.auth .box.wide { max-width: 760px; }
.auth .logo { text-align: center; margin-bottom: 24px; }
.auth .logo img { width: 100%; max-width: 240px; height: auto; }
/* „Nie pamietam hasla” pod polem hasla - sam link, nie na cala szerokosc pola */
.auth .forgot { align-self: flex-end; }

/* --- strona glowna --- */
.hero { background: var(--brand); color: #fff; }
.hero .inner { max-width: 1320px; margin: 0 auto; padding: 64px 20px 72px; }
.hero img.logo { width: 100%; max-width: 260px; height: auto; background: #fff; padding: 14px 18px; border-radius: var(--r); margin-bottom: 26px; }
.hero h1 { color: #fff; font-size: clamp(27px, 4vw, 42px); max-width: 20ch; margin-bottom: 14px; }
.hero p.lead { color: rgba(255,255,255,.88); font-size: clamp(16px, 1.6vw, 19px); max-width: 60ch; margin-bottom: 28px; }
.hero .btn.secondary { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.5); }
.hero .btn.secondary:hover { background: rgba(255,255,255,.2); }
.hero .btn:not(.secondary) { background: #fff; color: var(--brand-dark); }
.hero .btn:not(.secondary):hover { background: var(--brand-light); }

.features { max-width: 1320px; margin: 0 auto; padding: 56px 20px; }
.features h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-soft); margin-bottom: 26px; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; }
.feature .n { width: 34px; height: 34px; border-radius: var(--r); background: var(--brand); color: #fff;
              display: grid; place-items: center; font-weight: 700; margin-bottom: 13px; }
.feature h3 { color: var(--brand-dark); }
.feature p { color: var(--ink-soft); margin: 0; font-size: 14px; }

/* strona startowa: nazwa aplikacji nad tytulem, kroki pracy i pasek drugiej aplikacji */
.hero .app-tag { display: inline-block; margin-bottom: 12px; font-size: 13px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: rgba(255,255,255,.82); }
.hero .also { margin: 22px 0 0; font-size: 14px; color: rgba(255,255,255,.82); }
.hero .also a { color: #fff; text-decoration: underline; }
.features + .features { padding-top: 0; }
.steps { list-style: none; counter-reset: krok; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 24px; margin: 0; padding: 0; }
.steps li { counter-increment: krok; border-top: 3px solid var(--brand); padding-top: 14px; }
.steps li::before { content: counter(krok, decimal-leading-zero); display: block; margin-bottom: 6px; font-size: 14px; font-weight: 700; color: var(--brand); }
.steps h3 { margin: 0 0 6px; }
.steps p { margin: 0; font-size: 14px; color: var(--ink-soft); }
.apps-band {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
    background: var(--brand-tint); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px 24px;
}
.apps-band h3 { margin: 0 0 4px; font-size: 18px; color: var(--brand-dark); }
.apps-band p { margin: 0; max-width: 70ch; color: var(--ink-soft); }

/* --- drzewo dokumentacji --- */
.docs { display: grid; grid-template-columns: minmax(240px, 330px) 1fr; gap: 18px; align-items: start; }
@media (max-width: 860px) { .docs { grid-template-columns: 1fr; } }

.tree { list-style: none; margin: 0; padding: 6px; font-size: 14px; }
.tree ul { list-style: none; margin: 0; padding-left: 17px; border-left: 1px solid var(--line-soft); }
.tree li { margin: 1px 0; }
.tree .node {
    display: flex; align-items: center; gap: 7px;
    padding: 5px 8px; border-radius: var(--r-sm); color: var(--ink);
    width: 100%; text-align: left; border: 0; background: none; font: inherit; cursor: pointer;
}
.tree .node:hover { background: var(--brand-tint); text-decoration: none; }
.tree .node.current { background: var(--brand-light); color: var(--brand-dark); font-weight: 600; }
.tree .node .ico { flex: 0 0 auto; width: 18px; text-align: center; color: var(--ink-faint); }
.tree .node.folder .ico { color: var(--brand); }
.tree .node .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* wysokosc rezerwujemy tylko w panelu dokumentow - ta sama siatka opisu
   sluzy tez kartom WPQR i WPS, gdzie pusty pas pod trescia wyglada na blad */
.docs .preview { min-height: 340px; }
.preview .meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.preview .meta .k { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); font-weight: 600; }
.preview .meta .v { font-size: 14px; }
.preview .frame { width: 100%; height: 540px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); }
.preview img.shot { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--r); }

/* --- drobiazgi --- */
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.stack > * + * { margin-top: 14px; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- telefon --- */
@media (max-width: 860px) {
    .topbar { gap: 10px; padding: 0 12px; }
    .topbar .brand .title { display: none; }
    .topbar nav {
        display: none; position: absolute; top: var(--header-h); left: 0; right: 0;
        flex-direction: column; background: var(--brand-dark); padding: 8px; gap: 2px;
        box-shadow: var(--shadow-lg);
    }
    .topbar nav.open { display: flex; }
    .hamburger { display: block; }
    .topbar .user .who { display: none; }
    .topbar .user .app-switch { padding: 6px 8px; font-size: 13px; }
    .page { padding: 16px 12px 48px; }
    .card > .body { padding: 14px; }
    .card > form > .body:not(.tight) { padding: 14px; }
    .bulk { padding: 12px; }
    .btn-row .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ==========================================================================
   Panel ustawień, awatary i oś czasu historii
   ========================================================================== */

/* --- awatary --- */
.avatar {
    width: 36px; height: 36px; flex: 0 0 auto;
    border-radius: 50%; object-fit: cover;
    border: 1px solid var(--line);
    background: var(--bg);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600; letter-spacing: .02em;
    overflow: hidden; vertical-align: middle;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 72px; height: 72px; font-size: 24px; }

/* Zastępczy awatar: barwa z nazwy. Jasność i nasycenie są stałe, więc tekst
   w kolorze z tego samego odcienia, ale znacznie ciemniejszy, trzyma kontrast
   powyżej 4,5:1 niezależnie od wylosowanego odcienia. */
.avatar.fallback {
    background: hsl(var(--av, 210) 42% 90%);
    color: hsl(var(--av, 210) 65% 26%);
    border-color: hsl(var(--av, 210) 35% 80%);
}

.topbar .user .me { display: flex; align-items: center; gap: 9px; color: inherit; }
.topbar .user .me:hover { text-decoration: none; }
.topbar .user .me:hover .who { text-decoration: underline; }
.topbar .user .avatar { border-color: rgba(255,255,255,.4); }

/* --- układ panelu ustawień --- */
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.settings-grid > .card { margin-top: 0; }
.settings-grid + .card { margin-top: 18px; }

.logo-box {
    display: flex; align-items: center; justify-content: center;
    min-height: 110px; padding: 14px;
    border: 1px dashed var(--line); border-radius: var(--r); background: var(--bg);
}
.logo-box img { max-width: 100%; max-height: 90px; height: auto; display: block; }
.logo-box .empty-logo { color: var(--ink-faint); font-size: 13px; }

.avatar-box { display: flex; align-items: center; gap: 14px; }

/* formularz w wierszu tabeli - role i status zmienia się bez osobnego ekranu */
.row-form { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; margin: 0; max-width: 380px; margin-left: auto; }
/* obie listy musza pomiescic najdluzsza nazwe roli bez przycinania */
.row-form select { min-width: 150px; width: auto; flex: 1 1 150px; }
.row-form .reason { flex: 1 1 120px; width: auto; min-width: 0; }
.toolbar .reason { min-width: 170px; width: auto; }
/* pola dat w pasku filtrow nie moga rozpychac sie na cala szerokosc wiersza */
.toolbar input[type=date] { width: auto; min-width: 150px; }

/* --- oś czasu historii --- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 0; border-top: 1px solid var(--line-soft);
}
.timeline > li:first-child { border-top: 0; padding-top: 0; }
.timeline > li:last-child { padding-bottom: 0; }

.timeline .body { min-width: 0; flex: 1 1 auto; }
.timeline .head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.timeline .head .kind { color: var(--ink-soft); font-size: 13px; }
.timeline .changes { font-size: 13px; color: var(--ink); margin-top: 4px; overflow-wrap: anywhere; }
.timeline .comment {
    font-size: 13px; color: var(--ink-soft); margin-top: 4px;
    border-left: 2px solid var(--line); padding-left: 10px; font-style: italic;
    overflow-wrap: anywhere;
}
.timeline .meta { font-size: 12px; color: var(--ink-faint); margin-top: 5px; }

@media (max-width: 980px) {
    .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    .topbar .user .who { display: none; }
    .row-form { justify-content: flex-start; }
    .row-form .reason { width: 100%; }
}

/* ==========================================================================
   Uprawnienia
   ========================================================================== */

.perm-set { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px 12px; margin: 0; }
.perm-set legend { font-size: 13px; font-weight: 600; color: var(--ink-soft); padding: 0 6px; }

.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 18px; }
.perm-group .label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); font-weight: 600; margin-bottom: 5px; }
.perm-group .checkbox { margin-top: 3px; }
.perm-set .help { display: block; margin-top: 12px; font-size: 12px; color: var(--ink-faint); }

/* pole wyboru wylaczone to podglad, nie blokada - ma byc czytelne, nie wyblakle */
.perm-set input[disabled] + span { color: var(--ink); }
.perm-set input[disabled] { opacity: .9; }

/* zwiezle zestawienie uprawnien w tabeli kont */
.perm-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.perm-chips .chip {
    font-size: 12px; line-height: 1.5; padding: 1px 7px;
    border-radius: 999px; border: 1px solid var(--line); white-space: nowrap;
}
.perm-chips .chip.ro { background: var(--bg); color: var(--ink-soft); }
.perm-chips .chip.rw { background: var(--brand-light); color: var(--brand-dark); border-color: #C6D5EC; }

/* wiersz z rozwijanym edytorem konta */
table.data tr.editor-row td { padding-top: 0; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
table.data tr.editor-row summary { font-size: 13px; cursor: pointer; }
table.data tbody tr.editor-row:hover { background: transparent; }
table.data.users tbody tr:not(.editor-row) td { border-bottom: 0; }

/* ==========================================================================
   Spawacze, certyfikaty i załączniki PDF
   ========================================================================== */

/* Wyróżnienie terminu ważności. Pasek z lewej niesie informację niezależnie od
   koloru tła (czytelny także w druku i dla daltonistów), plakietka w wierszu
   mówi to samo słowem. */
table.data tbody tr.row-warn   { background: var(--warn-bg); }
table.data tbody tr.row-danger { background: var(--danger-bg); }
table.data tbody tr.row-warn   > td:first-child { box-shadow: inset 4px 0 0 #D9A23A; }
table.data tbody tr.row-danger > td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
table.data tbody tr.row-muted  { color: var(--ink-faint); }
table.data tbody tr.row-warn:hover   { background: #FAEBCD; }
table.data tbody tr.row-danger:hover { background: #FADAD6; }

.term { display: block; font-size: 12px; color: var(--ink-soft); }

/* plakietka na tle w tym samym odcieniu zlewa się z nim - na wyróżnionych
   wierszach i kafelkach dostaje białe tło i obrys */
tr.row-warn .badge.warn, tr.row-danger .badge.danger,
.welder-pick li.bad .badge.danger, .alert .badge {
    background: var(--surface); box-shadow: inset 0 0 0 1px currentColor;
}
.row-danger .term { color: var(--danger); font-weight: 600; }
.row-warn .term   { color: var(--warn); font-weight: 600; }

/* pasek ostrzeżeń nad listą - liczniki prowadzą do przefiltrowanej listy */
.alert .alert-links { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 4px; }
.alert .alert-links a { color: inherit; font-weight: 600; text-decoration: underline; }

/* --- pliki PDF: lista po lewej, podgląd po prawej --- */
.attachments { display: grid; grid-template-columns: minmax(220px, 320px) 1fr; gap: 18px; align-items: start; }
@media (max-width: 860px) { .attachments { grid-template-columns: 1fr; } }

.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list li {
    border: 1px solid var(--line); border-radius: var(--r); padding: 9px 11px;
    background: var(--surface);
}
.file-list li.active { border-color: var(--brand); background: var(--brand-tint); }
.file-list .name { display: block; font-weight: 600; overflow-wrap: anywhere; }
.file-list .info { display: block; font-size: 12px; color: var(--ink-faint); }
.file-list .desc { display: block; font-size: 13px; color: var(--ink-soft); margin-top: 2px; overflow-wrap: anywhere; }
.file-list .btn-row { margin-top: 7px; gap: 6px; }
.file-list form { margin: 0; }

.attachments .preview .frame { height: 640px; }
@media (max-width: 860px) { .attachments .preview .frame { height: 460px; } }

.upload-row { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(180px, 1fr) auto; gap: 10px; align-items: end; }
.upload-row input[type=file] { padding: 6px 0; font: inherit; font-size: 14px; }
@media (max-width: 760px) { .upload-row { grid-template-columns: 1fr; } }

/* --- wybór spawaczy przy spoinie --- */
.welder-pick { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.welder-pick li {
    border: 1px solid var(--line); border-radius: var(--r); padding: 9px 11px;
    display: flex; flex-direction: column; gap: 4px; background: var(--surface);
}
.welder-pick li.chosen { border-color: var(--brand); background: var(--brand-tint); }
.welder-pick li.chosen.bad { border-color: var(--danger); background: var(--danger-bg); }
.welder-pick .checkbox { font-weight: 600; }
.welder-pick .verdict { font-size: 12px; color: var(--ink-soft); padding-left: 25px; }
.welder-pick .verdict .badge { margin-right: 4px; }
.welder-pick-filter { max-width: 320px; margin-bottom: 10px; }
.weld-date { grid-template-columns: minmax(200px, 300px); }

.qual-problems { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.qual-problems li + li { margin-top: 2px; }

/* spawacze w wierszu listy spoin */
.welder-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.welder-chips .badge { font-weight: 600; }


/* --- dokumentacja powykonawcza --- */
.upload-row.four { grid-template-columns: minmax(180px, 1fr) minmax(200px, 1.2fr) minmax(200px, 1.2fr) auto; }
@media (max-width: 960px) { .upload-row.four { grid-template-columns: 1fr; } }

/* lista pol do zaznaczenia: kategorie, odcinki, personel w eksporcie */
.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.check-list li {
    display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px;
    border: 1px solid var(--line-soft); border-radius: var(--r); padding: 8px 11px; background: var(--surface);
}
.check-list li .badge { margin-right: 6px; }

/* edycja pliku rozwijana w wierszu tabeli */
.inline-edit { display: inline-block; }
.inline-edit > summary { list-style: none; }
.inline-edit > summary::-webkit-details-marker { display: none; }
.inline-edit[open] { display: block; }

/* --- konfiguracja projektu: badania NDT w kilku kolumnach --- */
.check-list.ndt-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* --- badania NDT przy spoinie --- */
.exam-table td { vertical-align: top; }
.exam-table input, .exam-table select { min-width: 110px; }
.exam-table .verdict { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.exam-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.exam-table .exam-comment { min-width: 180px; resize: vertical; }
/* wybor kilku badan na pasku listy spoin - lista rozwijana */
.exam-dropdown { position: relative; display: inline-block; }
.exam-dropdown > summary { list-style: none; cursor: pointer; }
.exam-dropdown > summary::-webkit-details-marker { display: none; }
.exam-dropdown-panel {
    position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 300px; max-height: 360px; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12); padding: 8px 12px; display: grid; gap: 6px;
}

/* operacje na zaznaczonych spoinach (dziennik, dobor WPS, badania) - sekcje leza
   w formularzu listy, wiec .card > .body ich nie obejmuje i odstepy maja wlasne */
.card > form > .body { padding: 18px; }
.card > form > .body.tight { padding: 0; }
.bulk-actions {
    display: grid; gap: 14px;
    background: var(--bg); border-top: 1px solid var(--line);
}
.bulk {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
    padding: 14px 16px;
}
.bulk-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.bulk-head h3 { font-size: 16px; margin: 0; }
.bulk .help {
    margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line-soft);
    font-size: 13px; line-height: 1.55; color: var(--ink-soft); max-width: 90ch;
}

/* --- obiekty: podglad mapy i model 3D --- */
.map-preview { margin-top: 12px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.map-preview iframe { display: block; width: 100%; height: 340px; border: 0; }
.model-3d { display: block; width: 100%; height: 480px; background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--r); }
.model-progress { display: none; }
@media (max-width: 760px) { .map-preview iframe { height: 260px; } .model-3d { height: 340px; } }

/* --- reklamacje: zakladki statusow, galeria zdjec, pola opisowe --- */
.status-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.status-chips a {
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; font-size: 14px;
    border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-soft); text-decoration: none;
}
.status-chips a b { font-weight: 600; color: var(--ink); }
.status-chips a:hover { border-color: var(--brand); color: var(--brand); }
.status-chips a.active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.status-chips a.active b { color: var(--on-brand); }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; }
.photo-grid li { position: relative; border: 1px solid var(--line-soft); border-radius: var(--r); overflow: hidden; background: var(--bg); }
.photo-grid img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.photo-grid .cap { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 4px 8px; font-size: 12px; color: var(--ink-soft); }
.photo-grid .cap form { margin: 0; }

/* izometria: miejsce wykonania - warsztat i montaz obok siebie, kazde ze swoimi polami */
.place-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.place-box { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; background: var(--surface); }

.capture-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
@media (max-width: 760px) { .capture-row { grid-template-columns: 1fr; } }

.note-field { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; margin: 0 0 14px; }
.note-field.req-now { border-left-color: var(--warn); }
.note-field .who { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }
.note-text { white-space: pre-wrap; margin: 0; }

/* --- awatar projektu: zaokraglony kwadrat, zeby nie mylil sie z osoba --- */
.avatar.project { border-radius: var(--r); }
th.avatar-col, td.avatar-col { width: 48px; padding-right: 0; }
td.avatar-col a { display: inline-flex; }
.page-head .project-avatar { margin-right: 4px; }
.page-head:has(> .project-avatar) { align-items: center; }

/* --- przelacznik jezyka w pasku gornym --- */
.topbar .lang-switch select {
    width: auto; min-width: 0; height: 30px; padding: 2px 6px; font-size: 13px;
    color: #fff; background: transparent; border: 1px solid rgba(255,255,255,.4); border-radius: var(--r-sm);
}
.topbar .lang-switch select:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.topbar .lang-switch option { color: var(--ink); background: var(--surface); }
@media (max-width: 760px) { .topbar .lang-switch select { max-width: 64px; } }

/* --- pole pliku z przyciskiem w jezyku interfejsu (app.js); natywne pole ukryte wizualnie, ale dostepne --- */
.file-picker { position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; padding: 4px 0; }
.file-picker input[type=file] {
    position: absolute; left: 0; top: 0; width: 1px; height: 1px; padding: 0; margin: 0;
    opacity: 0; overflow: hidden; border: 0;
}
.file-picker:focus-within .btn { outline: 2px solid var(--brand); outline-offset: 2px; }
.file-picker-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--ink-soft); }

/* --- pulpit uzytkownika --- */
/* Paleta wykresow: kazdy kolor ma co najmniej 3:1 do bieli (WCAG 1.4.11 dla grafiki).
   Kolor nie jest jedynym nosnikiem informacji - obok kazdego wykresu stoi tabela z liczbami. */
.c0 { --c: #305088; } .c1 { --c: #1F7A4D; } .c2 { --c: #B7791F; } .c3 { --c: #7B4FA0; }
.c4 { --c: #0E7C86; } .c5 { --c: #A23B72; } .c6 { --c: #6B7A2A; } .c7 { --c: #7A8496; }
.chart .ok { --c: #1F7A4D; } .chart .warn { --c: #B7791F; } .chart .danger { --c: #B42318; }
.chart .brand { --c: #305088; } .chart .muted { --c: #8B95A5; }

.dashboard .tiles a.tile { color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.dashboard .tiles a.tile:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.tile .value.danger { color: var(--danger); }
.dashboard section.card { scroll-margin-top: calc(var(--header-h) + 12px); }
.dashboard .card > header form { margin: 0; }

.dash-split { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 24px; align-items: start; }
@media (max-width: 760px) { .dash-split { grid-template-columns: 1fr; } }
.dash-sub { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); margin: 0 0 10px; }
.dash-note { font-size: 13px; color: var(--ink-soft); padding: 10px 18px 14px; margin: 0; }
.body .dash-note { padding: 8px 0 0; }
.warn-text { color: var(--warn); font-weight: 600; }
.danger-text { color: var(--danger); font-weight: 600; }

.chart { margin: 0; }
.chart-scroll { overflow-x: auto; }
.chart svg { display: block; width: 100%; height: auto; font-family: inherit; }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .tick, .chart .cat { font-size: 11px; fill: var(--ink-soft); }
.chart .cat.sub { font-size: 10px; fill: var(--ink-faint); }
.chart .line-tick { fill: var(--brand-dark); }
.chart rect.bar { fill: var(--c); }
.chart rect.bar:hover { opacity: .8; }
.chart .cumulative { fill: none; stroke: var(--ink); stroke-width: 2; stroke-dasharray: 5 3; }
.chart .cumulative-dot { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }
.chart-empty { color: var(--ink-soft); margin: 0; padding: 24px 0; text-align: center; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 13px; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; background: var(--c); display: inline-block; }
.legend .sw.line { height: 0; border-top: 2px dashed var(--ink); border-radius: 0; background: none; width: 16px; }
.legend.vertical { flex-direction: column; gap: 6px; }
.legend.vertical b { margin-left: auto; padding-left: 12px; color: var(--ink); }

.donut svg { max-width: 200px; margin: 0 auto; }
.donut .donut-track { fill: none; stroke: var(--line-soft); }
.donut .slice { fill: none; stroke: var(--c); }
.donut .donut-total { font-size: 28px; font-weight: 600; fill: var(--ink); }
.donut .donut-caption { font-size: 12px; fill: var(--ink-soft); }

.progress-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.progress-list .row { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 4px; }
.progress-list .row a { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-list .bar { height: 10px; background: var(--line-soft); border-radius: 5px; overflow: hidden; }
.progress-list .bar span { display: block; height: 100%; background: var(--ok); border-radius: 5px; }

.status-sum { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.status-sum > div { border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: var(--r); padding: 8px 14px; font-size: 13px; color: var(--ink-soft); }
.status-sum > div b { font-size: 20px; color: var(--ink); margin-right: 6px; }
.status-sum .ok { --c: #1F7A4D; } .status-sum .warn { --c: #B7791F; } .status-sum .danger { --c: #B42318; } .status-sum .muted { --c: #8B95A5; }

table.data.compact th, table.data.compact td { padding: 7px 8px; }
table.data th small { font-weight: 400; color: var(--ink-faint); }
table.data td.zero { color: var(--ink-faint); }
table.data tfoot th, table.data tfoot td { border-top: 2px solid var(--line); background: var(--brand-tint); font-weight: 600; }

/* poziome slupki pietrowane (projekty x statusy) - zwarte niezaleznie od liczby wierszy */
.chart.rows { display: grid; gap: 8px; }
.hrow { display: grid; grid-template-columns: minmax(120px, 240px) 1fr 44px; gap: 12px; align-items: center; font-size: 13px; }
.hlabel { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.hlabel b { color: var(--ink); font-weight: 600; }
.hlabel small { color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.htrack { display: flex; height: 22px; background: var(--line-soft); border-radius: 4px; overflow: hidden; }
.htrack .seg { background: var(--c); color: #FFFFFF; font-size: 12px; font-weight: 600; line-height: 22px; text-align: center;
               overflow: hidden; white-space: nowrap; min-width: 3px; box-shadow: inset -1px 0 0 rgba(255,255,255,.6); }
.htotal { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
.chart.rows .legend { margin-top: 6px; }
.chart svg { margin: 0 auto; }
@media (max-width: 560px) { .hrow { grid-template-columns: 80px 1fr 36px; } .hlabel small { display: none; } }

/* --- transport: kontrola zaladunku (masa, powierzchnia, podpowiedz pojazdu) --- */
.load-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.load-stat { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; background: var(--surface); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.load-stat .label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); font-weight: 600; }
.load-stat b { font-size: 18px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.load-stat small { font-size: 12px; color: var(--ink-soft); }
.load-bar { height: 6px; background: var(--line-soft); border-radius: 3px; overflow: hidden; margin-top: 2px; }
.load-bar i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.load-bar i.over { background: var(--danger); }
.load-bar i.warn { background: var(--warn); }
