/* ═══════════════════════════════════════════════════════════════════
   System ISO GAWRA — arkusz stylów (desktop + telefon; jasny domyślnie, ciemny opcjonalnie)
   ═══════════════════════════════════════════════════════════════════ */
:root {
  --accent: #2455d6;
  --accent-600: color-mix(in srgb, var(--accent) 88%, black);
  --accent-50: color-mix(in srgb, var(--accent) 8%, white);
  --accent-100: color-mix(in srgb, var(--accent) 15%, white);
  --accent-fg: #fff;

  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --border: #e3e8ef;
  --border-strong: #cfd7e3;
  --text: #16202e;
  --text-2: #4a5566;
  --text-3: #5f6b7d;
  --accent-text: var(--accent);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 4px 12px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .18);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --sidebar-w: 268px;
  --topbar-h: 60px;
  --bottombar-h: 64px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --gray-bg: #eef1f5; --gray-fg: #475467;
  --blue-bg: #e7efff; --blue-fg: #1d4ed8;
  --green-bg: #e3f6ea; --green-fg: #157a3d;
  --amber-bg: #fff3d6; --amber-fg: #9a5b00;
  --red-bg: #fde8e8; --red-fg: #b42318;
  --purple-bg: #f1e9ff; --purple-fg: #6b2fd0;
  --teal-bg: #dff6f4; --teal-fg: #0b7a70;
  color-scheme: light;
}

/* Motyw jasny jest domyślny; ciemny tylko na wyraźne życzenie użytkownika (menu użytkownika → Motyw) */
:root[data-theme="dark"] {
  --accent-50: color-mix(in srgb, var(--accent) 14%, #0f1520);
  --accent-100: color-mix(in srgb, var(--accent) 24%, #0f1520);
  --bg: #0b1017; --surface: #121a25; --surface-2: #151e2a; --surface-3: #1b2533;
  --border: #243042; --border-strong: #324157;
  --text: #e7edf5; --text-2: #aab6c7; --text-3: #8e9bb0;
  --accent-text: color-mix(in srgb, var(--accent) 45%, white);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 1px 3px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3); --shadow-lg: 0 16px 48px rgba(0,0,0,.55);
  --gray-bg: #232d3b; --gray-fg: #b6c1d1;
  --blue-bg: #17284a; --blue-fg: #8db1ff;
  --green-bg: #12301f; --green-fg: #74d69b;
  --amber-bg: #3a2a0a; --amber-fg: #f5c05b;
  --red-bg: #3b1616; --red-fg: #ff8f86;
  --purple-bg: #2a1d4a; --purple-fg: #c3a2ff;
  --teal-bg: #0f302d; --teal-fg: #6fe0d4;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-text); cursor: pointer; text-decoration: none; }
.linkbtn:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15.5px; } h4 { font-size: 14px; }
p { margin: 0 0 8px; }
small, .small { font-size: 12.5px; }
.muted { color: var(--text-2); } .faint { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: 13px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
svg.icon { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.icon-sm svg.icon, svg.icon.sm { width: 15px; height: 15px; }
.icon-lg svg.icon, svg.icon.lg { width: 22px; height: 22px; }

/* ─────────────── Układ aplikacji ─────────────── */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 40;
}
.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 16px 18px; min-height: var(--topbar-h); border-bottom: 1px solid var(--border); }
.brand .logo { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; font-weight: 800; font-size: 15px; overflow: hidden; flex: none; }
.brand .logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand .name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand .sub { font-size: 12px; color: var(--text-3); }
.nav { flex: 1; overflow-y: auto; padding: 10px 10px 24px; }
.nav-group { margin-top: 14px; }
.nav-group-title { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 6px 10px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--text-2);
  font-weight: 520; font-size: 14px; text-decoration: none; position: relative;
}
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.active { background: var(--accent-50); color: var(--accent-text); }
.nav a .code { font-size: 11px; font-weight: 700; color: var(--text-3); min-width: 30px; }
.nav a.active .code { color: var(--accent-text); }
.nav a .count { margin-left: auto; font-size: 11.5px; background: var(--red-bg); color: var(--red-fg); border-radius: 999px; padding: 1px 7px; font-weight: 700; }
.sidebar .foot { border-top: 1px solid var(--border); padding: 10px; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 24px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar .menu-btn { display: none; flex: none; }
.topbar .title { font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar .spacer { flex: 1; }
.search-box { position: relative; width: min(380px, 40vw); }
.search-box input { padding-left: 36px; background: var(--surface); }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
/* Wyszukiwarka funkcji (finder.js): podpowiedzi pod polem u góry i karta na stronie „Szukaj” */
.search-box .finder-pop svg { position: static; transform: none; color: inherit; }
.finder-pop { position: absolute; top: calc(100% + 6px); right: 0; width: min(580px, calc(100vw - 32px)); max-height: min(72vh, 640px); overflow-y: auto; overscroll-behavior: contain; z-index: 60; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; scroll-padding-bottom: 92px; }
.finder-end { position: sticky; bottom: -6px; margin: 4px -6px -6px; padding: 4px 6px 6px; background: var(--surface); border-top: 1px solid var(--border); }
.finder-sec { font-size: 11.5px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); padding: 8px 10px 4px; }
.finder-row { display: flex; gap: 10px; align-items: flex-start; padding: 7px 10px; border-radius: 9px; color: var(--text); text-decoration: none; cursor: pointer; }
.finder-row:hover { text-decoration: none; background: var(--surface-3); }
.finder-row.hi { background: var(--accent-50); }
.finder-row .ic { width: 30px; height: 30px; border-radius: 8px; background: var(--surface-3); color: var(--text-2); display: grid; place-items: center; flex: none; }
.finder-row .ic svg { width: 17px; height: 17px; }
.finder-row.hi .ic { background: var(--accent-100); color: var(--accent-text); }
.finder-row .tx { min-width: 0; display: flex; flex-direction: column; }
.finder-row .t { font-weight: 620; font-size: 14px; line-height: 1.3; }
.finder-row .s { font-size: 12.5px; color: var(--text-2); line-height: 1.35; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.finder-row mark { background: color-mix(in srgb, var(--amber-bg) 85%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.finder-note { padding: 10px; color: var(--text-3); font-size: 13px; }
.finder-foot { padding: 4px 10px 0; font-size: 12px; color: var(--text-3); }
.finder-card .finder-sec { padding: 10px 16px 4px; }
.finder-card .finder-list { padding: 0 6px 6px; }
.finder-card .finder-row { padding: 8px 10px; }
.content { padding: 8px 24px 48px; max-width: 1400px; width: 100%; }
.bottombar { display: none; }

.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-100); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.user-btn { display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 4px; border-radius: 999px; cursor: pointer; color: var(--text); }
.user-btn:hover { background: var(--surface-3); }

.backdrop { position: fixed; inset: 0; background: rgba(10, 16, 26, .45); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .2s; }
.backdrop.show { opacity: 1; pointer-events: auto; }

@media (max-width: 1023px) {
  .sidebar { transform: translateX(-102%); transition: transform .25s ease; box-shadow: var(--shadow-lg); width: min(86vw, 320px); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .topbar { padding: 0 12px; background: var(--surface); border-bottom-color: var(--border); }
  .topbar .menu-btn { display: inline-flex; }
  .topbar .search-box { display: none; }
  .content { padding: 12px 12px calc(var(--bottombar-h) + 28px + env(safe-area-inset-bottom)); }
  .bottombar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--bottombar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .bottombar a, .bottombar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text-3);
    font-size: 11px; font-weight: 600; text-decoration: none; background: none; border: 0; font-family: inherit; position: relative; cursor: pointer;
  }
  .bottombar .active { color: var(--accent-text); }
  .bottombar svg.icon { width: 22px; height: 22px; }
  .bottombar .dot { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 16px; height: 16px; border-radius: 999px; background: #e5484d; color: #fff; font-size: 10px; display: grid; place-items: center; padding: 0 4px; }
}

/* ─────────────── Nagłówek strony ─────────────── */
.page-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin: 12px 0 18px; }
.page-head .grow { flex: 1 1 440px; min-width: min(440px, 100%); } /* przy wielu przyciskach przyciski przechodzą pod tytuł */
.page-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head .desc { color: var(--text-2); margin-top: 4px; max-width: 760px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text-3); margin-bottom: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--text-2); }
.form-code { font-size: 12px; font-weight: 700; color: var(--text-2); background: var(--surface-3); border-radius: 6px; padding: 2px 7px; letter-spacing: .02em; }

