/* Generator ofert – style interfejsu. Jeden krój (IBM Plex Sans), neutralne szarości,
   kolor pojawia się tylko tam, gdzie coś znaczy: spółka, błąd, poprawna walidacja. */

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --desk: #e5e7eb;
  --line: #e5e8ec;
  --line-strong: #d2d7dd;
  --hover: #f2f3f5;
  --text: #16191d;
  --text-2: #49515c;
  --text-3: #79818c;
  --ink: #16191d;
  --focus: #2459c9;
  --focus-ring: rgba(36, 89, 201, 0.16);
  --ok: #17784b;
  --err: #be3219;
  --radius: 6px;
  --font: 'Plex Doc', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --item-cols: 74px 74px minmax(96px, 1fr) 70px 80px 104px;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13.5px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-ligatures: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

.icon {
  display: inline-flex;
  flex: none;
}

.app {
  display: grid;
  grid-template-rows: 56px auto minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.app.is-loading > * {
  visibility: hidden;
}

/* ---------- Pasek górny ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 14px 0 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  flex: none;
}

.brand-name {
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-sep {
  width: 1px;
  height: 22px;
  margin: 0 6px;
  background: var(--line);
}

.save-status {
  margin-right: 10px;
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}

.save-status.is-error {
  color: var(--err);
}

.count {
  display: inline-grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: #eceef1;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 21px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eceef1;
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-example {
  background: #fdf1dc;
  color: #84500a;
}

.badge-ok {
  background: #e3f3ea;
  color: var(--ok);
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 17px;
  padding: 0 6px;
  border-radius: 4px;
  background: #f1f2f4;
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ---------- Przyciski ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.btn:hover {
  background: var(--hover);
  border-color: #c3c9d0;
}

.btn:focus-visible,
.icon-btn:focus-visible,
.chip:focus-visible,
.segmented button:focus-visible,
.company-card:focus-visible,
.company-item:focus-visible,
.link-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring), 0 0 0 1px var(--focus);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.btn-primary:hover {
  background: #2c3239;
  border-color: #2c3239;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}

.btn-ghost:hover {
  background: var(--hover);
  border-color: transparent;
  color: var(--text);
}

.btn-dashed {
  border-style: dashed;
  color: var(--text-2);
  background: transparent;
}

.btn-small {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
}

.btn-danger {
  background: var(--err);
  border-color: var(--err);
  color: #fff;
}

.btn-danger:hover {
  background: #a42a14;
  border-color: #a42a14;
}

.btn-danger-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--err);
}

.btn-danger-ghost:hover {
  background: #fbefec;
  border-color: transparent;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background-color 0.12s, color 0.12s;
}

.icon-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
  background: transparent;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: #c3c9d0;
  text-underline-offset: 3px;
  border-radius: 3px;
}

.link-btn:hover {
  color: var(--text);
  text-decoration-color: currentColor;
}

/* ---------- Układ roboczy ---------- */

.pane-switch {
  display: none;
  grid-row: 2;
}

.workspace {
  grid-row: 3;
  display: grid;
  grid-template-columns: minmax(560px, 648px) minmax(0, 1fr);
  min-height: 0;
}

.editor-pane {
  overflow-y: auto;
  padding: 4px 30px 40px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  scrollbar-gutter: stable;
}

.preview-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--desk);
}

/* ---------- Sekcje formularza ---------- */

.section {
  padding: 22px 0 24px;
  border-bottom: 1px solid var(--line);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 30px;
  margin-bottom: 14px;
}

.section-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
}

.section-hint {
  color: var(--text-3);
  font-size: 12.5px;
  text-align: right;
}

.text-error {
  color: var(--err);
}

.editor-foot {
  margin: 20px 0 0;
  color: var(--text-3);
  font-size: 12px;
}

.row {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  align-items: start;
}

.row > .field {
  margin-bottom: 0;
}

.row-2 {
  grid-template-columns: 1fr 1fr;
}

.row-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.row-offer {
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr);
}

.row-client {
  grid-template-columns: 200px minmax(0, 1fr);
}

.row-address {
  grid-template-columns: minmax(0, 1.5fr) 96px minmax(0, 1fr);
}

.row-appearance {
  grid-template-columns: minmax(0, 1fr) 220px;
}

.row-numbering {
  grid-template-columns: minmax(0, 1fr) 160px 130px;
}

