:root {
  --line: #b4b4b4;
  --head: #d0d0d0;
  --accent: #2f6b4f;
  --bg: #e8e8e8;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Calibri, Arial, sans-serif;
  background: var(--bg);
  color: #222;
}
.page { padding: 24px; max-width: 960px; margin: 0 auto; }
.topbar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; }
.login-stack { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.login-logo { width: 148px; height: auto; display: block; }
.login-box, .list { background: #fff; border: 1px solid var(--line); }
.login-box { width: 400px; padding: 24px; display: grid; gap: 8px; background: #fff; }
.login-box h1 { margin: 0; font-size: 22px; line-height: 1.25; text-align: center; }
.login-box input { padding: 8px; }
.muted, .hint, .label, .status { color: #666; font-size: 13px; }
.list { width: 100%; border-collapse: collapse; }
.list th, .list td { border: 1px solid var(--line); padding: 8px; text-align: left; }
.list th { background: var(--head); }

.sheet {
  display: grid;
  grid-template-columns: 214px 1fr;
  grid-template-rows: 1fr auto;
  height: 100vh;
  overflow: hidden;
}
.toolbar {
  grid-row: 1 / -1;
  background: #f3f3f3;
  border-right: 1px solid var(--line);
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: visible;
  min-height: 0;
  position: relative;
  z-index: 20;
}
.toolbar-top {
  position: relative;
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 6px;
}
.brand-mark {
  width: 31px;
  height: 31px;
  object-fit: contain;
  display: block;
  flex: 0 0 auto;
}
.hamburger {
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 0;
}
.hamburger span {
  display: block;
  width: 14px;
  height: 2px;
  background: #333;
  border-radius: 1px;
}
.hamburger[aria-expanded="true"] {
  background: #e8eee9;
  border-color: var(--accent);
}
.app-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  padding: 6px;
  display: grid;
  gap: 2px;
  z-index: 30;
}
.app-menu[hidden] { display: none; }
.app-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 9px 10px;
  font: inherit;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  border-radius: 6px;
}
.app-menu-item.is-active {
  background: #e8eee9;
  font-weight: 600;
}
.hub-page { max-width: 880px; }
.funnel {
  margin: 0 0 22px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.funnel h2 { margin: 0 0 4px; font-size: 18px; }
.funnel-total { margin: 8px 0 12px; font-size: 28px; font-weight: 700; color: var(--accent); }
.funnel-stages { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.funnel-stage {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f4f7f5;
}
.funnel-stage strong { font-size: 15px; }
.offer-status { display: grid; gap: 8px; }
.toolbar-actions .status-toggle { width: 100%; }
.status-menu { position: relative; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.status-submenu {
  z-index: 40;
  min-width: 168px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.status-submenu[hidden] { display: none; }
.status-submenu form { display: grid; margin: 0; }
.status-choice {
  text-align: left;
  background: none;
  border: 0;
  font: inherit;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.status-choice:hover,
.status-choice:focus { background: #f4f7f5; }
.status-choice.is-current { font-weight: 700; background: #e8eee9; }
.status-cell { cursor: pointer; border: 0; font: inherit; }
.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #e4e4e4;
  color: #243028;
}
.status-wyslana { background: #d9e8ff; color: #16325c; }
.status-przyjeta { background: #d8f3e2; color: #145032; }
.status-odrzucona { background: #fde2e2; color: #6d2424; }
.status-zamknieta { background: #e6e6e6; color: #333; }
.order-link, #order-modal select { font: inherit; }
#order-modal select { width: 100%; padding: 6px; border: 1px solid var(--line); margin-top: 4px; }
.dash-page { max-width: 1280px; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.9fr); gap: 16px; align-items: start; }
.dash-main, .dash-side { display: grid; gap: 16px; }
.dash-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}
.dash-card h2 { margin: 0 0 6px; font-size: 18px; }
.dash-chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dash-scope { display: flex; align-items: center; margin-left: auto; }
.dash-scope label { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dash-scope select { font: inherit; padding: 4px 8px; }
.margin-ticker {
  margin: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: #e7f6ec;
  color: #146c36;
  font-weight: 700;
  font-size: 14px;
}
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 360px; margin: 16px 0 8px; }
.bar-col { flex: 1; display: grid; justify-items: center; gap: 6px; height: 100%; min-width: 0; }
.bar-pair { display: flex; align-items: flex-end; gap: 4px; height: calc(100% - 18px); width: 100%; justify-content: center; }
.bar { position: relative; width: 18px; border-radius: 4px 4px 0 0; min-height: 0; overflow: hidden; }
.bar-margin { position: absolute; left: 0; right: 0; bottom: 0; }
.bar-prev { background: #c5d4e8; }
.bar-prev .bar-margin { background: #6e8eb8; }
.bar-now { background: #2f6f4e; }
.bar-now .bar-margin { background: #e0b15a; }
.bar-legend { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; font-size: 13px; color: #555; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-left: 8px; }
.swatch.prev { background: #c5d4e8; margin-left: 0; }
.swatch.now { background: #2f6f4e; }
.swatch.prev-margin { background: #6e8eb8; }
.swatch.now-margin { background: #e0b15a; }
.dash-profit { margin: 0 0 8px; font-size: 18px; font-weight: 700; color: #8a6a1f; }
.dash-total-value { margin: 8px 0; font-size: 32px; font-weight: 700; color: var(--accent); }
.g-funnel { display: grid; justify-items: center; gap: 8px; margin-top: 12px; }
.g-funnel-step {
  display: grid;
  gap: 2px;
  min-width: 160px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #d9e8ff;
  text-align: center;
}
.g-funnel-step.step-orders { background: #d8f3e2; }
.date-stale { color: #9b1c1c; font-weight: 700; }
.hub-lead {
  font-size: 15px;
  color: #555;
  margin: 8px 0 18px;
}
.hub-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.hub-tile {
  display: grid;
  gap: 8px;
  padding: 28px 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(160deg, #fff 0%, #f4f8f6 100%);
  text-decoration: none;
  color: inherit;
  min-height: 140px;
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
}
.hub-tile:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(47, 107, 79, 0.12);
}
.hub-tile-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}
.hub-tile-desc {
  font-size: 14px;
  color: #555;
  line-height: 1.4;
}
.vat-figures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.vat-total {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
}
.vat-cost-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: end;
}
.vat-cost-form label {
  display: grid;
  gap: 4px;
}
.vat-docs .list td.col-num,
.vat-docs .list th.col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.history-list td.num,
.history-list th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.history-list input[type="search"] { min-width: 16rem; }
.history-sheet-page { max-width: none; }
.history-scroll { overflow-x: auto; }
.history-grid { border-collapse: collapse; background: #fff; min-width: 720px; }
.history-grid th,
.history-grid td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.history-grid th { background: var(--head); }
.history-grid .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.history-grid .doc-head,
.history-grid .doc-sub { text-align: center; font-weight: 600; white-space: nowrap; }
.history-grid .doc-sub { font-weight: 500; font-size: 12px; }
.history-grid td.wz-col,
.history-grid th.wz-col { background: #e7f3ec; }
.history-grid td.inv-col,
.history-grid th.inv-col { background: #f8f1e4; }
.history-grid td.wz-alone,
.history-grid th.wz-alone,
.history-grid tr.history-open td.wz-alone { background: #d4e4f7; }
.history-grid td.inv-gap,
.history-grid tr.history-open td.inv-gap { background: #f6d0d4; }
.history-grid tr.history-open td { background: #f8e6d8; }
.history-code { font-weight: 700; margin-right: 6px; }
.history-qty { cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
.vat-docs tr.vat-sale td { background: #e7f3ec; }
.vat-docs tr.vat-buy td { background: #f8f1e4; }
.vat-window .list { margin-top: 8px; }
.vat-window .list input,
.vat-window .list select {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
}
.vat-window .list th.vat-deduction,
.vat-window .list td.vat-deduction {
  width: 1%;
  white-space: nowrap;
}
.vat-window .list input.vat-deduction,
.vat-cost-form input.vat-deduction {
  width: 5.25rem;
  max-width: 5.25rem;
  text-align: right;
}
.vat-row-actions { white-space: nowrap; }
.topbar-with-menu { align-items: center; }
.page-menu { position: relative; z-index: 25; }
.order-status-page { max-width: 1100px; }
.order-status-bar {
  flex-wrap: wrap;
  gap: 10px 14px;
  position: sticky;
  top: 0;
  z-index: 15;
  background: var(--bg);
  padding-top: 8px;
  padding-bottom: 8px;
}
.order-open-total {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
  margin-right: auto;
}
.order-block > summary.order-head {
  width: 100%;
  display: grid;
}
.order-lines {
  padding: 4px 0 8px;
  border-top: 1px solid var(--line);
  background: #fafafa;
}
.order-open-total strong {
  font-size: 18px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.period-form, .custom-dates {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.custom-dates[hidden] { display: none; }
.custom-dates input[type="date"] {
  font: inherit;
  padding: 4px 6px;
  border: 1px solid var(--line);
}
.period-caption { margin: 0 0 10px; }
.order-board {
  border: 1px solid var(--line);
  background: #fff;
  overflow-x: auto;
}
.order-head {
  display: grid;
  grid-template-columns: 28px 14rem 6.75rem minmax(8rem, 1fr) minmax(8rem, 1fr) 8.5rem;
  column-gap: 10px;
  align-items: center;
  min-width: 760px;
  padding: 8px 12px;
  font-variant-numeric: tabular-nums;
}
.order-head > * {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.order-head > .col-kod { overflow: visible; }
.order-origin {
  display: inline-flex;
  vertical-align: -2px;
  margin-left: 0.28rem;
  color: #5d6b78;
}
.order-origin + .order-origin { margin-left: 0.1rem; }
html[data-theme="dark"] .order-origin { color: #c5d0da; }
.order-head-labels {
  background: var(--head);
  font-size: 12px;
  color: #555;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.order-block { border-bottom: 1px solid var(--line); }
.order-block > summary {
  list-style: none;
  cursor: pointer;
}
.order-block > summary::-webkit-details-marker { display: none; }
.order-block[open] > summary { background: #f4f8f6; }
.order-toggle {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  font-weight: 700;
  line-height: 1;
}
.order-toggle::before { content: "+"; }
.order-block[open] .order-toggle::before { content: "−"; }
.col-value { text-align: right; font-weight: 600; }
.order-lines { padding: 0 0 8px; }
.order-line {
  display: grid;
  grid-template-columns: 28px 7.5rem minmax(10rem, 1.6fr) 5.5rem 5.5rem 5.5rem 6rem 7rem;
  column-gap: 10px;
  align-items: center;
  min-width: 760px;
  padding: 6px 12px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.order-line > * {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.order-line-labels {
  font-size: 11px;
  color: #666;
  font-weight: 600;
  background: #e8e8e8;
}
.col-num { text-align: right; }
.line-delivered { background: #d9f2de; }
.line-open { background: #f8d4d6; }
.order-board.only-open .line-delivered { display: none; }
.empty-orders { padding: 16px; margin: 0; }
.year-pick { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.year-pick select,
.year-pick input { font: inherit; padding: 4px 6px; }
.year-pick input[type="search"] { min-width: 16rem; }
.status.error { color: #842029; background: #f8d7da; padding: 8px 10px; border-radius: 6px; }

@media (max-width: 860px) {
  .hub-tiles { grid-template-columns: 1fr; }
  .vat-figures { grid-template-columns: 1fr; }
  .funnel-stages { grid-template-columns: 1fr 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
  .bar { width: 8px; }
}
.app-menu-sep {
  border: 0;
  border-top: 1px solid #d8d8d8;
  margin: 6px 4px;
}
.app-menu-settings {
  color: #445;
  font-size: 13px;
}
.icon-gear { flex: 0 0 auto; opacity: 0.85; }
.toolbar-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 2px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.toolbar-actions > * { flex-shrink: 0; }
.toolbar-sep {
  border: 0;
  border-top: 1px solid #c8c8c8;
  margin: 0;
  width: 100%;
}
.toolbar > .toolbar-send { flex: 0 0 auto; margin-top: 4px; }
.toolbar > .toolbar-send .btn { width: 100%; }
.app-menu-logout { margin: 0; }
.toolbar-actions > .btn { width: 100%; }
.toolbar-actions form,
.toolbar-actions .offer-status,
.toolbar-actions .status-menu { margin: 0; width: 100%; }
.toolbar-actions form .btn,
.toolbar-actions .status-toggle { width: 100%; }
.workbook { background: #fff; padding: 10px 16px 8px; overflow: auto; min-height: 0; position: relative; }
.toolbar .btn {
  padding: 3px 5px;
  font-size: 12px;
  line-height: 1.25;
  border-radius: 4px;
}
.toolbar .offer-status { gap: 3px; }
.toolbar .status-pill { font-size: 11px; padding: 1px 6px; }
.toolbar-actions .status { margin: 0; font-size: 11px; line-height: 1.2; }
.toolbar-actions .status:empty { display: none; }
.logo-row {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 3px solid var(--accent);
  margin-bottom: 8px;
}
.portrait-inline {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--line);
}
.msg { white-space: pre-wrap; }
.settings-form { display: grid; gap: 16px; }
.settings-card { background: #fff; border: 1px solid var(--line); padding: 16px; display: grid; gap: 8px; }
.settings-card h1 { margin: 0; font-size: 18px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.settings-form label { display: grid; gap: 4px; font-size: 13px; }
.settings-form label.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
}
.settings-form label.check input {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  border: 0;
  flex: 0 0 auto;
}
.settings-form input, .settings-form textarea, .settings-form select {
  font: inherit;
  padding: 6px;
  border: 1px solid var(--line);
  background: #fff;
}
.settings-form input:disabled, .settings-form textarea:disabled { background: #f3f3f3; color: #444; }
.portrait-frame {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--line);
  cursor: grab;
  touch-action: none;
  flex: 0 0 auto;
  background: #111;
}
.portrait-frame.is-rect {
  width: 140px;
  height: 96px;
  border-radius: 4px;
  cursor: default;
  background: #f3f3f3;
}
.portrait-frame.is-rect img { object-fit: contain; }
.portrait-frame.is-off { opacity: 0.4; }
.portrait-shape {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
.portrait-shape legend { font-size: 13px; padding: 0; }
.portrait-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}
.portrait-hint { margin: 0 0 6px; max-width: 36rem; }
.settings-form .list input { width: 110px; }
.meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 6px; }
.meta input { width: 100%; border: 1px solid var(--line); padding: 3px 6px; font: inherit; }
.parties-wrap { margin: 4px 0 8px; font-size: 13px; }
.pay-alert {
  position: relative;
  margin: 0 0 8px;
  padding: 8px 28px 8px 10px;
  border-radius: 6px;
  background: #fde8c8;
  color: #5c3b12;
  font-size: 13px;
}
.pay-alert-x {
  position: absolute;
  top: 2px;
  right: 4px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.pay-alert[hidden] { display: none; }
.pay-alert ul { margin: 4px 0 0; padding-left: 18px; }
.pay-alert.is-error { background: #f8d7da; color: #842029; }
.parties-wrap summary { cursor: pointer; color: #444; }
.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 0; align-items: start; }
.party { border: 1px solid var(--line); padding: 6px 8px; background: #fafafa; display: grid; gap: 3px; align-items: start; align-content: start; }
.party strong { font-size: 13px; }
.party-fields { display: grid; grid-template-columns: 1fr 1fr auto; gap: 4px; align-items: center; width: 100%; }
.party input, .party select { width: 100%; border: 1px solid var(--line); padding: 3px 5px; font: inherit; }
.new-customer { margin-top: 6px; }
.new-customer summary { cursor: pointer; }
.new-customer-form { display: grid; gap: 4px; margin-top: 6px; }
.new-customer-note { margin: 0; }
.client-list[hidden] { display: none; }
.search-arch { display: flex; gap: 6px; flex: 1; }
.search-arch input { flex: 1; padding: 6px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.row-actions form { margin: 0; }
.lead { font-size: 13px; margin: 4px 0 8px; }

.page.supply-page { max-width: 1480px; }
.supply-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin: 8px 0; }
.supply-supplier select { min-width: 320px; max-width: 100%; }
.supply-scroll { overflow: auto; max-width: 100%; margin: 8px 0 12px; border: 1px solid #6e6e6e; }
.supply-grid {
  min-width: 1180px;
  table-layout: auto;
  font-size: 12px;
  border-collapse: collapse;
}
.supply-grid th,
.supply-grid td {
  border: 1px solid #6e6e6e;
  padding: 3px 6px;
  white-space: nowrap;
}
.supply-grid th {
  background: #c8c8c8;
  font-size: 11px;
  font-weight: 700;
}
.supply-grid tbody tr:nth-child(even) { background: #f3f3f3; }
.supply-grid tbody tr.supply-short td { background: #f6c9c9; }
.supply-grid tbody tr.supply-over td { background: #cfe8d4; }
.supply-grid tr.supply-short input.qty { background: #f6c9c9; }
.supply-grid tr.supply-over input.qty { background: #cfe8d4; }
.supply-grid .supply-name {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.supply-grid .col-num, .supply-grid td.col-num { text-align: right; font-variant-numeric: tabular-nums; }
.supply-grid input.qty { width: 64px; text-align: right; font: inherit; padding: 2px 4px; }
.supply-upload { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin: 8px 0 4px; }
.supply-upload p { flex-basis: 100%; margin: 0; }
.supply-h { font-size: 16px; margin: 16px 0 4px; }
.supply-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin: 12px 0; }
.supply-add input, .supply-add select { min-width: 320px; max-width: 100%; }
.supply-total { margin: 8px 0; font-weight: 700; }
.supply-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 20px; }
.supply-actions #suggestion-note { flex-basis: 100%; margin: 0; }
.webapi-lamp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.2;
  color: #555;
}
.webapi-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #b5b5b5;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  flex: 0 0 auto;
}
.webapi-lamp[data-state="up"] .webapi-dot { background: #1f8a4c; }
.webapi-lamp[data-state="slow"] .webapi-dot { background: #d4a017; }
.webapi-lamp[data-state="down"] .webapi-dot { background: #c0392b; }
.toolbar .webapi-lamp { margin: 2px 0 0; }
.toolbar-drawer,
.toolbar-backdrop { display: none; }

.grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.grid th, .grid td { border: 1px solid var(--line); padding: 3px 5px; vertical-align: middle; }
.grid th { background: var(--head); font-weight: 600; font-size: 12px; }
.grid tbody tr.item { height: 52px; }
.grid tbody tr.margin-row td {
  background: #f4f8f6;
  font-size: 12px;
  color: #355;
  padding: 2px 8px;
}
.margin-row .margin-line {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.margin-row .margin-stan {
  margin-left: auto;
  font-weight: 600;
}
.margin-zapas { font-weight: 600; }
.margin-droga { font-weight: 600; }
.margin-droga[title],
.margin-zapas[title] {
  cursor: help;
  text-decoration: underline dotted;
}
.margin-row input {
  width: 72px;
  min-height: 24px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 2px 4px;
}
.metrics {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  background: #1f3d31;
  color: #fff;
  padding: 8px 16px;
  font-size: 14px;
  border-top: 3px solid var(--accent);
  z-index: 5;
}
.metrics input {
  width: 80px;
  margin: 0 4px;
  padding: 3px 6px;
  font: inherit;
}
.metrics strong { font-size: 16px; }
.col-photo { width: 88px; }
.col-opis { width: 38%; }
.col-del { width: 36px; text-align: center; }
.btn-del {
  border: 1px solid #c45b66;
  background: #fff;
  color: #842029;
  width: 28px;
  height: 28px;
  padding: 0;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  border-radius: 4px;
}
.btn-del:hover { background: #f8d7da; }
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  position: sticky;
  bottom: 0;
  background: inherit;
  padding-top: 8px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  position: sticky;
  top: 0;
  background: inherit;
  z-index: 1;
}
.modal-head p { margin: 0; font-weight: 700; }
.modal-x {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  flex: 0 0 auto;
}
.grid tr.item input, .grid .opis {
  width: 100%;
  border: 0;
  font: inherit;
  background: transparent;
  min-height: 40px;
}
.grid .opis { cursor: pointer; }
.grid tfoot td { font-weight: 700; background: #f7f7f7; }
.grid tr.add-row td { text-align: center; padding: 8px 0 2px; background: transparent; border-bottom: 0; }
.add-row-btn {
  width: 28px;
  height: 28px;
  border: 1px solid #c8c8c8;
  border-radius: 50%;
  background: #fff;
  color: #333;
  font-size: 20px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}
.add-row-btn:hover { background: #f3f7f5; }
.photo {
  width: 76px;
  height: 50px;
  background: #f0f0f0;
  border: 1px dashed #ccc;
  margin: 0 auto;
  object-fit: contain;
  display: block;
}
.photo.on { background: #dceee4; }
.photo.editable { cursor: pointer; }
td.photo-cell:focus {
  outline: 2px solid #2f6b45;
  outline-offset: -2px;
}
.grid tr.item input.qty-mismatch {
  background: #f8d7da !important;
  border: 1px solid #c45b66;
  font-style: italic;
  color: #842029;
  font-weight: 600;
}

.btn {
  border: 1px solid #888;
  background: #fafafa;
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  color: inherit;
  text-align: center;
}
.btn-yellow { background: #f3d56a; border-color: #c9a227; color: #3a2e08; }
.btn-rose { background: #f4b4b4; border-color: #d98989; color: #5c2424; }
.btn-gray { background: #d0d0d0; border-color: #9a9a9a; color: #222; }
.btn-salmon { background: #f0a08c; border-color: #d07d68; color: #4a2418; }
.btn-blue { background: #b7d4f5; border-color: #7eaddf; color: #102844; }
.btn-green { background: #2f6b4f; border-color: #24563f; color: #fff; }
.btn.primary { background: var(--accent); color: #fff; border-color: #24563f; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.archive-heading { font-size: 16px; margin: 18px 0 8px; }
.archive-bar { flex-wrap: nowrap; }
.archive-title,
.archive-who { white-space: nowrap; flex: 0 0 auto; }
.archive-page .search-arch { flex-wrap: nowrap; min-width: 0; }
.archive-page .search-arch input[name="q"] { min-width: 0; }
.archive-page .search-arch .btn { flex: 0 0 auto; }
.archive-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 8px;
}
.archive-head .archive-heading { margin: 0; }
.sort-wrap { margin: 0 0 10px; font-size: 13px; }
.sort-wrap summary { cursor: pointer; color: #444; width: fit-content; }
.sort-wrap summary span { color: #666; }
.sort-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 6px 0 0;
  padding: 5px 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.sort-modes { display: inline-flex; }
.sort-modes .btn { border-radius: 0; margin: 0; padding: 2px 8px; font-size: 12px; min-height: 0; }
.sort-modes .btn:first-child { border-radius: 6px 0 0 6px; }
.sort-modes .btn:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.sort-mode.is-on { background: var(--accent); color: #fff; border-color: #24563f; }
.status-tiles { display: flex; flex-wrap: wrap; gap: 4px; }
.status-tile {
  border: 1px solid transparent;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px 2px 5px;
  touch-action: none;
  user-select: none;
}
.status-tile .tile-grip { opacity: 0.45; margin-right: 3px; cursor: grab; }
.status-tile.is-off {
  background: #fff;
  color: #8a8a8a;
  border: 1px dashed #b4b4b4;
  text-decoration: line-through;
}
.status-tile.is-dragging { outline: 2px solid var(--accent); cursor: grabbing; opacity: 0.85; }
.status-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.status-tiles:not(.is-ordering) .tile-grip { opacity: 0.25; }
.sort-hint { font-size: 11px; }
/* The phone card layout sets display on rows; a hidden status must still hide them. */
.list tr.offer-row[hidden],
.list tr.offer-all-hidden[hidden] { display: none !important; }
@media (max-width: 860px) {
  .sort-panel { align-items: flex-start; }
  .sort-hint { flex-basis: 100%; }
  .status-tile { padding: 5px 10px 5px 7px; font-size: 12px; }
  .sort-modes .btn { padding: 5px 10px; font-size: 13px; }
}
.share-list { display: grid; gap: 6px; max-height: 240px; overflow: auto; }
.margin-low { background: #fff3cd; }
#export-lock { color: #842029; }
.check { font-size: 13px; display: flex; gap: 6px; align-items: center; }
#import-text, #import-layout {
  width: 100%;
  font: inherit;
  padding: 6px;
  border: 1px solid var(--line);
}
#import-text { min-height: 96px; resize: vertical; }
#import-report { white-space: pre-wrap; margin: 0; }

.modal {
  position: fixed;
  top: 0; right: 0; left: 0;
  bottom: 64px;
  z-index: 50;
  background: rgba(0,0,0,.35);
  display: grid; place-items: center;
  padding: 12px 16px;
  overflow: auto;
}
.modal[hidden] { display: none; }
.modal-box {
  background: #fff;
  padding: 16px;
  width: min(520px, 92vw);
  max-height: 100%;
  overflow: auto;
  display: grid;
  gap: 8px;
  border: 1px solid #777;
}
.import-box {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.import-scroll {
  overflow: auto;
  min-height: 0;
  display: grid;
  gap: 8px;
  padding: 0 16px 8px;
}
.import-box .modal-head { padding: 12px 16px 0; }
.import-box .modal-actions {
  margin: 0;
  padding: 8px 16px 12px;
}
.search-modal-box { width: min(720px, 94vw); }
.search-filters { display: grid; gap: 6px; }
.search-filter-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.8fr 0.8fr;
  gap: 8px;
}
.search-filter-grid label { display: grid; gap: 2px; font-size: 12px; }
.search-filter-grid input {
  font: inherit;
  font-size: 13px;
  padding: 6px;
  border: 1px solid var(--line);
  width: 100%;
}
.search-results-wrap {
  max-height: 42vh;
  overflow: auto;
  border: 1px solid var(--line);
}
.search-results {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.search-results th,
.search-results td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  vertical-align: top;
}
.search-results th {
  position: sticky;
  top: 0;
  background: #ececec;
  text-align: left;
  z-index: 1;
}
.search-results .col-name { word-break: break-word; }
.search-results .col-stan,
.search-results .col-cena {
  width: 7.5rem;
  text-align: right;
  white-space: nowrap;
}
.search-results tbody tr { cursor: pointer; }
.search-results tbody tr:hover { background: #f3f7f5; }
.search-results tbody tr.selected,
.search-results tbody tr.selected:hover { background: #dceee4; }
.search-results tbody tr.empty {
  cursor: default;
  color: #666;
  text-align: center;
}
.search-results tbody tr.empty:hover { background: transparent; }
.search-results .col-check { width: 34px; text-align: center; padding-left: 4px; padding-right: 4px; }
.search-results .col-check input { width: 18px; height: 18px; margin: 0; cursor: pointer; vertical-align: middle; }
.search-pick-hint { margin: 6px 0 8px; font-size: 12px; }
#dup-modal { z-index: 60; }
.dup-modal-box { width: min(560px, 94vw); }
.dup-modal-box h2 { margin: 0 0 6px; font-size: 17px; }
.dup-list { list-style: none; margin: 10px 0 14px; padding: 0; max-height: 50vh; overflow: auto; }
.dup-list li + li { border-top: 1px solid var(--line); }
.dup-list label { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; padding: 8px 2px; cursor: pointer; }
.dup-list input { width: 20px; height: 20px; margin: 0; grid-row: span 2; }
.dup-list small { grid-column: 2; font-size: 12px; }
@media (pointer: coarse) {
  .search-results .col-check { width: 44px; }
  .search-results .col-check input { width: 24px; height: 24px; }
}
.qty-spin {
  display: flex;
  align-items: stretch;
  margin: 4px 2px;
  border: 1px solid #c8c8c8;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  min-height: 32px;
}
.grid tr.item .qty-spin input {
  min-height: 0;
  height: 30px;
  width: 100%;
  padding: 0 4px;
  text-align: center;
  background: transparent;
}
.qty-spin-btns {
  display: flex;
  flex-direction: column;
  flex: 0 0 18px;
  width: 18px;
  border-left: 1px solid #d5d5d5;
}
.qty-spin-btn {
  flex: 1;
  border: 0;
  background: #f6f6f6;
  padding: 0;
  cursor: pointer;
  line-height: 0;
}
.qty-spin-btn + .qty-spin-btn { border-top: 1px solid #e6e6e6; }
.qty-spin-btn:hover { background: #ececec; }
.chevron {
  display: block;
  width: 0;
  height: 0;
  margin: 0 auto;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}
.chevron.up { border-bottom: 4px solid #8d8d8d; }
.chevron.down { border-top: 4px solid #8d8d8d; }
.mail-list { display: grid; gap: 6px; max-height: 220px; overflow: auto; }
.contact-row {
  display: flex;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  padding: 6px 8px;
  background: #fafafa;
}
.contact-row label {
  flex: 1;
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  cursor: pointer;
}
#mail-form label { display: grid; gap: 4px; font-size: 13px; }
#mail-form input {
  font: inherit;
  padding: 6px;
  border: 1px solid var(--line);
}
.list-wrap { overflow-x: auto; }
.portrait-row { display: flex; gap: 12px; align-items: center; }

@media (max-width: 860px) {
  .page { padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .topbar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar .search-arch {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
  }
  .archive-page .search-arch { flex-wrap: nowrap; }
  .login-box { width: min(360px, calc(100vw - 24px)); }
  .login-box input, .settings-form input, .settings-form textarea,
  .party input, .metrics input, .grid input, .meta input, .modal-box input {
    font-size: 16px;
  }
  .settings-grid, .parties, .party-fields, .meta {
    grid-template-columns: 1fr;
  }

  .sheet {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    height: 100dvh;
  }
  .toolbar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(280px, calc(100vw - 36px));
    z-index: 40;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 3px;
    border-right: 0;
    border-left: 1px solid var(--line);
    padding: 8px 8px calc(12px + env(safe-area-inset-bottom));
    overflow: auto;
    transform: translateX(100%);
    transition: transform 0.2s ease;
    box-shadow: none;
  }
  .sheet.toolbar-open .toolbar {
    transform: translateX(0);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.16);
  }
  .toolbar-drawer {
    display: flex;
    position: fixed;
    top: 50%;
    right: 0;
    z-index: 41;
    width: 28px;
    height: 56px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--line);
    border-right: 0;
    border-radius: 8px 0 0 8px;
    background: #f3f3f3;
    transform: translateY(-50%);
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .toolbar-drawer::before {
    content: "";
    width: 8px;
    height: 8px;
    border-left: 2px solid #333;
    border-bottom: 2px solid #333;
    transform: rotate(45deg);
    margin-left: 4px;
  }
  .sheet.toolbar-open .toolbar-drawer {
    right: min(280px, calc(100vw - 36px));
  }
  .sheet.toolbar-open .toolbar-drawer::before {
    transform: rotate(-135deg);
    margin-left: 0;
    margin-right: 4px;
  }
  .toolbar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 35;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(0, 0, 0, 0.28);
    cursor: pointer;
  }
  .sheet.toolbar-open .toolbar-backdrop { display: block; }
  .toolbar-actions {
    flex: 1 1 auto;
    margin-top: 0;
    overflow: visible;
  }
  .workbook {
    grid-row: 1;
    grid-column: 1;
    padding: 8px;
    -webkit-overflow-scrolling: touch;
  }
  .logo-row { font-size: 15px; min-height: 36px; }
  .portrait-inline { width: 40px; height: 40px; }
  .metrics {
    grid-column: 1;
    grid-row: 2;
    gap: 8px 12px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    font-size: 13px;
  }
  .metrics strong { font-size: 14px; }
  .metrics input { width: 72px; }

  .grid thead { display: none; }
  .grid, .grid tbody { display: block; width: 100%; }
  .grid tbody tr.item {
    display: grid;
    grid-template-columns: 84px 1fr 1fr 36px;
    grid-template-areas:
      "photo opis opis del"
      "cena cena rabat del"
      "netto ilosc wartosc del";
    height: auto;
    margin: 0 0 8px;
    border: 1px solid var(--line);
    background: #fff;
  }
  .grid tbody tr.item td {
    border: 0;
    border-top: 1px solid #ececec;
    padding: 4px 8px 6px;
    min-height: 0;
  }
  .grid tbody tr.item td::before {
    content: attr(data-label);
    display: block;
    font-size: 10px;
    color: #666;
    margin-bottom: 2px;
  }
  .grid tbody tr.item td:nth-child(1) { grid-area: photo; border-top: 0; }
  .grid tbody tr.item td:nth-child(1)::before { display: none; }
  .grid tbody tr.item td:nth-child(2) { grid-area: opis; border-top: 0; }
  .grid tbody tr.item td:nth-child(3) { grid-area: cena; }
  .grid tbody tr.item td:nth-child(4) { grid-area: rabat; }
  .grid tbody tr.item td:nth-child(5) { grid-area: netto; }
  .grid tbody tr.item td:nth-child(6) { grid-area: ilosc; }
  .grid tbody tr.item td:nth-child(7) { grid-area: wartosc; }
  .grid tbody tr.item td:nth-child(8) {
    grid-area: del;
    border-top: 0;
    display: flex;
    align-items: start;
    justify-content: center;
    padding-top: 8px;
  }
  .grid tbody tr.item td:nth-child(8)::before { display: none; }
  .grid tr.item input, .grid .opis { min-height: 32px; }
  .grid tbody tr.margin-row { display: block; margin: -6px 0 12px; border: 1px solid var(--line); border-top: 0; }
  .grid tbody tr.margin-row td { display: block; }
  .photo { width: 72px; height: 48px; }

  .list thead { display: none; }
  .list, .list tbody, .list tr, .list td { display: block; width: 100%; border: 0; }
  .list tr {
    background: #fff;
    border: 1px solid var(--line);
    margin-bottom: 10px;
    padding: 8px 10px;
  }
  .list td {
    padding: 4px 0;
    display: flex;
    justify-content: space-between;
    gap: 12px;
  }
  .list td::before {
    content: attr(data-label);
    color: #666;
    font-size: 12px;
  }
  .list td:last-child { display: block; }
  .list td:last-child::before { content: none; }
  .list td:last-child .btn { display: block; width: 100%; }
  .list td:last-child .row-actions { display: flex; }
  .list td:last-child .row-actions .btn { width: auto; flex: 1; }

  .modal-box { width: calc(100vw - 16px); padding: 12px; }
  .search-results-wrap { max-height: 40vh; }
}

.sales-page { max-width: 1180px; }
.sales-bar {
  flex-wrap: wrap;
  gap: 10px 14px;
}
.sales-who { margin-right: auto; }
.sales-form { margin-bottom: 12px; }
.sales-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 8px;
}
.sales-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 280px;
  font-size: 13px;
}
.sales-search input {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--line);
  min-width: 0;
  flex: 1;
}
.sales-controls input[type="date"],
.sales-controls select {
  font: inherit;
  padding: 4px 6px;
  border: 1px solid var(--line);
}
#price-mode[hidden] { display: none; }
.sales-lead { margin: 8px 0; font-weight: 600; }
.sales-client { margin: 0 0 10px; font-size: 18px; font-weight: 700; }
.sales-board {
  border: 1px solid var(--line);
  background: #fff;
  overflow-x: auto;
}
.sales-line {
  display: grid;
  column-gap: 10px;
  align-items: center;
  padding: 6px 12px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.sales-line.lines {
  grid-template-columns: 6.5rem 9.5rem 7.5rem minmax(12rem, 1.6fr) 5.5rem 6.5rem 7.5rem;
  min-width: 920px;
}
.sales-line.agg {
  grid-template-columns: 7.5rem minmax(12rem, 1.6fr) 5.5rem 7rem 7.5rem 6.5rem;
  min-width: 760px;
}
.sales-line > * {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sales-head {
  background: var(--head);
  font-size: 12px;
  color: #555;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.sales-neg { background: #f8ecec; }
.sales-line[title] { cursor: help; }
.sales-total {
  background: #f4f8f6;
  font-weight: 600;
  border-top: 1px solid var(--line);
}
.sales-notice {
  background: #e8eee9;
  border: 1px solid var(--accent);
  padding: 10px 12px;
  margin: 0 0 12px;
}
.sales-notice p { margin: 0 0 6px; }
.sales-notice p:last-child { margin-bottom: 0; }
.sales-notice:has(p.warning),
.sales-notice:has(p.error) {
  background: #f8ecec;
  border-color: #c45b66;
}
.sales-pickbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 0 0 8px;
}
.sales-board.is-offer .sales-line.lines {
  grid-template-columns: 2rem 6.5rem 9.5rem 7.5rem minmax(12rem, 1.6fr) 5.5rem 6.5rem 7.5rem;
}
.sales-board.is-offer .sales-line.agg {
  grid-template-columns: 2rem 7.5rem minmax(12rem, 1.6fr) 5.5rem 7rem 7.5rem 6.5rem;
}
.sales-line input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

.payments-page { max-width: 1280px; }
.payments-page .list td.col-num,
.payments-page .list th.col-num { text-align: right; white-space: nowrap; }
.pay-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  color: #444;
  font-size: 13px;
}
.pay-legend li { display: flex; align-items: center; gap: 6px; }
.pay-legend .swatch {
  width: 18px;
  height: 14px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  display: inline-block;
}
.list tr.pay-14,
.swatch.pay-14 { background: #fde8e8; }
.list tr.pay-30,
.swatch.pay-30 { background: #f8c4c4; }
.list tr.pay-60,
.swatch.pay-60 { background: #ef9797; }
.list tr.pay-60p,
.swatch.pay-60p { background: #e06a6a; }
.list tr[title] { cursor: help; }
.pay-no-mail,
.pay-saved {
  display: block;
  font-size: 12px;
}
.pay-no-mail { color: #8a3d45; }
.pay-saved { color: #2f6b45; }
.pay-summary {
  background: #fff;
  border: 1px solid var(--line);
  padding: 12px 14px;
  margin: 0 0 12px;
  display: grid;
  gap: 8px;
}
.pay-summary p { margin: 0; }
.pay-summary ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.pay-summary li { display: flex; align-items: center; gap: 6px; }
.payments tfoot td { font-weight: 600; background: #f4f8f6; }

@media (max-width: 860px) {
  .payments td:last-child {
    display: flex;
    justify-content: space-between;
  }
  .payments td:last-child::before { content: attr(data-label); }
}

.photo-log img {
  width: 76px;
  height: 56px;
  object-fit: contain;
  background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 50% / 12px 12px;
}
.photo-log .q-ok { color: #1d6b3a; }
.photo-log .q-bad { color: #8a2a2a; }
.photo-log-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.photo-log-actions form { margin: 0; }
.freehand-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.freehand-grid label, .freehand-log label { display: grid; gap: 4px; font-size: 13px; }
.freehand-grid .wide { grid-column: 1 / -1; }
.freehand-kind { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.freehand-kind label { display: flex; gap: 6px; align-items: center; }
.freehand-page { max-width: 1180px; }
.freehand-log { font-size: 12px; }
.freehand-log .list { table-layout: fixed; }
.freehand-log .list th,
.freehand-log .list td { padding: 4px 5px; vertical-align: top; }
.freehand-log .list th { font-size: 11px; line-height: 1.25; }
.freehand-log .col-check { width: 28px; text-align: center; }
.freehand-log .col-kod { width: 15%; }
.freehand-log .col-opis { width: 24%; }
.freehand-log .col-unit { width: 52px; }
.freehand-log .col-pack { width: 58px; }
.freehand-log .col-price { width: 76px; }
.freehand-log .col-currency { width: 52px; }
.freehand-log .col-photo { width: 132px; }
.freehand-log .col-who { width: 84px; }
.freehand-log input:not([type="checkbox"]):not([type="file"]) {
  width: 100%;
  font-size: 12px;
  padding: 3px 4px;
}
.freehand-log input[type="file"] { width: 100%; max-width: 124px; font-size: 10px; }
.freehand-log .missing { background: #fde8e8; }
.freehand-log img { width: 76px; height: 56px; object-fit: contain; background: #f3f3f3; }
.freehand-log textarea {
  width: 100%;
  font: inherit;
  font-size: 12px;
  padding: 3px 4px;
  resize: vertical;
  min-height: 2.6em;
}
.freehand-log .freehand-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: inherit; }
.freehand-check-text { display: none; }
.freehand-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 5px;
  border-radius: 3px;
  background: #fff3cd;
  color: #7a5b00;
  font-size: 10px;
}
.freehand-filter { margin: 0 0 10px; }
.freehand-help summary { cursor: pointer; color: #555; font-size: 13px; }
.freehand-help[open] summary { margin-bottom: 6px; }
.freehand-filter a { margin-left: 6px; }
.tidy-note { color: #9a6700; font-size: 11px; margin-top: 2px; }
.tidy-note[hidden] { display: none; }
[data-tidy].has-spaces { outline: 2px solid #e0a800; outline-offset: -1px; }

/* Phones: every row becomes a card with labelled, full-width fields big enough to type in. */
@media (max-width: 860px) {
  .freehand-log { font-size: 15px; }
  .freehand-log .list { table-layout: auto; }
  .freehand-log .list tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
    padding: 12px;
  }
  .freehand-log .list td,
  .freehand-log .list td:last-child {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 4px;
    width: auto;
    padding: 0;
    min-width: 0;
  }
  .freehand-log .list td::before,
  .freehand-log .list td:last-child::before {
    content: attr(data-label);
    font-size: 12px;
    color: #666;
  }
  .freehand-log .list td.missing { background: none; }
  .freehand-log .list td.missing input:not([type="checkbox"]):not([type="file"]) { background: #fde8e8; }
  .freehand-log .col-check,
  .freehand-log .col-kod,
  .freehand-log .col-opis,
  .freehand-log .col-photo,
  .freehand-log .col-who { grid-column: 1 / -1; }
  .freehand-log .list td.col-check { flex-direction: row; align-items: center; justify-content: space-between; }
  .freehand-log .list td.col-check::before { content: none; }
  .freehand-log .freehand-check { gap: 10px; font-weight: 600; }
  .freehand-check-text { display: inline; }
  .freehand-check input[type="checkbox"] { width: 26px; height: 26px; margin: 0; }
  .freehand-badge { font-size: 12px; margin: 0; }
  .freehand-log input:not([type="checkbox"]):not([type="file"]),
  .freehand-log textarea {
    font-size: 16px; /* 16 px stops iOS from zooming into the field */
    min-height: 44px;
    padding: 8px 10px;
    border-radius: 6px;
  }
  .freehand-log textarea { min-height: 76px; }
  .freehand-log input[type="file"] { max-width: none; font-size: 14px; padding: 6px 0; }
  .freehand-log img { width: 100%; height: 160px; }
  .freehand-log .col-photo .btn { width: 100%; min-height: 44px; }
  .tidy-note { font-size: 13px; }
  .freehand-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 0 -16px -16px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.08);
  }
  .freehand-actions .btn { width: 100%; min-height: 44px; font-size: 15px; margin: 0; }
  .freehand-actions .btn.primary { grid-column: 1 / -1; font-size: 16px; }
  .freehand-actions .btn[value="export"] { font-size: 0; }
  .freehand-actions .btn[value="export"]::after { content: "Eksport do Excela"; font-size: 15px; }
}

html[data-theme="dark"] {
  --line: #3c3c3c;
  --head: #2a2a2a;
  --accent: #6fbf96;
  --bg: #141414;
  color-scheme: dark;
}
html[data-theme="dark"] body { color: #ececec; }
html[data-theme="dark"] .history-grid,
html[data-theme="dark"] .history-grid th { background: #1e1e1e; color: #ececec; }
html[data-theme="dark"] .history-grid td.wz-col,
html[data-theme="dark"] .history-grid th.wz-col { background: #1c3328; }
html[data-theme="dark"] .history-grid td.inv-col,
html[data-theme="dark"] .history-grid th.inv-col { background: #2e291f; }
html[data-theme="dark"] .history-grid td.wz-alone,
html[data-theme="dark"] .history-grid th.wz-alone,
html[data-theme="dark"] .history-grid tr.history-open td.wz-alone { background: #1d3d5c; color: #e7f1fb; }
html[data-theme="dark"] .history-grid td.inv-gap,
html[data-theme="dark"] .history-grid tr.history-open td.inv-gap { background: #5c3034; color: #fbeaeb; }
html[data-theme="dark"] .history-grid tr.history-open td { background: #4a3428; color: #f6e8e0; }
html[data-theme="dark"] .vat-docs tr.vat-sale td { background: #1c3328; }
html[data-theme="dark"] .vat-docs tr.vat-buy td { background: #2e291f; }
html[data-theme="dark"] .pay-alert { background: #4a3420; color: #f6e4cc; }
html[data-theme="dark"] .pay-alert.is-error { background: #5c3034; color: #fbeaeb; }
html[data-theme="dark"] .webapi-lamp { color: #c8c8c8; }
html[data-theme="dark"] .workbook,
html[data-theme="dark"] .login-box,
html[data-theme="dark"] .list,
html[data-theme="dark"] .toolbar,
html[data-theme="dark"] .app-menu,
html[data-theme="dark"] .dash-card,
html[data-theme="dark"] .hub-tile,
html[data-theme="dark"] .funnel,
html[data-theme="dark"] .funnel-stage,
html[data-theme="dark"] .modal-box,
html[data-theme="dark"] .settings-card,
html[data-theme="dark"] .status-submenu,
html[data-theme="dark"] .hamburger,
html[data-theme="dark"] .toolbar-drawer,
html[data-theme="dark"] .grid tfoot td,
html[data-theme="dark"] .payments tfoot td {
  background: #1e1e1e;
  color: #ececec;
}
html[data-theme="dark"] .hub-tile {
  background: linear-gradient(160deg, #242424 0%, #1b2420 100%);
}
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
  background: #2a2a2a;
  color: #ececec;
  border-color: #4a4a4a;
}
html[data-theme="dark"] .hub-tile-desc,
html[data-theme="dark"] .hub-lead,
html[data-theme="dark"] .muted,
html[data-theme="dark"] .bar-legend { color: #b5b5b5; }
html[data-theme="dark"] .hamburger span { background: #eee; }
html[data-theme="dark"] .toolbar-drawer::before { border-color: #eee; }
html[data-theme="dark"] .app-menu-item.is-active,
html[data-theme="dark"] .hamburger[aria-expanded="true"] { background: #2c4036; }
html[data-theme="dark"] .toolbar-sep,
html[data-theme="dark"] .app-menu-sep { border-top-color: #4a4a4a; }
html[data-theme="dark"] .btn-gray { background: #4a4a4a; border-color: #666; color: #f2f2f2; }
html[data-theme="dark"] .supply-scroll { border-color: #6a6a6a; }
html[data-theme="dark"] .supply-grid th,
html[data-theme="dark"] .supply-grid td { border-color: #6a6a6a; }
html[data-theme="dark"] .supply-grid th { background: #2e2e2e; color: #f2f2f2; }
html[data-theme="dark"] .supply-grid tbody tr:nth-child(even) { background: #242424; }
html[data-theme="dark"] .supply-grid tbody tr.supply-short td,
html[data-theme="dark"] .supply-grid tr.supply-short input.qty { background: #6a3036; color: #f6e8e8; }
html[data-theme="dark"] .supply-grid tbody tr.supply-over td,
html[data-theme="dark"] .supply-grid tr.supply-over input.qty { background: #1d4a34; color: #e7f6ec; }
html[data-theme="dark"] .search-results-wrap { background: #1a1a1a; }
html[data-theme="dark"] .search-results th {
  background: #2a2a2a;
  color: #d7d7d7;
}
html[data-theme="dark"] .search-results td { color: #ececec; }
html[data-theme="dark"] .search-results tbody tr:hover { background: #2a332f; }
html[data-theme="dark"] .search-results tbody tr.selected,
html[data-theme="dark"] .search-results tbody tr.selected:hover {
  background: #1d4a34;
  color: #f4fbf7;
}
html[data-theme="dark"] .search-results tbody tr.selected td { color: #f4fbf7; }
html[data-theme="dark"] .search-results tbody tr.empty,
html[data-theme="dark"] .search-results tbody tr.empty:hover { color: #b5b5b5; background: transparent; }
html[data-theme="dark"] .search-modal-box .btn:not(.primary) {
  background: #2a2a2a;
  color: #ececec;
  border-color: #5a5a5a;
}
html[data-theme="dark"] .search-modal-box .btn.ghost { background: transparent; color: #d0d0d0; }
html[data-theme="dark"] .qty-spin { background: #2a2a2a; border-color: #5a5a5a; }
html[data-theme="dark"] .qty-spin-btns { border-left-color: #5a5a5a; }
html[data-theme="dark"] .qty-spin-btn { background: #333; }
html[data-theme="dark"] .qty-spin-btn:hover { background: #3c3c3c; }
html[data-theme="dark"] .qty-spin-btn + .qty-spin-btn { border-top-color: #4a4a4a; }
html[data-theme="dark"] .chevron.up { border-bottom-color: #c8c8c8; }
html[data-theme="dark"] .chevron.down { border-top-color: #c8c8c8; }
html[data-theme="dark"] .grid tr.add-row td { background: transparent; }
html[data-theme="dark"] .add-row-btn {
  background: #2a2a2a;
  color: #ececec;
  border-color: #5a5a5a;
}
html[data-theme="dark"] .add-row-btn:hover { background: #333; }
html[data-theme="dark"] .grid tbody tr.margin-row td {
  background: #b7bdb8;
  color: #1a4a32;
}
html[data-theme="dark"] .margin-row input {
  background: #c8cec9;
  color: #1a4a32;
  border-color: #8d9890;
}

.toolbar-actions > .btn-beta {
  line-height: 1.25;
  text-align: center;
  white-space: normal;
}
.btn-beta {
  background: #efe6c9;
  border-color: #b9a36a;
  color: #3d3420;
}
.beta-mark {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #3d3420;
  color: #f6edd4;
  border-radius: 999px;
  padding: 1px 6px;
  vertical-align: 1px;
}
.compete-page.page { max-width: 1280px; }
.compete-warn {
  background: #fff6dd;
  border: 1px solid #e0c56a;
  color: #3d3420;
  padding: 10px 12px;
  margin: 0 0 12px;
}
.compete-shops {
  border: 0;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
}
.compete-shops legend {
  width: 100%;
  padding: 0;
  margin: 0 0 4px;
  font-size: 13px;
  color: #666;
}
.compete-shops label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.compete-run { margin: 0 0 12px; }
.compete-scroll { overflow-x: auto; }
.compete-table { min-width: 980px; }
.compete-table td, .compete-table th { vertical-align: top; font-size: 13px; }
.compete-table a { color: inherit; }
.delta-down { color: #1d6b3a; font-weight: 600; }
.delta-up { color: #9a3412; font-weight: 600; }
html[data-theme="dark"] .btn-beta {
  background: #3a3424;
  border-color: #8a7340;
  color: #f3e6c4;
}
html[data-theme="dark"] .beta-mark { background: #c8aa62; color: #241e10; }
html[data-theme="dark"] .compete-warn {
  background: #3a3424;
  border-color: #8a7340;
  color: #f3e6c4;
}
html[data-theme="dark"] .compete-shops legend { color: #b5b5b5; }
html[data-theme="dark"] .compete-table .delta-down { color: #8dcea8; }
html[data-theme="dark"] .compete-table .delta-up { color: #f0a8a0; }
html[data-theme="dark"] .grid tbody tr.margin-row.margin-low td {
  background: #d4c48a;
  color: #3d3010;
}
html[data-client="1"] .margin-secret,
html[data-client="1"] .metric-secret { display: none; }
html[data-client="1"] .grid tbody tr.margin-row.margin-low,
html[data-client="1"] .grid tbody tr.margin-row.margin-low td {
  background: #f4f8f6;
  color: #355;
}
html[data-theme="dark"][data-client="1"] .grid tbody tr.margin-row.margin-low,
html[data-theme="dark"][data-client="1"] .grid tbody tr.margin-row.margin-low td {
  background: #b7bdb8;
  color: #1a4a32;
}

/* Supplier availability next to the quantity on supplier orders */
.supply-grid td.supply-qty { white-space: nowrap; }
.supply-stock { display: inline-flex; vertical-align: middle; margin-right: 4px; color: #2f6b4f; cursor: help; }
html[data-theme="dark"] .supply-stock { color: #8fd1ae; }

/* Stock top-up shown in the shortage table */
.supply-topup-btn { min-width: 44px; padding: 2px 8px; border: 1px solid #2f6b4f; border-radius: 4px; background: #e3f2e9; color: #1d4a34; font: inherit; font-weight: 700; text-align: right; cursor: pointer; }
.supply-topup-btn:hover, .supply-topup-btn:focus-visible { background: #2f6b4f; color: #fff; }
html[data-theme="dark"] .supply-topup-btn { border-color: #8fd1ae; background: #1d4a34; color: #e7f6ec; }
html[data-theme="dark"] .supply-topup-btn:hover, html[data-theme="dark"] .supply-topup-btn:focus-visible { background: #8fd1ae; color: #10261a; }

/* Purchase invoices from KSeF */
.ksef-status { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin: 0 0 8px; }
.ksef-env { background: #f3d56a; color: #3a2e08; border-radius: 4px; padding: 2px 8px; font-size: 13px; font-weight: 600; }
.ksef-filters input[type="search"] { min-width: 280px; padding: 5px; }
.ksef-filters input[type="date"] { padding: 4px; }
.ksef-grid { min-width: 1100px; }
.ksef-grid .ksef-seller { max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
.ksef-grid tfoot th { background: #e3e3e3; }
.ksef-tag { font-size: 10px; text-transform: uppercase; background: #fbe3b4; color: #6b4a07; border-radius: 3px; padding: 0 4px; }
.ksef-overdue { color: #842029; font-weight: 700; }
.ksef-warn { color: #842029; }
.ksef-pages { display: flex; gap: 10px; align-items: center; margin: 4px 0 12px; }
html[data-theme="dark"] .ksef-grid tfoot th { background: #333; }
html[data-theme="dark"] .ksef-tag { background: #5a4310; color: #f6e2b5; }
html[data-theme="dark"] .ksef-overdue, html[data-theme="dark"] .ksef-warn { color: #f19aa3; }

/* Offer hero image */
.hero-page.page { max-width: 1280px; }
.hero-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px 16px; align-items: end; margin: 0 0 16px; }
.hero-form label { display: flex; flex-direction: column; gap: 4px; }
.hero-form .hero-wide { grid-column: 1 / -1; }
.hero-form input[type="url"], .hero-form select, .hero-form textarea { padding: 5px; font: inherit; }
.hero-form button { justify-self: start; }
.hero-style, .hero-sources { margin: 0 0 12px; padding-left: 18px; }
.hero-sources li { word-break: break-all; }
.hero-variants { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.hero-variant { margin: 0; border: 2px solid transparent; padding: 6px; border-radius: 6px; }
.hero-variant.is-chosen { border-color: #2f6b4f; }
.hero-variant img { width: 100%; height: auto; display: block; border-radius: 4px; }
.hero-variant figcaption { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 6px; }
.hero-variant form { display: inline-flex; gap: 8px; align-items: center; }
.hero-ok { color: #1d5c3d; font-weight: 700; }
.hero-warn { color: #8a5a00; font-weight: 700; }
.hero-problems { width: 100%; margin: 0; padding-left: 18px; font-size: 12px; color: #6b4a07; }
html[data-theme="dark"] .hero-variant.is-chosen { border-color: #8fd1ae; }
html[data-theme="dark"] .hero-ok { color: #8fd1ae; }
html[data-theme="dark"] .hero-warn, html[data-theme="dark"] .hero-problems { color: #f0c674; }

/* Sales invoices */
.invoices-page.page { max-width: 1400px; }
.inv-filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin: 0 0 8px; }
.inv-filters label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.inv-filters input[type="search"] { min-width: 240px; padding: 5px; }
.inv-filters input[type="date"], .inv-filters select { padding: 4px; }
.inv-section { margin: 18px 0 26px; }
.inv-sum { font-size: 13px; font-weight: 400; margin-left: 8px; }
.inv-h3 { font-size: 15px; margin: 16px 0 6px; }
.inv-scroll { overflow-x: auto; }
.inv-table { width: 100%; min-width: 1100px; table-layout: fixed; }
.inv-table td { vertical-align: top; overflow-wrap: anywhere; }
.inv-table .col-num { white-space: nowrap; overflow-wrap: normal; text-align: right; }
.inv-table .inv-date { white-space: nowrap; overflow-wrap: normal; }
.inv-table .inv-col-party { width: auto; }
.inv-correction td { background: #fff7ed; }
.inv-final td { background: #eef6ff; }
.inv-tag { display: inline-block; font-size: 10px; text-transform: uppercase; background: #fde2c4; color: #7a3d00; border-radius: 3px; padding: 0 4px; margin-left: 4px; }
.inv-final-badge { display: inline-block; font-size: 10px; text-transform: uppercase; background: #cfe3fb; color: #123d6b; border-radius: 3px; padding: 0 4px; margin-left: 4px; cursor: help; }
.inv-ok { color: #1d5c3d; font-weight: 600; }
.inv-part { color: #8a5a00; font-weight: 600; cursor: help; border-bottom: 1px dotted currentColor; }
.inv-no { color: #842029; font-weight: 600; cursor: help; }
.inv-late { color: #842029; font-weight: 700; }
.inv-print { padding: 2px 8px; font-size: 12px; }
html[data-theme="dark"] .inv-correction td { background: #3a2a18; }
html[data-theme="dark"] .inv-final td { background: #182a3d; }
html[data-theme="dark"] .inv-tag { background: #6b3d0f; color: #fde2c4; }
html[data-theme="dark"] .inv-final-badge { background: #1f4a7a; color: #dceafe; }
html[data-theme="dark"] .inv-ok { color: #8fd1ae; }
html[data-theme="dark"] .inv-part { color: #f0c674; }
html[data-theme="dark"] .inv-no, html[data-theme="dark"] .inv-late { color: #f19aa3; }

html[data-theme="dark"] .freehand-actions { background: #1e1e1e; }
html[data-theme="dark"] .freehand-badge { background: #4a3d10; color: #f3d77a; }
html[data-theme="dark"] .tidy-note { color: #e0b84a; }

/* Group change in the offer editor: tick lines, by code prefix or text, and set one discount. */
.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--head);
  font-size: 13px;
}
.bulk-bar[hidden] { display: none; }
.bulk-all { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.bulk-label { color: #666; }
.bulk-prefixes { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.bulk-chip {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 2px 9px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.bulk-chip.part { border-color: #3a7bd5; background: #eef4fd; }
.bulk-chip.on { border-color: #3a7bd5; background: #3a7bd5; color: #fff; }
.bulk-text { width: 190px; box-sizing: border-box; max-width: 100%; }
.bulk-count { color: #444; font-weight: 600; }
.bulk-rabat { display: inline-flex; align-items: center; gap: 5px; }
.bulk-rabat input { width: 64px; }
td.photo-cell { position: relative; }
.line-pick {
  position: absolute;
  top: 2px;
  left: 2px;
  z-index: 2;
  display: flex;
  padding: 2px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.85);
  cursor: pointer;
}
.line-pick input { width: 16px; height: 16px; margin: 0; cursor: pointer; }
.grid tbody tr.item.picked td { background: #eef4fd; }
html[data-theme="dark"] .bulk-chip { background: #2a2a2a; color: inherit; }
html[data-theme="dark"] .bulk-chip.part { background: #1f3350; }
html[data-theme="dark"] .bulk-chip.on { background: #3a7bd5; color: #fff; }
html[data-theme="dark"] .grid tbody tr.item.picked td { background: #1f3350; }
html[data-theme="dark"] .line-pick { background: rgba(30, 30, 30, 0.85); }
@media (pointer: coarse) {
  .line-pick input { width: 24px; height: 24px; }
  .bulk-chip { padding: 6px 12px; font-size: 14px; }
  .bulk-bar input, .bulk-bar .btn { min-height: 40px; }
  .bulk-text { width: 100%; }
}
