/* ===== Trichron — wspólny arkusz stylów ===== */

/* Roboto (self-hosted). Wgraj pliki roboto-v19-latin-*.woff2 / .woff do public/fonts/.
   Źródło: google-webfonts-helper (gwfh.mranftl.com), rodzina Roboto, wersja latin.
   Dopóki plików nie ma, zadziała fallback systemowy poniżej. */
@font-face {
    font-family: 'Roboto'; font-style: normal; font-weight: 400; font-display: swap;
    src: url('/fonts/roboto-v19-latin-regular.woff2') format('woff2'),
         url('/fonts/roboto-v19-latin-regular.woff') format('woff');
}
@font-face {
    font-family: 'Roboto'; font-style: normal; font-weight: 500; font-display: swap;
    src: url('/fonts/roboto-v19-latin-500.woff2') format('woff2'),
         url('/fonts/roboto-v19-latin-500.woff') format('woff');
}
@font-face {
    font-family: 'Roboto'; font-style: normal; font-weight: 700; font-display: swap;
    src: url('/fonts/roboto-v19-latin-700.woff2') format('woff2'),
         url('/fonts/roboto-v19-latin-700.woff') format('woff');
}

:root {
    --bg: #f3f4f6; --fg: #111827; --muted: #6b7280; --faint: #9ca3af;
    --line: #f0f0f0; --border: #d1d5db; --card: #fff;
    --blue: #2563eb; --blue-dk: #1d4ed8; --red: #ef4444;
    --maxw: 1900px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Roboto', -apple-system, "Segoe UI", sans-serif;
    font-size: 13px; line-height: 1.5;
    background: var(--bg); color: var(--fg); margin: 0;
}
body.login { display: flex; min-height: 100vh; align-items: center; justify-content: center; }

