:root {
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: #fff1db;
  background: #170803;
  font-synthesis: none;
  color-scheme: dark;
  --accent: #ffb25f;
  --line: #754322;
  --muted: #d3b59a;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background:
    radial-gradient(ellipse at 100% 0%, #77300855, transparent 55%), #170803;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
input,
select {
  min-height: 44px;
}
button {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 16px;
  background: #2a1108;
  color: #fff1db;
  cursor: pointer;
  font-weight: 600;
}
button:hover {
  background: #48200d;
}
button.primary {
  background: linear-gradient(110deg, #f4b65c, #d77825);
  color: #251006;
  border-color: #c27a25;
}
button:disabled {
  opacity: 0.55;
  cursor: wait;
}
a {
  color: var(--accent);
}
:focus-visible {
  outline: 3px solid #b26617;
  outline-offset: 3px;
}
h1 {
  font-size: 30px;
  letter-spacing: -1px;
  margin: 0;
}
h2 {
  font-size: 19px;
  margin: 0 0 18px;
}
h3 {
  font-size: 15px;
}
p {
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.muted,
small {
  color: var(--muted);
}
.shell {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: linear-gradient(150deg, #160603, #4b1b05 70%, #873807);
  color: #fff1db;
  padding: 30px 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 750;
  font-size: 21px;
  letter-spacing: -0.7px;
  padding: 0 10px;
}
.brand-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.brand-copy small {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 2px;
  color: #d78a2d;
}
.auth .brand-copy small {
  color: #ffb25f;
}
.brand img {
  width: 36px;
  height: 36px;
}
.nav {
  display: grid;
  gap: 5px;
}
.nav button {
  text-align: left;
  background: transparent;
  color: #ecd0ac;
  border-color: transparent;
  font-weight: 500;
}
.nav button.active {
  background: #6c2f0c;
  color: #fff;
  box-shadow: inset 3px 0 #d78a2d;
}
.account {
  margin-top: auto;
  border-top: 1px solid #754322;
  padding-top: 20px;
  display: grid;
  gap: 8px;
}
.account button {
  background: transparent;
  color: #fff1db;
  border-color: #b77439;
}
.account small {
  color: #ecd0ac;
}
.main {
  padding: 30px 40px;
  min-width: 0;
  max-width: 1800px;
  width: 100%;
}
.topbar,
.heading,
.toolbar,
.actions,
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar {
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 20px;
  margin-bottom: 28px;
}
.connection {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}
.connection:before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #12a890;
}
.heading {
  justify-content: space-between;
  margin-bottom: 24px;
}
.heading p {
  margin: 6px 0 0;
}
.panel {
  background: #2a1108;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 22px;
}
.toolbar {
  justify-content: space-between;
  margin-bottom: 18px;
}
.toolbar input {
  min-width: 230px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}
.stat {
  padding: 22px 24px;
  background: #2a1108;
  border: 1px solid var(--line);
  border-radius: 10px;
  border-top: 3px solid #d78a2d;
}
.stat strong {
  font-size: 34px;
  font-weight: 650;
  display: block;
  margin: 7px 0;
}
.stat span {
  font-size: 14px;
  color: var(--muted);
}
.action-rail {
  background: #48200d;
  border: 1px solid #895122;
  padding: 18px 22px;
  border-radius: 9px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}
.action-rail p {
  margin: 4px 0;
}
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}
th {
  font-weight: 600;
  color: #d3b59a;
  font-size: 12px;
  background: #301308;
  white-space: nowrap;
}
th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid #65351b;
}
td strong {
  font-weight: 600;
}
td.number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.badge {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 5px;
  font-size: 12px;
  white-space: nowrap;
  background: #4c2816;
  color: #efd0a6;
}
.badge.posted {
  background: #e4f6ee;
  color: #18724d;
}
.badge.low {
  background: #fff1d8;
  color: #8c5b09;
}
.empty {
  text-align: center;
  padding: 45px 20px;
  color: var(--muted);
}
.empty strong {
  display: block;
  color: #ffe3b8;
  font-size: 18px;
  margin-bottom: 8px;
}
.auth {
  max-width: 440px;
  margin: 7vh auto;
  padding: 32px;
}
.auth .brand {
  color: #fff1db;
  padding: 0;
  margin-bottom: 32px;
}
.auth h1 {
  font-size: 25px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 17px;
}
.field {
  display: grid;
  gap: 7px;
  font-size: 14px;
  font-weight: 550;
}
.field input,
.field select,
.field textarea,
input.search {
  width: 100%;
  border: 1px solid #9c6236;
  border-radius: 6px;
  padding: 11px 12px;
  background: #2a1108;
  color: #fff1db;
  min-width: 0;
}
.field textarea {
  min-height: 80px;
  resize: vertical;
}
input::placeholder,
textarea::placeholder {
  color: #c1a58a;
  opacity: 1;
}
.full {
  grid-column: 1/-1;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}
.error {
  color: #a62525;
  background: #fff0f0;
  padding: 12px;
  border-radius: 6px;
  margin: 14px 0;
  display: none;
}
.error.visible {
  display: block;
}
dialog {
  background: #2a1108;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  width: min(850px, calc(100% - 28px));
  max-height: 90vh;
  overflow: auto;
  color: #fff1db;
  box-shadow: 0 20px 100px #00000066;
}
dialog::backdrop {
  background: #120502bb;
}
.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}
.dialog-heading h2 {
  margin: 0;
}
.close {
  font-size: 22px;
  padding: 3px;
  width: 44px;
}
.line {
  background: #301308;
  padding: 15px;
  border-radius: 7px;
  margin: 12px 0;
}
.line-fields {
  display: grid;
  grid-template-columns: 2fr 1fr 1.5fr 1.5fr auto;
  gap: 10px;
  align-items: end;
}
.line-fields.count {
  grid-template-columns: 2fr 1fr auto;
}
.line-fields button {
  padding: 10px;
}
.hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin: 12px 0;
}
.detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}
.note {
  white-space: pre-wrap;
}
.scan-video {
  width: 100%;
  max-height: 300px;
  background: #fff1db;
}
.label-preview {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.product-label {
  border: 1px solid #9c6236;
  padding: 14px;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: center;
  break-inside: avoid;
}
.product-label svg {
  max-width: 100%;
}
#notice {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 22px;
  background: #48200d;
  color: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px #0003;
  z-index: 100;
  display: none;
  max-width: 90vw;
}
#notice.show {
  display: block;
}
#print-area {
  display: none;
}
.loading {
  padding: 40px;
}
.inline-link {
  border: 0;
  background: none;
  color: var(--accent);
  padding: 0;
  text-align: left;
}
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}
.auth form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}
.auth .primary {
  width: 100%;
}
@media (max-width: 1000px) {
  .main {
    padding: 24px;
  }
  .shell {
    grid-template-columns: 190px 1fr;
  }
  .sidebar {
    padding: 24px 12px;
  }
  .line-fields {
    grid-template-columns: 1fr 1fr;
  }
  .split {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 680px) {
  .shell {
    display: block;
  }
  .sidebar {
    height: auto;
    position: static;
    padding: 16px;
    gap: 18px;
  }
  .brand {
    font-size: 22px;
  }
  .nav {
    display: flex;
    overflow: auto;
    margin: 0 -16px;
    padding: 0 16px;
  }
  .nav button {
    white-space: nowrap;
  }
  .account {
    margin: 0;
    padding: 12px 0 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
  }
  .account small {
    display: none;
  }
  .account button {
    font-size: 12px;
    min-height: 44px;
    padding: 7px 10px;
  }
  .main {
    padding: 20px 16px;
  }
  .topbar {
    margin-bottom: 22px;
    padding-bottom: 15px;
  }
  .topbar > span {
    display: none;
  }
  h1 {
    font-size: 26px;
  }
  .stats {
    gap: 8px;
  }
  .stat {
    padding: 16px 12px;
  }
  .stat strong {
    font-size: 27px;
  }
  .stat span {
    font-size: 12px;
  }
  .panel {
    padding: 17px;
  }
  .toolbar input {
    min-width: 0;
    width: 100%;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .line-fields,
  .line-fields.count {
    grid-template-columns: 1fr;
  }
  .auth {
    margin: 20px 14px;
    padding: 25px;
  }
  .detail-meta {
    grid-template-columns: 1fr;
  }
  dialog {
    padding: 20px;
  }
  .heading .actions {
    width: 100%;
  }
  .heading .actions button {
    flex: 1;
  }
  .action-rail .actions {
    width: 100%;
  }
  .action-rail .actions button {
    flex: 1;
  }
  .connection {
    font-size: 12px;
  }
}
@media print {
  body > * {
    display: none !important;
  }
  #print-area {
    display: block !important;
    color: #000;
    background: #2a1108;
    padding: 10mm;
  }
  #print-area table {
    font-size: 11px;
  }
  #print-area h1 {
    font-size: 24px;
  }
  .product-label {
    display: inline-block;
    margin: 4mm;
    border: 1px solid #000;
    width: 70mm;
  }
  .no-print {
    display: none !important;
  }
}
[hidden] {
  display: none !important;
}
.document-scan {
  background: #48200d;
  border: 1px solid #895122;
  border-radius: 7px;
  padding: 14px;
  margin: 15px 0;
  display: grid;
  gap: 12px;
}
.document-scan .field {
  max-width: 420px;
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 1rem 0;
}
.scan-matches {
  display: grid;
  gap: 0.5rem;
  max-height: 18rem;
  overflow-y: auto;
  padding: 0.25rem;
}
.scan-matches button {
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}
.product-picker {
  min-width: 0;
}
.product-picker small {
  display: block;
  color: var(--muted, #596579);
  margin-bottom: 0.75rem;
}
.product-picker select {
  width: 100%;
  max-width: 100%;
}
@media (max-width: 650px) {
  .pagination button {
    flex: 1;
  }
  .pagination span {
    order: -1;
    width: 100%;
    text-align: center;
  }
}
.menu-toggle,
.cell-label {
  display: none;
}
.shell > *,
.form-grid > *,
.line-fields > *,
.detail-meta > * {
  min-width: 0;
}
.cell-value {
  min-width: 0;
  overflow-wrap: anywhere;
}
@media screen and (max-width: 1000px) {
  .shell {
    display: block;
  }
  .sidebar {
    display: grid;
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    max-height: 100dvh;
    overflow-y: auto;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 10px 14px;
  }
  .sidebar .brand {
    padding: 0;
    font-size: 20px;
  }
  .sidebar .brand-copy {
    display: grid;
    gap: 4px;
    min-width: 0;
  }
  .brand-copy small {
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 2px;
    color: #d78a2d;
  }
  .auth .brand-copy small {
    color: #ffb25f;
  }
  .brand img {
    width: 30px;
    height: 30px;
  }
  .menu-toggle {
    display: block;
  }
  .sidebar .menu-toggle,
  .sidebar .menu-toggle:hover,
  .sidebar .menu-toggle:active,
  .sidebar .menu-toggle:focus-visible {
    background: #6c2f0c;
    color: #ffffff;
    border-color: #b48651;
  }
  .sidebar .menu-toggle:hover,
  .sidebar .menu-toggle:active {
    background: #77401f;
  }
  .sidebar .nav {
    display: none;
    grid-column: 1 / -1;
    margin: 0;
    padding: 0;
    overflow: visible;
  }
  .sidebar.menu-open .nav {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 5px;
  }
  .nav button {
    white-space: normal;
    overflow-wrap: anywhere;
    padding: 10px;
  }
  .sidebar .account {
    display: none;
    grid-column: 1 / -1;
    gap: 8px;
    padding-top: 10px;
  }
  .sidebar.menu-open .account {
    display: flex;
  }
  .account strong {
    width: 100%;
    overflow-wrap: anywhere;
  }
  .main {
    padding: 12px;
  }
  .topbar {
    margin-bottom: 14px;
    padding-bottom: 10px;
  }
  .heading {
    margin-bottom: 16px;
  }
  .heading p {
    font-size: 14px;
  }
  .panel {
    padding: 14px;
    margin-bottom: 14px;
  }
  .table-wrap {
    overflow: visible;
    width: 100%;
    min-width: 0;
  }
  .table-wrap table,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
    width: 100%;
    min-width: 0;
  }
  .table-wrap thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
  .table-wrap tbody {
    display: grid;
    gap: 12px;
  }
  .table-wrap tbody tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 12px;
    background: #2a1108;
  }
  .table-wrap td {
    padding: 9px 0;
    border-bottom: 1px solid #65351b;
    text-align: left;
  }
  .table-wrap td:last-child {
    border-bottom: 0;
  }
  .cell-label {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
  }
  .cell-value,
  .cell-value > *,
  .badge,
  button,
  p,
  strong,
  h1,
  h2 {
    white-space: normal;
    overflow-wrap: anywhere;
    max-width: 100%;
  }
  .actions,
  .form-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .actions > *,
  .form-actions > * {
    min-width: 0;
  }
  .action-rail {
    padding: 14px;
  }
  .action-rail .actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }
  .line-fields,
  .line-fields.count,
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .field,
  form,
  .line,
  .document-scan {
    min-width: 0;
    max-width: 100%;
  }
  .field select,
  .field input,
  .field textarea {
    max-width: 100%;
    font-size: 16px;
  }
  dialog {
    padding: 16px;
    width: calc(100% - 16px);
    max-width: calc(100% - 16px);
    max-height: calc(100dvh - 16px);
  }
  .dialog-heading {
    gap: 12px;
  }
  .close {
    flex: 0 0 44px;
  }
  .stats {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .stat {
    padding: 10px 12px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 12px;
  }
  .stat strong {
    grid-column: 2;
    grid-row: 1 / 3;
    font-size: 25px;
    margin: 0;
  }
}

