/* Generator pieczątek Amigo – wygląd aplikacji (kolory i czcionki z amigomultipunkt.pl) */
:root {
  --red: #E2001A;
  --stamp: #A80014;
  --white: #FFFFFF;
  --paper: #F1F1F3;
  --ink: #22222B;
  --ink-2: #4A4A55;
  --muted: #7A7A85;
  --line: #D6D6DC;
  --warn: #F5B301;
  --warn-tint: #FFF8E1;
  --red-tint: #FFF3F4;
  --font-h: "Rubik", system-ui, sans-serif;
  --font-b: "Public Sans", system-ui, sans-serif;
  --radius: 6px;
  --topbar-h: 56px;
  --ctl-h: 32px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-b);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-2);
  background: var(--white);
}
h1, h2 { font-family: var(--font-h); color: var(--ink); margin: 0; line-height: 1.2; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Pasek górny ---------- */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 1.25rem;
  border-top: 4px solid var(--red);
  border-bottom: 1px solid var(--line);
  background: var(--white);
}
.brand { display: flex; align-items: center; gap: .7rem; flex: none; }
.brand-mark {
  width: 26px; height: 18px; border: 2.5px solid var(--red); border-radius: 3px;
  box-shadow: inset 0 0 0 2px var(--white), inset 0 0 0 4px var(--red);
}
.brand h1 { font-size: 1.2rem; font-weight: 600; white-space: nowrap; }
.brand h1 span { color: var(--red); }
.topbar-actions { display: flex; gap: .4rem; align-items: center; }
.topbar-actions .btn[aria-pressed="true"] { background: var(--paper); color: var(--ink); }
.doc-title { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; gap: .6rem; padding-left: 1.2rem; margin-left: .4rem; border-left: 1px solid var(--line); }
.doc-name { font-family: var(--font-h); font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-state { font-size: .78rem; white-space: nowrap; }
.doc-state.is-dirty { color: var(--stamp); }
.doc-state.is-dirty::before { content: "● "; color: var(--red); }
.doc-state.is-saved { color: var(--muted); }
.doc-state.is-saved::before { content: "✓ "; }

/* ---------- Przyciski ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  font-family: var(--font-h); font-weight: 500; font-size: .92rem; line-height: 1;
  padding: .6em 1em; border-radius: var(--radius);
  border: 1.5px solid var(--line); background: var(--white); color: var(--ink);
  cursor: pointer; white-space: nowrap;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover { border-color: var(--ink-2); }
.btn:disabled { opacity: .4; cursor: default; }
.btn--primary { background: var(--red); border-color: var(--red); color: var(--white); }
.btn--primary:hover { background: var(--stamp); border-color: var(--stamp); }
.btn--ghost { border-color: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--paper); border-color: transparent; color: var(--ink); }
.btn--icon { width: 32px; height: var(--ctl-h); padding: 0; font-size: 1.1rem; }
.btn--sm { height: var(--ctl-h); padding: 0 .8em; font-size: .85rem; }
.btn--toggle[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--white); }
/* tylko część linii (fragment) pogrubiona albo pochylona */
.btn--toggle[aria-pressed="mixed"] { background: linear-gradient(135deg, var(--white) 50%, var(--line) 50%); border-color: var(--ink); }
.btn--square { width: var(--ctl-h); height: var(--ctl-h); padding: 0; font-size: 1rem; }
.btn--link {
  border: 0; padding: .3em 0; background: none; color: var(--stamp);
  font-family: var(--font-b); font-weight: 400; font-size: .85rem;
  text-decoration: underline; text-underline-offset: 3px;
}
.btn--link:hover { color: var(--red); }
.btn-pair { display: inline-flex; gap: .25rem; }
.ico-italic { font-family: "PT Serif", Georgia, serif; font-weight: 700; font-size: 1.05rem; }
.ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; padding: 0;
  border: 0; border-radius: 4px; background: transparent; color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--white); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.icon-btn:disabled { opacity: .25; cursor: default; background: none; box-shadow: none; }
