/* Zlewnia. Czcionki lokalne: urząd nie może wysyłać adresów IP mieszkańców do zewnętrznych CDN-ów. */
@font-face { font-family: 'Source Sans 3'; font-weight: 200 900; font-display: swap; src: url(/vendor/fonts/source-sans-3-latin-ext-wght-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+1E00-1E9F, U+2C60-2C7F; }
@font-face { font-family: 'Source Sans 3'; font-weight: 200 900; font-display: swap; src: url(/vendor/fonts/source-sans-3-latin-wght-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212; }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; font-display: swap; src: url(/vendor/fonts/ibm-plex-mono-latin-ext-400-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+1E00-1E9F; }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; font-display: swap; src: url(/vendor/fonts/ibm-plex-mono-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 500; font-display: swap; src: url(/vendor/fonts/ibm-plex-mono-latin-ext-500-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+1E00-1E9F; }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 500; font-display: swap; src: url(/vendor/fonts/ibm-plex-mono-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }

:root {
  --ink: #0e2a47;
  --ink-2: #42566c;
  --ink-3: #5d7086;
  --paper: #f2f5f9;
  --paper-2: #e8ebf4;
  --card: #ffffff;
  --line: #d6dbe4;
  --line-strong: #a9b3c2;
  --brand: #114273;
  --brand-dark: #0f3c69;
  --brand-tint: #dcebf6;
  --amber: #e9a500;
  --amber-ink: #5c4300;
  --st-ok: #1b7a50;     --st-ok-bg: #dff1e7;
  --st-soon: #8f5b00;   --st-soon-bg: #fbeecb;
  --st-late: #b3261e;   --st-late-bg: #fbe2df;
  --st-never: #7d3c98;  --st-never-bg: #efe2f5;
  --st-new: #3a6a8a;    --st-new-bg: #e2ecf2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(14, 42, 71, .06), 0 4px 14px rgba(14, 42, 71, .05);
  --sans: 'Source Sans 3', 'Segoe UI', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 17px/1.45 var(--sans); }
h1, h2, h3 { line-height: 1.15; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 30px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
p { margin: 0; }
a { color: var(--brand); text-underline-offset: 2px; }
.mono { font-family: var(--mono); font-size: .93em; letter-spacing: -.01em; }
.muted { color: var(--ink-2); }
.small { font-size: 15px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
/* minmax(0, 1fr): bez tego kolumna rośnie do szerokości tabeli i strona wyjeżdża poza telefon */
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.stack-lg { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1 1 auto; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--card); padding: 8px 14px; z-index: 50; border-radius: 6px; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; border-radius: 4px; }

/* formularze */
label.f { display: grid; gap: 4px; font-weight: 600; font-size: 15px; }
label.f small { font-weight: 400; color: var(--ink-2); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line-strong); border-radius: 8px; padding: 9px 11px; width: 100%; min-height: 42px; }
textarea { min-height: 84px; resize: vertical; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--brand); flex: none; }
label.check { display: flex; gap: 9px; align-items: flex-start; font-size: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 14px; margin: 0; }
legend { font-weight: 700; padding: 0 6px; }

.btn { font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--card); color: var(--ink); padding: 8px 15px; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--paper-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--st-late); border-color: var(--st-late); }
.btn.small { min-height: 34px; padding: 4px 11px; font-size: 15px; }
.btn[disabled] { opacity: .55; cursor: default; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); text-decoration: underline; cursor: pointer; }