/* ─────────────── Przyciski ─────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 600 14px/1 var(--font);
  cursor: pointer; white-space: nowrap; text-decoration: none !important; transition: background .12s, border-color .12s, box-shadow .12s;
  box-shadow: var(--shadow-sm); user-select: none;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { background: var(--accent-600); }
.btn.danger { color: var(--red-fg); }
.btn.danger.solid { background: #d92d20; border-color: #d92d20; color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { height: 46px; padding: 0 20px; font-size: 15px; }
.btn.icon { width: 38px; padding: 0; }
.btn.icon.sm { width: 32px; }
.btn.block { width: 100%; }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 640px) {
  .page-head .actions .btn .label-long { display: none; }
  /* cele dotykowe ≥ 40–44 px na telefonie */
  .btn.sm, .chip { min-height: 40px; }
  .seg button, .seg.sm button { min-height: 44px; min-width: 48px; }
  .btn.icon, .btn.icon.sm { min-width: 40px; min-height: 40px; }
  .subtable td.rm .btn { min-width: 44px; min-height: 44px; }
  label.switch { min-height: 40px; }
  .list-plain a.item { min-height: 44px; }
  .crumbs a { padding: 8px 0; }
  .file .btn { min-width: 40px; min-height: 40px; }
}

/* ─────────────── Karty ─────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { flex: 1; }
.card-body { padding: 16px 18px; }
.card + .card { margin-top: 16px; }
.grid > .card, .stack > .card, .split > .card, .row > .card, .chips > .card { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: minmax(0, 1fr); } .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } }

/* KPI */
.kpi { padding: 16px; display: flex; flex-direction: column; gap: 6px; text-decoration: none !important; color: inherit; }
.kpi .label { font-size: 13px; color: var(--text-2); font-weight: 560; }
.kpi .value { font-size: 28px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; }
.kpi .hint { font-size: 12px; color: var(--text-3); }
.kpi.tone-red .value { color: var(--red-fg); } .kpi.tone-green .value { color: var(--green-fg); }
.kpi.tone-amber .value { color: var(--amber-fg); } .kpi.tone-purple .value { color: var(--purple-fg); } .kpi.tone-blue .value { color: var(--blue-fg); }
a.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
@media (max-width: 700px) { .kpi { padding: 12px; } .kpi .value { font-size: 22px; } }

