/* Czas Pracy — design: chłodny błękit (klimatyzacja), granatowy pasek, IBM Plex.
   Kolory TYLKO dla wyjątków (reguła Karola): czerwony=źle, żółty=ostrzeżenie,
   zielony=ważna dobra informacja, reszta neutralna. */
:root {
  --ink: #1a2434; --muted: #5b6b7f; --bg: #edf1f6; --panel: #fff; --line: #dce3ec;
  --head: #16233a; --head-ink: #e7edf5;
  --brand: #1266a5; --brand-strong: #0e5488; --brand-soft: #e8f1f9;
  --bad: #c02b2b; --bad-bg: #fbeeee;
  --warn: #9a6700; --warn-bg: #fff6df;
  --good: #1b7f3b; --good-bg: #e9f6ed;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ── górny pasek ── */
header {
  background: var(--head); color: var(--head-ink);
  padding: 0 24px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 10px rgb(10 20 40 / .25);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 13px 0; }
.brand h1 { font-size: 17px; font-weight: 700; margin: 0; letter-spacing: .2px; color: #fff; }
.brand .ic { width: 22px; height: 22px; stroke: #7fb7e6; }
.firm { background: var(--brand); color: #fff; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 4px; letter-spacing: .8px; }
nav { display: flex; gap: 2px; flex-wrap: wrap; }
nav button {
  border: 0; background: none; padding: 16px 13px; cursor: pointer; font: inherit; font-weight: 500;
  color: #93a3b8; border-bottom: 3px solid transparent;
}
nav button:hover { color: #d7e2ef; }
nav button.active { color: #fff; border-bottom-color: #5aa5dd; font-weight: 600; }
.madeby { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; text-decoration: none; font-size: 11.5px; color: #93a3b8; }
.madeby:hover { color: #d7e2ef; }
.madeby img { height: 16px; opacity: .9; }

/* ikony Lucide (inline SVG) */
.ic { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -2px; flex: none; }

/* ── układ ── */
main { max-width: 1720px; margin: 0 auto; padding: 22px 36px 40px; }
.tab { display: none; }
.tab.active { display: block; }
h2 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 20px 0 8px; }
.bar { display: flex; align-items: center; gap: 10px; margin: 4px 0 16px; flex-wrap: wrap; }
.range { font-weight: 600; font-size: 15px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.warn { color: var(--warn); font-weight: 600; }
.bad { color: var(--bad); font-weight: 600; }
.good { color: var(--good); font-weight: 600; }
.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px 18px; margin: 0 0 16px; }
.panel h2 { margin-top: 2px; }

/* ── formularze / przyciski ── */
input, select {
  font: inherit; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink);
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
input[type="search"] { min-width: 320px; }
button {
  font: inherit; font-weight: 600; padding: 9px 16px; border: 0; border-radius: 8px;
  background: var(--brand); color: #fff; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
button:hover { background: var(--brand-strong); }
button.ghost { background: var(--panel); color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
button.ghost:hover { background: var(--brand-soft); border-color: #b9d4ea; }

/* ── tabele ── */
table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid #e9eef5; }
th { background: #f4f7fb; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: 0; }
th.num, td.num { text-align: right; }
/* zebra dla czytelności */
table:not(.report-table) > tbody > tr:nth-child(even) > td { background: #f7f9fc; }
.report-table > tbody > tr.stripe > td { background: #f7f9fc; }
/* podsumowanie zwarte — kolumny blisko siebie, nie na całą szerokość */
.report-table { width: auto; min-width: 900px; margin: 0 auto; }
.report-table th, .report-table td { white-space: nowrap; padding-right: 28px; }
td.num, .hours { font-family: var(--mono); font-size: 13px; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--brand); }
th.sort-asc::after { content: " ▲"; font-size: 9px; }
th.sort-desc::after { content: " ▼"; font-size: 9px; }
.cols-fixed { table-layout: fixed; width: 100%; }
.cols-fixed td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cols-fixed th { white-space: normal; overflow-wrap: break-word; vertical-align: bottom; } /* nagłówki się zawijają, nie ucinają */

.badge {
  display: inline-block; font-family: var(--mono); font-size: 12px; font-weight: 600;
  background: var(--brand-soft); color: var(--brand-strong); border: 1px solid #c4dbee;
  border-radius: 6px; padding: 1px 8px;
}
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); margin-right: 5px; vertical-align: 1px; }
.dot-good { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); margin-right: 6px; vertical-align: 1px; }
tr.inactive td { opacity: .45; }
.holiday-row td { background: var(--bad-bg); }
.free-row td { background: #f6f8fb; color: var(--muted); }

/* miernik normy dnia (Teraz) */
.meter { display: inline-block; width: 74px; height: 6px; background: #e4eaf2; border-radius: 3px; vertical-align: 2px; margin-left: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.meter i.over { background: var(--warn); }

/* raport tydzień/miesiąc */
.emp-row { cursor: pointer; }
.emp-detail > td { background: #f6f8fb; padding: 0 0 10px; }
.emp-detail table { border: 0; border-top: 1px solid var(--line); border-radius: 0; }
.detail-table { width: auto; min-width: 720px; margin: 0 auto; }
.detail-table th, .detail-table td { white-space: nowrap; padding-right: 26px; }
.chev { font-size: 15px; color: var(--brand); text-align: center; }

/* siatka obecności */
.grid-scroll { overflow-x: auto; }
.grid-table th, .grid-table td { padding: 7px 8px; text-align: center; }
.grid-table th:first-child, .grid-table td:first-child { text-align: left; min-width: 210px; }
.grid-table td.cell { font-family: var(--mono); font-size: 12.5px; min-width: 64px; }
.grid-table .cell.absent { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.grid-table .cell.leave { background: #eef1f6; color: var(--muted); font-weight: 600; font-family: inherit; }
.grid-table .cell.freeday { background: #f6f8fb; color: #b7c2cf; }
.grid-table .cell.odd { box-shadow: inset 0 -3px 0 var(--warn); }
.grid-table .today-col { background: var(--brand-soft) !important; }
.grid-table th.today-col { color: var(--brand-strong); }
.grid-table th small { display: block; font-weight: 500; color: inherit; opacity: .75; text-transform: none; }

/* kafle */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.card .v { font-size: 22px; font-weight: 700; font-family: var(--mono); }
.card .v.small { font-size: 15px; font-family: inherit; }
.card .l { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card.is-bad { border-color: #eec7c7; background: var(--bad-bg); }
.card.is-bad .v { color: var(--bad); }
.card.is-warn { border-color: #ecd9a8; background: var(--warn-bg); }
.card.is-warn .v { color: var(--warn); }

/* wykres rozliczenia */
#stl-chart { position: relative; }
#stl-chart svg { display: block; width: 100%; height: 240px; }
.chart-tip {
  position: absolute; pointer-events: none; background: var(--head); color: #fff;
  font-size: 12px; padding: 6px 10px; border-radius: 6px; transform: translate(-50%, -110%);
  white-space: nowrap; z-index: 5; box-shadow: 0 3px 10px rgb(0 0 0 / .25);
}
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* status */
.action-boxes { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; margin: 8px 0 16px; }
.action-box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.action-box p { margin: 10px 0 0; font-size: 13px; }

/* status — wyśrodkowany, kafle 3 w rzędzie */
#tab-status .cards { max-width: 1000px; margin: 0 auto 14px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
#tab-status .action-boxes { max-width: 1000px; margin: 0 auto 14px; }
#tab-status pre { max-width: 1000px; margin: 0 auto; }

/* ustawienia — wyśrodkowane */
#settings-form { max-width: 880px; margin: 0 auto; }
.settings-group { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px 20px; margin-bottom: 14px; }
.settings-group > h2 { margin: 2px 0 4px; }
.settings-group > p { margin: 0 0 14px; font-size: 13px; }
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.settings label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--ink); font-weight: 600; }
.settings label small { font-weight: 400; color: var(--muted); line-height: 1.4; }
#settings-form > button { margin-top: 4px; }

/* toast + modale */
#toast[hidden], #modal[hidden], #leave-modal[hidden], #transfer-modal[hidden] { display: none; }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--head); color: #fff; padding: 11px 20px; border-radius: 8px; z-index: 40; box-shadow: 0 4px 14px rgb(0 0 0 / .3); }
#modal, #leave-modal, #transfer-modal { position: fixed; inset: 0; background: rgb(10 20 40 / .45); display: flex; align-items: center; justify-content: center; z-index: 30; }
.modal-box { background: var(--panel); border-radius: 12px; padding: 22px 24px; width: min(440px, 92vw); box-shadow: 0 14px 50px rgb(0 0 0 / .3); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.leave-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.leave-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
.leave-form label.full { grid-column: 1 / -1; }

pre { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; overflow-x: auto; font-size: 12px; }

/* logowanie (login.html korzysta z tych tokenów) */

@media (max-width: 900px) { input[type="search"] { min-width: 200px; } main { padding: 16px; } header { padding: 0 14px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  header, .bar, #toast, #modal, #leave-modal { display: none !important; }
  .tab { display: none; }
  .tab.active { display: block; }
  body { background: #fff; }
  .emp-detail { display: table-row !important; }
}
nav button .ic { width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; }
/* archiwum bylych pracownikow — wygaszone */
#emp-archive td { color: var(--muted); }
#emp-archive .badge { opacity: .55; }
#emp-archive b { color: #6b7a8d; }