/* Większa czytelność stanowiska komputerowego bez powiększania telefonu. */
@media screen and (min-width: 1001px) {
  :root {
    --muted: #e1c7ad;
  }
  .nav button {
    font-size: 16px;
    font-weight: 600;
    color: #fff1db;
  }
  table {
    font-size: 16px;
  }
  th {
    font-size: 14px;
    color: #efdbc5;
  }
  td strong {
    font-weight: 700;
  }
  .field,
  .stat span {
    font-size: 16px;
  }
  .hint,
  .connection,
  .badge,
  .account small {
    font-size: 14px;
  }
}
/* Papier i kody pozostają czytelne niezależnie od ciemnego interfejsu. */
.product-label {
  background: #fff;
  color: #000;
}
@media print {
  body {
    background: #fff;
    color: #000;
  }
  #print-area,
  #print-area th,
  #print-area td {
    background: #fff;
    color: #000;
  }
  #print-area small,
  #print-area .muted {
    color: #000;
  }
}

.appearance-settings {
  display: grid;
  gap: 18px;
}
.appearance-settings .field:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
}
.appearance-settings input[type="checkbox"] {
  width: 24px;
  min-height: 24px;
  height: 24px;
  accent-color: #d78a2d;
}
@media screen {
  :root[data-text-size="large"] {
    --text-scale: 1.15;
  }
  :root[data-text-size="largest"] {
    --text-scale: 1.3;
  }
  :root[data-text-size="large"],
  :root[data-text-size="largest"] {
    font-size: calc(16px * var(--text-scale));
  }
  :root[data-text-size="large"] h1,
  :root[data-text-size="largest"] h1 {
    font-size: calc(30px * var(--text-scale));
  }
  :root[data-text-size="large"] h2,
  :root[data-text-size="largest"] h2 {
    font-size: calc(21px * var(--text-scale));
  }
  :root[data-text-size="large"] h3,
  :root[data-text-size="largest"] h3 {
    font-size: calc(18px * var(--text-scale));
  }
  :root[data-text-size="large"]
    :is(button, input, select, textarea, table, .field, .stat span),
  :root[data-text-size="largest"]
    :is(button, input, select, textarea, table, .field, .stat span) {
    font-size: calc(16px * var(--text-scale));
  }
  :root[data-text-size="large"]
    :is(th, .hint, .muted, .connection, .cell-label, .badge, .account small),
  :root[data-text-size="largest"]
    :is(th, .hint, .muted, .connection, .cell-label, .badge, .account small) {
    font-size: calc(14px * var(--text-scale));
  }
  :root[data-contrast="strong"] {
    --muted: #fff1db;
    --line: #c38a55;
  }
  :root[data-contrast="strong"]
    :is(.muted, .hint, th, .cell-label, .account small, .connection) {
    color: #fff1db;
  }
  :root[data-contrast="strong"] .nav button {
    color: #fff1db;
    font-weight: 700;
  }
  :root[data-contrast="strong"] :is(input, select, textarea) {
    border-color: #dca265;
  }
  :root[data-contrast="strong"] :is(input, textarea)::placeholder {
    color: #f0d7ba;
  }
}