/* Moduły (kafelki) */
.tile { display: flex; gap: 14px; padding: 16px; align-items: flex-start; color: inherit; text-decoration: none !important; }
.tile .ico { width: 42px; height: 42px; border-radius: 11px; background: var(--accent-50); color: var(--accent-text); display: grid; place-items: center; flex: none; }
.tile .ico svg.icon { width: 22px; height: 22px; }
.tile h3 { margin-bottom: 3px; }
.tile p { color: var(--text-2); font-size: 13px; margin: 0; }

/* ─────────────── Plakietki ─────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 650; line-height: 1.6; white-space: nowrap; background: var(--gray-bg); color: var(--gray-fg); }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tone-gray { background: var(--gray-bg); color: var(--gray-fg); }
.tone-blue { background: var(--blue-bg); color: var(--blue-fg); }
.tone-green { background: var(--green-bg); color: var(--green-fg); }
.tone-amber { background: var(--amber-bg); color: var(--amber-fg); }
.tone-red { background: var(--red-bg); color: var(--red-fg); }
.tone-purple { background: var(--purple-bg); color: var(--purple-fg); }
.tone-teal { background: var(--teal-bg); color: var(--teal-fg); }
.kpi.tone-red, .kpi.tone-green, .kpi.tone-amber, .kpi.tone-purple, .kpi.tone-blue, .kpi.tone-gray, .kpi.tone-teal { background: var(--surface); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font: 600 13px var(--font); cursor: pointer; white-space: nowrap; }
.chip:hover { background: var(--surface-3); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.chip .n { font-size: 11.5px; opacity: .75; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

/* ─────────────── Formularze ─────────────── */
input, select, textarea {
  width: 100%; font: 15px/1.4 var(--font); color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 9px 12px; min-height: 40px; transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); padding: 0; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-3); color: var(--text-2); }