/* Nagłówek aplikacji */
header { background: var(--card); padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
header b { font-size: 16px; }
header .who { color: var(--muted); font-size: 12px; margin-left: 12px; }
header form { margin: 0; }
header button { background: #e5e7eb; border: 0; padding: 7px 13px; border-radius: 8px; cursor: pointer; font-size: 12px; }
.header-brand { display: flex; align-items: center; }
.header-logo { height: 28px; max-width: 140px; object-fit: contain; margin-right: 10px; }
.logo-podglad { margin-bottom: 12px; }
.logo-podglad img { height: 48px; max-width: 240px; object-fit: contain; background: #f9fafb; border: 1px solid var(--border); border-radius: 8px; padding: 8px; }

/* Układ */
main { max-width: var(--maxw); margin: 24px auto; padding: 0 24px; }
.box { background: var(--card); padding: 20px; border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,.05); margin-bottom: 22px; }
h1 { margin: 0 0 4px; font-size: 22px; }
h2 { margin: 0 0 16px; font-size: 14px; }
.sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }

/* Nawigacja dzienny/tygodniowy */
.nav { margin-bottom: 18px; font-size: 13px; }
.nav a { color: var(--muted); text-decoration: none; }
.nav strong { color: var(--blue); }
.nav .sep { color: #d1d5db; }
.nav .grupa { color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; margin: 0 10px 0 16px; }

/* Komunikaty */
.ok   { background: #ecfdf5; color: #047857; padding: 9px 13px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.err  { background: #fef2f2; color: #b91c1c; padding: 9px 13px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.hint { color: var(--faint); font-size: 12px; margin: 4px 0 16px; }

/* Formularze */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.full { grid-column: 1 / -1; }
label { display: block; font-size: 12px; color: #374151; margin-bottom: 6px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit; }
textarea { resize: vertical; min-height: 42px; }

/* Przyciski */
.submit { margin-top: 14px; background: var(--blue); color: #fff; border: 0; padding: 10px 20px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.submit:hover { background: var(--blue-dk); }
.row { display: flex; gap: 10px; margin-top: 14px; align-items: center; }
.cancel { text-decoration: none; color: var(--muted); font-size: 13px; }

/* Logowanie */
.card { background: var(--card); width: 340px; padding: 30px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,.08); }
.card label { display: block; font-size: 12px; margin-bottom: 14px; color: #374151; }
.card input[type=email], .card input[type=password] { margin-top: 6px; }
.card .row { font-size: 13px; margin-top: 0; margin-bottom: 4px; }
.card .row input { width: auto; margin: 0; }
.card button { width: 100%; margin-top: 10px; padding: 10px; background: var(--blue); color: #fff; border: 0; border-radius: 8px; font-size: 14px; cursor: pointer; }
.card button:hover { background: var(--blue-dk); }

/* Tabele */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.mono { font-variant-numeric: tabular-nums; }
.empty { color: var(--faint); padding: 16px 0; }

/* Statusy */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; }
.roboczy       { background: #f3f4f6; color: #4b5563; }
.zgloszony     { background: #fef3c7; color: #92400e; }
.zaakceptowany { background: #dcfce7; color: #166534; }
.odrzucony     { background: #fee2e2; color: #991b1b; }

/* Akcje w wierszu (widok dzienny) */
.akcje { display: flex; gap: 6px; }
.akcje form { margin: 0; }
.lnk { text-decoration: none; font-size: 12px; padding: 5px 10px; border-radius: 6px; border: 1px solid var(--border); background: #fff; color: #374151; cursor: pointer; }
.lnk:hover { background: #f9fafb; }
.lnk.zglos { border-color: var(--blue); color: var(--blue); }
.lnk.del   { border-color: var(--red); color: var(--red); }
.lock { color: var(--faint); font-size: 12px; }

/* Widok tygodniowy */
.weeknav { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.weeknav a { text-decoration: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; color: #374151; font-size: 13px; }
.weeknav .tyt { font-weight: 500; font-size: 14px; }
.weeknav input[type=date].wybor-daty { width: auto; padding: 6px 10px; font-size: 13px; margin-left: auto; }
th.l, td.l { text-align: left; }
th small { display: block; color: var(--faint); font-weight: 400; }
td.proj { min-width: 200px; } td.zad { min-width: 150px; }
input.g { text-align: center; padding: 6px 6px; }
.suma { font-variant-numeric: tabular-nums; font-weight: 500; text-align: center; }
tfoot td { border-top: 2px solid #e5e7eb; border-bottom: 0; font-weight: 500; color: var(--fg); }
.del { border: 0; background: transparent; color: var(--red); cursor: pointer; font-size: 16px; line-height: 1; }
.actions { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }
.addrow { border: 1px dashed var(--faint); background: #fff; color: #374151; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; }

/* w tabeli tygodnia komórki centrowane, nagłówki dni też */
.tydzien th, .tydzien td { text-align: center; }
.tydzien th.l, .tydzien td.l { text-align: left; }

/* Widok miesięczny — tabela przewijana poziomo, węższe kolumny dni */
.tabela-scroll { overflow-x: auto; padding-bottom: 4px; }
.miesiac { width: auto; }
.miesiac th, .miesiac td { padding: 6px 4px; }
.miesiac th.l, .miesiac td.l { padding-left: 8px; padding-right: 8px; }
.miesiac td.proj { min-width: 170px; } .miesiac td.zad { min-width: 130px; }
.miesiac th:not(.l), .miesiac td:not(.l) { min-width: 38px; }
.miesiac input.g { padding: 5px 2px; font-size: 12px; }
.miesiac th.weekend, .miesiac td.weekend { background: #fafafa; }
.miesiac .daysum.weekend { background: transparent; }

/* Siatki tygodniowa/miesięczna w raportach: przycięcie długich nazw projektów, żeby zmieściła się cała szerokość.
   Uwaga: max-width na <td> jest ignorowany przy table-layout:auto z white-space:nowrap — przycinamy więc
   wewnętrzny <span>, który jako inline-block faktycznie respektuje max-width. */
.raport-siatka .proj-etykieta { display: inline-block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

/* Sobota na szaro, niedziela na czerwono — nagłówki dni i wartości w komórkach */
.raport-siatka th.dzien-so, .raport-siatka td.dzien-so { background: #fafafa; }
.raport-siatka th.dzien-so, .raport-siatka td.dzien-so, .raport-siatka th.dzien-so small { color: var(--muted); }
.raport-siatka th.dzien-nd, .raport-siatka td.dzien-nd { background: #fef2f2; }
.raport-siatka th.dzien-nd, .raport-siatka td.dzien-nd, .raport-siatka th.dzien-nd small { color: var(--red); }

/* Widok miesięczny akceptacji */
.legenda { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.legenda .kropka { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.legenda .kropka.roboczy       { background: #9ca3af; }
.legenda .kropka.zgloszony     { background: #f59e0b; }
.legenda .kropka.zaakceptowany { background: #22c55e; }
.legenda .kropka.odrzucony     { background: #ef4444; }
.miesiac td.roboczy, .miesiac td.zgloszony, .miesiac td.zaakceptowany, .miesiac td.odrzucony { font-variant-numeric: tabular-nums; }

/* Panel akceptacji */
.filtry { display: flex; gap: 16px; flex-wrap: wrap; }
.filtry > div { min-width: 220px; }
.uwaga { color: var(--faint); font-size: 11px; margin-top: 3px; max-width: 240px; }
.chkcol { width: 28px; }
.odrzuc-form { margin-top: 8px; min-width: 220px; }
.odrzuc-form textarea { min-height: 50px; }
.bulkbar { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.lnk:disabled { opacity: .4; cursor: default; }
.lnk:disabled:hover { background: #fff; }

/* Panel użytkowników */
.rola-pracownik { background: #f3f4f6; color: #4b5563; }
.rola-kierownik { background: #dbeafe; color: #1e40af; }
.rola-zarzad    { background: #ede9fe; color: #5b21b6; }
.rola-admin     { background: #fee2e2; color: #991b1b; }

/* Macierz uprawnień ról */
.uprawnienia th:not(.l), .uprawnienia td:not(.l) { text-align: center; width: 110px; }
.uprawnienia input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }
.uprawnienia .kategoria-wiersz td { background: var(--bg); color: var(--muted); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .03em; padding: 7px 8px; border-bottom: 1px solid var(--line); }

/* Status projektu (aktywny/nieaktywny) */
.stan-aktywny    { background: #dcfce7; color: #166534; }
.stan-nieaktywny { background: #f3f4f6; color: #6b7280; }

/* Panele słownikowe (klienci/tagi/działy) */
.slownik-dodaj { display: flex; gap: 10px; margin-bottom: 18px; max-width: 420px; }
.slownik-edytuj { display: flex; gap: 8px; align-items: center; }
.slownik-edytuj input { width: auto; flex: 1; min-width: 160px; }
.slownik-nazwa + .slownik-edytuj { margin-top: 4px; }

/* Pulpit (dashboard) */
.stat-rzad { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-kafel { background: var(--bg); border-radius: 10px; padding: 14px 18px; min-width: 160px; }
.stat-etykieta { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
.stat-wartosc { font-size: 24px; font-weight: 500; font-variant-numeric: tabular-nums; }

.wykres-slupki { display: flex; align-items: flex-end; gap: 14px; height: 190px; padding-top: 20px; }
.slupek-kol { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; flex: 1; height: 100%; }
.slupek-etykieta { font-size: 11px; color: var(--muted); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.slupek { width: 100%; max-width: 40px; background: var(--blue); border-radius: 4px 4px 0 0; }
.slupek-dzien { margin-top: 8px; font-size: 12px; color: var(--muted); }
.slupek-kol.weekend .slupek-dzien { color: var(--red); }
.wykres-slupki.wykres-miesiac { gap: 5px; }
.wykres-slupki.wykres-miesiac .slupek { max-width: 20px; }
.wykres-slupki.wykres-miesiac .slupek-etykieta { font-size: 9px; }
.wykres-slupki.wykres-miesiac .slupek-dzien { font-size: 10px; margin-top: 4px; }

.podzial-lista { display: flex; flex-direction: column; gap: 10px; }
.podzial-wiersz { display: grid; grid-template-columns: 240px 1fr 150px; align-items: center; gap: 12px; font-size: 13px; }
.podzial-nazwa { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podzial-pasek-tlo { background: var(--bg); border-radius: 999px; height: 8px; overflow: hidden; }
.podzial-pasek { background: var(--blue); height: 100%; border-radius: 999px; }
.podzial-proc { color: var(--muted); text-align: right; }

/* Raporty: sortowanie i rozwijane podsumowania */
.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.sort-link:hover { color: var(--blue); }
.sort-link.aktywna { color: var(--blue); }
.sort-strzalka { margin-left: 3px; font-size: 9px; }
tr.klikalny { cursor: pointer; }
tr.klikalny:hover { background: var(--bg); }
td.klikalny { cursor: pointer; }
td.klikalny:hover { background: var(--bg); }
.rozwin { color: var(--faint); font-size: 11px; margin-left: 4px; }
tr.wiersz-szczegoly td { padding: 0 0 14px 24px; border-bottom: 1px solid var(--line); }
.tabela-zagniezdzona { width: auto; min-width: 60%; background: var(--bg); border-radius: 8px; overflow: hidden; }
.tabela-zagniezdzona th, .tabela-zagniezdzona td { padding: 6px 10px; font-size: 12px; }
.tabela-zagniezdzona th { background: #ebedf0; }

/* Kalendarz dzienny (przeciąganie) */
.kalendarz-wrapper { max-height: 600px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.kalendarz-flex { display: flex; }
.kalendarz-godziny { width: 52px; flex-shrink: 0; border-right: 1px solid var(--line); position: sticky; left: 0; background: var(--card); z-index: 1; }
.kalendarz-godzina-etykieta { height: 48px; line-height: 48px; font-size: 11px; color: var(--faint); text-align: right; padding-right: 8px; box-sizing: border-box; }
.kalendarz-siatka {
    position: relative; flex: 1; height: 1152px; cursor: crosshair; user-select: none;
    background-image: repeating-linear-gradient(to bottom, var(--line) 0, var(--line) 1px, transparent 1px, transparent 48px);
}
.kalendarz-zaznaczenie { position: absolute; left: 4px; right: 4px; background: rgba(37,99,235,.18); border: 1px dashed var(--blue); border-radius: 4px; pointer-events: none; }
.kalendarz-blok {
    position: absolute; left: 4px; right: 4px; border-radius: 6px; padding: 3px 8px; font-size: 11px;
    overflow: hidden; cursor: pointer; line-height: 1.4;
    border-top: 1px solid rgba(17,24,39,.15); border-right: 1px solid rgba(17,24,39,.15); border-bottom: 1px solid rgba(17,24,39,.15);
    border-left: 3px solid;
    box-shadow: 0 1px 2px rgba(17,24,39,.06);
}
.kalendarz-blok-tresc strong { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kalendarz-blok.status-roboczy       { background: #f3f4f6; border-left-color: #9ca3af; }
.kalendarz-blok.status-zgloszony     { background: #fef3c7; border-left-color: #f59e0b; }
.kalendarz-blok.status-zaakceptowany { background: #dcfce7; border-left-color: #22c55e; }
.kalendarz-blok.status-odrzucony     { background: #fee2e2; border-left-color: #ef4444; }

/* Kalendarz tygodniowy (przeciąganie, 7 kolumn) */
.kalendarz-zakladki { display: flex; gap: 8px; margin-bottom: 14px; }
.kalendarz-zakladka { border: 1px solid var(--border); background: #fff; color: #374151; padding: 7px 16px; border-radius: 8px; font-size: 13px; cursor: pointer; }
.kalendarz-zakladka.aktywna { background: var(--blue); border-color: var(--blue); color: #fff; }
.kalendarz-tydz-wrapper { max-height: 600px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.kalendarz-tydz-flex { display: flex; min-width: 900px; }
.kalendarz-tydz-flex .kalendarz-godziny { position: sticky; top: 0; }
.kalendarz-tydz-kolumna { flex: 1; min-width: 110px; border-right: 1px solid var(--line); }
.kalendarz-tydz-kolumna:last-child { border-right: 0; }
.kalendarz-tydz-header { position: sticky; top: 0; z-index: 2; background: var(--card); border-bottom: 1px solid var(--line); text-align: center; padding: 8px 4px; font-size: 12px; font-weight: 500; }
.kalendarz-tydz-header small { display: block; color: var(--faint); font-weight: 400; }
.kalendarz-tydz-header.dzien-dzis { background: #eff6ff; color: var(--blue); }
.kalendarz-godziny-spacer { height: 37px; border-bottom: 1px solid var(--line); box-sizing: border-box; position: sticky; top: 0; background: var(--card); z-index: 2; }
.kalendarz-tydz-kolumna .kalendarz-blok-tresc strong { font-size: 11px; }

/* Modal (nowy/edycja/podgląd wpisu) */
.modal-tlo { position: fixed; inset: 0; background: rgba(17,24,39,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-okno { background: var(--card); border-radius: 12px; padding: 24px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: 0 12px 40px rgba(0,0,0,.2); }
.modal-okno .row { align-items: center; }

/* Widżet wielokrotnego wyboru (filtry raportów) */
.multiselect { position: relative; }
.multiselect-toggle {
    width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff;
    font-size: 13px; font-family: inherit; color: var(--fg); cursor: pointer;
    display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left;
}
.multiselect-toggle:hover { background: var(--bg); }
.multiselect-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multiselect-arrow { color: var(--faint); font-size: 10px; flex-shrink: 0; }
.multiselect-panel {
    position: absolute; top: calc(100% + 4px); left: 0; z-index: 60; min-width: 100%; width: max-content; max-width: 320px;
    background: var(--card); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
    padding: 8px;
}
.multiselect-szukaj { margin-bottom: 6px; padding: 6px 8px; font-size: 12px; }
.multiselect-lista { max-height: 240px; overflow-y: auto; }
.multiselect-opcja { display: flex; align-items: center; gap: 8px; padding: 5px 4px; border-radius: 6px; font-size: 13px; font-weight: 400; margin: 0; cursor: pointer; }
.multiselect-opcja:hover { background: var(--bg); }
.multiselect-opcja input[type=checkbox] { width: 15px; height: 15px; flex-shrink: 0; cursor: pointer; }
.multiselect-opcja span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multiselect-brak { color: var(--faint); font-size: 12px; padding: 6px 4px; }
.multiselect-kasuj { width: 100%; margin-top: 6px; padding-top: 8px; border: 0; border-top: 1px solid var(--line); background: none; color: var(--blue); font-size: 12px; font-family: inherit; text-align: center; cursor: pointer; }
.multiselect-kasuj:hover { color: var(--blue-dk); }