/* karty i tabele */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card > h2 + *, .card > h3 + * { margin-top: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 15.5px; }
th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 13.5px; text-transform: uppercase; letter-spacing: .04em; background: var(--paper); }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.right, th.right { text-align: right; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #faf9f4; }

.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 1px 10px 2px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.pill .ico { font-weight: 800; }
.pill.ok { background: var(--st-ok-bg); color: var(--st-ok); }
.pill.soon { background: var(--st-soon-bg); color: var(--st-soon); }
.pill.overdue, .pill.bad { background: var(--st-late-bg); color: var(--st-late); }
.pill.never { background: var(--st-never-bg); color: var(--st-never); }
.pill.new, .pill.pending, .pill.neutral { background: var(--st-new-bg); color: var(--st-new); }
.flag { display: inline-block; background: var(--st-soon-bg); color: var(--st-soon); border-radius: 5px; padding: 0 7px 1px; font-size: 14px; margin: 1px 3px 1px 0; }
.note { background: var(--paper); border-left: 4px solid var(--brand); padding: 10px 14px; border-radius: 0 8px 8px 0; font-size: 15.5px; }
.note.warn { background: var(--st-soon-bg); border-color: var(--st-soon); }
.note.bad { background: var(--st-late-bg); border-color: var(--st-late); }
.note.good { background: var(--st-ok-bg); border-color: var(--st-ok); }
.empty { padding: 26px; text-align: center; color: var(--ink-2); }
.demo-ribbon { background: var(--amber); color: #2e2200; font-size: 14px; font-weight: 600; text-align: center; padding: 3px 10px; }

/* panel */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--ink); color: #dfe7f0; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 21px; letter-spacing: -.02em; color: inherit; text-decoration: none; padding: 2px 10px 12px; }
.brand svg { width: 26px; height: 26px; flex: none; }
.side .who { font-size: 14.5px; color: #a9bcbb; padding: 0 10px 14px; border-bottom: 1px solid #2a4149; margin-bottom: 10px; }
.side .who strong { display: block; color: #fff; font-weight: 600; }
.side a.nav { display: flex; justify-content: space-between; gap: 8px; color: #dfe7f0; text-decoration: none; padding: 9px 10px; border-radius: 7px; font-weight: 500; }
.side a.nav:hover { background: #1b353d; }
.side a.nav[aria-current=page] { background: var(--brand); color: #fff; font-weight: 600; }
.side .count { background: var(--amber); color: #2e2200; border-radius: 999px; font-size: 13px; font-weight: 700; padding: 0 8px; align-self: center; }
.side .foot { margin-top: auto; padding: 12px 10px 0; display: grid; gap: 6px; font-size: 15px; }
.side .foot button { color: #dfe7f0; text-align: left; }
.main { padding: 26px 30px 60px; max-width: 1240px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { color: var(--ink-2); margin-top: 3px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { flex: 1 1 240px; width: auto; }
.toolbar select, .row select { width: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { font: inherit; font-weight: 600; background: none; border: 0; padding: 8px 14px; cursor: pointer; color: var(--ink-2); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs button[aria-selected=true] { color: var(--brand); border-color: var(--brand); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: inherit; display: block; box-shadow: var(--shadow); }
a.kpi:hover { border-color: var(--brand); }
.kpi .v { font-size: 34px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 15px; color: var(--ink-2); margin-top: 2px; }
.kpi.alert .v { color: var(--st-late); }
.two { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.seg { display: flex; gap: 2px; height: 14px; margin: 10px 0 12px; }
.seg span { display: block; min-width: 3px; }
.seg span:first-child { border-radius: 4px 0 0 4px; }
.seg span:last-child { border-radius: 0 4px 4px 0; }
.seg-legend { display: grid; gap: 5px; font-size: 15.5px; }
.seg-legend div { display: flex; justify-content: space-between; gap: 10px; }
.seg-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 7px; }
.bars { position: relative; }
.bars svg { display: block; width: 100%; height: auto; overflow: visible; }
.bars rect.hit { fill: transparent; }
.bars g.col:hover .barp, .bars g.col:focus .barp { fill: var(--brand-dark); }
.bars g.col:focus { outline: none; }
.bars text { font: 400 12px var(--sans); fill: var(--ink-2); }
.bars line { stroke: var(--line); }
.bars .tip { position: absolute; background: var(--ink); color: #fff; font-size: 14px; padding: 3px 9px; border-radius: 6px; pointer-events: none; transform: translate(-50%, -110%); white-space: nowrap; }

#map { height: 460px; border-radius: var(--radius); border: 1px solid var(--line); z-index: 0; }
.dl { display: grid; grid-template-columns: minmax(130px, auto) 1fr; gap: 4px 16px; margin: 0; font-size: 16px; }
.dl dt { color: var(--ink-2); }
.dl dd { margin: 0; font-weight: 500; }

dialog { border: 0; border-radius: 12px; padding: 0; max-width: min(640px, calc(100vw - 24px)); width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.3); color: var(--ink); }
dialog::backdrop { background: rgba(14, 42, 71, .55); }
.dialog-body { padding: 20px 22px; display: grid; gap: 14px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; }

#toasts { position: fixed; right: 14px; bottom: 14px; display: grid; gap: 8px; z-index: 100; max-width: min(420px, calc(100vw - 28px)); }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 9px; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.toast.bad { background: var(--st-late); }

/* karta QR */
.qr-card { background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 16px 18px; display: grid; grid-template-columns: 150px 1fr; gap: 16px; align-items: center; break-inside: avoid; max-width: 520px; }
.qr-card svg { width: 150px; height: 150px; display: block; }
.qr-card .eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); }
.qr-card .no { font: 500 22px var(--mono); margin: 2px 0 4px; }
.cards-print { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }

/* kwit */
.receipt { background: #fff; max-width: 440px; margin: 0 auto; border-radius: 10px 10px 0 0; box-shadow: var(--shadow); padding: 22px 22px 26px; position: relative; }
.receipt::after { content: ''; position: absolute; left: 0; right: 0; bottom: -10px; height: 10px; background: radial-gradient(circle at 8px 0, #fff 7px, transparent 7.5px) 0 0 / 16px 10px repeat-x; }
.receipt .big { font: 700 52px var(--sans); letter-spacing: -.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.receipt hr { border: 0; border-top: 2px dashed var(--line-strong); margin: 16px 0; }

/* strony bez panelu */
.public { min-height: 100vh; display: flex; flex-direction: column; }
.public-top { background: var(--ink); color: #fff; padding: 12px 18px; }
.public-top .brand { padding: 0; font-size: 20px; }
.public-main { flex: 1; padding: 26px 16px 50px; width: 100%; max-width: 760px; margin: 0 auto; }
.narrow { max-width: 440px; margin: 0 auto; }

/* kierowca: duże cele, rękawice, słońce */
.drv { max-width: 560px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: var(--paper); font-size: 19px; }
.drv-top { background: var(--ink); color: #fff; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 5; }
.drv-top .brand { padding: 0; font-size: 19px; }
.drv-top button, .drv-top a { color: #fff; }
.drv-main { padding: 14px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; flex: 1; align-content: start; }
.btn.huge { width: 100%; min-height: 76px; font-size: 24px; border-radius: 12px; font-weight: 700; }
.btn.huge.scan { background: var(--amber); border-color: #b58510; color: #231a00; }
.btn.huge.scan:hover { background: #e3a81f; }
.btn.big { width: 100%; min-height: 58px; font-size: 20px; border-radius: 10px; }
.stepper { display: grid; grid-template-columns: 72px 1fr 72px; gap: 8px; align-items: stretch; }
.stepper button { font: 700 34px var(--sans); border-radius: 10px; border: 1px solid var(--line-strong); background: #fff; cursor: pointer; color: var(--ink); min-height: 72px; }
.stepper input { font: 700 40px var(--sans); font-variant-numeric: tabular-nums; text-align: center; padding: 4px; min-height: 72px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips button { font: 600 17px var(--sans); padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink); cursor: pointer; }
.drv-addr { font-size: 25px; font-weight: 700; line-height: 1.15; }
.gauge { height: 14px; background: var(--paper-2); border-radius: 7px; overflow: hidden; margin-top: 6px; }
.gauge i { display: block; height: 100%; background: var(--brand); }
.gauge i.full { background: var(--st-late); }
.queue-banner { background: var(--amber); color: #231a00; font-weight: 600; padding: 9px 14px; border-radius: 9px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.offline-banner { background: var(--st-never); color: #fff; font-weight: 600; text-align: center; padding: 5px; font-size: 16px; }
.scan-box { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 1; }
.scan-box video, .scan-box canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-box.hit .frame { border-color: var(--st-ok); }
.scan-box .frame { position: absolute; inset: 14%; border: 4px solid var(--amber); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.done-mark { width: 74px; height: 74px; border-radius: 50%; background: var(--st-ok); color: #fff; display: grid; place-items: center; font-size: 44px; font-weight: 800; margin: 6px auto 0; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; padding: 8px; gap: 2px; align-items: center; }
  .side .who, .side .foot { display: none; }
  .side .brand { padding: 0 10px 0 4px; font-size: 18px; }
  .side a.nav { white-space: nowrap; padding: 7px 10px; gap: 6px; }
  .main { padding: 16px 16px 50px; }
  h1 { font-size: 25px; }
  .two { grid-template-columns: 1fr; }
  .qr-card { grid-template-columns: 110px 1fr; }
  .qr-card svg { width: 110px; height: 110px; }
  .cards-print { grid-template-columns: 1fr; }
  #map { height: 340px; }
}
@media (max-width: 520px) {
  .hide-sm { display: none; }
}

@media print {
  body { background: #fff; font-size: 12pt; }
  .side, .no-print, #toasts, .demo-ribbon, .drv-top { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .card, .table-wrap, .kpi { box-shadow: none; border-color: #999; }
  .card { break-inside: avoid; }
  .cards-print { grid-template-columns: 1fr 1fr; gap: 8mm; }
  .qr-card svg { width: 34mm; height: 34mm; }
  .qr-card { grid-template-columns: 36mm 1fr; }
}

/* Lista warunków kontroli widoczna dla mieszkańca */
.checks-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checks-list li { display: flex; gap: 9px; align-items: baseline; }
.checks-list li > span:first-child { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 13px; font-weight: 800; transform: translateY(2px); }
.checks-list li.ok > span:first-child { background: var(--st-ok-bg); color: var(--st-ok); }
.checks-list li.no > span:first-child { background: var(--st-soon-bg); color: var(--st-soon); }
