:root {
  color-scheme: light;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  --ink: #1d252c;
  --muted: #66717c;
  --line: #d7dee5;
  --panel: #ffffff;
  --soft: #f3f6f8;
  --accent: #0f766e;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #eef2f4;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
  padding: 0 14px;
}

button.ghost {
  background: #dfe7e9;
  color: var(--ink);
}

button.danger {
  background: var(--danger);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

input {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 40px;
  padding: 8px 10px;
  width: 100%;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
}

h1,
h2,
h3 {
  margin: 0;
}

.hidden {
  display: none !important;
}

.auth {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 20px;
  max-width: 820px;
  padding: 28px;
  width: 100%;
}

.form {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form button {
  align-self: end;
}

.secondary {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.message {
  color: var(--danger);
  font-weight: 700;
  min-height: 20px;
}

.download-link {
  color: #075e57;
  text-decoration: underline;
}

.app {
  min-height: 100vh;
}

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

.topbar span {
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

.upload-band {
  background: #e7edef;
  border-bottom: 1px solid var(--line);
  padding: 18px 24px;
}

.lot-entry-grid {
  display: grid;
  gap: 14px;
}

.upload-grid {
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  padding: 14px;
}

.tabs {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 8px;
  padding: 10px 24px;
}

.tabs button {
  background: transparent;
  color: var(--muted);
}

.tabs button.active {
  background: #d7ece9;
  color: #0b534d;
}

.layout {
  display: grid;
  grid-template-columns: 330px 1fr;
  min-height: calc(100vh - 210px);
}

.lot-list {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px;
}

.lot-list h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

.lot-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  padding: 12px;
}

.lot-card.active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.lot-card strong {
  overflow-wrap: anywhere;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.detail,
.search {
  padding: 22px 24px;
}

.empty {
  color: var(--muted);
  padding: 48px;
  text-align: center;
}

.actions,
.rz-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}

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

.metric,
.rz-card,
.item-row,
.result-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 12px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.metric strong {
  display: block;
  font-size: 20px;
  margin-top: 4px;
}

.progress-metric em {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-style: normal;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.progress-bar {
  background: #e1e8eb;
  border-radius: 999px;
  height: 8px;
  margin-top: 8px;
  overflow: hidden;
}

.progress-bar i {
  background: var(--accent);
  display: block;
  height: 100%;
}

.rz-grid {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
}

.rz-search {
  background: #dfe8eb;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
  margin: 12px 0 8px;
  padding: 12px;
}

.rz-card {
  min-height: 128px;
  overflow: hidden;
  padding: 8px 10px;
  position: relative;
  text-align: center;
}

.rz-card strong {
  display: block;
  font-size: 14px;
  line-height: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rz-card-details {
  color: var(--muted);
  display: grid;
  font-size: 11px;
  gap: 2px 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  line-height: 14px;
  margin-top: 4px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.15s ease, opacity 0.15s ease;
}

.rz-card-details span {
  text-align: left;
}

.rz-card-details strong {
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 14px;
  text-align: right;
  white-space: nowrap;
}

.rz-card:hover .rz-card-details,
.rz-card:focus-within .rz-card-details,
.rz-card.selected .rz-card-details {
  max-height: 88px;
  opacity: 1;
}

.rz-card-actions {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.rz-card-actions button {
  font-size: 12px;
  min-height: 30px;
  padding: 0 8px;
}

.rz-card.selected {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.scan-opened {
  align-items: center;
  background: #dfe8eb;
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 18px 0;
  padding: 14px;
}

.scan-opened .muted {
  flex: 1;
  min-width: 260px;
}

.scan-only .layout {
  grid-template-columns: 1fr;
  min-height: calc(100vh - 73px);
}

.scan-only .lot-list {
  display: none;
}

.scan-only .detail {
  padding: 18px;
}

.scan-page {
  display: grid;
  gap: 14px;
}

.scan-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.scan-heading h2 {
  font-size: 30px;
  margin-top: 4px;
}

.pallet-panel {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.pallet-heading {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.pallet-heading h2 {
  font-size: 28px;
  margin-top: 4px;
}

.pallet-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.button-link {
  align-items: center;
  background: var(--accent);
  border-radius: 6px;
  color: #fff;
  display: inline-flex;
  font-weight: 700;
  min-height: 40px;
  padding: 0 14px;
  text-decoration: none;
}

.pallet-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.pallet-row {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 2fr 0.9fr 1.1fr 1fr 0.8fr;
  padding: 10px;
}

.pallet-row:last-child {
  border-bottom: 0;
}

.pallet-row-head {
  background: #e7edef;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.pallet-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.pallet-row small {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.scan-box {
  background: #dfe8eb;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto auto auto auto auto;
  margin: 18px 0;
  padding: 14px;
}

.check-option {
  align-items: center;
  color: var(--ink);
  display: flex;
  font-size: 14px;
  gap: 8px;
  white-space: nowrap;
}

.check-option input {
  min-height: auto;
  width: auto;
}

.custom-text-row {
  align-items: end;
  background: #eef4f5;
  border: 1px solid #cddadd;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) 180px;
  padding: 12px;
}

.custom-text-row label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
}

.custom-text-row strong {
  color: #075e57;
  font-size: 13px;
}

.items {
  display: grid;
  gap: 8px;
}

.item-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 1.2fr 2fr 0.8fr 0.7fr 0.9fr auto;
  padding: 10px;
}

.item-row small,
.code-cell small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 3px;
}

.code-cell strong {
  display: block;
}

.badge {
  background: #e6edf0;
  border-radius: 999px;
  color: var(--muted);
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
}

.badge.excess {
  background: #fce7dc;
  color: #9a3412;
}

.search-bar {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
}

.result-card {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr auto;
  margin-top: 10px;
  padding: 12px;
}

.diverse-shell {
  display: grid;
  gap: 14px;
}

.diverse-form {
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1.4fr 1fr 0.8fr 0.8fr auto;
  padding: 14px;
}

.diverse-heading {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.diverse-heading h2 {
  font-size: 24px;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.diverse-items {
  margin-top: 12px;
}

.diverse-rz-form {
  align-items: center;
  background: #dfe8eb;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 180px auto 1fr auto;
  margin: 10px 0;
  padding: 12px;
}

.diverse-rz-form strong {
  color: #075e57;
  overflow-wrap: anywhere;
}

.diverse-rz-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 10px;
}

.diverse-rz-list button {
  background: #dfe7e9;
  color: var(--ink);
  min-height: 34px;
}

.diverse-rz-list button.active {
  background: #d7ece9;
  color: #075e57;
  box-shadow: inset 0 0 0 2px var(--accent);
}

.diverse-rz-list span {
  color: var(--muted);
  margin-left: 6px;
}

.diverse-label-options {
  background: #dfe8eb;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: auto auto auto 1fr;
  margin: 10px 0 4px;
  padding: 12px;
}

.diverse-label-options .custom-text-row {
  grid-column: 1 / -1;
}

.diverse-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.diverse-row {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: 0.65fr 0.9fr 1fr 2fr 0.45fr 0.7fr 0.7fr 0.8fr;
  padding: 10px;
}

.diverse-rz-divider {
  background: #eef4f5;
  border-bottom: 1px solid var(--line);
  color: #075e57;
  font-size: 13px;
  font-weight: 800;
  padding: 8px 10px;
}

.diverse-row button {
  font-size: 12px;
  min-height: 32px;
  padding: 0 10px;
}

.diverse-row:last-child {
  border-bottom: 0;
}

.diverse-row-head {
  background: #e7edef;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.diverse-row span,
.diverse-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.admin-shell {
  display: grid;
  gap: 18px;
  padding: 22px 24px;
}

#adminUsersTab,
#adminCatalogTab {
  display: grid;
  gap: 18px;
}

.admin-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.admin-form {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr 1fr auto;
  margin-top: 14px;
}

.admin-heading {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.admin-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.admin-row {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 1.5fr) 0.5fr 0.5fr 0.7fr minmax(360px, 1.4fr);
  padding: 12px;
}

.catalog-request-row {
  grid-template-columns: minmax(260px, 1.5fr) minmax(120px, 0.6fr) minmax(100px, 0.5fr) 88px minmax(100px, 0.6fr) minmax(90px, 0.5fr) minmax(190px, 0.8fr);
}

.catalog-product-row {
  grid-template-columns: minmax(280px, 1.7fr) minmax(130px, 0.7fr) minmax(100px, 0.5fr) minmax(100px, 0.5fr) minmax(110px, 0.6fr) minmax(180px, 0.8fr);
}

.admin-row:last-child {
  border-bottom: 0;
}

.admin-row-head {
  background: #e7edef;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-row strong,
.admin-row .muted {
  display: block;
  overflow-wrap: anywhere;
}

.admin-actions,
.password-form {
  align-items: center;
  display: flex;
  gap: 8px;
}

.password-form {
  flex: 1;
}

.password-form input {
  min-width: 130px;
}

.catalog-thumb {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  height: 64px;
  object-fit: cover;
  width: 64px;
}

.catalog-link {
  color: #075e57;
  font-weight: 800;
}

.label-modal {
  background: rgb(0 0 0 / 0.42);
  display: grid;
  inset: 0;
  place-items: center;
  position: fixed;
  z-index: 20;
}

.label-stage {
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 20px 80px rgb(0 0 0 / 0.25);
  display: grid;
  gap: 14px;
  padding: 18px;
}

.decision-stage {
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 20px 80px rgb(0 0 0 / 0.25);
  display: grid;
  gap: 14px;
  max-width: 620px;
  padding: 20px;
  width: min(620px, calc(100vw - 32px));
}

.decision-stage h2 {
  font-size: 20px;
}

.decision-body-row {
  display: grid;
  gap: 4px;
}

.decision-body-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.decision-body-row strong {
  overflow-wrap: anywhere;
}

.decision-fields {
  display: grid;
  gap: 10px;
}

.decision-fields label {
  display: grid;
  gap: 6px;
}

.decision-fields input {
  background: #fff;
  border-color: #9fb4c2;
}

.label-print {
  background: #fff;
  border: 1px solid #cfd6dc;
  box-sizing: border-box;
  color: #111;
  display: grid;
  gap: 2px;
  grid-template-rows: 10mm 13mm 3.5mm 6mm;
  height: 40mm;
  overflow: hidden;
  padding: 2.5mm 4mm 1.8mm;
  width: 60mm;
}

.label-print.has-note {
  grid-template-rows: 8mm 10.5mm 3mm 5mm 4.5mm;
  padding-bottom: 1.5mm;
}

.label-desc {
  font-family: Arial, sans-serif;
  font-size: 8.5px;
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
  overflow: hidden;
}

.has-note .label-desc {
  font-size: 7.6px;
  line-height: 1.12;
}

.label-barcode {
  align-self: end;
  fill: #111;
  height: 15mm;
  justify-self: center;
  margin-top: 2px;
  width: 49mm;
}

.has-note .label-barcode {
  height: 11.5mm;
}

.label-sku {
  align-self: center;
  font-family: Arial, sans-serif;
  font-size: 8px;
  font-weight: 500;
  justify-self: center;
  letter-spacing: 3.2px;
  line-height: 1;
  margin-top: -2px;
}

.has-note .label-sku {
  font-size: 7.4px;
}

.label-price {
  align-self: end;
  font-family: Arial Black, Arial, sans-serif;
  font-size: 16px;
  line-height: 1;
  white-space: nowrap;
}

.has-note .label-price {
  font-size: 14.5px;
}

.label-note {
  border-top: 1px solid #111;
  display: none;
  font-family: Arial, sans-serif;
  font-size: 6.8px;
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
  overflow: hidden;
  padding-top: 0.8mm;
  text-transform: uppercase;
}

.has-note .label-note {
  display: block;
}

.label-controls {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: center;
}

#labelPrintRoot {
  display: none;
}

@media (max-width: 900px) {
  .form,
  .upload-grid,
  .layout,
  .summary-grid,
  .rz-search,
  .scan-box,
  .custom-text-row,
  .item-row,
  .diverse-rz-form,
  .diverse-label-options,
  .diverse-form,
  .diverse-row,
  .pallet-row,
  .result-card,
  .admin-form,
  .admin-row {
    grid-template-columns: 1fr;
  }

  .admin-actions,
  .password-form,
  .admin-heading,
  .pallet-heading,
  .pallet-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

@media print {
  @page {
    margin: 0;
    size: 60mm 40mm;
  }

  html,
  body {
    height: 40mm;
    margin: 0;
    overflow: hidden;
    width: 60mm;
  }

  body > :not(#labelModal) {
    display: none !important;
  }

  body.printing-label > :not(#labelPrintRoot) {
    display: none !important;
  }

  body.printing-label #labelPrintRoot {
    display: block !important;
    height: 40mm;
    left: 0;
    overflow: hidden;
    position: fixed;
    top: 0;
    width: 60mm;
  }

  #labelPreview {
    display: block;
    height: 40mm;
    width: 60mm;
  }

  .label-modal,
  .label-stage {
    background: transparent;
    box-shadow: none;
    display: block;
    height: 40mm;
    inset: auto;
    padding: 0;
    position: static;
    width: 60mm;
  }

  .label-print {
    border: 0;
    height: 40mm;
    page-break-after: avoid;
    page-break-before: avoid;
    page-break-inside: avoid;
    width: 60mm;
  }

  .label-controls {
    display: none;
  }
}