.remove-btn:hover { color: var(--red); }

/* ---------- Układ ---------- */
.layout {
  display: grid;
  grid-template-columns: 370px minmax(0, 1fr);
  height: calc(100% - var(--topbar-h));
}
.panel {
  overflow-y: auto;
  border-right: 1px solid var(--line);
  padding: .75rem .9rem;
  display: flex; flex-direction: column; gap: .7rem;
}
.card { display: flex; flex-direction: column; gap: .45rem; }
.card + .card { border-top: 1px solid var(--line); padding-top: .7rem; }
.card h2 { font-size: .95rem; font-weight: 600; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }

/* ---------- Pola formularza ---------- */
.field-label { font-size: .78rem; font-weight: 600; color: var(--ink); }

input[type="text"], input[type="number"], input[type="password"], select {
  width: 100%;
  height: var(--ctl-h);
  padding: 0 .6rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  transition: border-color .12s ease;
}
input:hover, select:hover { border-color: #B9B9C2; }
input:focus, select:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(226, 0, 26, .12); }
input:disabled { background: var(--paper); color: var(--muted); }
input.is-warn { border-color: var(--warn); background: var(--warn-tint); }

.mini-field { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; color: var(--ink-2); white-space: nowrap; }
.mini-field input { width: 58px; padding: 0 .3rem; text-align: center; }

/* ---------- Wymiar i ramka ---------- */
.size-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.size-label { font-family: var(--font-h); font-weight: 600; font-size: .95rem; color: var(--ink); width: 70px; flex: none; }
.size-row select { flex: 1 1 0; min-width: 0; }
.size-custom { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; flex-basis: 100%; padding-left: calc(70px + .5rem); }
.size-custom input { width: 62px; padding: 0 .35rem; text-align: center; }
.frame-row { gap: .45rem; }
.frame-row { justify-content: space-between; }
.frame-row .mini-field input { width: 50px; }
.check { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; width: auto; margin-right: .3rem; }
.check input { width: 17px; height: 17px; margin: 0; accent-color: var(--red); cursor: pointer; }

/* ---------- Lista linii ---------- */
.lines-form { display: flex; flex-direction: column; gap: 3px; }
.line-group {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem; align-items: center;
  padding: 3px .25rem 3px .4rem;
  border-left: 3px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) 0;
  cursor: pointer;
}
.line-group:hover { background: var(--paper); }
.line-group.is-selected { background: var(--red-tint); border-left-color: var(--red); }
.line-group.is-blank { border-left-style: dashed; }
.line-fields { display: flex; flex-direction: column; gap: 3px; }
.line-tools { display: flex; align-items: center; }
.line-arrows { display: flex; flex-direction: column; }
.line-arrows .icon-btn { width: 24px; height: 15px; }
.line-row { display: grid; grid-template-columns: 82px minmax(0, 1fr) auto; align-items: center; gap: .35rem; }
.line-row:not(:has(.eye-btn)) { grid-template-columns: 82px minmax(0, 1fr); }
.line-row .field-label { line-height: 1.15; cursor: pointer; }
/* wybór zawodu w miejscu opisu pola „Nr PWZ” */
.line-row .field-select { width: 100%; height: auto; padding: .15rem 0; border: 0; background: transparent; font-size: .78rem; font-weight: 600; color: var(--ink); cursor: pointer; }
.line-row .field-select:focus-visible { outline: 2px solid var(--red); outline-offset: 1px; }
.line-row.is-empty .field-label { color: var(--muted); font-weight: 500; }
.line-row.is-hidden input { color: var(--muted); text-decoration: line-through; background: var(--paper); }
.line-row.is-hidden .eye-btn { color: var(--red); }

