/* Elektro-Podhale — Budowy i Rozliczenia
   Kierunek: narzędzie robocze na budowę. Jasne tło czytelne w słońcu, mocny kontrast,
   jeden kolor akcji (żółty „ostrzegawczy” z czarnym tekstem), duże cele dotyku. */
:root {
  --bg: #f3f1eb;
  --surface: #ffffff;
  --ink: #15171a;
  --muted: #545a62;
  --line: #d6d1c4;
  --line-strong: #a9a395;
  --nav: #1b2430;
  --nav-ink: #f3f1eb;
  --accent: #ffc400;
  --accent-press: #e6b000;
  --accent-ink: #15171a;
  --ok: #17663a;
  --ok-bg: #e5f3ea;
  --warn: #7a4a00;
  --warn-bg: #fff3d1;
  --danger: #a8231a;
  --danger-bg: #fbe9e7;
  --info-bg: #e8eef6;
  --focus: #1a5fd0;
  --radius: 10px;
  --tap: 48px;
  --gutter: 16px;
  font-size: 17px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
.num, td.num, .amount, .hours { font-variant-numeric: tabular-nums; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; margin-top: 1.5rem; }
h3 { font-size: 1rem; }
p { margin: .4rem 0; }
a { color: #0f4fae; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; background: #fff; padding: 8px 12px; z-index: 100; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Pasek górny i nawigacja ---------- */
.topbar { background: var(--nav); color: var(--nav-ink); position: sticky; top: 0; z-index: 20; }
.topbar-in { max-width: 980px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 0 var(--gutter); min-height: 52px; position: relative; }
.brand { color: var(--nav-ink); text-decoration: none; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.brand svg { color: var(--accent); }
.mainnav { display: none; }
.menu-btn { margin-left: auto; background: transparent; color: var(--nav-ink); border: 1px solid #4a5566; border-radius: 8px; min-height: 40px; padding: 0 14px; font: inherit; font-size: .95rem; }
.menu { position: absolute; right: var(--gutter); top: 52px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.18); min-width: 240px; padding: 6px; }
.menu a, .menu button { display: block; width: 100%; text-align: left; padding: 12px 14px; min-height: var(--tap); color: var(--ink); text-decoration: none; background: none; border: 0; font: inherit; border-radius: 8px; }
.menu a:hover, .menu button:hover { background: var(--bg); }
.menu .who { padding: 10px 14px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: .9rem; color: var(--muted); }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 62px;
  color: var(--muted); text-decoration: none; font-size: .8rem; font-weight: 600; border-top: 3px solid transparent; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--ink); border-top-color: var(--accent); }

@media (min-width: 900px) {
  body { padding-bottom: 32px; }
  .tabbar { display: none !important; }
  .mainnav { display: flex; gap: 4px; margin-left: 24px; }
  .mainnav a { color: #c9cfd8; text-decoration: none; padding: 0 14px; min-height: 52px; display: flex; align-items: center; font-weight: 600; border-bottom: 3px solid transparent; }
  .mainnav a[aria-current="page"] { color: #fff; border-bottom-color: var(--accent); }
}

#banner { background: #5b1d8c; color: #fff; padding: 10px var(--gutter); font-size: .92rem; text-align: center; }
#banner.demo { background: #8a2b00; }
#banner button { margin-left: 8px; background: #fff; color: #222; border: 0; border-radius: 6px; padding: 6px 10px; font: inherit; font-weight: 600; }

main { max-width: 980px; margin: 0 auto; padding: 16px var(--gutter) 24px; outline: none; }
.narrow { max-width: 640px; }
.loading { color: var(--muted); padding: 24px 0; }

/* ---------- Przyciski ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 18px;
  border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: #faf9f5; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent-press); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-press); }
.btn.dark { background: var(--nav); color: #fff; border-color: var(--nav); }
.btn.danger { color: var(--danger); border-color: #d9a39e; }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.block { display: flex; width: 100%; }
.btn.big { min-height: 60px; font-size: 1.15rem; }
.btn.small { min-height: 40px; padding: 0 12px; font-size: .92rem; }
.btn.link { border: 0; background: none; color: #0f4fae; padding: 0 6px; text-decoration: underline; min-height: 40px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.row > .grow { flex: 1 1 auto; }
.stack > * + * { margin-top: 12px; }

/* ---------- Data dnia ---------- */
.datebar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 14px; }
.date-sticky { position: sticky; top: 52px; z-index: 10; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; padding: 8px 10px; box-shadow: 0 3px 8px rgba(0,0,0,.06); }
.date-sticky .row { flex-wrap: nowrap; }
.date-sticky .dlabel { font-size: 1rem; }
.datebar.date-chips { border-top: 0; border-radius: 0 0 var(--radius) var(--radius); padding-top: 8px; }
.dlabel { font-weight: 700; font-size: 1.1rem; text-align: center; flex: 1; }
.dlabel small { display: block; font-weight: 500; color: var(--muted); font-size: .85rem; }
.btn.arrow { width: var(--tap); padding: 0; font-size: 1.3rem; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; }
.chip[aria-pressed="true"] { background: var(--nav); color: #fff; border-color: var(--nav); }
.chip input[type="date"] { border: 0; background: transparent; font: inherit; min-height: 40px; }

/* ---------- Karty / listy ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card + .card { margin-top: 12px; }
.card h3 { margin-bottom: 2px; }
.card .loc { color: var(--muted); font-size: .92rem; }
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.list > li + li { border-top: 1px solid var(--line); }
.list a.item, .list .item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 56px; color: var(--ink); text-decoration: none; }
.list a.item:hover { background: #faf9f5; }
.item .main { flex: 1 1 auto; min-width: 0; }
.item .title { font-weight: 650; }
.item .sub { color: var(--muted); font-size: .9rem; }
.item .side { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.item .chev { color: var(--line-strong); font-size: 1.3rem; }
.group-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 12px 14px 10px; border-bottom: 1px solid var(--line); background: #fbfaf6; border-radius: var(--radius) var(--radius) 0 0; }
.group-head .title { font-weight: 700; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 22px 0 10px; }
.section-title h2 { margin: 0; }

.badge { display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); vertical-align: 1px; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: #ecd08a; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: #a9d3b7; }
.badge.closed { background: var(--info-bg); color: #24446e; border-color: #b6c6dc; }
.badge.danger { background: var(--danger-bg); color: var(--danger); border-color: #e3b1ab; }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 10px 0 4px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.kpi .k { font-size: .82rem; color: var(--muted); }
.kpi .v { font-size: 1.25rem; font-weight: 750; font-variant-numeric: tabular-nums; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } }

table.t { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.t th, table.t td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.t th { font-size: .82rem; color: var(--muted); font-weight: 650; }
table.t td.num, table.t th.num { text-align: right; white-space: nowrap; }
table.t tfoot td { font-weight: 750; border-bottom: 0; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- Zakładki ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; overflow-x: auto; margin: 10px 0 14px; padding-bottom: 2px; scrollbar-width: none; }
.tabs a { white-space: nowrap; min-height: 44px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 999px; text-decoration: none; color: var(--ink); border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; font-size: .95rem; }
.tabs a[aria-current="page"] { background: var(--nav); border-color: var(--nav); color: #fff; }

/* ---------- Formularze ---------- */
.field { margin-bottom: 14px; }
.field > label, .field > .label, fieldset > legend { display: block; font-weight: 650; margin-bottom: 6px; }
.field .hint { font-size: .86rem; color: var(--muted); margin-top: 4px; }
input[type="text"], input[type="password"], input[type="tel"], input[type="date"], input[type="time"], input:not([type]), input[inputmode], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; font: inherit; font-size: 1.05rem; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line-strong); border-radius: 8px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: 3px solid rgba(26,95,208,.25); outline-offset: 0; }
[aria-invalid="true"] { border-color: var(--danger) !important; background: #fff8f7; }
.err-text { color: var(--danger); font-size: .9rem; margin-top: 4px; font-weight: 600; }
fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 12px; min-height: var(--tap); cursor: pointer; }
.check input { width: 24px; height: 24px; flex: none; accent-color: var(--nav); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1.5px solid var(--nav); border-radius: var(--radius); overflow: hidden; }
.seg button { min-height: var(--tap); border: 0; background: var(--surface); font: inherit; font-weight: 650; color: var(--ink); cursor: pointer; }
.seg button + button { border-left: 1.5px solid var(--nav); }
.seg button[aria-pressed="true"] { background: var(--nav); color: #fff; }

/* wybór budowy / pracowników — duże pola zaznaczenia */
.pick { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pick label { display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 56px; background: var(--surface);
  border: 1.5px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.pick input { width: 24px; height: 24px; flex: none; accent-color: var(--nav); }
.pick label:has(input:checked) { border-color: var(--nav); background: #eef1f5; box-shadow: inset 4px 0 0 var(--accent); }
.pick .main { flex: 1; min-width: 0; }
.pick .title { font-weight: 650; }
.pick .sub { color: var(--muted); font-size: .88rem; }

.person { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 10px 12px; }
.person + .person { margin-top: 8px; }
.person .top { display: flex; align-items: center; gap: 10px; }
.person .top .name { flex: 1; font-weight: 650; }
.person .more { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }

.notice { border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; border: 1px solid; }
.notice.warn { background: var(--warn-bg); border-color: #ecd08a; color: #4f3000; }
.notice.err { background: var(--danger-bg); border-color: #e3b1ab; color: #6d1510; }
.notice.ok { background: var(--ok-bg); border-color: #a9d3b7; color: #0f4527; }
.notice.info { background: var(--info-bg); border-color: #b6c6dc; color: #1d3557; }
.notice ul { margin: 6px 0 0; padding-left: 20px; }
.notice h2, .notice h3 { margin-top: 0; }

.savebar { position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, rgba(243,241,235,0)); padding: 14px 0 6px; margin-top: 10px; }
@media (min-width: 900px) { .savebar { bottom: 0; } }
.total-line { font-weight: 700; margin-bottom: 8px; font-variant-numeric: tabular-nums; }

.steps { counter-reset: s; list-style: none; padding: 0; margin: 8px 0 0; }
.steps li { counter-increment: s; display: flex; gap: 12px; align-items: center; padding: 10px 0; }
.steps li::before { content: counter(s); width: 32px; height: 32px; border-radius: 50%; background: var(--nav); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.steps li.done::before { content: "✓"; background: var(--ok); }
.steps li .grow { flex: 1; }

details.expand > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: #0f4fae; font-weight: 600; list-style: none; }
details.expand > summary::-webkit-details-marker { display: none; }
details.expand > summary::before { content: "▸"; margin-right: 8px; }
details.expand[open] > summary::before { content: "▾"; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 50; max-width: calc(100% - 32px); }
#toast .t { background: var(--ok); color: #fff; padding: 12px 18px; border-radius: var(--radius); font-weight: 650; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
#toast .t.err { background: var(--danger); }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100% - 24px)); box-shadow: 0 20px 50px rgba(0,0,0,.35); color: var(--ink); }
dialog::backdrop { background: rgba(10, 14, 20, .55); }
dialog .dlg-in { padding: 18px; }
dialog h2 { margin-top: 0; }

.login { max-width: 420px; margin: 8vh auto 0; }
.login .brandbig { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.3rem; margin-bottom: 4px; }
.login .brandbig svg { color: #b88a00; }
.empty { text-align: center; color: var(--muted); padding: 20px 10px; }
.confirm-box { text-align: left; }
.confirm-box .big { font-size: 1.35rem; font-weight: 800; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; word-break: break-all; }
.footer-co { margin-top: 32px; color: var(--muted); font-size: .82rem; text-align: center; }