.row-defaults {
  grid-template-columns: 150px auto auto;
  justify-content: start;
  column-gap: 24px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin-bottom: 14px;
}

.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}

.field-hint {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-3);
}

.field-status {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  min-height: 17px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-3);
}

.field-status:empty {
  min-height: 0;
}

.field-status .icon {
  margin-top: 1px;
}

.field-status.is-ok {
  color: var(--ok);
}

.field-status.is-error {
  color: var(--err);
}

.terms {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.term {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

/* ---------- Pola ---------- */

.input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  font-size: 13.5px;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.input:hover {
  border-color: #b8bfc7;
}

.input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.input::placeholder {
  color: #a3a9b1;
}

.input.is-invalid {
  border-color: var(--err);
}

.input.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(190, 50, 25, 0.14);
}

.input.is-valid {
  border-color: #92c6aa;
}

.textarea {
  display: block;
  height: auto;
  min-height: 34px;
  padding: 7px 10px;
  line-height: 1.45;
  resize: none;
  field-sizing: content;
}

.textarea[rows='2'] {
  min-height: 56px;
}

.textarea[rows='3'] {
  min-height: 76px;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.input-mono {
  font-variant-numeric: tabular-nums;
}

input[type='date'].input {
  padding-right: 6px;
}

.select {
  appearance: none;
  padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2379818c' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
}

.input-affix {
  position: relative;
  min-width: 0;
}

.input-affix .input {
  padding-right: 27px;
}

.affix {
  position: absolute;
  top: 50%;
  right: 9px;
  transform: translateY(-50%);
  color: var(--text-3);
  font-size: 12.5px;
  pointer-events: none;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.chip {
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text-2);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}

.chip:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.segmented-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.segmented-label {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  border-radius: 7px;
  background: #eceef1;
}

.segmented button {
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.segmented button.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12), 0 0 0 1px rgba(16, 24, 40, 0.04);
}

/* ---------- Wybór spółki ---------- */

.company-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.company-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  min-width: 0;
  padding: 13px 12px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s, background-color 0.12s;
}

.company-card:hover {
  border-color: #b8bfc7;
}

.company-card.is-selected {
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 5%, #fff);
  box-shadow: inset 0 0 0 1px var(--c);
}

.company-logo {
  display: block;
  height: 27px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
}

.company-logo-text {
  height: 27px;
  overflow: hidden;
  font-weight: 600;
  line-height: 27px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.company-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  color: var(--text-3);
  font-size: 11.5px;
}

.company-code {
  font-weight: 500;
  letter-spacing: 0.04em;
}

.company-card.is-selected .company-code {
  color: var(--c);
}

/* ---------- Pozycje ---------- */

.items-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 16px;
}

.items-head {
  display: grid;
  grid-template-columns: var(--item-cols);
  gap: 8px;
  padding: 0 0 8px 34px;
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 500;
}

.items-head span:nth-child(1),
.items-head span:nth-child(3),
.items-head span:nth-child(4),
.items-head .col-value {
  text-align: right;
}

.item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.item-index {
  padding-top: 8px;
  color: var(--text-3);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.item-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  column-gap: 8px;
  min-width: 0;
}

.input-name {
  font-weight: 500;
}

.input-desc {
  grid-column: 1;
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-2);
}

/* Ostatnia kolumna siatki ma tę samą szerokość co kolumna akcji (104 px),
   więc nazwa, opis i pola liczbowe kończą się na jednej linii. */