input[type="color"] { padding: 3px; height: 40px; width: 64px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a8699' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px; }
@media (max-width: 700px) { input, select, textarea { font-size: 16px; } }
/* Pole wyboru z przyciskiem „+ Nowy…” / „+ Dodaj” (nowy wpis lub pozycja słownika bez wychodzenia z formularza) */
.ref-add { display: flex; gap: 6px; align-items: flex-start; }
.ref-add > :first-child { flex: 1 1 auto; min-width: 0; }
.ref-add .ref-new { flex: none; height: 40px; }
.subtable .ref-add .ref-new { height: 36px; width: 36px; min-width: 36px; }
/* Pole wyboru z podpowiedziami (długie listy, np. kartoteka materiałów) */
.combo { position: relative; }
.combo .combo-input { width: 100%; padding-right: 34px; }
.combo-clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--text-3); width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; cursor: pointer; }
.combo-clear:hover { background: var(--surface-3); color: var(--text); }
.combo-pop { position: fixed; z-index: 150; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-lg); overflow-y: auto; padding: 4px; overscroll-behavior: contain; }
.combo-item { padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 14px; line-height: 1.3; color: var(--text); }
.combo-item.hi { background: var(--accent-50); color: var(--accent-text); }
.combo-item.sel { font-weight: 650; }
.combo-note { padding: 8px 10px; color: var(--text-3); font-size: 13px; }
/* nagłówek grupy na liście podpowiedzi (np. grupa materiału) — zostaje u góry przy przewijaniu */
.combo-group { position: sticky; top: -4px; z-index: 1; padding: 8px 10px 4px; background: var(--surface); font-size: 11.5px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.combo-group:not(:first-child) { margin-top: 4px; border-top: 1px solid var(--border); }
.combo-pop .combo-item, .combo-sheet .combo-item { scroll-margin-top: 32px; }
.combo-create { display: flex; gap: 6px; align-items: center; color: var(--accent-text); font-weight: 600; border-top: 1px solid var(--border); margin-top: 4px; }
@media (max-width: 640px) { .combo-item { padding: 11px 12px; font-size: 15px; } }
.combo .combo-input[readonly] { cursor: pointer; }
/* telefon: wybór z długiej listy na całym ekranie (pole wpisywania u góry, nad klawiaturą) */
.combo-sheet { position: fixed; left: 0; right: 0; top: 0; height: 100%; z-index: 160; display: flex; flex-direction: column; background: var(--surface); animation: fade .12s ease; }
.combo-sheet-head { flex: none; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; border-bottom: 1px solid var(--border); background: var(--surface); touch-action: none; }
.combo-sheet-title { font-size: 13px; font-weight: 650; color: var(--text-2); margin: 0 2px 6px; }
.combo-sheet-bar { display: flex; gap: 8px; align-items: center; }
.combo-sheet-bar .combo-sheet-input { flex: 1; min-width: 0; }
.combo-sheet-list { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 4px 6px calc(24px + env(safe-area-inset-bottom)); }
.combo-sheet .combo-item { padding: 12px 10px; font-size: 16px; line-height: 1.35; border-radius: 8px; }
.combo-sheet .combo-item + .combo-item { margin-top: 2px; }
.combo-sheet .combo-note { font-size: 14px; }
@media (max-width: 640px) { .ref-add .ref-new span { display: none; } .ref-add .ref-new { width: 40px; padding: 0; } }

.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px 16px; }
.field { grid-column: span 12; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.w-half { grid-column: span 6; } .field.w-third { grid-column: span 4; } .field.w-quarter { grid-column: span 3; } .field.w-2third { grid-column: span 8; }
@media (max-width: 800px) { .field.w-half, .field.w-third, .field.w-quarter, .field.w-2third { grid-column: span 12; } .field.w-quarter.keep, .field.w-third.keep { grid-column: span 6; } }
.field > label, .field .label { font-size: 13px; font-weight: 620; color: var(--text-2); display: flex; gap: 6px; align-items: center; }
.field .req { color: var(--red-fg); }
.field .help { font-size: 12.5px; color: var(--text-3); }
.field .err { font-size: 12.5px; color: var(--red-fg); font-weight: 560; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: #d92d20; }
.form-section { grid-column: span 12; margin-top: 10px; padding-top: 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.form-section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.form-section h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
.form-section p { font-size: 13px; color: var(--text-3); margin: 0; }
.info-box { grid-column: span 12; background: var(--accent-50); border: 1px solid var(--accent-100); color: var(--text); padding: 12px 14px; border-radius: 10px; font-size: 13.5px; display: flex; gap: 10px; }
.info-box svg { color: var(--accent); margin-top: 2px; }
.input-affix { display: flex; align-items: stretch; }
.input-affix input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-affix .affix { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 10px 10px 0; background: var(--surface-3); color: var(--text-2); font-size: 13px; }

/* Przełączniki segmentowe (TAK/NIE, oceny, opcje) */
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  min-width: 44px; height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-2); font: 650 14px var(--font); cursor: pointer;
}
.seg button:hover { background: var(--surface-3); }
.seg button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.seg button.on.v-TAK, .seg button.on.tone-green { background: #16a34a; border-color: #16a34a; color: #fff; }
.seg button.on.v-NIE, .seg button.on.tone-red { background: #dc2626; border-color: #dc2626; color: #fff; }
.seg button.on.v-ND, .seg button.on.tone-gray { background: #64748b; border-color: #64748b; color: #fff; }
.seg button.on.tone-amber { background: #d97706; border-color: #d97706; color: #fff; }
.seg.sm button { height: 32px; min-width: 38px; padding: 0 9px; font-size: 13px; border-radius: 8px; }
.seg:has(button:disabled) button { cursor: default; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 560; font-size: 14px; color: var(--text); }
.switch input { appearance: none; width: 40px; height: 24px; border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s; border: 0; min-height: 0; padding: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }

/* Tabela edytowalna w formularzu */
.subtable { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.subtable table { width: 100%; border-collapse: collapse; }
.subtable th { background: var(--surface-2); text-align: left; font-size: 12px; font-weight: 700; color: var(--text-2); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.subtable td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.subtable tr:last-child td { border-bottom: 0; }
.subtable td input, .subtable td select { min-height: 36px; padding: 6px 9px; font-size: 14px; }
.subtable .row-label { font-weight: 620; font-size: 13.5px; white-space: nowrap; }
.subtable .add-row { padding: 8px; background: var(--surface-2); border-top: 1px solid var(--border); }
@media (max-width: 800px) {
  .subtable thead { display: none; }
  .subtable table, .subtable tbody, .subtable tr, .subtable td { display: block; width: 100%; }
  .subtable tr { padding: 10px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .subtable td { border: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
  .subtable td.row-label, .subtable td.wide { grid-column: span 2; }
  .subtable td::before { content: attr(data-label); font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; }
  .subtable td.row-label::before, .subtable td.rm::before { display: none; }
  .subtable td.rm { grid-column: span 2; align-items: flex-end; }
}

/* Lista kontrolna */
.checklist { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.cl-group { background: var(--surface-2); padding: 9px 12px; font-size: 12.5px; font-weight: 750; color: var(--text-2); text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--border); }
.cl-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; padding: 10px 12px; border-bottom: 1px solid var(--border); align-items: center; }
.cl-item:last-child { border-bottom: 0; }
.cl-item .t { font-weight: 600; font-size: 14px; }
.cl-item .t .k { color: var(--text-3); font-weight: 700; margin-right: 6px; font-size: 12.5px; }
.cl-item .h { font-size: 12.5px; color: var(--text-3); }
.cl-item .note { grid-column: span 2; }
.cl-item .note input { min-height: 34px; font-size: 13.5px; padding: 6px 10px; }
.cl-item .meas { display: flex; gap: 8px; align-items: center; }
.cl-item .meas input { width: 92px; min-height: 36px; padding: 6px 8px; }
.cl-item.nok { background: color-mix(in srgb, var(--red-bg) 55%, transparent); }
@media (max-width: 700px) { .cl-item { grid-template-columns: minmax(0, 1fr); } .cl-item .note { grid-column: span 1; } }

/* Podpis */
.sig { display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px dashed var(--border-strong); border-radius: 10px; background: var(--surface-2); flex-wrap: wrap; }
.sig.signed { border-style: solid; border-color: color-mix(in srgb, #16a34a 45%, transparent); background: var(--green-bg); color: var(--green-fg); }
.sig .who { font-weight: 650; }
.sig .when { font-size: 12.5px; opacity: .8; }

/* ─────────────── Tabele / listy ─────────────── */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .search { position: relative; flex: 1; min-width: 200px; max-width: 420px; }
.toolbar .search input { padding-left: 36px; }
.toolbar .search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.toolbar .filters { display: contents; }
.filter-toggle { display: none !important; }
@media (max-width: 700px) {
  .filter-toggle { display: inline-flex !important; }
  .toolbar .filters { display: none; width: 100%; flex-direction: column; gap: 8px; }
  .toolbar .filters.open { display: flex; }
  .toolbar .filters select { width: 100% !important; }
  .toolbar .search { min-width: 0; flex-basis: 0; }
}
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow-sm); }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
table.data th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-size: 12px; font-weight: 700; color: var(--text-2); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; cursor: default; user-select: none; }
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--text); }
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .overdue { color: var(--red-fg); font-weight: 650; }
.cell-title { font-weight: 600; color: var(--text); }
.cell-no { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
/* kody materiałów w magazynie — pogrubione i większe (stan magazynowy; listy: pole z emphasis: true) */
.cell-kod, table.data td.cell-strong { font-weight: 750; font-size: 15.5px; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 800px) {
  .table-wrap.responsive { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .table-wrap.responsive table.data, .table-wrap.responsive tbody { display: block; }
  .table-wrap.responsive thead { display: none; }
  .table-wrap.responsive tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
  .table-wrap.responsive td { display: flex; flex-direction: column; gap: 2px; padding: 0; border: 0; min-width: 0; }
  .table-wrap.responsive td::before { content: attr(data-label); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-3); }
  .table-wrap.responsive td.primary { grid-column: span 2; order: -1; }
  .table-wrap.responsive td.primary::before { display: none; }
  .table-wrap.responsive td.num { text-align: left; }
  .table-wrap.responsive tbody tr:hover td { background: transparent; }
}
.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty .ico { width: 56px; height: 56px; border-radius: 16px; background: var(--surface-3); display: grid; place-items: center; margin: 0 auto 12px; color: var(--text-3); }
.empty .ico svg.icon { width: 26px; height: 26px; }
.empty h3 { margin-bottom: 6px; color: var(--text); }

.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; gap: 12px; align-items: center; padding: 11px 16px; border-bottom: 1px solid var(--border); }
.list-plain li:last-child { border-bottom: 0; }
.list-plain a.item { display: flex; gap: 12px; align-items: center; flex: 1; min-width: 0; color: inherit; text-decoration: none; min-height: 36px; }
.cell-title a, a.row-link { color: inherit; text-decoration: none; }
.cell-title a:hover { text-decoration: underline; }
.ref-list { display: flex; flex-direction: column; gap: 3px; }
.list-plain .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-plain .s { font-size: 12.5px; color: var(--text-3); }
.list-plain .grow { flex: 1; min-width: 0; }

/* ─────────────── Widok rekordu ─────────────── */
.dl { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 0 20px; }
.dl .item { grid-column: span 6; padding: 11px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.dl .item.w-full { grid-column: span 12; } .dl .item.w-third { grid-column: span 4; } .dl .item.w-quarter { grid-column: span 3; }
.dl .k { font-size: 12.5px; font-weight: 620; color: var(--text-3); margin-bottom: 3px; }
.dl .v { font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }
.dl .v.empty-v { color: var(--text-3); }
.dl .section { grid-column: span 12; padding: 18px 0 4px; font-size: 13px; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
.dl .section:first-child { padding-top: 0; }
@media (max-width: 800px) { .dl .item, .dl .item.w-third, .dl .item.w-quarter { grid-column: span 12; } }
.ro-table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 4px; }
.ro-table th, .ro-table td { max-width: 320px; overflow-wrap: normal; word-break: normal; }
.ro-table th, .ro-table td { border: 1px solid var(--border); padding: 7px 9px; text-align: left; vertical-align: top; }
.ro-table th { background: var(--surface-2); font-size: 12px; color: var(--text-2); }
.ro-wrap { overflow-x: auto; }

.status-line { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.meta-line { font-size: 12.5px; color: var(--text-3); display: flex; gap: 14px; flex-wrap: wrap; }
.files { display: flex; flex-direction: column; gap: 8px; }
.file { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.file .ext { width: 38px; height: 38px; border-radius: 9px; background: var(--surface-3); display: grid; place-items: center; font-size: 10.5px; font-weight: 800; color: var(--text-2); text-transform: uppercase; flex: none; }
.file .ext.pdf { background: #fde8e8; color: #b42318; } .file .ext.docx, .file .ext.doc { background: #e7efff; color: #1d4ed8; }
.file .ext.xlsx, .file .ext.xls, .file .ext.csv { background: #e3f6ea; color: #157a3d; } .file .ext.jpg, .file .ext.jpeg, .file .ext.png, .file .ext.webp, .file .ext.heic { background: #f1e9ff; color: #6b2fd0; }
.file .ext.pptx, .file .ext.ppt { background: #fff3d6; color: #9a5b00; }
.file .nm { flex: 1; min-width: 0; }
.file .nm a { font-weight: 600; color: var(--text); word-break: break-word; }
.file .nm .s { font-size: 12px; color: var(--text-3); }
.dropzone { border: 2px dashed var(--border-strong); border-radius: 12px; padding: 16px; text-align: center; color: var(--text-2); font-size: 13.5px; transition: all .15s; }
.dropzone.over { border-color: var(--accent); background: var(--accent-50); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; font-size: 13.5px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline li::after { content: ""; position: absolute; left: 8.5px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline .when { font-size: 12px; color: var(--text-3); }
.diff { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }
.diff b { color: var(--text); font-weight: 620; }

/* ─────────────── Modal, menu, toast ─────────────── */
.modal-layer { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(10, 16, 26, .5); animation: fade .15s ease; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 40px); background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: pop .18s ease; }
.modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { flex: 1; font-size: 17px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
@media (max-width: 640px) {
  .modal-layer { padding: 0; place-items: end stretch; }
  .modal, .modal.wide { width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; }
  .modal-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.menu { position: fixed; z-index: 110; min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; animation: pop .12s ease; }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 10px; border: 0; background: none; border-radius: 8px; font: 550 14px var(--font); color: var(--text); cursor: pointer; text-align: left; text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--surface-3); }
.menu .sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu .danger { color: var(--red-fg); }
.menu .head { padding: 8px 10px 6px; font-size: 12.5px; color: var(--text-3); }
.toasts { position: fixed; z-index: 200; left: 50%; transform: translateX(-50%); bottom: 24px; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(460px, calc(100vw - 24px)); }
@media (max-width: 1023px) { .toasts { bottom: calc(var(--bottombar-h) + 16px + env(safe-area-inset-bottom)); } }
.toast { pointer-events: auto; background: #1b2433; color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 520; display: flex; gap: 10px; align-items: center; animation: pop .18s ease; max-width: 100%; }
.toast.error { background: #b42318; } .toast.success { background: #157a3d; }
.update-bar { position: fixed; z-index: 190; top: calc(10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px); display: flex; gap: 10px; align-items: center; background: var(--accent); color: #fff; padding: 8px 8px 8px 14px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 520; animation: pop .18s ease; }
.update-bar .btn { flex: none; background: #fff; color: #1b2433; border-color: transparent; }
@media (max-width: 600px) { .update-bar { width: calc(100vw - 32px); font-size: 13px; } }

.spinner { width: 22px; height: 22px; border: 2.5px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
.loading { display: grid; place-items: center; padding: 60px 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: 0; padding: 10px 14px; font: 600 14px var(--font); color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--accent-text); border-bottom-color: var(--accent-text); }
.tabs button .n { font-size: 11.5px; background: var(--surface-3); border-radius: 999px; padding: 1px 7px; margin-left: 4px; }

.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: 14px; align-items: flex-start; border: 1px solid transparent; }
.alert.warn { background: var(--amber-bg); color: var(--amber-fg); border-color: color-mix(in srgb, var(--amber-fg) 20%, transparent); }
.alert.info { background: var(--blue-bg); color: var(--blue-fg); }
.alert.danger { background: var(--red-bg); color: var(--red-fg); }
.alert.success { background: var(--green-bg); color: var(--green-fg); }
.alert .grow { flex: 1; }
.alert a { color: inherit; text-decoration: underline; font-weight: 650; }

/* Macierz uprawnień */
.perm-table td, .perm-table th { padding: 8px 10px; }
.perm-table .seg button { height: 32px; min-width: 0; padding: 0 10px; font-size: 12.5px; }

/* Logowanie */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, var(--accent-100), transparent), radial-gradient(900px 500px at 110% 110%, var(--accent-50), transparent), var(--bg); }
.login-card { width: min(420px, 100%); padding: 32px 28px; }
.login-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-wrap button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }

/* QR */
.qr { background: #fff; padding: 10px; border-radius: 12px; display: inline-block; line-height: 0; border: 1px solid var(--border); }
.qr svg { width: 180px; height: 180px; }
.link-box { display: flex; gap: 8px; }
.link-box input { font-family: var(--mono); font-size: 13px; }

/* Pasek akcji (mobilny) */
.sticky-actions { position: sticky; bottom: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); padding: 12px 0; margin-top: 16px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--border); }
@media (max-width: 1023px) { .sticky-actions { bottom: calc(var(--bottombar-h) + env(safe-area-inset-bottom)); padding: 10px 0; } .sticky-actions .btn { flex: 1; } }

/* Macierz ryzyka i widoki specjalne — wspólne */
.heat { display: grid; gap: 4px; }
.heat .cell { border-radius: 8px; min-height: 54px; display: grid; place-items: center; font-weight: 750; font-size: 15px; cursor: pointer; border: 2px solid transparent; }
.heat .cell.sel { border-color: var(--text); }
.heat .ax { font-size: 12px; color: var(--text-3); font-weight: 650; display: grid; place-items: center; }

/* ─────────────── Wydruk ─────────────── */
.print-root { display: none; }
@media print {
  /* numer strony na każdej stronie wydruku (GQMS-P-01 pkt 5) */
  @page { size: A4; margin: 12mm 12mm 14mm; @bottom-right { content: "Strona " counter(page) " z " counter(pages); font: 8pt Arial, Helvetica, sans-serif; color: #444; } }
  body { background: #fff; color: #000; font-size: 11pt; }
  body.printing .app, body.printing .toasts, body.printing .modal-layer, body.printing .update-bar { display: none !important; }
  body.printing .print-root { display: block; }
  .no-print { display: none !important; }
}
.pdoc { color: #000; font-family: Arial, Helvetica, sans-serif; font-size: 10.5pt; line-height: 1.35; }
.pdoc + .pdoc { page-break-before: always; }
.pdoc .phead { display: grid; grid-template-columns: 90px 1fr 150px; border: 1.5px solid #000; margin-bottom: 10px; }
.pdoc .phead > div { padding: 6px 8px; border-right: 1px solid #000; display: flex; flex-direction: column; justify-content: center; }
.pdoc .phead > div:last-child { border-right: 0; font-size: 8.5pt; }
.pdoc .phead .logo { align-items: center; font-weight: 800; font-size: 13pt; }
.pdoc .phead .logo img { max-width: 76px; max-height: 50px; }
.pdoc .phead .ttl { text-align: center; }
.pdoc .phead .ttl .co { font-size: 8.5pt; }
.pdoc .phead .ttl .t { font-size: 13pt; font-weight: 700; text-transform: uppercase; }
.pdoc .phead .ttl .code { font-size: 9pt; font-weight: 700; }
.pdoc h2 { font-size: 11pt; margin: 12px 0 5px; text-transform: uppercase; border-bottom: 1px solid #000; padding-bottom: 2px; }
.pdoc table { width: 100%; border-collapse: collapse; margin: 4px 0 8px; page-break-inside: auto; }
.pdoc tr { page-break-inside: avoid; }
.pdoc th, .pdoc td { border: 1px solid #000; padding: 4px 6px; text-align: left; vertical-align: top; font-size: 9.5pt; }
.pdoc th { background: #eee; font-weight: 700; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.pdoc .kv td:first-child { width: 34%; font-weight: 700; background: #f5f5f5; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.pdoc .box { display: inline-block; width: 11px; height: 11px; border: 1px solid #000; margin-right: 4px; vertical-align: -1px; text-align: center; line-height: 10px; font-size: 9px; font-weight: 800; }
.pdoc .sigs { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 28px; }
.pdoc .sigs .ln { border-top: 1px dotted #000; padding-top: 3px; font-size: 8.5pt; text-align: center; }
.pdoc .pfoot { margin-top: 18px; border-top: 1px solid #000; padding-top: 4px; font-size: 7.5pt; color: #333; display: flex; justify-content: space-between; gap: 10px; }
.pdoc .pre { white-space: pre-wrap; }
.pdoc td.strong { font-weight: 700; font-size: 10.5pt; white-space: nowrap; }
/* Stan magazynowy (A4 poziomo): miejsce na datę, 10 kratek na wydania (−) / zwroty (+) w ciągu dnia i „Razem” */
.pdoc.arkusz .phead { margin-bottom: 6px; }
.pdoc.arkusz .data-wpisu { display: flex; align-items: flex-end; gap: 18px; margin: 2px 0 6px; }
.pdoc.arkusz .data-wpisu .pole { display: inline-flex; align-items: flex-end; gap: 6px; font-size: 12pt; white-space: nowrap; }
.pdoc.arkusz .data-wpisu .ln { display: inline-block; width: 55mm; height: 8mm; border-bottom: 1.5px solid #000; }
.pdoc.arkusz .data-wpisu .uw { font-size: 8.5pt; line-height: 1.3; }
.pdoc.arkusz table { table-layout: fixed; margin-top: 0; }
.pdoc.arkusz th, .pdoc.arkusz td { padding: 2px 4px; font-size: 8.5pt; line-height: 1.2; vertical-align: middle; }
.pdoc.arkusz th { text-align: center; }
.pdoc.arkusz td { height: 9mm; }
.pdoc.arkusz td.lp { text-align: right; font-size: 8pt; }
.pdoc.arkusz td.kod { font-weight: 700; font-size: 10.5pt; white-space: nowrap; overflow: hidden; }
.pdoc.arkusz td.nazwa { overflow: hidden; }
.pdoc.arkusz td.stan { text-align: right; font-weight: 700; font-size: 9.5pt; white-space: nowrap; }
.pdoc.arkusz td.stan .min { font-weight: 400; font-size: 7.5pt; }
.pdoc.arkusz th.kr { padding: 2px 0; font-size: 8pt; }
.pdoc.arkusz .razem { background: #efefef; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.pdoc.arkusz tr.grp { break-after: avoid; page-break-after: avoid; }
.pdoc.arkusz tr.grp td { height: auto; padding: 3px 6px; background: #e4e4e4; font-weight: 700; font-size: 9pt; text-transform: uppercase; letter-spacing: .03em; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.pdoc.arkusz .uwagi { font-size: 8pt; margin-top: 4px; }
.print-preview { background: #fff; color: #000; padding: 28px; border-radius: 10px; box-shadow: var(--shadow); max-width: 900px; margin: 0 auto; }
@media print { .print-preview { box-shadow: none; padding: 0; border-radius: 0; max-width: none; } }

/* Etykiety / naklejki */
.labels-sheet { display: grid; gap: 0; }
.label-cell { border: 1px dashed #bbb; padding: 3mm 4mm; overflow: hidden; color: #000; background: #fff; font-family: Arial, Helvetica, sans-serif; }
@media print { .label-cell { border-color: transparent; } }

/* ───────── Uproszczenia: pola „więcej szczegółów”, etapy procesu, strona modułu ───────── */
.field.more-collapsed { display: none; }
.more-toggle { grid-column: span 12; justify-self: start; display: inline-flex; align-items: center; gap: 6px; background: none; border: 1px dashed var(--border-strong); color: var(--accent-text); font: inherit; font-size: 13.5px; font-weight: 600; padding: 7px 12px; border-radius: 999px; cursor: pointer; margin: 2px 0 4px; }
.more-toggle:hover { background: var(--accent-50); }
.more-toggle .icon { width: 16px; height: 16px; transition: transform .15s ease; }
.more-toggle.open .icon { transform: rotate(180deg); }
.stepper { display: flex; gap: 0; align-items: flex-start; margin: 14px 0 4px; max-width: 860px; }
.stepper .step { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; position: relative; font-size: 12.5px; color: var(--text-3); }
.stepper .step::before { content: ''; position: absolute; top: 13px; left: calc(-50% + 16px); right: calc(50% + 16px); height: 2px; background: var(--border-strong); }
.stepper .step:first-child::before { display: none; }
.stepper .step .dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--surface); border: 2px solid var(--border-strong); color: var(--text-3); position: relative; z-index: 1; }
.stepper .step .dot .icon { width: 15px; height: 15px; }
.stepper .step .lbl { margin-top: 6px; line-height: 1.25; padding: 0 4px; overflow-wrap: anywhere; }
.stepper .step.done .dot { background: var(--green-fg); border-color: var(--green-fg); color: #fff; }
.stepper .step.done::before, .stepper .step.current::before { background: var(--green-fg); }
.stepper .step.current .dot { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--accent-100); }
.stepper .step.current .lbl { color: var(--text); font-weight: 700; }
.stepper.off .step .dot { opacity: .5; }
.next-step { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; padding: 9px 12px; border-radius: 10px; background: var(--accent-50); color: var(--text); font-size: 14px; max-width: 860px; }
.next-step .icon { color: var(--accent-text); flex: none; margin-top: 2px; }
.next-step.done { background: var(--green-bg); }
.next-step.done .icon { color: var(--green-fg); }
@media (max-width: 700px) {
  .stepper .step .lbl { display: none; }
  .stepper .step.current .lbl { display: block; position: absolute; top: 34px; white-space: nowrap; }
  .stepper { margin-bottom: 26px; }
}
.task-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }
.task-buttons .btn { min-height: 52px; padding: 10px 18px; font-size: 15px; border-radius: 12px; }
.task-buttons .btn .icon { width: 20px; height: 20px; }
@media (max-width: 700px) { .task-buttons .btn { flex: 1 1 100%; justify-content: flex-start; } }
details.more-registers > summary { cursor: pointer; font-weight: 650; color: var(--text-2); margin: 18px 0 10px; list-style: none; display: inline-flex; gap: 6px; align-items: center; }
details.more-registers > summary::-webkit-details-marker { display: none; }
details.more-registers[open] > summary .icon { transform: rotate(180deg); }
.btn .more-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--accent-fg); font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; margin-left: 2px; }
.card .table-wrap table.data th { white-space: normal; }
.card .table-wrap table.data td { overflow-wrap: anywhere; }

/* iPhone / iPad: pole tekstowe z czcionką mniejszą niż 16 px przybliża stronę przy dotknięciu (Safari).
   Na ekranach dotykowych i wąskich każde pole ma min. 16 px — także w tabelach pozycji, listach kontrolnych i widokach. */
@media (pointer: coarse), (max-width: 700px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), select, textarea { font-size: 16px !important; }
}

/* iPhone (Safari): pola daty i godziny mają systemowy wygląd o stałej szerokości i wystają poza ramkę —
   zwykłe pole na całą szerokość, wartość od lewej (jak w pozostałych polach). */
input[type="date"], input[type="datetime-local"], input[type="time"], input[type="month"], input[type="week"] {
  -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%;
}
input::-webkit-date-and-time-value { text-align: left; margin: 0; min-height: 1.4em; }