.account .help-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #b77439;
  border-radius: 7px;
  color: #fff1db;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

/* Keep translated controls and headings within narrow panels. */
.auth,
.account,
.action-rail,
.dialog-heading h2 {
  overflow-wrap: anywhere;
}

.media-thumb {
  min-height: 44px;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.media-thumb img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}
.media-preview {
  display: block;
  max-width: 100%;
  max-height: 45vh;
  object-fit: contain;
}
.media-preview[hidden],
.location-tools[hidden] {
  display: none;
}
.device-row {
  border-top: 1px solid currentColor;
  padding-block: 1rem;
  overflow-wrap: anywhere;
}
.device-admin svg {
  display: block;
  background: white;
  max-width: 100%;
  height: auto;
}
dialog fieldset {
  min-width: 0;
  margin: 0 0 1rem;
}
dialog input[type="file"] {
  max-width: 100%;
  min-width: 0;
}
.device-admin button,
.location-tools button,
dialog fieldset input,
.device-row button {
  min-height: 44px;
}
.device-row code {
  display: block;
}
dialog label:has(input[type="checkbox"]) {
  min-height: 44px;
}
.receipt-product {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  overflow-wrap: anywhere;
}
.receipt-product img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}
.location-tools summary {
  min-height: 44px;
  padding-block: 0.5rem;
  cursor: pointer;
}

.offline-admin,
.offline-list {
  display: grid;
  gap: 1rem;
  min-width: 0;
}
.offline-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  min-width: 0;
  overflow-wrap: anywhere;
}
.offline-card h3,
.offline-card h4 {
  margin: 0 0 0.75rem;
}
.offline-card .field,
.offline-card form {
  margin: 0.75rem 0;
}
.offline-card code {
  display: block;
  overflow-wrap: anywhere;
}
.offline-card details {
  margin: 0.75rem 0;
}
.offline-card summary {
  cursor: pointer;
  padding: 0.5rem 0;
  min-height: 44px;
}
.offline-scope-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.5rem 0;
}
.offline-scope-item span {
  min-width: 0;
  overflow-wrap: anywhere;
}
@media screen and (max-width: 1000px) {
  .offline-card {
    padding: 0.75rem;
  }
  .offline-scope-item {
    align-items: start;
    flex-wrap: wrap;
  }
}