/* ---------- Pasek właściwości linii ---------- */
.propbar {
  display: flex; flex-direction: column; gap: .4rem;
  padding: .5rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--white);
}
.propbar-row { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.propbar-name { display: inline-flex; align-items: baseline; gap: .35rem; min-width: 0; margin-right: .2rem; }
.propbar-caption { font-size: .75rem; color: var(--muted); }
.propbar-name strong { font-family: var(--font-h); font-weight: 600; color: var(--stamp); white-space: nowrap; display: inline-block; vertical-align: bottom; max-width: 7em; overflow: hidden; text-overflow: ellipsis; }
.propbar-font { width: 160px; }
.stepper { display: inline-flex; align-items: center; gap: .25rem; }
.stepper input { width: 54px; text-align: center; padding: 0 .3rem; }
.stepper.is-disabled { opacity: .45; }
.unit { font-size: .8rem; color: var(--ink-2); white-space: nowrap; margin-left: .15rem; }
.propbar .segmented button { height: var(--ctl-h); padding: 0 .65em; display: inline-flex; align-items: center; }
.propbar-row:first-child .btn--link { margin-left: auto; }
.propbar-caption--gap { margin-left: .4rem; }
.line-dims { margin-left: auto; font-size: .8rem; color: var(--ink-2); white-space: nowrap; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.propbar-row:last-child { flex-wrap: nowrap; }
.propbar-row:last-child > :not(.line-dims) { flex: none; }
.line-dims.is-muted { color: var(--muted); font-style: italic; }
.line-dims.is-error { color: var(--red); font-weight: 600; }
.propbar--stamp { padding-top: .35rem; padding-bottom: .35rem; background: var(--paper); }
.propbar--stamp .segmented button { height: 30px; font-size: .85rem; }

.segmented { display: inline-flex; border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.segmented button {
  flex: 1; border: 0; background: var(--white); padding: .55em .8em;
  font-family: var(--font-h); font-weight: 500; font-size: .85rem; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.segmented button + button { border-left: 1.5px solid var(--line); }
.segmented button:hover { background: var(--paper); }
.segmented button[aria-pressed="true"] { background: var(--ink); color: var(--white); }
.segmented--small button { padding: .4em .7em; font-size: .82rem; }

/* ---------- Podgląd ---------- */
.preview { display: flex; flex-direction: column; background: var(--paper); min-width: 0; min-height: 0; }
.preview-canvas { flex: 1; min-height: 0; overflow: auto; display: flex; padding: 24px; }
#stamp-svg { display: block; flex: none; margin: auto; }
.preview-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .45rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--white);
}
.preview-info { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; }
.preview-info strong { font-family: var(--font-h); font-weight: 600; font-size: 1.05rem; color: var(--ink); }
.preview-info span { font-size: .85rem; }

/* Ostrzeżenia */
.warnings {
  list-style: none; margin: 0; padding: .4rem 1rem;
  display: flex; flex-direction: column; gap: .25rem;
  max-height: 30%; overflow-y: auto;
  border-top: 1px solid var(--line);
  background: var(--white);
}
.warning { position: relative; padding: .3rem .6rem .3rem 1.6rem; border-radius: 4px; font-size: .83rem; line-height: 1.35; }
.warning::before { position: absolute; left: .55rem; top: .3rem; font-weight: 700; }
.warning--error { background: var(--red-tint); color: var(--stamp); }
.warning--error::before { content: "!"; color: var(--red); }
.warning--warn { background: var(--warn-tint); color: #6B4E00; }
.warning--warn::before { content: "!"; color: #B58300; }
.warning.is-link { cursor: pointer; }
.warning.is-link:hover { text-decoration: underline; }

/* Elementy SVG */
.stamp-area { fill: var(--white); stroke: #9A9AA5; stroke-width: 1px; vector-effect: non-scaling-stroke; }
.stamp-margin { fill: none; stroke: #C9C9D1; stroke-width: 1px; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.stamp-text { fill: #000; white-space: pre; cursor: move; }
.stamp-ink-stroke { fill: none; stroke: #000; }
.stamp-ink-fill { fill: #000; stroke: none; }
.is-placeholder .stamp-text { fill: #BDBDC6; cursor: default; }
/* zaznaczanie liter na podglądzie (dwuklik w linię) */
.text-sel { fill: rgba(0, 120, 215, .35); pointer-events: none; }
.text-caret { fill: #0078D7; pointer-events: none; }
.is-text-mode .is-text { cursor: text; }
.is-placeholder .stamp-ink-stroke { stroke: #BDBDC6; }
.is-placeholder .stamp-ink-fill { fill: #BDBDC6; }
.line-hit { fill: transparent; cursor: move; }
.line-box { fill: none; stroke: none; pointer-events: none; }
.line-hit:hover + .line-box { fill: rgba(226, 0, 26, .05); }
.line-box.is-selected { fill: rgba(226, 0, 26, .08); stroke: var(--red); stroke-width: 1px; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.line-box.is-overflow { fill: rgba(226, 0, 26, .14); stroke: var(--red); stroke-width: 2px; stroke-dasharray: none; vector-effect: non-scaling-stroke; }
.ruler-tick { stroke: #8A8A95; stroke-width: 1px; vector-effect: non-scaling-stroke; }
.ruler-label { fill: var(--ink-2); font-family: var(--font-b); }

/* ---------- Ekran „Projekty” ---------- */
.library { height: calc(100% - var(--topbar-h)); overflow-y: auto; background: var(--paper); padding: 1.25rem 1.5rem 2rem; }
.library-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; margin-bottom: 1rem; }
.library-title { display: flex; align-items: center; gap: .5rem; margin-right: auto; }
.library-title h2 { font-size: 1.35rem; font-weight: 600; }
.btn--back { padding-left: .5em; }
.sheet-head { align-items: center; justify-content: flex-start; }
.sheet-head .hint { margin-left: auto; }
.pdf-scale input { width: 3.6em; }
.library-tools { display: flex; gap: .5rem; align-items: center; flex: 0 1 560px; }
.library-tools input[type="search"] { height: 38px; flex: 1; min-width: 0; }
.library-tools .btn { height: 38px; flex: none; }
.library-folder { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem 1rem; font-size: .85rem; }
.library-folder strong { color: var(--ink); }
.library-status { max-width: 640px; margin: 1rem 0 1.25rem; }
.library-status p { margin: 0 0 .75rem; }
.library-status .btn { height: 40px; }
.library-status .muted, .list-table .muted { color: var(--muted); }
.library-status .error, .list-table .error { color: var(--stamp); }
.library-empty { grid-column: 1 / -1; margin: 0; }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .9rem; }

.project-card {
  display: flex; flex-direction: column; text-align: left;
  padding: 0; border: 1.5px solid var(--line); border-radius: 8px; background: var(--white);
  overflow: hidden; cursor: pointer; font: inherit; color: inherit;
  transition: border-color .12s ease, box-shadow .12s ease;
}
button.project-card:hover { border-color: var(--red); box-shadow: 0 4px 14px rgba(34, 34, 43, .08); }
.project-card.is-error { cursor: default; border-style: dashed; }
.project-thumb { display: grid; place-items: center; height: 140px; padding: 12px; background: #FAFAFB; border-bottom: 1px solid var(--line); }
.project-thumb svg { max-width: 100%; max-height: 100%; }
.thumb-error { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--red-tint); color: var(--red); font-weight: 700; font-size: 1.4rem; }
.project-body { display: flex; flex-direction: column; gap: .15rem; padding: .65rem .8rem .75rem; min-width: 0; }
.project-title { font-family: var(--font-h); font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-meta { font-size: .8rem; }
.project-file { font-size: .75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.is-error .project-meta { color: var(--stamp); }
.is-error .project-title { white-space: normal; }
/* karta z przyciskiem usuwania w rogu (widocznym po najechaniu albo przy obsłudze klawiaturą) */
.project-item { position: relative; display: flex; }
.project-item > .project-card { flex: 1; min-width: 0; }
.project-del {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink-2);
  opacity: 0; transition: opacity .12s ease;
}
.project-item:hover .project-del, .project-del:focus-visible { opacity: 1; }
.project-del:hover { color: var(--red); border-color: var(--red); }
@media (hover: none) { .project-del { opacity: 1; } } /* ekran dotykowy: bez najechania myszą */
.delete-file { word-break: break-all; color: var(--muted); }
/* okno usuwania: domyślny (bezpieczny) przycisk wyróżniony, usuwanie tylko obrysowane */
.btn--safe { background: var(--ink); border-color: var(--ink); color: var(--white); }
.btn--safe:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn--safe:focus { outline: 2px solid var(--ink); outline-offset: 2px; }
.btn--danger { color: var(--red); border-color: var(--red); background: var(--white); }
.btn--danger:hover { background: var(--red-tint); }

/* ---------- Arkusz A4 ---------- */
.badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--red); color: var(--white); font-size: .72rem; font-weight: 600; line-height: 1;
}
.topbar-sep { width: 1px; height: 24px; background: var(--line); margin: 0 .2rem; }
.btn--wide { width: 100%; height: 42px; font-size: 1rem; }
.lib-pick-hint { font-size: .85rem; color: var(--stamp); }
.library.is-picking button.project-card:hover { border-color: var(--ink); }

.sheet-layout { display: grid; grid-template-columns: 370px minmax(0, 1fr); height: calc(100% - var(--topbar-h)); }
.sheet-add { display: flex; gap: .4rem; flex-wrap: wrap; }
.sheet-empty { margin: 0; font-size: .85rem; color: var(--muted); }
.sheet-row {
  display: flex; flex-direction: column; gap: .3rem;
  padding: .4rem .5rem .45rem .55rem;
  border-left: 3px solid var(--line); border-radius: 0 var(--radius) var(--radius) 0;
  cursor: pointer;
}
.sheet-row:hover { background: var(--paper); }
.sheet-sel { cursor: default; }
.sheet-row.is-selected { background: var(--red-tint); border-left-color: var(--red); }
.sheet-row.is-warn { border-left-color: var(--warn); }
.sheet-row.is-error { border-left-color: var(--red); border-left-style: dashed; }
.sheet-row-head { display: flex; align-items: baseline; gap: .45rem; min-width: 0; }
.sheet-row-no { font-size: .75rem; color: var(--muted); width: 1.1rem; flex: none; }
.sheet-row-head strong { font-family: var(--font-h); font-weight: 600; color: var(--ink); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sheet-row-dim { font-size: .75rem; color: var(--muted); margin-left: auto; white-space: nowrap; }
.sheet-row-pos { display: flex; align-items: center; gap: .4rem; padding-left: 1.55rem; }
.sheet-row-pos .mini-field input { width: 64px; }
.sheet-row-tools { margin-left: auto; display: inline-flex; align-items: center; gap: .3rem; }
.sheet-panel .check { margin: 0; }
.sheet-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

.sheet-zoom { display: inline-flex; align-items: center; gap: .5rem; flex: none; }
.zoom-label { font-size: .82rem; font-weight: 600; color: var(--ink); min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }
.sheet-preview .preview-footer { flex-wrap: nowrap; }
.sheet-preview .preview-info { flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; }
.sheet-preview .preview-info strong { white-space: nowrap; flex: none; }
.sheet-preview .preview-info span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#sheet-svg { display: block; flex: none; margin: auto; touch-action: none; user-select: none; }
#sheet-svg .page { fill: var(--white); stroke: #B9B9C2; stroke-width: 1px; vector-effect: non-scaling-stroke; filter: drop-shadow(0 1px 3px rgba(34, 34, 43, .15)); }
#sheet-svg .page-grid line { vector-effect: non-scaling-stroke; stroke-width: 1px; }
#sheet-svg .page-grid .g1 { stroke: #F6F6F8; }
#sheet-svg .page-grid .g5 { stroke: #EBEBEF; }
#sheet-svg .page-grid .g10 { stroke: #E2E2E8; }
#sheet-svg .printer-margin { fill: none; stroke: #B9B9C2; stroke-width: 1px; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
#sheet-svg .item-outline { fill: none; stroke: #9A9AA5; stroke-width: 1px; stroke-dasharray: 2 2; vector-effect: non-scaling-stroke; pointer-events: none; }
#sheet-svg .item-outline.is-selected { stroke: var(--red); stroke-width: 2px; stroke-dasharray: none; }
#sheet-svg .item-outline.is-warn { stroke: var(--warn); stroke-width: 2px; stroke-dasharray: none; }
#sheet-svg .item-outline.is-error { stroke: var(--red); stroke-width: 2px; stroke-dasharray: 5 3; fill: rgba(226, 0, 26, .08); }
#sheet-svg .item-hit { fill: transparent; cursor: grab; }
#sheet-svg .item-hit:active { cursor: grabbing; }
.sheet-stamp .stamp-text { cursor: inherit; }
.neg-bg { fill: #000; }
.is-negative .stamp-text { fill: #fff; }
.is-negative .stamp-ink-stroke { stroke: #fff; }
.is-negative .stamp-ink-fill { fill: #fff; }
.control-ruler line { stroke: #000; }
.control-ruler text { fill: #000; font-family: "Arimo", Arial, sans-serif; }

.export-row { display: inline-flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
#editor .preview-footer { flex-wrap: nowrap; gap: .75rem; }
#editor .preview-footer > * { flex: none; }
#editor .preview-footer .preview-info { flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; }
#editor .preview-footer .preview-info strong { white-space: nowrap; flex: none; }
#editor .preview-footer .preview-info span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#editor .preview-footer .export-row { flex-wrap: nowrap; }
.export-row .btn--sm { padding: 0 .7em; }
.preview-footer .export-row { margin-left: auto; }
.preview-footer #btn-to-sheet { margin-left: auto; }
.preview-footer #btn-to-sheet + .export-row { margin-left: 0; }

/* ---------- Wydruk: tylko arkusz, skala 1:1 ---------- */
#print-root { display: none; }
@page { size: A4 portrait; margin: 0; }
@media print {
  html, body { height: auto; margin: 0; padding: 0; background: #fff; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; width: 210mm; height: 297mm; overflow: hidden; }
  #print-root svg { display: block; width: 210mm; height: 297mm; }
  #print-root .stamp-text { fill: #000; }
  #print-root .is-negative .stamp-text { fill: #fff; }
  #print-root .stamp-ink-fill { fill: #000; }
  #print-root .is-negative .stamp-ink-fill { fill: #fff; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Okno pytania i powiadomienie ---------- */
.dialog { border: 0; border-radius: 10px; padding: 1.4rem 1.5rem 1.2rem; max-width: 440px; box-shadow: 0 18px 50px rgba(34, 34, 43, .25); }
.dialog::backdrop { background: rgba(34, 34, 43, .35); }
.dialog h2 { font-size: 1.1rem; margin-bottom: .5rem; }
.dialog p { margin: 0 0 1.2rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; }

.toast {
  position: fixed; left: 50%; bottom: 72px; transform: translateX(-50%); z-index: 50;
  max-width: min(560px, calc(100% - 2rem));
  padding: .6rem 1rem; border-radius: 8px;
  background: var(--ink); color: var(--white); font-size: .9rem;
  box-shadow: 0 8px 24px rgba(34, 34, 43, .25);
  pointer-events: none; /* komunikat leży nad podglądem – nie może zasłaniać liter przed kliknięciem */
}
.toast--error { background: var(--stamp); }

/* ---------- Mniejsze ekrany ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); height: auto; }
  .panel { border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .preview { order: -1; }
  .preview-canvas { min-height: 260px; }
  .topbar { height: auto; min-height: var(--topbar-h); flex-wrap: wrap; padding: .6rem 1rem; }
  .line-dims { margin-left: 0; }
  .propbar-row:last-child { flex-wrap: wrap; }
  #editor .preview-footer { flex-wrap: wrap; }
  .doc-title { order: 3; flex-basis: 100%; border-left: 0; padding-left: 0; margin-left: 0; }
  .library { height: auto; min-height: calc(100vh - var(--topbar-h)); padding: 1rem; }
  .library-tools { flex-basis: 100%; }
  .library-grid { grid-template-columns: 1fr; }
  .sheet-layout { grid-template-columns: minmax(0, 1fr); height: auto; }
  .sheet-preview { order: -1; min-height: 70vh; }
}.sheet-scale { margin: .35rem 0 .1rem; }

/* ---------- Dane z NIP ---------- */
.card-head-tools { display: inline-flex; gap: .9rem; }
.dialog--nip { max-width: 520px; width: calc(100vw - 2rem); }
.dialog--nip .nip-status { margin: 0 0 .7rem; font-size: .85rem; }
.nip-status.is-warn { color: #8a5a00; }
.nip-name-mode { margin-bottom: .6rem; }
.nip-fields { display: grid; grid-template-columns: auto auto 1fr; gap: .4rem .6rem; align-items: center; margin-bottom: .6rem; }
.nip-fields .field-label { white-space: nowrap; }
.nip-fields input[type="text"] { width: 100%; min-width: 0; height: 32px; }
.nip-fields .nip-old { grid-column: 3; margin-top: -.3rem; font-size: .75rem; color: #8a8a95; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog--nip .hint { margin: 0 0 1rem; }

/* ---------- Logo ---------- */
.stamp-logo { pointer-events: none; }
.is-negative .stamp-logo { filter: invert(1); }
.logo-card.is-drop { outline: 2px dashed var(--red, #E2001A); outline-offset: -4px; }
.logo-settings { display: flex; flex-direction: column; gap: .45rem; margin-top: .5rem; }
.logo-row { display: flex; align-items: center; gap: .5rem; flex-wrap: nowrap; }
.logo-thumb { width: 44px; height: 30px; object-fit: contain; border: 1px solid #D6D6DC; border-radius: 4px; background: #fff; padding: 2px; flex: none; }
.logo-row .mini-field input { width: 4.4em; }
.logo-row input[type="range"] { flex: 1; min-width: 60px; accent-color: var(--red); }
.logo-empty { margin: .35rem 0 0; }
.logo-hit { fill: transparent; stroke: transparent; stroke-width: .25; stroke-dasharray: .6 .4; cursor: move; }
.logo-hit:hover, .logo-hit.is-selected { stroke: var(--red); }
#logo-pos button { padding-left: .55em; padding-right: .55em; }
.logo-reserve-row { font-size: .85rem; }

/* ---------- Okno „Nowy”: rodzaje pieczątek ---------- */
#type-label { width: auto; min-width: 70px; }
.dialog--new { max-width: 720px; width: calc(100vw - 2rem); }
.dialog--new p { margin-bottom: .9rem; }
.type-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; margin-bottom: 1.1rem; }
.type-tile {
  display: flex; flex-direction: column; align-items: center; gap: .25rem;
  padding: .8rem .5rem .7rem; border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--white); color: var(--ink); font: inherit; text-align: center; cursor: pointer;
}
.type-tile:hover:not(:disabled), .type-tile:focus-visible { border-color: var(--red); background: var(--red-tint); }
.type-tile strong { font-family: var(--font-h); font-weight: 600; font-size: .95rem; }
.type-tile-hint { font-size: .75rem; color: var(--muted); line-height: 1.3; }
.type-tile:disabled { cursor: default; opacity: .5; }
.type-tile:disabled .type-tile-hint { font-style: italic; }
.type-icon { width: 56px; height: 56px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.type-tile:disabled .type-icon { stroke: var(--muted); }
.propbar-group { display: inline-flex; align-items: center; gap: .55rem; }
.propbar--stamp .check { font-size: .85rem; margin-right: 0; }
#ls-place { height: var(--ctl-h); padding: 0 .4rem; }
.size-custom.is-round > span[aria-hidden] { display: none; }
.ring-opts { display: inline-flex; align-items: center; gap: .35rem; margin-left: -.2rem; }
.ring-opts .mini-field input { width: 3.6em; }

/* ---------- Wspólne projekty: logowanie, konto, administrator ---------- */
.auth {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center; padding: 1rem;
  background: var(--paper);
}
.auth-box {
  width: min(380px, 100%);
  display: flex; flex-direction: column; gap: .7rem;
  padding: 1.6rem 1.6rem 1.4rem; border-radius: 10px;
  background: var(--white); border-top: 4px solid var(--red);
  box-shadow: 0 18px 50px rgba(34, 34, 43, .12);
}
.auth-brand { margin-bottom: .4rem; }
.auth-box h2 { font-size: 1.15rem; }
.auth-intro { margin: -.3rem 0 .2rem; font-size: .88rem; }
.auth-field { display: flex; flex-direction: column; gap: .2rem; font-size: .8rem; font-weight: 600; color: var(--ink); }
.auth-field input { height: 38px; font-weight: 400; font-size: .95rem; }
.auth-fields { display: flex; flex-direction: column; gap: .7rem; }
.auth-error { margin: 0; padding: .45rem .65rem; border-radius: var(--radius); background: var(--red-tint); color: var(--stamp); font-size: .85rem; }
.auth-box .btn--wide { margin-top: .3rem; }

.user-menu { position: relative; }
.user-btn { max-width: 170px; }
.user-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 220px; padding: .35rem; border-radius: 8px;
  background: var(--white); border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(34, 34, 43, .18);
  display: flex; flex-direction: column;
}
.user-pop-who { margin: 0; padding: .35rem .6rem .5rem; font-size: .78rem; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: .25rem; }
.user-pop button { text-align: left; padding: .45rem .6rem; border: 0; border-radius: 5px; background: none; cursor: pointer; }
.user-pop button:hover, .user-pop button:focus-visible { background: var(--paper); color: var(--ink); }

.lib-source { margin-left: .6rem; }

.dialog--wide { max-width: 760px; width: calc(100vw - 2rem); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .7rem; }
.dialog-head h2 { margin: 0; }
.dialog .hint { font-size: .82rem; color: var(--muted); margin: 0 0 .8rem; }
.table-wrap { max-height: 46vh; overflow-y: auto; margin-bottom: 1rem; border: 1px solid var(--line); border-radius: var(--radius); }
.list-table { width: 100%; border-collapse: collapse; font-size: .87rem; }
.list-table th { position: sticky; top: 0; background: var(--paper); text-align: left; font-weight: 600; color: var(--ink); padding: .45rem .7rem; font-size: .78rem; }
.list-table td { padding: .45rem .7rem; border-top: 1px solid var(--line); vertical-align: middle; }
.list-table td strong { color: var(--ink); }
.list-table tr.is-off td { color: var(--muted); }
.tag-off { color: var(--stamp); }
.cell-actions { text-align: right; white-space: nowrap; }
.user-form { border-top: 1px solid var(--line); padding-top: .9rem; }
.user-form h3 { font-family: var(--font-h); font-size: 1rem; color: var(--ink); margin: 0 0 .6rem; }
.user-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem .9rem; margin-bottom: .6rem; }
.user-form-checks { display: flex; align-items: flex-end; gap: 1rem; padding-bottom: .5rem; }
.user-form .auth-error { margin-bottom: .7rem; }
.btn--left { margin-right: auto; }
