/* Layout: sticky top bar with three workspaces (Wyceny / Katalog / Ustawienia); the quote editor is a two-column workbench — form on the left, catalog picker + live totals on the right — with an A4 paper preview tab. */
:root {
  --bg: #eef0ef;
  --surface: #ffffff;
  --surface-2: #f6f7f6;
  --ink: #1a1f22;
  --muted: #5b656b;
  --line: #d6dbdc;
  --line-strong: #b9c1c3;
  --accent: #a85f00;
  --accent-ink: #ffffff;
  --accent-soft: #fbefdc;
  --focus: #2b6cb0;
  --ok: #2e7d4f; --ok-soft: #e1f2e7;
  --warn: #9a6a00; --warn-soft: #fbf1d6;
  --bad: #b23a3a; --bad-soft: #f8e3e3;
  --info: #2c5d8f; --info-soft: #e2ecf6;
  --shadow: 0 1px 2px rgba(20,30,35,.06), 0 4px 14px rgba(20,30,35,.05);
  /* paper is always paper: fixed print colors, deliberately theme-independent */
  --paper: #ffffff; --paper-ink: #1c2226; --paper-muted: #66717a; --paper-line: #dfe3e6; --paper-soft: #f4f6f7;
  --f-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --f-body: "IBM Plex Sans", "Segoe UI", Roboto, Arial, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --r: 6px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #15191b; --surface: #1d2326; --surface-2: #232a2e; --ink: #e6eaeb; --muted: #9aa5ab; --line: #313a3e; --line-strong: #46525a;
  --accent: #f0a43a; --accent-ink: #1a1203; --accent-soft: #3a2c16; --focus: #7fb2ec;
  --ok: #6fcf97; --ok-soft: #1c3527; --warn: #e8c15a; --warn-soft: #3a3118; --bad: #f08a8a; --bad-soft: #3d2222; --info: #8dbbea; --info-soft: #1d2c3d;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #15191b; --surface: #1d2326; --surface-2: #232a2e; --ink: #e6eaeb; --muted: #9aa5ab; --line: #313a3e; --line-strong: #46525a;
  --accent: #f0a43a; --accent-ink: #1a1203; --accent-soft: #3a2c16; --focus: #7fb2ec;
  --ok: #6fcf97; --ok-soft: #1c3527; --warn: #e8c15a; --warn-soft: #3a3118; --bad: #f08a8a; --bad-soft: #3d2222; --info: #8dbbea; --info-soft: #1d2c3d;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--f-body); }

h1, h2, h3 { font-family: var(--f-display); margin: 0; text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 15px; font-weight: 600; }
.wrap { max-width: 1320px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.num, .mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

/* top bar */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 20px; min-height: 56px; flex-wrap: wrap; padding-block: 6px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--f-display); font-weight: 700; font-size: 16px; }
.brand-mark { width: 28px; height: 28px; border-radius: 5px; background: var(--ink); color: var(--bg); display: grid; place-items: center; font-family: var(--f-mono); font-size: 12px; font-weight: 500; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a { padding: 7px 12px; border-radius: var(--r); color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.who { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); font-size: 12px; font-weight: 500; white-space: nowrap; }

main { padding-block: 22px 60px; }
.banner { margin-bottom: 16px; padding: 10px 14px; border-radius: var(--r); background: var(--warn-soft); color: var(--ink); border: 1px solid var(--line); }
.banner.info { background: var(--info-soft); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 65ch; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 13px; border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn.danger.armed { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn.icon { padding: 4px 8px; min-width: 30px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label.f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
label.f > span { font-size: 12px; color: var(--muted); font-weight: 500; letter-spacing: .02em; }
input[type=text], input[type=email], input[type=date], input[type=search], input:not([type]), select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); min-width: 0;
}
textarea { resize: vertical; min-height: 64px; line-height: 1.45; }
input:disabled, textarea:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }
input.r { text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
@media (max-width: 720px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } .span2 { grid-column: auto; } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card > .body { padding: 16px; }
.eyebrow { font-family: var(--f-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* tables */
.tw { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t .r { text-align: right; }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr.click:hover td { background: var(--surface-2); }
.sub { color: var(--muted); font-size: 12px; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-family: var(--f-display); font-size: 16px; margin-bottom: 4px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-draft { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.st-sent { background: var(--info-soft); color: var(--info); }
.st-accepted { background: var(--ok-soft); color: var(--ok); }
.st-rejected { background: var(--bad-soft); color: var(--bad); }
.tag-ex { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--warn-soft); color: var(--warn); font-weight: 500; margin-left: 6px; }

/* stats strip */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 16px; }
.stats > div { background: var(--surface); padding: 12px 16px; }
.stats b { display: block; font-family: var(--f-mono); font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=search] { width: 260px; max-width: 100%; }
.toolbar select { width: auto; }

/* editor */
.ed-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.ed-head .ttl { display: flex; flex-direction: column; min-width: 0; }
.ed-head .ttl .mono { font-size: 13px; color: var(--muted); }
.ed-head .grow { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 13px; cursor: pointer; font-weight: 500; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.save-state { font-size: 12px; color: var(--muted); min-width: 92px; }
.ed-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.ed-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ed-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 72px); min-width: 0; }
@media (max-width: 1000px) { .ed-grid { grid-template-columns: minmax(0, 1fr); } .ed-side { position: static; } }

table.lines td { padding: 6px 8px; vertical-align: top; }
table.lines th { padding: 8px; }
table.lines input { padding: 5px 7px; }
table.lines .c-name { min-width: 230px; }
table.lines .c-name input + input { margin-top: 4px; font-size: 12px; color: var(--muted); }
table.lines .c-qty { width: 78px; } table.lines .c-unit { width: 64px; } table.lines .c-price { width: 112px; } table.lines .c-disc { width: 70px; }
table.lines .c-tot { width: 120px; text-align: right; padding-top: 11px; white-space: nowrap; }
table.lines .c-act { width: 1%; white-space: nowrap; padding-top: 8px; }
table.lines tr.grp td { background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 8px; letter-spacing: .03em; }
.line-actions { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }

.picker-list { max-height: 340px; overflow-y: auto; border-top: 1px solid var(--line); }
.pick { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.pick:last-child { border-bottom: 0; }
.pick .nm { flex: 1; min-width: 0; }
.pick .nm div { overflow: hidden; text-overflow: ellipsis; }
.pick .pr { font-family: var(--f-mono); font-size: 12px; white-space: nowrap; color: var(--muted); }
.cats { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 14px 10px; }
.cats button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 2px 10px; font-size: 12px; cursor: pointer; color: var(--muted); }
.cats button[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); background: var(--surface-2); }

.sum { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 13px; }
.sum dt { color: var(--muted); }
.sum dd { margin: 0; text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.sum .big { font-size: 20px; color: var(--ink); font-weight: 500; }
.sum hr { grid-column: 1 / -1; border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.internal { margin-top: 12px; padding: 10px 12px; border-radius: var(--r); background: var(--surface-2); border: 1px dashed var(--line-strong); }
.meter { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; background: var(--ok); }

/* preview */
.preview { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 24px 16px; overflow: hidden; }
.preview .pages { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.preview .pages > .sheet { box-shadow: 0 2px 12px rgba(0,0,0,.18); }
#measure { position: absolute; left: -12000px; top: 0; width: 794px; }

/* A4 sheet (96 dpi: 794 × 1123) */
.sheet { width: 794px; height: 1123px; background: var(--paper); color: var(--paper-ink); padding: 52px 58px 34px; display: flex; flex-direction: column; font: 10.5pt/1.45 var(--f-body); flex: none; }
.sheet .sb { flex: 1; overflow: hidden; display: flex; flex-direction: column; gap: 0; }
.sheet .sb > * + * { margin-top: 14px; }
.sheet .sf { border-top: 1px solid var(--paper-line); padding-top: 8px; display: flex; justify-content: space-between; gap: 12px; color: var(--paper-muted); font-size: 7.5pt; }
.of-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding-bottom: 14px; border-bottom: 3px solid var(--brand, #1f3a5f); }
.of-head img { max-height: 64px; max-width: 220px; display: block; }
.of-head .co-name { font-family: var(--f-display); font-weight: 700; font-size: 15pt; color: var(--brand, #1f3a5f); }
.of-head .co { text-align: right; font-size: 8.5pt; color: var(--paper-muted); white-space: pre-line; }
.of-head .co b { color: var(--paper-ink); font-size: 9.5pt; }
.of-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.of-title h1 { font-size: 21pt; color: var(--paper-ink); letter-spacing: .01em; }
.of-title .meta { text-align: right; font-size: 9pt; color: var(--paper-muted); }
.of-title .meta b { color: var(--paper-ink); font-family: var(--f-mono); font-weight: 500; }
.of-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.of-parties > div { background: var(--paper-soft); padding: 10px 12px; border-radius: 4px; font-size: 9.5pt; white-space: pre-line; }
.of-lbl { display: block; font-size: 7.5pt; letter-spacing: .1em; text-transform: uppercase; color: var(--paper-muted); margin-bottom: 3px; font-weight: 600; }
.of-subject { font-family: var(--f-display); font-weight: 600; font-size: 12.5pt; }
.of-intro { white-space: pre-line; }
table.of-t { width: 100%; border-collapse: collapse; font-size: 9pt; }
table.of-t th { background: var(--brand, #1f3a5f); color: #fff; font-weight: 600; text-align: left; padding: 6px 7px; font-size: 8pt; letter-spacing: .02em; }
table.of-t td { padding: 6px 7px; border-bottom: 1px solid var(--paper-line); vertical-align: top; }
table.of-t .r { text-align: right; white-space: nowrap; font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-size: 8.5pt; }
table.of-t .lp { width: 26px; color: var(--paper-muted); }
table.of-t tr.grp td { background: var(--paper-soft); font-weight: 600; font-size: 8.5pt; letter-spacing: .04em; text-transform: uppercase; color: var(--paper-muted); }
table.of-t .d { color: var(--paper-muted); font-size: 8pt; }
.of-sum { margin-left: auto; width: 290px; font-size: 9.5pt; }
.of-sum div { display: flex; justify-content: space-between; padding: 3px 0; }
.of-sum div span:last-child { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.of-sum .tot { border-top: 2px solid var(--brand, #1f3a5f); margin-top: 4px; padding-top: 6px; font-weight: 600; font-size: 11.5pt; }
.of-terms { display: grid; grid-template-columns: 150px 1fr; gap: 4px 14px; font-size: 9.5pt; }
.of-terms dt { color: var(--paper-muted); }
.of-terms dd { margin: 0; white-space: pre-line; }
.of-small { font-size: 8.5pt; color: var(--paper-muted); white-space: pre-line; }
.of-sign { display: flex; justify-content: flex-end; }
.of-sign > div { width: 230px; text-align: center; font-size: 9pt; padding-top: 40px; border-bottom: 1px dotted var(--paper-muted); padding-bottom: 4px; }
.of-sign small { display: block; color: var(--paper-muted); font-size: 7.5pt; margin-top: 4px; }

/* catalog & settings */
.two { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .two { grid-template-columns: minmax(0, 1fr); } }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.hint code { font-family: var(--f-mono); background: var(--surface-2); padding: 0 4px; border-radius: 3px; }
.logo-box { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo-box img { max-height: 56px; max-width: 200px; background: #fff; padding: 4px; border: 1px solid var(--line); border-radius: 4px; }
details.imp summary { cursor: pointer; font-weight: 500; }
.toast { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r); box-shadow: var(--shadow); z-index: 20; max-width: min(420px, calc(100vw - 32px)); }
@media (prefers-reduced-motion: no-preference) { .toast { animation: tin .18s ease-out; } @keyframes tin { from { transform: translateY(6px); opacity: .4; } } }

/* standalone version: login and account */
html, body { margin: 0; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left, 0px)); }
.login .card { width: 100%; max-width: 380px; }
.login h1 { font-size: 20px; margin-bottom: 4px; }
.login .err { color: var(--bad); font-size: 13px; min-height: 1.2em; margin: 0; }
.who a, .who button { color: var(--muted); }
.who .btn { padding: 4px 10px; font-size: 13px; }
.top { top: 0; }
[hidden] { display: none !important; }
img { max-width: 100%; }
