/* ogcut, kierunek „Odcinek”. Tokeny i zasady: docs/ARCHITECTURE.md (sekcja Frontend). */

@font-face { font-family: "Bricolage Grotesque"; font-weight: 200 800; font-display: swap;
  src: url("../fonts/bricolage-grotesque-latin-wght-normal-XEJcKrT.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Bricolage Grotesque"; font-weight: 200 800; font-display: swap;
  src: url("../fonts/bricolage-grotesque-latin-ext-wght-normal-xZIEQZr.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Public Sans"; font-weight: 100 900; font-display: swap;
  src: url("../fonts/public-sans-latin-wght-normal-29KbApT.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Public Sans"; font-weight: 100 900; font-display: swap;
  src: url("../fonts/public-sans-latin-ext-wght-normal-S6ClAuw.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --paper: #ECEFF1; --sheet: #FFFFFF; --ink: #262B30; --ink-2: #5B6670; --line: #D2D8DD;
  --brand: #EF5423; --brand-strong: #B83508; --brand-ink: #FFFFFF; --brand-soft: #FDE6DD;
  --ok: #12795A; --warn: #9A5B00; --bad: #B42318;
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --text: "Public Sans", "Segoe UI", system-ui, sans-serif;
  --r: 10px; --r-sm: 8px;
  /* cienie „grubość kartki”: twarda dolna krawędź bez rozmycia (docs/design/cienie.html, wariant C) */
  --shadow-card: 0 3px 0 -1px rgb(22 32 42 / 0.10), 0 1px 0 rgb(22 32 42 / 0.05);
  --shadow-btn: 0 2px 0 rgb(22 32 42 / 0.14);
  --shadow-btn-primary: 0 2px 0 #7D2504;
  --shadow-pop: 0 10px 24px -8px rgb(22 32 42 / 0.28), 0 2px 0 rgb(22 32 42 / 0.08);
  --shadow-btn-hover: 0 4px 0 rgb(22 32 42 / 0.14);
  --shadow-btn-primary-hover: 0 4px 0 #7D2504;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --paper: #14181B; --sheet: #1D2226; --ink: #E7EBEE; --ink-2: #9BA6AF; --line: #333B41;
  --brand: #FF6A3D; --brand-strong: #FF6A3D; --brand-ink: #1A0E09; --brand-soft: #3A2119; --ok: #45C495; --warn: #E3A44A; --bad: #F2867B; color-scheme: dark;
  --shadow-card: 0 3px 0 -1px rgb(0 0 0 / 0.22), 0 1px 0 rgb(0 0 0 / 0.11); --shadow-btn: 0 2px 0 rgb(0 0 0 / 0.31); --shadow-btn-primary: 0 2px 0 #9C3419; --shadow-pop: 0 10px 24px -8px rgb(0 0 0 / 0.6), 0 2px 0 rgb(0 0 0 / 0.3); --shadow-btn-hover: 0 4px 0 rgb(0 0 0 / 0.31); --shadow-btn-primary-hover: 0 4px 0 #9C3419;
} }
:root[data-theme="dark"] {
  --paper: #14181B; --sheet: #1D2226; --ink: #E7EBEE; --ink-2: #9BA6AF; --line: #333B41;
  --brand: #FF6A3D; --brand-strong: #FF6A3D; --brand-ink: #1A0E09; --brand-soft: #3A2119; --ok: #45C495; --warn: #E3A44A; --bad: #F2867B; color-scheme: dark;
  --shadow-card: 0 3px 0 -1px rgb(0 0 0 / 0.22), 0 1px 0 rgb(0 0 0 / 0.11); --shadow-btn: 0 2px 0 rgb(0 0 0 / 0.31); --shadow-btn-primary: 0 2px 0 #9C3419; --shadow-pop: 0 10px 24px -8px rgb(0 0 0 / 0.6), 0 2px 0 rgb(0 0 0 / 0.3); --shadow-btn-hover: 0 4px 0 rgb(0 0 0 / 0.31); --shadow-btn-primary-hover: 0 4px 0 #9C3419;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.55 var(--text); }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.wrap { max-width: 1120px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
h1, h2, h3 { font-family: var(--display); font-weight: 650; letter-spacing: -0.015em; margin: 0; text-wrap: balance; }
h1 { font-size: 2rem; line-height: 1.15; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
.muted { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Górna belka */
header.top { background: var(--sheet); border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--sheet); }
.top .wrap { display: flex; align-items: center; gap: 24px; padding-block: 10px; }
.logo { height: 30px; width: auto; color: var(--ink); display: block; }
.logo .logo-dot { fill: var(--brand); }
nav.main { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
nav.main a { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; padding: 6px 12px 6px 6px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500; white-space: nowrap; }
nav.main a:hover { color: var(--ink); background: var(--paper); }
nav.main a[aria-current="page"] { color: var(--ink); background: var(--brand-soft); }
nav.main a svg.i, .meta svg.i { box-sizing: content-box; width: 14px; height: 14px; padding: 5px; border-radius: 7px; background: var(--paper); color: var(--ink-2); }
.meta svg.i { width: 12px; height: 12px; padding: 4px; border-radius: 6px; }
nav.main a:hover svg.i { background: var(--sheet); }
nav.main a[aria-current="page"] svg.i { background: var(--brand-strong); color: var(--brand-ink); }
.who { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 0.875rem; white-space: nowrap; }
a.avatar { text-decoration: none; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-strong); display: grid; place-items: center; font-weight: 600; font-size: 0.8rem; }
main { padding-block: 32px 64px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; } /* minmax(0, 1fr): długa treść nie poszerza kolumny ponad ekran */
footer.foot { padding-block: 16px 32px; color: var(--ink-2); font-size: 0.8125rem; }

/* Przyciski i pola */
svg.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.btn { font: 600 0.9375rem var(--text); border: 1px solid var(--line); background: var(--sheet); color: var(--ink); padding: 9px 16px; border-radius: var(--r-sm); cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; box-shadow: var(--shadow-btn); }
@media (hover: hover) { .btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-btn-hover); background-color: color-mix(in srgb, var(--sheet) 55%, var(--paper)); } .btn.primary:hover { box-shadow: var(--shadow-btn-primary-hover); background-color: color-mix(in srgb, var(--brand-strong) 88%, black); border-color: transparent; } }
.btn.primary { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--brand-ink); box-shadow: var(--shadow-btn-primary); }
.btn.danger { color: var(--bad); }
.btn:active, .btn.primary:active { transform: translateY(2px); box-shadow: none; }
.btn.small { padding: 6px 12px; font-size: 0.875rem; }
.csv-bottom { display: none; } /* tylko telefon, reguła pokazująca jest w bloku max-width 640px */
.btn[data-copied] { border-color: var(--ok); color: var(--ok); }
label { font-size: 0.875rem; font-weight: 600; display: block; margin-bottom: 6px; }
input[type=date] { min-height: 44px; }
/* własna strzałka listy: odstęp od prawej krawędzi równy odstępowi tekstu od lewej (12 px) */
select, input[type=text] + select { -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%239BA6AF' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px; }
input[type=text], input[type=url], input[type=email], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; font: 400 1rem var(--text); color: var(--ink); background-color: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; min-width: 0; }
select { padding-right: 36px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
input[readonly], input:disabled { color: var(--ink-2); cursor: not-allowed; }
.field { display: grid; gap: 0; min-width: 0; align-content: start; }
.field .help, .hint, .note { font-size: 0.8125rem; color: var(--ink-2); margin-top: 6px; }
.errors { list-style: none; margin: 6px 0 0; padding: 0; color: var(--bad); font-size: 0.875rem; }
.field.has-error input, .field.has-error select { border-color: var(--bad); }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; font-size: 0.9375rem; }
.check label { margin: 0; font-weight: 500; font-size: 0.9375rem; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.flash { padding: 12px 16px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--sheet); }
.flash.success, .flash.info { border-color: var(--ok); }
.flash.danger, .flash.error { border-color: var(--bad); color: var(--bad); }
.flash strong { font-weight: 650; }

/* Bilet: odcinek | perforacja | treść */
.ticket { --notch: 10px; display: grid; grid-template-columns: minmax(200px, 300px) 1fr; background: var(--sheet); border-radius: var(--r); position: relative; border: 1px solid var(--line); box-shadow: var(--shadow-card); }
.ticket .stub { padding: 18px 22px; display: grid; align-content: center; gap: 2px; border-right: 2px dashed var(--line); position: relative; min-width: 0; }
.ticket .stub::before, .ticket .stub::after { content: ""; position: absolute; right: calc(var(--notch) * -1 - 1px); width: calc(var(--notch) * 2); height: calc(var(--notch) * 2); border-radius: 50%; background: var(--paper); }
.ticket .stub::before { top: calc(var(--notch) * -1 - 1px); clip-path: inset(calc(50% - 4px) 0 0 0); }
.ticket .stub::after { bottom: calc(var(--notch) * -1 - 1px); clip-path: inset(0 0 calc(50% - 4px) 0); }
.stub .domain { font-size: 0.8125rem; color: var(--ink-2); }
.stub .alias { font-family: var(--display); font-weight: 750; font-size: 1.375rem; line-height: 1.2; overflow-wrap: anywhere; text-decoration: none; }
.stub a.alias:hover { color: var(--brand); }
/* cały odcinek jest linkiem do szczegółów: link rozciągnięty na odcinek (::after), podświetlenie po najechaniu i przy fokusie */
.stub.linked { border-radius: var(--r) 0 0 var(--r); transition: background .15s; }
.stub.linked .stretch { text-decoration: none; }
.stub.linked .stretch::after { content: ""; position: absolute; inset: 0; }
.stub.linked .stretch:focus-visible { outline: none; }
.stub.linked:hover { background: var(--paper); }
.stub.linked:hover .alias { color: var(--brand); }
.stub.linked:has(.stretch:focus-visible) { outline: 2px solid var(--brand); outline-offset: -2px; }
.ticket .body { padding: 16px 22px 16px 28px; display: grid; grid-template-columns: 1fr auto; gap: 6px 20px; align-items: center; min-width: 0; }
.body .title { font-weight: 600; overflow-wrap: anywhere; }
.body .target { color: var(--ink-2); font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.body .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.8125rem; color: var(--ink-2); grid-column: 1; }
.body .count { grid-row: 1 / span 3; grid-column: 2; text-align: right; display: grid; gap: 6px; justify-items: end; }
/* kolumna z kilkoma przyciskami (np. akcje użytkownika): wszystkie tej samej szerokości */
.body .count:has(.btn ~ .btn, .btn ~ form, form ~ form, form ~ .btn) { justify-items: stretch; }
.body .count:has(.btn ~ .btn, .btn ~ form, form ~ form, form ~ .btn) > .btn, .body .count:has(.btn ~ .btn, .btn ~ form, form ~ form, form ~ .btn) form > .btn { width: 100%; justify-content: center; }
.body .count:has(.btn ~ .btn, .btn ~ form, form ~ form, form ~ .btn) form { display: grid; }
/* menu „Zarządzaj” w bilecie (lista użytkowników): akcje w wysuwanym panelu, bez przycisków na wierzchu */
.body .menu { grid-row: 1 / span 3; grid-column: 2; position: relative; align-self: center; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { background-color: color-mix(in srgb, var(--sheet) 55%, var(--paper)); }
.menu .pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 4; min-width: 220px; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-pop); padding: 6px; display: grid; }
.menu .pop form { margin: 0; }
.menu .pop button { font: inherit; font-weight: 500; font-size: 0.9375rem; width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink); text-align: left; cursor: pointer; white-space: nowrap; }
.menu .pop button:hover { background: var(--paper); }
.menu .pop button.danger { color: var(--bad); }
.menu .pop button small { display: block; font-size: 0.75rem; font-weight: 400; color: var(--ink-2); }
.menu .pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
.count b { font-family: var(--display); font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1; }
.count small { color: var(--ink-2); font-size: 0.8125rem; }
.meta > span { display: inline-flex; align-items: center; gap: 6px; }
.meta .expiring { color: var(--warn); } .meta .expired { color: var(--bad); }
.meta .expiring svg.i { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.meta .expired svg.i { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; font-weight: 500; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.active { color: var(--ok); } .pill.inactive, .pill.expiring { color: var(--warn); } .pill.expired { color: var(--bad); } .pill.archived { color: var(--ink-2); }
.ticket.inactive .alias, .ticket.expired .alias, .ticket.archived .alias { color: var(--ink-2); }
.ticket.expired .alias, .ticket.archived .alias { text-decoration: line-through; text-decoration-thickness: 1px; }
.list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.ticket.preview { grid-template-columns: 1fr; }
.ticket.preview .stub { border-right: 0; border-bottom: 2px dashed var(--line); }
.ticket.preview .stub::before, .ticket.preview .stub::after { top: auto; bottom: calc(var(--notch) * -1 - 1px); }
.ticket.preview .stub::before { left: calc(var(--notch) * -1 - 1px); right: auto; clip-path: inset(0 0 0 calc(50% - 4px)); }
.ticket.preview .stub::after { right: calc(var(--notch) * -1 - 1px); clip-path: inset(0 calc(50% - 4px) 0 0); }
.ticket.preview .body { grid-template-columns: 1fr; padding: 16px 22px; }
.hero-ticket .stub { padding: 26px 28px; }
.hero-ticket .alias { font-size: clamp(1.75rem, 4vw, 2.75rem); }
.hero-ticket .body { grid-template-columns: 1fr; gap: 10px; padding: 22px 28px 22px 32px; }
.hero-ticket .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.qr-live { display: contents; }
.qr-title { font-size: 1.375rem; }
.hero-ticket .body .target { white-space: normal; overflow-wrap: anywhere; }
/* talon z kodem QR: druga perforacja po prawej stronie biletu */
.qr-ticket { grid-template-columns: minmax(180px, 230px) minmax(0, 1fr) minmax(220px, 270px); }
.qr-ticket .stub { padding: 22px; }
.qr-ticket .alias { font-size: clamp(1.5rem, 2.4vw, 2rem); overflow-wrap: normal; }
.qr-ticket .body { align-content: center; }
.qr-ticket .slip { position: relative; border-left: 2px dashed var(--line); padding: 18px 20px; display: grid; gap: 12px; align-content: center; justify-items: stretch; min-width: 0; }
.qr-ticket .slip::before, .qr-ticket .slip::after { content: ""; position: absolute; left: calc(var(--notch) * -1 - 1px); width: calc(var(--notch) * 2); height: calc(var(--notch) * 2); border-radius: 50%; background: var(--paper); }
.qr-ticket .slip::before { top: calc(var(--notch) * -1 - 1px); clip-path: inset(calc(50% - 4px) 0 0 0); }
.qr-ticket .slip::after { bottom: calc(var(--notch) * -1 - 1px); clip-path: inset(0 0 calc(50% - 4px) 0); }
.qr-ticket .slip .qr-preview { padding: 10px; }
.qr-ticket .slip .actions { display: grid; grid-template-columns: minmax(0, 1fr); }
.qr-ticket .slip .actions .btn { justify-content: center; }
.qr-ticket .slip .note { text-align: center; font-size: 0.8125rem; color: var(--ink-2); }

/* Szybkie skracanie */
.maker { display: grid; gap: 14px; }
.maker .ticket { grid-template-columns: 1fr minmax(240px, 360px); }
.maker .stub { order: 2; border-right: 0; border-left: 2px dashed var(--line); }
.maker .stub::before, .maker .stub::after { right: auto; left: calc(var(--notch) * -1 - 1px); }
.maker .body { padding: 20px 28px 20px 22px; grid-template-columns: 1fr; }
.aliasfield { display: flex; align-items: baseline; }
.aliasfield input { font: 750 1.375rem var(--display); background: transparent; border: 0; border-bottom: 2px solid var(--line); border-radius: 0; padding: 2px 0; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Panele, wykresy, rankingi */
.grid2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 24px; align-items: stretch; }
.grid2 > .panel { align-content: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.panel { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-card); padding: 20px 22px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; }
#stats { scroll-margin-top: 72px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.lead { font-size: 1.0625rem; max-width: 60ch; }
.lead b { font-family: var(--display); font-weight: 650; }
svg.bars { width: 100%; height: auto; display: block; }
svg.bars .grid { stroke: var(--line); stroke-width: 1; }
svg.bars .tick { fill: var(--ink-2); font: 11px var(--text); }
svg.bars.bars-narrow { display: none; }
svg.bars.bars-narrow .tick { font-size: 12.5px; }
svg.bars .bar { fill: var(--ink-2); opacity: 0.55; }
svg.bars .bar-last { fill: var(--brand); opacity: 1; }
.hbars { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font-size: 0.875rem; }
.hbar > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.hbar .track { grid-column: 1 / -1; display: block; width: 100%; height: 6px; background: var(--paper); border-radius: 3px; overflow: hidden; }
.hbar .fill { fill: var(--ink-2); }
.hbar:first-child .fill { fill: var(--brand); }
.hbar a { text-decoration: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar a:hover { color: var(--brand); text-decoration: underline; }
.kpis { display: flex; gap: 32px; flex-wrap: wrap; }
.kpi { display: grid; }
.kpi b { font-family: var(--display); font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--ink-2); font-size: 0.8125rem; }

/* Lista: narzędzia */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.toolbar form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; flex: 1 1 auto; }
.toolbar .search { max-width: 320px; flex: 1 1 220px; }
.toolbar select { width: auto; }
.seg { display: inline-flex; background: var(--sheet); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg a { font-weight: 500; font-size: 0.875rem; color: var(--ink-2); padding: 6px 12px; border-radius: 6px; text-decoration: none; }
.seg a[aria-current="true"] { background: var(--paper); color: var(--ink); font-weight: 600; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; }
.empty { padding: 40px 22px; text-align: center; color: var(--ink-2); background: var(--sheet); border: 1px dashed var(--line); border-radius: var(--r); display: grid; gap: 12px; justify-items: center; }

/* Kody QR */
input[type=color] { width: 72px; height: 44px; padding: 4px; cursor: pointer; }
input[type=file] { font: 400 0.9375rem var(--text); color: var(--ink); width: 100%; }
.choices { display: grid; gap: 8px; }
.qr-preview { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-card); padding: 16px; display: grid; gap: 12px; justify-items: center; }
.qr-preview img { width: 100%; max-width: 320px; height: auto; aspect-ratio: 1; border-radius: var(--r-sm); background: #fff; }
.qr-preview .qr-error { color: var(--bad); font-size: 0.875rem; text-align: center; }
.qr-preview code { font-size: 0.8125rem; color: var(--ink-2); overflow-wrap: anywhere; text-align: center; }
.qr-list .hbar { align-items: center; }
.qr-edit { display: grid; grid-template-columns: minmax(220px, 280px) minmax(0, 1fr); gap: 32px; align-items: start; margin-top: 12px; }
.qr-edit aside { position: sticky; top: 16px; display: grid; gap: 10px; }
/* odporność po lewej, dwa przełączniki po prawej, równo z polem wyboru */
.qr-edit .qr-checks { display: grid; gap: 14px; align-content: start; padding-top: 28px; }
.qr-edit aside .note { text-align: center; }
/* pola w dwóch kolumnach, żeby formularz był niski i wypełniał panel; szerokie pola na całą szerokość */
.qr-edit .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 24px; }
.qr-edit .fields > :first-child, .qr-edit .fields > .field:has(input[type=radio]), .qr-edit .fields > .row, .qr-edit .fields > .actions, .qr-edit .fields > .flash { grid-column: 1 / -1; }
@media (max-width: 760px) { .qr-edit { grid-template-columns: minmax(0, 1fr); } .qr-edit aside { position: static; } .qr-edit .fields { grid-template-columns: minmax(0, 1fr); } .qr-edit .qr-checks { padding-top: 0; } .qr-edit .qr-preview img { max-width: 200px; } }
.qr-row { grid-template-columns: 148px 1fr; }
.qr-row .stub { place-items: center; padding: 14px; }
.qr-thumb { width: 96px; height: 96px; border-radius: 6px; background: #fff; border: 1px solid var(--line); }
.qr-row a.title { text-decoration: none; }
.qr-row a.title:hover { color: var(--brand); }
@media (max-width: 640px) { .qr-row { grid-template-columns: 1fr; } }

/* Formularz linku */
.form { display: grid; grid-template-columns: 1fr minmax(260px, 340px); gap: 24px; align-items: start; }
.fields { display: grid; gap: 18px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px 18px; margin: 0; display: grid; gap: 14px; min-width: 0; }
legend { font-family: var(--display); font-weight: 650; padding: 0 6px; }
.final { font-size: 0.875rem; background: var(--paper); border-radius: var(--r-sm); padding: 10px 12px; overflow-wrap: anywhere; color: var(--ink-2); }
.final mark { background: var(--brand-soft); color: var(--ink); border-radius: 3px; padding: 0 2px; }
.sticky { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 76px); display: grid; gap: 14px; }
details.confirm { display: inline-block; }
details.confirm summary { list-style: none; cursor: pointer; }
details.confirm summary::-webkit-details-marker { display: none; }
details.confirm[open] { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
details.confirm[open] summary { display: none; }
.inline { display: inline; margin: 0; }

/* Ekrany logowania i rejestracji */
.auth { min-height: 100vh; display: grid; place-items: center; padding-block: 32px; }
.auth-card { width: 100%; max-width: 420px; display: grid; gap: 22px; }
.auth-card .logo { height: 44px; margin-inline: auto; }
.auth-card form { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-card); padding: 24px; display: grid; gap: 16px; }
.auth-card .btn { justify-content: center; }
.auth-card h1 { text-align: center; font-size: 1.5rem; }
.auth-lead { text-align: center; }
.auth-aux { text-align: center; font-size: 0.875rem; margin: 0; }

@media (max-width: 860px) {
  .grid2, .form, .grid3 { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .who .name { display: none; }
}
@media (max-width: 640px) {
  h1 { font-size: 1.5rem; }
  .lead { font-size: 0.9375rem; line-height: 1.4; }
  /* meta biletu: na telefonie sama ikona bez kafelka, żeby informacje mieściły się w mniejszej liczbie linii */
  .ticket .body:has(> .menu) { grid-template-columns: minmax(0, 1fr); }
  .body .menu { grid-column: 1; grid-row: auto; align-self: stretch; }
  .menu summary { width: 100%; justify-content: center; }
  .menu .pop { left: 0; right: 0; }
  .meta svg.i { padding: 0; background: none; width: 13px; height: 13px; }
  .meta .expiring svg.i, .meta .expired svg.i { background: none; }
  svg.bars.bars-wide { display: none; } svg.bars.bars-narrow { display: block; }
  .csv-top { display: none; }
  .csv-bottom { display: inline-flex; width: 100%; justify-content: center; }
  .ticket, .maker .ticket { grid-template-columns: 1fr; }
  .stub.linked { border-radius: var(--r) var(--r) 0 0; }
  .ticket .stub, .maker .stub { order: 0; border-right: 0; border-left: 0; border-bottom: 2px dashed var(--line); }
  .ticket .stub::before, .ticket .stub::after, .maker .stub::before, .maker .stub::after { top: auto; bottom: calc(var(--notch) * -1 - 1px); }
  .ticket .stub::before, .maker .stub::before { left: calc(var(--notch) * -1 - 1px); right: auto; clip-path: inset(0 0 0 calc(50% - 4px)); }
  .ticket .stub::after, .maker .stub::after { right: calc(var(--notch) * -1 - 1px); left: auto; clip-path: inset(0 calc(50% - 4px) 0 0); }
  .ticket .body, .maker .body { padding: 14px 18px; grid-template-columns: minmax(0, 1fr) auto; }
  /* szczegóły linku: jedna kolumna (reguła wyżej ma tę samą specyficzność co .hero-ticket .body, więc bez tego treść i przyciski wychodzą poza ekran) */
  .hero-ticket .body { grid-template-columns: minmax(0, 1fr); padding: 18px; }
  .hero-ticket .stub { padding: 18px; }
  .maker .body { grid-template-columns: 1fr; }
  /* szczegóły kodu QR: odcinek, treść i talon jeden pod drugim; przyciski równej szerokości, w jednej linii */
  .qr-ticket { grid-template-columns: minmax(0, 1fr); }
  .qr-ticket .body { grid-template-columns: minmax(0, 1fr); padding: 18px; }
  .qr-ticket .stub { padding: 20px 18px; }
  .qr-ticket .actions, .qr-ticket .slip .actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; align-items: stretch; }
  .qr-ticket .actions .btn { width: 100%; justify-content: center; text-align: center; }
  .qr-ticket details.confirm, .qr-ticket details.confirm[open] { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .qr-ticket details.confirm span { text-align: center; }
  .qr-ticket form.inline { display: grid; }
  .qr-ticket .slip { border-left: 0; border-top: 2px dashed var(--line); padding: 20px 18px; }
  .qr-ticket .slip::before { top: calc(var(--notch) * -1 - 1px); left: calc(var(--notch) * -1 - 1px); clip-path: inset(0 0 0 calc(50% - 4px)); }
  .qr-ticket .slip::after { top: calc(var(--notch) * -1 - 1px); bottom: auto; left: auto; right: calc(var(--notch) * -1 - 1px); clip-path: inset(0 calc(50% - 4px) 0 0); }
  .qr-ticket .qr-preview img { max-width: 240px; }
  /* w szybkim skracaniu odcinek jest pod polem adresu, więc perforacja jest nad nim */
  .maker .stub { border-bottom: 0; border-top: 2px dashed var(--line); }
  .maker .stub::before, .maker .stub::after { top: calc(var(--notch) * -1 - 1px); bottom: auto; }
  .row, .row3 { grid-template-columns: 1fr; }
  /* telefon: górą tylko logo i konto, nawigacja w dolnej belce */
  .top .wrap { justify-content: space-between; }
  nav.main, .who > :not(.avatar):not(.icon-btn) { display: none; }
  nav.tabbar { display: grid; }
  .icon-btn { width: 40px; height: 40px; }
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: no-preference) { .btn, nav.main a { transition: background .15s, border-color .15s, color .15s, box-shadow .12s, transform .12s; } }

/* logo na środku kodu QR: pole z plikiem rozwija się pod zaznaczonym polem wyboru */
.qr-logo { display: grid; gap: 12px; }
.qr-logo-panel { display: none; padding: 14px 16px; border: 1px dashed var(--line); border-radius: var(--r); background: var(--paper); }
.qr-logo:has(input[type=checkbox]:checked) .qr-logo-panel { display: block; }
.qr-logo input[type=file]::file-selector-button { font: 500 0.875rem var(--text); color: var(--ink); background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 12px; margin-right: 12px; cursor: pointer; }
.qr-logo input[type=file]::file-selector-button:hover { border-color: var(--ink-2); }

/* karty podziałów statystyk (źródła, kraje, urządzenia) */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 16px; align-items: start; }
.stat-grid .panel { margin: 0; }
.chart-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.attribution { margin: 32px 0 24px; font-size: 0.8125rem; color: var(--ink-2); }
.attribution a { color: inherit; }
.attribution-bar span { text-wrap: balance; }
.attribution-bar span a { white-space: nowrap; }
.attribution-bar { display: flex; justify-content: space-between; align-items: baseline; gap: 6px 24px; flex-wrap: wrap; }
@media (max-width: 640px) { .attribution-bar { display: grid; justify-content: stretch; } }

/* strona polityki prywatności */
.legal { max-width: 760px; padding-block: 32px; }
.legal-head { margin-bottom: 20px; }
.legal h2 { margin-top: 28px; font-size: 1.125rem; }
.legal ul { padding-left: 1.2em; display: grid; gap: 6px; }

/* nazwa w nagłówku jest linkiem do ekranu „Moje konto” */
.who a.name { color: inherit; text-decoration: none; }
.who a.name:hover, .who a.name[aria-current] { text-decoration: underline; text-underline-offset: 3px; }

/* Przełącznik motywu: ikona przy nicku (słońce w ciemnym, księżyc w jasnym) */
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: none; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { color: var(--ink); background: var(--paper); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .to-light { display: none; }
[data-dark="1"] .icon-btn .to-dark { display: none; }
[data-dark="1"] .icon-btn .to-light { display: inline; }

/* Dolna belka na telefonie (<= 640 px) */
.tabbar { display: none; position: fixed; inset: auto 0 0; z-index: 6; grid-template-columns: repeat(5, 1fr); align-items: end;
  background: var(--sheet); border-top: 1px solid var(--line); padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); }
.tabbar > a, .tabbar > button { display: grid; justify-items: center; gap: 2px; min-height: 52px; align-content: center; padding: 4px 2px; border: 0; background: none;
  font: inherit; font-size: 0.75rem; font-weight: 500; color: var(--ink-2); text-decoration: none; border-radius: var(--r-sm); cursor: pointer; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar [aria-current="page"] { color: var(--ink); }
.tabbar > [aria-current="page"] svg { box-sizing: content-box; padding: 3px 14px; margin-block: -3px; border-radius: 12px; background: var(--brand-soft); color: var(--brand-strong); }
.tabbar .tab-new { color: var(--ink); }
.tabbar .tab-new { position: relative; }
.tabbar .tab-new span { margin-top: 26px; }
/* kółko wystaje ponad belkę; łuk obrysu (tylko część nad linią belki) przerywa jej ramkę wokół kółka */
.tabbar .tab-new::before { content: ""; position: absolute; left: 50%; top: -28px; width: 64px; height: 64px; transform: translateX(-50%);
  border-radius: 50%; background: var(--sheet); border: 1px solid var(--line); box-sizing: border-box; clip-path: inset(0 0 calc(100% - 22px) 0); }
.tabbar .tab-new svg { position: absolute; left: 50%; top: -22px; transform: translateX(-50%); width: 52px; height: 52px; padding: 14px; border-radius: 50%; background: var(--brand-strong); stroke: var(--brand-ink); stroke-width: 2.2; box-sizing: border-box; }
.tabbar .sheet { position: absolute; right: 12px; bottom: calc(100% + 8px); width: min(280px, calc(100vw - 24px)); display: grid; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); padding: 6px; }
.tabbar .sheet[hidden] { display: none; }
.sheet > a { display: flex; justify-content: space-between; gap: 12px; padding: 12px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; font-weight: 500; }
.sheet > a[aria-current="page"] { background: var(--paper); }
.sheet-foot { display: flex; gap: 8px; padding: 10px 6px 6px; margin-top: 4px; border-top: 1px solid var(--line); }
.sheet-foot .btn { flex: 1; justify-content: center; }
@media (prefers-reduced-motion: no-preference) { .tabbar .sheet:not([hidden]) { animation: sheet-in .15s ease-out; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(6px); } }

/* loader w polu nazwy podczas pobierania tytułu strony (obrót SVG przez SMIL; przy ograniczonym ruchu statyczna kropka) */
input[data-loading] { padding-right: 40px; background-repeat: no-repeat; background-position: right 12px center; background-size: 18px 18px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23EF5423' stroke-width='3' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9' stroke='%23D2D8DD' stroke-width='2'/%3E%3Cpath d='M12 3a9 9 0 0 1 9 9'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='0.8s' repeatCount='indefinite'/%3E%3C/path%3E%3C/svg%3E"); }
@media (prefers-reduced-motion: reduce) { input[data-loading] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23EF5423'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3C/svg%3E"); } }

/* pole hasła z przyciskiem „pokaż/ukryj” po prawej stronie, wewnątrz pola */
.pw { position: relative; display: grid; }
.pw input { padding-right: 48px; }
.pw-toggle { position: absolute; top: 0; right: 0; bottom: 0; width: 46px; display: grid; place-items: center; background: none; border: 0; border-radius: 0 var(--r-sm) var(--r-sm) 0; color: var(--ink-2); cursor: pointer; }
.pw-toggle:hover { color: var(--ink); }
.pw-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: -3px; }
.pw-toggle .pw-eye-off, .pw-toggle[aria-pressed="true"] .pw-eye { display: none; }
.pw-toggle[aria-pressed="true"] .pw-eye-off { display: block; }

/* Układy, które były w atrybutach style= (CSP przepuszcza tylko style z plików). Specyficzność dobrana tak, żeby wygrywały z regułami ogólnymi, tak jak wcześniej atrybut. */
.centered { text-align: center; }
.panel.narrow { max-width: 560px; }
.stack-form { display: grid; gap: 16px; }
.actions.inline-form { align-items: flex-start; }
.inline-form > .grow { flex: 1 1 280px; }
.inline-form > div.offset-label { padding-top: 26px; }   /* przycisk na wysokości pola pod etykietą */
.inline-form > .btn.offset-label { margin-top: 26px; }
section.recent { display: grid; gap: 14px; }
h1.link-title { font-size: 1.375rem; }
.hbar.history-row { grid-template-columns: 1fr auto; }
.hbar.qr-row { grid-template-columns: 1fr auto auto auto; }
.hbar.member-row { grid-template-columns: 1fr auto auto; align-items: center; }
.stub .alias.initials { font-size: 1.75rem; }
.stub .alias.invite-name { font-size: 1.5rem; }
.hint.flush { margin: 0; }
.dup-list { margin: 6px 0 0; padding-left: 20px; }
.dup-note { margin: 8px 0 0; }