.item-grid {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: var(--item-cols);
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.item-value {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.item-actions {
  display: flex;
  justify-content: flex-end;
  align-self: center;
}

.item-actions .icon-btn {
  width: 26px;
  color: #aab0b7;
}

.item:hover .item-actions .icon-btn,
.item:focus-within .item-actions .icon-btn {
  color: var(--text-3);
}

.item-actions .icon-btn:hover {
  color: var(--text);
}

.item-error {
  grid-column: 1 / -1;
  margin-top: 7px;
  color: var(--err);
  font-size: 12px;
}

.items-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.totals {
  display: flex;
  align-items: baseline;
  gap: 18px;
}

.total {
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}

.total-label {
  color: var(--text-3);
  font-size: 12px;
}

.total-value {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.total-main .total-label {
  color: var(--text-2);
}

.total-main .total-value {
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ---------- Podgląd ---------- */

.preview-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 46px;
  padding: 0 14px 0 24px;
  border-bottom: 1px solid #d8dbe0;
  background: #eceef1;
}

.preview-title {
  font-size: 13px;
  font-weight: 600;
}

.preview-info {
  color: var(--text-3);
  font-size: 12px;
}

.zoom {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.zoom-label {
  min-width: 112px;
  font-variant-numeric: tabular-nums;
}

.preview-scroll {
  flex: 1;
  overflow: auto;
  padding: 28px 32px 56px;
}

.pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.page {
  flex: none;
  width: var(--page-w, 760px);
  aspect-ratio: 595.28 / 841.89;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 10px 30px rgba(16, 24, 40, 0.1);
}

.page svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Tekst w podglądzie musi mieć dokładnie te same szerokości co w PDF:
   kerning tak (z tabeli GPOS), ligatury i alternatywy kontekstowe nie. */
.doc-page {
  font-kerning: normal;
  font-variant-ligatures: none;
  font-feature-settings: 'liga' 0, 'clig' 0, 'calt' 0;
  text-rendering: geometricPrecision;
  white-space: pre;
}

.preview-empty {
  padding: 80px 0;
  color: var(--text-3);
}

/* ---------- Okna dialogowe ---------- */

.dialog {
  max-width: 96vw;
  max-height: min(880px, 92vh);
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 24px 64px rgba(16, 24, 40, 0.24), 0 2px 8px rgba(16, 24, 40, 0.08);
}

.dialog::backdrop {
  background: rgba(17, 20, 24, 0.38);
}

.dialog[open] {
  display: flex;
  flex-direction: column;
}

.dialog-small {
  width: 440px;
}

.dialog-wide {
  width: 1000px;
}

.dialog-companies {
  width: 1100px;
  height: min(880px, 92vh);
}

.dialog-body {
  padding: 22px 24px 20px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 20px 16px 24px;
  border-bottom: 1px solid var(--line);
}

.dialog-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dialog-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.dialog-sub,
.dialog-text {
  margin: 5px 0 0;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}

.dialog-sub {
  color: var(--text-3);
}

.dialog-list {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--text-2);
  font-size: 12.5px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}

/* Szkice */

.drafts {
  overflow: auto;
  min-height: 120px;
}

.draft {
  display: grid;
  grid-template-columns: 64px 176px minmax(0, 1fr) 112px 92px auto;
  align-items: center;
  gap: 16px;
  padding: 12px 20px 12px 24px;
  border-bottom: 1px solid var(--line);
}

.draft.is-current {
  background: #f7f8fa;
}

.draft-company {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c, #8e959f);
  flex: none;
}

.draft-number {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
}

.mono {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  white-space: nowrap;
}

.faint {
  color: var(--text-3);
  font-weight: 400;
}

.draft-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.draft-title,
.draft-client {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.draft-title {
  font-weight: 500;
}

.draft-client,
.draft-date {
  color: var(--text-3);
  font-size: 12.5px;
}

.draft-total {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.draft-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.draft-actions .btn {
  margin-right: 4px;
  min-width: 72px;
}

/* Spółki */

.companies-body {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

.companies-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: #f9fafb;
}

.company-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.company-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.company-item:hover {
  background: #f1f2f4;
}

.company-item.is-selected {
  background: #fff;
  border-color: var(--line-strong);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

.company-item-logo {
  display: grid;
  place-items: center start;
  width: 62px;
  height: 26px;
  flex: none;
}

.company-item-logo img {
  max-width: 62px;
  max-height: 22px;
}

.company-item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.company-item-name {
  overflow: hidden;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.company-item-meta {
  color: var(--text-3);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.sample-box {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.sample-box p {
  margin: 0;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.45;
}

.company-form {
  overflow: auto;
  padding: 6px 28px 28px;
}

.form-title {
  margin: 24px 0 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
}

.form-title:first-child {
  margin-top: 12px;
  padding-top: 0;
  border-top: 0;
}

.field-code {
  max-width: 220px;
}

.logo-box {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 74px;
  padding: 12px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
}

.logo-box > img {
  max-width: 200px;
  max-height: 48px;
}

.logo-empty {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-3);
  font-size: 12.5px;
}

.logo-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.logo-actions .field-hint {
  flex-basis: 100%;
}

.color-row {
  display: flex;
  gap: 8px;
}

.color-input {
  flex: none;
  width: 42px;
  height: 34px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
}

.number-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin: 2px 0 10px;
  padding: 11px 14px;
  border-radius: 8px;
  background: #f5f6f8;
}

.number-preview-label {
  color: var(--text-3);
  font-size: 12px;
}

.number-preview .mono {
  font-size: 15px;
  font-weight: 600;
}

.number-preview .text-error {
  font-size: 12px;
}

.tokens {
  margin: 0;
}

.form-danger {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.empty {
  max-width: 420px;
  margin: 72px auto;
  text-align: center;
}

.empty h2 {
  margin: 0 0 8px;
  font-size: 17px;
}

.empty p {
  margin: 0 0 18px;
  color: var(--text-2);
}

/* ---------- Komunikaty ---------- */

.toasts {
  position: fixed;
  inset: auto auto 22px 50%;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: 92vw;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
  transform: translateX(-50%);
  pointer-events: none;
}

.toasts[popover]:not(:popover-open) {
  display: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(600px, 92vw);
  padding: 10px 12px 10px 14px;
  border-radius: 8px;
  background: #16191d;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.25);
  pointer-events: auto;
  animation: toast-in 0.18s ease-out;
}

.toast.leaving {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.18s, transform 0.18s;
}

.toast-success .icon {
  color: #74d4a1;
}

.toast-error .icon {
  color: #ff917b;
}

.toast-info .icon {
  color: #9fb7ea;
}

.toast-action {
  margin-left: 4px;
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-weight: 500;
  cursor: pointer;
}

.toast-action:hover {
  background: rgba(255, 255, 255, 0.22);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.is-busy,
.is-busy * {
  cursor: progress !important;
}

.fatal {
  max-width: 560px;
  margin: 12vh auto;
  padding: 0 24px;
}

.fatal pre {
  white-space: pre-wrap;
  color: var(--text-3);
}

/* ---------- Mniejsze ekrany ---------- */

@media (max-width: 1240px) {
  .workspace {
    grid-template-columns: minmax(540px, 1.05fr) minmax(0, 1fr);
  }

  .save-status {
    display: none;
  }
}

@media (max-width: 1000px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .pane-switch {
    display: flex;
    gap: 4px;
    padding: 6px 12px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
  }

  .pane-switch button {
    flex: 1;
    height: 30px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-2);
    font-weight: 500;
    cursor: pointer;
  }

  .pane-switch button.is-active {
    background: #eceef1;
    color: var(--text);
  }

  .workspace[data-pane='editor'] .preview-pane,
  .workspace[data-pane='preview'] .editor-pane {
    display: none;
  }

  .editor-pane {
    border-right: 0;
  }

  .topbar .btn > span:not(.icon):not(.count),
  .brand .badge,
  .topbar-sep {
    display: none;
  }

  .dialog-companies .companies-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .companies-side {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .draft {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .draft-company,
  .draft-date {
    display: none;
  }
}

@media (max-width: 640px) {
  .editor-pane {
    padding: 4px 16px 32px;
  }

  .company-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .row-2,
  .row-3,
  .row-offer,
  .row-client,
  .row-address,
  .row-appearance,
  .row-numbering,
  .row-defaults,
  .term {
    grid-template-columns: minmax(0, 1fr);
  }

  .term {
    gap: 6px;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .section-hint {
    text-align: left;
  }

  :root {
    --item-cols: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr);
  }

  .items-head {
    display: none;
  }

  .items-controls {
    justify-content: flex-start;
  }

  .item-body {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .input-desc {
    grid-column: 1 / -1;
  }

  .items-foot,
  .totals {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .dialog-header {
    flex-direction: column;
  }
}

/* Wydruk z przeglądarki (Ctrl+P): tylko strony dokumentu. */
@media print {
  @page {
    size: A4;
    margin: 0;
  }

  html,
  body,
  .app {
    display: block;
    height: auto;
    background: #fff;
  }

  .topbar,
  .pane-switch,
  .editor-pane,
  .preview-bar,
  .toasts {
    display: none !important;
  }

  /* Kartka A4 jest węższa niż 1000 px, więc trzeba nadpisać też układ z zakładkami. */
  .workspace,
  .workspace[data-pane] .preview-pane,
  .preview-scroll {
    display: block !important;
    padding: 0;
    overflow: visible;
    background: #fff;
  }

  .pages {
    display: block;
  }

  .page {
    width: 210mm !important;
    height: 297mm;
    box-shadow: none;
    border-radius: 0;
    break-after: page;
  }

  .page:last-child {
    break-after: auto;
  }
}

/* Wersja demonstracyjna na warstwai.pl: pasek nad generatorem w kolorach strony. */

@font-face {
  font-family: "Schibsted Grotesk";
  src: url("../fonts/schibsted-grotesk-latin.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+2190-2193, U+2212, U+2713, U+20AC;
}
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("../fonts/schibsted-grotesk-pl.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0100-017F;
}

/* Zastępczy krój o tych samych metrykach co na stronie: podmiana fontu nie przesuwa paska. */
@font-face {
  font-family: "Grotesk Fallback";
  src: local("Arial"), local("Helvetica Neue"), local("Helvetica"), local("Liberation Sans"), local("Roboto");
  size-adjust: 100%;
  ascent-override: 97.7%;
  descent-override: 25.8%;
  line-gap-override: 0%;
}

/* Drobny szary tekst generatora przyciemniony do kontrastu 4,5:1 (WCAG AA). */
:root {
  --text-3: #646c77;
}

body.demo {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

body.demo .app {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}

.demobar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px 22px;
  padding: 10px 16px 10px 18px;
  background: #101b38;
  color: #fff;
  font-family: "Schibsted Grotesk", "Grotesk Fallback", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.35;
}

.demobar-brand {
  flex: none;
  display: block;
  line-height: 0;
  border-radius: 4px;
}

.demobar-text {
  min-width: 0;
  flex: 1 1 auto;
}

.demobar-title {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.demobar-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: #fbeed6;
  color: #8a4b05;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
}

.demobar-note {
  margin: 2px 0 0;
  color: #c9d2e3;
  font-size: 13px;
}

.demobar-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Przyciski działają dopiero po starcie skryptu; do tego czasu zajmują miejsce, żeby pasek nie skakał. */
.demobar-btn {
  display: inline-flex;
  align-items: center;
  visibility: hidden;
  height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 6px;
  background: transparent;
  color: #fff;
  font: 600 13.5px/1 "Schibsted Grotesk", "Grotesk Fallback", system-ui, sans-serif;
  cursor: pointer;
  transition: background-color .2s, border-color .2s;
}

.demobar.is-ready .demobar-btn {
  visibility: visible;
}

.demobar-btn:hover {
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .5);
}

.demobar-btn.is-primary {
  background: #1769ff;
  border-color: #1769ff;
}

.demobar-btn.is-primary:hover {
  background: #1157e0;
  border-color: #1157e0;
}

.demobar-link {
  margin-left: 6px;
  color: #fff;
  font-weight: 600;
  font-size: 13.5px;
  text-decoration: underline;
  text-decoration-color: #6fa0ff;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.demobar-link:hover {
  text-decoration-color: #fff;
}

.demobar a:focus-visible,
.demobar-btn:focus-visible {
  outline: 2px solid #6fa0ff;
  outline-offset: 2px;
}

.demobar .short {
  display: none;
}

body.demo noscript .fatal a {
  color: #1157e0;
}

@media (max-width: 1240px) {
  .demobar {
    flex-wrap: wrap;
  }

  .demobar-text {
    flex-basis: calc(100% - 140px);
  }

  .demobar-actions {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .demobar {
    padding: 10px 16px;
    gap: 8px 12px;
  }

  .demobar .long,
  .demobar-brand {
    display: none;
  }

  .demobar .short {
    display: inline;
  }

  .demobar-text {
    flex-basis: 100%;
  }

  .demobar-title {
    font-size: 14px;
  }

  .demobar-note {
    font-size: 12px;
  }

  .demobar-actions {
    flex-wrap: wrap;
    gap: 6px;
  }

  .demobar-btn {
    height: 32px;
    padding: 0 11px;
    font-size: 13px;
  }

  .demobar-link {
    margin-left: auto;
    font-size: 13px;
  }

  .demobar-title {
    gap: 4px 8px;
  }

  .demobar-chip {
    height: 20px;
    padding: 0 8px;
    font-size: 11.5px;
  }
}
