:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1d252d;
  --muted: #64717f;
  --line: #d9dee5;
  --accent: #176b87;
  --accent-2: #0f766e;
  --warn: #9a5b13;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
}

.isHidden {
  display: none !important;
}

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

.loginCard {
  display: grid;
  gap: 16px;
  width: min(420px, calc(100vw - 40px));
  min-width: 0;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.loginCard input,
.loginCard button {
  width: 100%;
  min-width: 0;
}

.passwordInputWrap {
  position: relative;
  display: block;
}

.passwordInputWrap input {
  padding-right: 46px;
}

.loginCard .passwordToggle {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 38px;
  height: 36px;
  padding: 0;
  border-left: 1px solid var(--line);
  border-radius: 0 5px 5px 0;
  background: white;
  color: var(--muted);
}

.passwordToggle:hover,
.passwordToggle:focus-visible {
  color: var(--accent);
}

.passwordEyeIcon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.passwordEyeSlash {
  display: none;
}

.passwordToggle[aria-pressed="true"] .passwordEyeSlash {
  display: block;
}

.loginStatus[data-state="error"] {
  color: #8b2530;
}

.loginStatus {
  min-height: 20px;
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.shell {
  width: min(1380px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 11px 14px;
  background: linear-gradient(135deg, #17242f, #203746);
  border: 1px solid #263f4e;
  border-radius: 8px;
  color: white;
  box-shadow: 0 8px 24px rgb(29 37 45 / 0.14), inset 0 -3px 0 var(--accent);
}

.topbarActions {
  display: grid;
  gap: 10px;
  justify-items: end;
}

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

.appTitle {
  min-width: 0;
}

.appTitle h1,
.appTitle p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.appTitle p {
  margin-top: 2px;
  color: #b9d2da;
  font-size: 12px;
  font-weight: 600;
}

.appTitle h1 {
  color: white;
  font-size: 20px;
  line-height: 1.15;
}

.salesControls {
  display: grid;
  grid-template-columns: minmax(220px, 0.5fr) minmax(0, 1.5fr);
  align-items: end;
  gap: 20px;
  margin-bottom: 12px;
}

.salesSource {
  min-width: 0;
}

h1, h2, p {
  margin: 0;
}

h1 {
  font-size: 28px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
  font-weight: 700;
}

#sourceStatus,
.panelTitle span,
.metrics span,
.metrics small {
  color: var(--muted);
}

#sourceStatus {
  margin-top: 4px;
  font-size: 14px;
}

.updateInfo {
  display: grid;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.updateInfo strong {
  color: var(--text);
  font-weight: 700;
}

.refreshButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  min-width: 112px;
  height: 34px;
  padding: 0 12px;
}

.syncSpinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgb(255 255 255 / 0.45);
  border-top-color: white;
  border-radius: 999px;
}

.isSyncing .syncSpinner {
  display: inline-block;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.filters,
.accountTools {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 820px;
}

.accountTools {
  max-width: 920px;
}

.quickRanges {
  display: flex;
  align-items: end;
  gap: 6px;
  flex-wrap: wrap;
}

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

input,
select,
button {
  height: 38px;
  border-radius: 6px;
  font: inherit;
}

input,
select {
  min-width: 160px;
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  padding: 0 10px;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: var(--accent);
  color: white;
  padding: 0 16px;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
}

.quickRanges button {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  padding: 0 12px;
}

#logoutButton {
  min-height: 44px;
  border: 1px solid rgb(255 255 255 / 0.32);
  background: rgb(255 255 255 / 0.08);
  color: white;
}

#logoutButton:hover,
#logoutButton:focus-visible {
  border-color: rgb(255 255 255 / 0.58);
  background: rgb(255 255 255 / 0.16);
}

.quickRanges button.active {
  border-color: var(--accent);
  background: #e8f4f7;
  color: var(--accent);
  font-weight: 700;
}

button:disabled {
  opacity: .65;
  cursor: wait;
}

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

.metrics article,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics article {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.metrics strong {
  font-size: 30px;
  line-height: 1;
}

.panel {
  padding: 16px;
}

.chartPanel {
  margin-bottom: 12px;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}

.tabs button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.tabs button.active {
  border-color: var(--accent);
  background: #e8f4f7;
  color: var(--accent);
  font-weight: 700;
}

.tabs span {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}

.tabPanel {
  display: none;
}

.tabPanel.active {
  display: block;
}

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

#salesChart {
  display: block;
  width: 100%;
  height: 320px;
}

#selectedChart {
  display: block;
  width: 100%;
  height: 380px;
}

#salesChart,
#selectedChart {
  touch-action: pan-y;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 460px) minmax(0, 1fr);
  gap: 12px;
}

.selectionList {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
  padding-right: 4px;
}

.selectionItem {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.selectionItem > div:first-child {
  min-width: 0;
}

.selectionItem.isSelected {
  border-color: var(--accent);
  background: #f0f9fb;
}

.selectionItem strong {
  display: inline-block;
  min-width: 56px;
  margin-right: 8px;
}

.selectionItem span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selectionItem small {
  display: block;
  color: var(--muted);
  text-align: right;
}

.selectionItem button {
  height: 32px;
  padding: 0 10px;
  background: #eef1f4;
  color: var(--text);
}

.selectionItem.isSelected button {
  background: var(--accent);
  color: white;
}

.tableWrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

#appView table th,
#appView table td,
#appView table td > strong,
#appView table td > small,
#appView table td > span,
#appView table td > code,
#appView table td > a {
  text-align: left;
}

td:nth-child(3),
td:nth-child(4),
td:nth-child(5),
th:nth-child(3),
th:nth-child(4),
th:nth-child(5) {
  text-align: left;
}

td:nth-child(3) strong {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 58px;
  padding: 5px 9px;
  border-radius: 6px;
  background: #e8f4f7;
  color: var(--accent);
}

.articleRow {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--row-color), transparent 86%) var(--share), transparent var(--share)),
    var(--panel);
}

.articleRow:nth-child(even) {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--row-color), transparent 88%) var(--share), transparent var(--share)),
    #fafbfc;
}

.articleRow strong {
  color: var(--text);
}

.shareCell {
  min-width: 140px;
}

.shareCell span {
  display: inline-block;
  min-width: 54px;
  color: var(--muted);
}

.shareCell i {
  display: inline-block;
  width: 72px;
  height: 8px;
  margin-left: 8px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--row-color) var(--share), #e7ebef var(--share));
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.legendItem {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 260px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbfc;
  font-size: 13px;
}

.legendItem span {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 999px;
}

.legendItem em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: normal;
  color: var(--muted);
}

.empty {
  color: var(--muted);
  padding: 20px 0;
}

.warning {
  color: var(--warn);
}

.draftQueueCommands,
.draftBadges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.draftQueueCommands {
  display: grid;
  grid-template-columns: minmax(0, 0.75fr) minmax(0, 1.25fr);
  width: 100%;
}

.draftQueuePanel > .panelTitle {
  display: grid;
  grid-template-columns: minmax(100px, 0.75fr) minmax(0, 2fr);
  align-items: center;
}

.draftQueuePanel > .panelTitle > h2 {
  grid-column: 1;
  grid-row: 1 / span 2;
}

.draftQueuePanel .draftQueueCommands {
  grid-column: 2;
  grid-row: 1 / span 2;
}

#deletePendingDrafts {
  grid-column: 1 / -1;
}

.draftQueueCommands button {
  width: 100%;
  height: auto;
  min-height: 38px;
  padding: 6px 8px;
  line-height: 1.2;
  white-space: normal;
}

  .draftSourceTabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 10px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eef1f4;
}

.draftSourceTabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.draftSourceTabs button.active {
  background: white;
  color: var(--text);
  box-shadow: 0 1px 2px rgb(26 35 44 / 0.14);
  font-weight: 700;
}

.dangerTextButton {
  border-color: #c99399;
  color: #8b2530;
}

.moduleNavigation {
  position: relative;
  z-index: 15;
  flex: 0 0 auto;
}

.moduleMenuButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-height: 44px;
  padding: 0 11px;
  border: 1px solid rgb(255 255 255 / 0.32);
  background: rgb(255 255 255 / 0.08);
  color: white;
  box-shadow: none;
}

.moduleMenuButton:hover,
.moduleMenuButton:focus-visible,
.moduleMenuButton[aria-expanded="true"] {
  border-color: rgb(255 255 255 / 0.58);
  background: rgb(255 255 255 / 0.16);
}

.burgerIcon {
  display: grid;
  gap: 4px;
  width: 20px;
}

.burgerIcon i {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.moduleTabs {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: min(280px, calc(100vw - 28px));
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--line);
  box-shadow: 0 14px 30px rgb(29 37 45 / 0.18);
  max-height: max(160px, calc(100vh - 100px));
  overflow-y: auto;
}

.moduleTabs[hidden] {
  display: none;
}

.moduleTabs button {
  min-height: 44px;
  border-radius: 0;
  background: var(--panel);
  color: var(--text);
  text-align: left;
}

.moduleTabs button.active {
  background: var(--text);
  color: white;
  font-weight: 700;
}

.moduleView {
  display: none;
}

.moduleView.active {
  display: block;
}

.catalogTabPanel {
  display: none;
}

.catalogTabPanel.active {
  display: block;
}

.catalogViewControls {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: 12px;
  padding-block: 12px;
}

.catalogViewIntro h2,
.catalogViewIntro p {
  margin: 0;
}

.catalogViewIntro > p:not(.formMessage) {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.catalogViewIntro .formMessage:not(:empty) {
  margin-top: 8px;
}

.catalogViewIntro .formMessage:empty {
  min-height: 0;
  margin: 0;
}

.catalogViewSelector {
  width: min(360px, 100%);
  min-width: 0;
}

.catalogViewSelector select {
  width: 100%;
  min-width: 0;
}

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

.catalogListPanel,
.catalogFormPanel {
  min-width: 0;
}

.catalogListHeader {
  align-items: end;
}

.catalogTitleActions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.catalogTitleActions h2 {
  margin: 0;
}

.catalogTitleActions button {
  white-space: nowrap;
}

.catalogFilters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, .75fr) auto;
  gap: 10px;
  width: min(680px, 100%);
  align-items: end;
}

.catalogFilters label {
  min-width: 0;
}

.catalogSearch {
  width: 100%;
}

.catalogFilters input,
.catalogFilters select,
.catalogSearch input {
  width: 100%;
}

.catalogTableWrap {
  max-height: 650px;
  overflow: auto;
}

.catalogProductTable {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.catalogSupplierTable {
  min-width: 1280px;
}

.catalogProductTable thead th,
.catalogSupplierTable thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #edf1f4;
}

.productStockTableWrap {
  overflow-x: clip;
}

.catalogProductTable th:nth-child(1) { width: 10%; }
.catalogProductTable th:nth-child(2) { width: 16%; }
.catalogProductTable th:nth-child(3) { width: 18%; }
.catalogProductTable th:nth-child(4) { width: 11%; }
.catalogProductTable th:nth-child(5) { width: 6%; }
.catalogProductTable th:nth-child(6) { width: 8%; }
.catalogProductTable th:nth-child(7) { width: 10%; }
.catalogProductTable th:nth-child(8) { width: 10%; }
.catalogProductTable th:nth-child(9) { width: 11%; }

.catalogProductTable th,
.catalogProductTable td {
  min-width: 0;
  overflow-wrap: anywhere;
}

.catalogProductAction {
  white-space: normal;
}

.catalogProductActionGroup {
  display: flex;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  gap: 6px;
  width: 100%;
  min-width: 0;
}

.catalogProductEditButton {
  order: 1;
}

.catalogProductDetailsButton {
  order: 2;
}

.catalogProductStockButton {
  order: 3;
}

.catalogProductReviewButton {
  order: 4;
}

.catalogProductAction .compactButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 0;
  padding-inline: 9px;
  text-align: center;
  white-space: nowrap;
}

.catalogProductActionGroup .compactButton {
  flex: 1 1 58px;
}

.catalogSupplierTable th:last-child,
.catalogSupplierTable td:last-child {
  position: sticky;
  right: 0;
  z-index: 1;
  width: 115px;
  min-width: 115px;
  background: var(--panel);
  box-shadow: -1px 0 0 var(--line);
  text-align: left;
}

.catalogSupplierTable thead th:last-child {
  z-index: 3;
  background: #edf1f4;
}

.catalogSupplierAction .compactButton {
  width: 100%;
  white-space: nowrap;
}

.catalogTableWrap td strong,
.catalogTableWrap td small {
  display: block;
}

.catalogTableWrap td small {
  margin-top: 3px;
  color: var(--muted);
}

.catalogReviewPanel {
  min-width: 0;
}

.catalogReviewHeader {
  align-items: start;
}

.catalogReviewHeader button {
  flex: 0 0 auto;
}

.catalogReviewSection + .catalogReviewSection {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.catalogReviewSectionTitle {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.catalogReviewSectionTitle h3 {
  margin: 0;
  font-size: 18px;
}

.catalogReviewSectionTitle span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.catalogReviewSearch {
  width: min(440px, 100%);
  margin-bottom: 12px;
}

.catalogReviewFilters {
  display: grid;
  grid-template-columns: minmax(240px, 440px) minmax(180px, 260px);
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.catalogReviewFilters .catalogSearch {
  width: 100%;
}

.importHeader {
  align-items: end;
}

.importHeaderActions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 12px;
}

.importHeaderActions label {
  display: grid;
  gap: 4px;
  min-width: 210px;
}

.importHeaderActions label > span,
.importCount {
  color: var(--muted);
  font-size: 12px;
}

.importCount {
  align-self: center;
  white-space: nowrap;
}

.importSummary span,
#importsView td[data-label="Datoteka"] strong,
#importsView td[data-label="Datoteka"] small {
  display: block;
}

.importSummary span + span,
#importsView td[data-label="Datoteka"] small {
  margin-top: 3px;
}

#importsView td[data-label="Datoteka"] small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.catalogReviewTableWrap {
  max-height: 330px;
  overflow: auto;
}

.catalogReviewTable {
  min-width: 850px;
}

.catalogReviewTable thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #edf1f4;
}

.catalogReviewTable td strong,
.catalogReviewTable td small {
  display: block;
}

.catalogReviewTable td small {
  margin-top: 3px;
  color: var(--muted);
}

.reviewSourceCell .sourceBadge {
  margin: 2px 4px 2px 0;
}

.sourceBadge[data-source="fiscal_bill"] {
  border-color: #d8b871;
  background: #fff5dc;
  color: #74520b;
}

.sourceBadge[data-source="manual"],
.sourceBadge[data-source="manual_invoice"] {
  border-color: #aeb7c1;
  background: #f2f4f6;
  color: #3e4b58;
}

.sourceBadge[data-source="email"] {
  border-color: #8fb9c2;
  background: #e8f4f7;
  color: #155d6b;
}

.sourceBadge[data-source="linked"] {
  border-color: #8fb9c2;
  background: #e8f4f7;
  color: #155d6b;
}

.importDetailsDialog {
  width: min(1180px, calc(100% - 32px));
}

.importDetailsContent {
  display: grid;
  gap: 16px;
  min-height: 0;
  max-height: calc(100dvh - 132px);
  overflow-y: auto;
  padding: 18px;
}

.importDetailsSectionTitle {
  margin: 0;
}

.importDetailsReceipts {
  display: grid;
  gap: 14px;
}

.listContinuationButton {
  display: block;
  min-height: 44px;
  margin: 14px auto 0;
}

.listContinuationButton[hidden] {
  display: none;
}

.importReceiptCard {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.importReceiptCard > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-subtle, #f7f9fb);
}

.importReceiptCard > header div,
.importReceiptCard > header small {
  display: block;
}

.importReceiptCard > header small,
.importReceiptCard > header span,
.importReceiptMeta {
  color: var(--muted);
  font-size: 12px;
}

.importReceiptCard > header small {
  margin-top: 3px;
}

.importReceiptMeta {
  margin: 0;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.importReceiptTableWrap {
  border: 0;
  border-radius: 0;
}

.importReceiptTableWrap table {
  min-width: 900px;
}

.catalogReviewAction {
  width: 120px;
  text-align: left;
}

.catalogReviewAction .compactButton {
  white-space: nowrap;
}

.catalogForm {
  display: grid;
  gap: 12px;
}

.catalogForm input,
.catalogForm select {
  width: 100%;
  min-width: 0;
}

#productSupplierAliasField > small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

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

.inlineSupplierFields {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin: 4px 0 0;
  padding: 14px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.inlineSupplierFields legend {
  padding: 0 10px 0 0;
  color: var(--text);
  font-weight: 700;
}

.productAlternativeNames {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin-top: 4px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.productAlternativeNamesHeader {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.productAlternativeNamesHeader h3,
.productAlternativeNamesHeader p {
  margin: 0;
}

.productAlternativeNamesHeader p {
  max-width: 620px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

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

.productAlternativeNameRow {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(190px, 1.25fr) minmax(90px, 0.45fr) auto;
  gap: 8px;
  align-items: end;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafcfd;
}

.productAlternativeNameRow label {
  min-width: 0;
}

.productAlternativeNameRow label > span {
  display: block;
  margin-bottom: 4px;
}

.productAlternativeNameUnit[readonly] {
  background: #eef2f4;
  color: var(--muted);
}

.productAlternativeNameRemove {
  min-height: 44px;
}

.productAlternativeNamesEmpty {
  margin: 0;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
}

.productDetailsSummary .productDetailsAlternatives {
  grid-column: 1 / -1;
}

.catalogFormActions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

.catalogDialog {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 18px 56px rgb(18 30 39 / 0.24);
}

.catalogDialog.productReviewDialog {
  width: min(980px, calc(100vw - 32px));
}

.catalogDialog::backdrop {
  background: rgb(20 30 38 / 0.48);
}

.catalogDialogHeader {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.catalogDialogHeader > div {
  min-width: 0;
}

.dialogCloseButton {
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0 0 3px;
  font-size: 24px;
  line-height: 1;
}

.catalogDialog .catalogForm {
  padding: 16px;
}

.productReviewImportContext {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin-top: 4px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.productReviewImportHeader {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.productReviewImportHeader h3,
.productReviewImportHeader p {
  margin: 0;
}

.productReviewImportHeader p,
.productReviewImportHeader > span {
  color: var(--muted);
  font-size: 12px;
}

.productReviewImportHeader p {
  margin-top: 4px;
}

.productReviewImportList {
  display: grid;
  gap: 12px;
  max-height: min(44dvh, 440px);
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

.productReviewImportActions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.productReviewImportActions button {
  min-height: 44px;
}

.productMatchSection {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin-top: 4px;
  padding: 16px;
  border: 1px solid #9fc7d1;
  border-radius: 8px;
  background: #f2f9fa;
}

.productMatchSection h3,
.productMatchSection p {
  margin: 0;
}

.productMatchSection > div:first-child p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

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

.productMatchCandidateDetails span {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  overflow-wrap: anywhere;
}

.productMatchCandidateDetails strong,
.productMatchCandidateDetails small {
  display: block;
}

.productMatchCandidateDetails small {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.productMatchActions {
  display: flex;
  justify-content: flex-end;
}

.productMatchActions button {
  min-height: 44px;
}

.productDetailsDialog {
  width: min(980px, calc(100vw - 32px));
}

.uploadDetailsDialog {
  width: min(820px, calc(100vw - 32px));
}

.dialogSubtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.productDetailsContent {
  display: grid;
  gap: 22px;
  padding: 16px;
}

.uploadDetailsContent {
  display: grid;
  gap: 18px;
  padding: 16px;
}

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

.uploadDetailsSummary .uploadDetailsImportId {
  grid-column: 1 / -1;
}

.uploadDetailsSection {
  display: grid;
  gap: 10px;
}

.uploadReviewProductList {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.uploadReviewProductList li {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafcfd;
}

.uploadReviewProductList strong,
.uploadReviewProductList small {
  display: block;
  overflow-wrap: anywhere;
}

.uploadReviewProductList small {
  margin-top: 3px;
  color: var(--muted);
}

.uploadDetailsError {
  padding: 12px;
  border: 1px solid #e2a5aa;
  border-radius: 6px;
  background: #fff7f8;
}

.uploadDetailsError h3,
.uploadDetailsError p {
  margin: 0;
}

.uploadDetailsError p {
  margin-top: 6px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.productDetailsSummary,
.productHistoryCard dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.productDetailsSummary > div,
.productHistoryCard dl > div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafcfd;
}

.productDetailsSummary .productDetailsStock {
  grid-column: span 2;
}

.productDetailsSummary .productDetailsAlternatives {
  grid-column: span 2;
}

.productDetailsSummary dt,
.productHistoryCard dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .025em;
  text-transform: uppercase;
}

.productDetailsSummary dd,
.productHistoryCard dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.productHistoryHeader,
.productHistoryCard header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.productHistoryHeader h3 {
  margin: 0;
}

.productHistoryHeader span,
.productHistoryCard header > span,
.productHistoryHint,
.productHistoryCard header small {
  color: var(--muted);
  font-size: 12px;
}

.productHistoryHint {
  margin: 5px 0 12px;
}

.productHistoryList {
  display: grid;
  gap: 12px;
}

.productHistoryCard {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.productHistoryCard header {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.productHistoryCard header strong,
.productHistoryCard header small {
  display: block;
}

.productHistoryCard header small {
  margin-top: 3px;
}

.productHistoryCard dd small {
  display: inline;
  color: var(--muted);
}

.productHistoryEmpty {
  margin: 0;
}

.stockTable {
  min-width: 1160px;
}

.stockHeader {
  align-items: end;
}

.stockHeaderControls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
  width: min(520px, 100%);
}

.stockSearch,
.stockSearch input {
  width: 100%;
  min-width: 0;
}

.stockSearchStatus {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

#appView table thead th {
  padding-top: 12px;
  padding-bottom: 12px;
  border-top: 1px solid var(--line);
  border-bottom: 2px solid #c9d2db;
  background: #edf1f4;
  color: #435260;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.035em;
  vertical-align: middle;
}

#appView table tbody td {
  vertical-align: middle;
}

.stockTable td.stockQuantityLow,
.catalogProductTable td.stockQuantityLow {
  background: #f8dfe2;
  color: #8b2530;
}

.stockTable td.stockQuantityWarning,
.catalogProductTable td.stockQuantityWarning {
  background: #fff0cf;
  color: #77520e;
}

.stockTable td.stockQuantityLow strong,
.stockTable td.stockQuantityWarning strong,
.catalogProductTable td.stockQuantityLow strong,
.catalogProductTable td.stockQuantityWarning strong {
  color: inherit;
}

.stockTable td .stockQuantityIndicator,
.catalogProductTable td .stockQuantityIndicator {
  display: block;
  margin-top: 3px;
  color: inherit;
  font-size: 11px;
  font-weight: 700;
}

#appView table th,
#appView table td {
  text-align: left;
}

#appView table tbody tr:hover {
  background: #fafcfd;
}

.stockTable th:nth-child(1),
.stockTable td:nth-child(1) {
  min-width: 150px;
}

.stockTable th:nth-child(2),
.stockTable td:nth-child(2),
.stockTable th:nth-child(3),
.stockTable td:nth-child(3) {
  min-width: 190px;
}

.stockTable th:nth-child(3),
.stockTable td:nth-child(3) {
  text-align: left;
}

.stockTable td:nth-child(3) strong {
  min-width: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
}

.stockTable th:nth-child(6),
.stockTable td:nth-child(6) {
  width: 130px;
  min-width: 130px;
}

.stockTable th:nth-child(7),
.stockTable td:nth-child(7) {
  width: 230px;
  min-width: 230px;
}

.stockTable th:last-child,
.stockTable td:last-child {
  width: 180px;
  min-width: 180px;
}

.stockTable td strong,
.stockTable td small {
  display: block;
}

.stockTable td small {
  margin-top: 3px;
  color: var(--muted);
}

.stockSupplierList,
.stockSupplierList > span {
  display: grid;
  gap: 2px;
}

.stockSupplierList {
  gap: 8px;
}

.stockQuantityInput,
.stockReasonInput {
  width: 100%;
  min-width: 0;
}

.stockQuantityInput {
  text-align: left;
}

.stockActionCell {
  text-align: left;
  white-space: nowrap;
}

.stockActionCell button {
  min-width: 78px;
  padding-left: 10px;
  padding-right: 10px;
}

@media (min-width: 641px) {
  #appView table th + th,
  #appView table td + td {
    border-left: 1px solid #e3e8ed;
  }

  .stockActionCell button + button {
    margin-left: 6px;
  }

  .catalogProductActionGroup button + button {
    margin-left: 0;
  }
}

@media (min-width: 861px) and (max-width: 1100px) {
  .catalogProductAction .compactButton {
    display: flex;
    width: 100%;
  }

  .catalogProductAction button + button {
    margin-top: 6px;
    margin-left: 0;
  }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .catalogDialog button,
  .catalogDialog input,
  .catalogDialog select {
    min-height: 44px;
  }
}

.formMessage[data-state="success"] {
  color: var(--accent-2);
}

.formMessage[data-state="error"] {
  color: #8b2530;
}

.secondaryButton {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
}

.dangerButton {
  background: #a52a37;
  color: white;
}

.uploadPanel {
  margin-bottom: 12px;
}

.dropZone {
  display: grid;
  min-height: 148px;
  place-items: center;
  gap: 14px;
  border: 2px dashed #aeb8c3;
  border-radius: 6px;
  background: #fafbfc;
  text-align: center;
  transition: border-color .15s ease, background .15s ease;
}

.dropZone.isDisabled {
  cursor: default;
  opacity: 0.58;
  pointer-events: none;
}

.dropZone.isDragging,
.dropZone:focus-visible {
  outline: 0;
  border-color: var(--accent);
  background: #eef8fa;
}

.uploadCommands,
.draftActions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filePickerInput {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}

.filePickerButton {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font: inherit;
}

.filePickerButton.secondaryButton {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
}

.filePickerButton:focus-within {
  outline: 3px solid rgb(25 126 148 / 0.3);
  outline-offset: 2px;
}

.filePickerButton:has(.filePickerInput:disabled) {
  cursor: default;
  opacity: 0.58;
}

.filePickerInput:disabled {
  cursor: default;
}

.uploadQueue {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.uploadQueueItem {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 140px minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

.uploadQueueItem strong,
.uploadQueueItem code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.uploadQueueItem span {
  color: var(--muted);
}

.uploadQueueItem[data-state="Greška"] span,
.uploadQueueItem[data-state="Nepodržana datoteka"] span,
.uploadQueueItem[data-state="Prevelika datoteka"] span {
  color: #a52a37;
}

.uploadQueueItem[data-state="Greška"] code,
.uploadQueueItem[data-state="Nepodržana datoteka"] code,
.uploadQueueItem[data-state="Prevelika datoteka"] code {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  font-family: inherit;
  line-height: 1.4;
}

.importActionButton {
  height: 32px;
  padding: 0 10px;
}

.uploadQueueActions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.uploadQueueActions button {
  min-height: 36px;
  white-space: nowrap;
}

.procurementWorkspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 12px;
}

.draftQueue {
  display: grid;
  gap: 10px;
  max-height: 760px;
  overflow: auto;
}

.draftDocumentGroup {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

.draftDocumentHeader {
  display: flex;
  min-width: 0;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  background: #edf1f4;
}

.draftDocumentIdentity {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.draftDocumentIdentity strong,
.draftDocumentIdentity small,
.draftDocumentIdentity code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.draftDocumentIdentity small,
.draftDocumentIdentity code {
  color: var(--muted);
}

.draftDocumentDrafts {
  display: grid;
  border-top: 1px solid var(--line);
}

.draftQueueItem {
  display: grid;
  width: 100%;
  height: auto;
  min-height: 88px;
  gap: 4px;
  padding: 10px;
  border: 0;
  border-radius: 0;
  background: white;
  color: var(--text);
  text-align: left;
}

.draftQueueItem + .draftQueueItem {
  border-top: 1px solid var(--line);
}

.draftDocumentDeleteButton {
  flex: 0 0 auto;
  display: grid;
  width: 28px;
  height: 28px;
  min-height: 28px;
  place-items: center;
  padding: 0 0 2px;
  border: 1px solid #d9a5aa;
  border-radius: 50%;
  background: white;
  color: #8b2530;
  font-size: 21px;
  line-height: 1;
}

.draftDocumentDeleteButton:hover,
.draftDocumentDeleteButton:focus-visible {
  border-color: #a52a37;
  background: #fff1f2;
  color: #a52a37;
}

.draftQueueItem:hover,
.draftQueueItem.active {
  background: #f2f8fa;
}

.draftQueueItem.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.draftQueueOrdinal {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.draftQueueItem span,
.draftQueueItem small,
.draftQueueItem code {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.draftForm {
  display: grid;
  gap: 14px;
}

.draftHeader {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.draftHeader code {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.draftBadges {
  justify-content: flex-end;
}

.sourceBadge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sourceBadge[data-source="email_procurement"] {
  border-color: #8fb9c2;
  background: #e8f4f7;
  color: #155d6b;
}

.supplierDetails {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
  margin: 0;
  padding: 10px 0;
  border-block: 1px solid var(--line);
}

.supplierDetails > label {
  display: grid;
  gap: 5px;
}

.supplierDetails .supplierNameField {
  grid-column: 1 / -1;
}

.supplierDetails span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.supplierDetails input {
  width: 100%;
}

.supplierDetailsHint {
  grid-column: 1 / -1;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.statusBadge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 6px;
  background: #e7ebef;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.statusBadge[data-status="processed"],
.statusBadge[data-status="posted"] {
  background: #dff4e5;
  color: #226b36;
}

.statusBadge[data-status="failed"],
.statusBadge[data-status="rejected"] {
  background: #f8dfe2;
  color: #8b2530;
}

.statusBadge[data-status="pending"],
.statusBadge[data-status="draft"] {
  background: #fff0cf;
  color: #77520e;
}

.draftPreviewWrap {
  display: grid;
  min-height: 360px;
}

.draftPreview {
  width: 100%;
  height: 360px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f5f7f9;
}

.draftPreviewMessage {
  align-self: center;
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.draftFields {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr);
  gap: 10px;
}

.draftFields input {
  width: 100%;
}

.wideField {
  grid-column: 1 / -1;
}

.draftRowsViewport {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.draftHorizontalScroll {
  height: 16px;
  overflow-x: scroll;
  overflow-y: hidden;
  scrollbar-gutter: stable;
  scrollbar-color: #8b98a5 #edf0f3;
}

.draftHorizontalScroll > div {
  height: 1px;
}

.draftRowsWrap {
  max-height: clamp(320px, 52vh, 620px);
  overflow: scroll;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-color: #8b98a5 #edf0f3;
  border-block: 1px solid var(--line);
}

.draftRowsWrap:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.draftRowsWrap::-webkit-scrollbar,
.draftHorizontalScroll::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

.draftRowsWrap::-webkit-scrollbar-thumb,
.draftHorizontalScroll::-webkit-scrollbar-thumb {
  border: 3px solid var(--panel);
  border-radius: 7px;
  background: #8b98a5;
}

.draftRowsWrap::-webkit-scrollbar-track,
.draftHorizontalScroll::-webkit-scrollbar-track {
  background: #edf0f3;
}

.draftRowsTable {
  min-width: 1480px;
}

.draftRowsTable thead {
  display: table-header-group;
}

.draftRowsTable tbody {
  display: table-row-group;
}

.draftRowsTable tbody > tr:not(.articleRow) {
  display: table-row;
}

.draftRowsTable th,
.draftRowsTable td {
  display: table-cell;
}

.draftRowsTable td::before {
  content: none;
}

.draftRowsTable thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #edf1f4;
  box-shadow: 0 1px 0 var(--line);
}

.draftRowsTable input {
  min-width: 0;
  width: 100%;
  text-align: left;
}

.draftRowsTable th:first-child,
.draftRowsTable td:first-child {
  width: 260px;
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--panel);
  box-shadow: 1px 0 0 var(--line);
}

.draftRowsTable thead th:first-child,
.draftRowsTable thead th:last-child {
  z-index: 4;
  background: #edf1f4;
}

.draftRowsTable th:not(:first-child):not(:last-child),
.draftRowsTable td:not(:first-child):not(:last-child) {
  width: 118px;
}

.vatCell small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  white-space: nowrap;
}

.draftRowsTable th:last-child,
.draftRowsTable td:last-child {
  width: 44px;
  position: sticky;
  right: 0;
  z-index: 2;
  background: var(--panel);
  box-shadow: -1px 0 0 var(--line);
  text-align: left;
}

.draftRowsTable .removeRow {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 20px;
}

.draftActions {
  justify-content: flex-end;
}

.formMessage {
  min-height: 20px;
  color: var(--muted);
}

.errorCell {
  max-width: 360px;
  color: #8b2530;
  overflow-wrap: anywhere;
}

@media (max-width: 860px) {
  .catalogProductTable .catalogProductActionGroup {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .catalogProductTable .catalogProductActionGroup > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

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

  .shell {
    width: min(100% - 16px, 1380px);
    padding-top: 14px;
    padding-bottom: 24px;
  }

  .filters,
  .accountTools {
    align-items: stretch;
  }

  .workspace,
  .procurementWorkspace,
  .catalogGrid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .tabs {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .tabs span {
    grid-column: 1 / -1;
    margin-left: 0;
  }

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

  .salesControls input,
  .salesControls select,
  .salesControls button {
    width: 100%;
    min-width: 0;
  }

  #appView button,
  #appView input:not(.filePickerInput),
  #appView select,
  .loginCard > button,
  .loginCard input,
  .filePickerButton {
    min-height: 44px;
  }

  #appView .draftDocumentDeleteButton,
  #appView .draftRowsTable .removeRow {
    width: 44px;
    min-width: 44px;
    height: 44px;
  }

  .topbar {
    position: static;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 14px;
  }

  .salesControls {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 14px;
  }

  .refreshButton {
    width: 100%;
  }

  h1 {
    font-size: 24px;
  }

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

  .topbarActions {
    justify-items: stretch;
  }

  .accountTools {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    max-width: none;
  }

  .quickRanges {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  #applyRange {
    grid-column: 1 / -1;
  }

  .metrics strong {
    font-size: 26px;
    overflow-wrap: anywhere;
  }

  .panel {
    padding: 14px;
  }

  .panelTitle {
    align-items: start;
    gap: 8px;
  }

  .chartPanel {
    overflow: hidden;
  }

  #salesChart {
    height: 270px;
  }

  #selectedChart {
    height: 330px;
  }

  .selectionList {
    max-height: none;
    padding-right: 0;
  }

  .legendItem {
    max-width: 100%;
  }

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

  .uploadQueueItem code {
    grid-column: 1 / -1;
  }

  .uploadQueueActions {
    grid-column: 1 / -1;
  }
}

@media (min-width: 641px) and (max-width: 860px) {
  .productStockTableWrap {
    max-height: none;
    overflow: visible;
  }

  .catalogProductTable > thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    border: 0;
    white-space: nowrap;
  }

  .catalogProductTable tbody {
    display: grid;
    gap: 8px;
  }

  .catalogProductTable tbody > tr {
    display: block;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
  }

  .catalogProductTable td {
    display: flex;
    min-width: 0;
    justify-content: flex-start;
    gap: 12px;
    padding: 9px 10px;
    overflow-wrap: anywhere;
  }

  .catalogProductTable td::before {
    content: attr(data-label);
    flex: 0 0 34%;
    max-width: 34%;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
  }

  .catalogProductTable td.empty::before {
    content: none;
  }

  .catalogProductTable td[data-label="Proizvod"] {
    display: grid;
    grid-template-columns: 34% minmax(0, 1fr);
    align-items: start;
    gap: 4px 12px;
  }

  .catalogProductTable td[data-label="Proizvod"]::before {
    grid-row: 1 / span 2;
    max-width: none;
  }

  .catalogProductTable td[data-label="Proizvod"] > strong,
  .catalogProductTable td[data-label="Proizvod"] > small {
    grid-column: 2;
  }

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

  .catalogProductTable .stockActionCell::before {
    grid-column: 1 / -1;
  }

  .catalogProductTable .stockActionCell button {
    width: 100%;
    min-height: 44px;
  }

  .catalogProductTable .stockEditField {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .salesControls {
    grid-template-columns: minmax(200px, 0.6fr) minmax(0, 1.4fr);
  }

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

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

  #applyRange {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 14px;
  }

  .shell {
    width: 100%;
    padding: 0 8px 20px;
  }

  .topbar {
    position: static;
    margin: 0 -8px 10px;
    gap: 10px;
    padding: 10px 14px;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .topbar #logoutButton {
    width: auto;
    min-width: 96px;
  }

  .metrics {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 8px;
  }

  .metrics article {
    padding: 13px 14px;
  }

  .panel,
  .metrics article {
    border-radius: 6px;
  }

  .chartPanel,
  .tabs {
    margin-bottom: 8px;
  }

  .panelTitle {
    display: grid;
    grid-template-columns: 1fr;
  }

  .draftQueuePanel > .panelTitle,
  .draftQueueCommands {
    grid-template-columns: minmax(0, 0.75fr) minmax(0, 1.25fr);
  }

  .draftQueuePanel > .panelTitle {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .draftQueuePanel > .panelTitle > h2,
  .draftQueuePanel .draftQueueCommands {
    grid-column: auto;
    grid-row: auto;
  }

  .panelTitle span {
    font-size: 13px;
  }

  .tabs {
    gap: 6px;
  }

  .tabs button,
  .quickRanges button {
    padding: 0 8px;
    font-size: 13px;
  }

  .loginCard .passwordToggle {
    width: 44px;
    height: 44px;
    min-height: 44px;
  }

  #salesChart {
    height: 250px;
  }

  #selectedChart {
    height: 310px;
  }

  table {
    min-width: 0;
  }

  .catalogProductTable,
  .catalogSupplierTable,
  .catalogReviewTable,
  .stockTable {
    min-width: 0;
  }

  .stockHeaderControls {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  .catalogViewControls {
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
  }

  .catalogViewSelector {
    width: 100%;
  }

  .catalogTitleActions {
    width: 100%;
  }

  .catalogDialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }

  .catalogDialog.productReviewDialog {
    width: calc(100vw - 16px);
  }

  .productReviewImportHeader {
    display: grid;
    gap: 5px;
  }

  .productReviewImportActions button {
    width: 100%;
  }

  .productMatchCandidateDetails {
    grid-template-columns: 1fr;
  }

  .productMatchActions button {
    width: 100%;
  }

  .productDetailsSummary,
  .productHistoryCard dl {
    grid-template-columns: minmax(0, 1fr);
  }

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

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

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

  .uploadQueueActions button:only-child {
    grid-column: 1 / -1;
  }

  .uploadQueueActions button {
    width: 100%;
    min-height: 44px;
  }

  .productDetailsSummary .productDetailsStock {
    grid-column: auto;
  }

  .productDetailsSummary .productDetailsAlternatives {
    grid-column: auto;
  }

  .productAlternativeNamesHeader,
  .productAlternativeNameRow {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .productAlternativeNamesHeader button,
  .productAlternativeNameRemove {
    width: 100%;
  }

  .productHistoryHeader,
  .productHistoryCard header {
    display: grid;
    gap: 5px;
  }

  .catalogDialog button,
  .catalogDialog input,
  .catalogDialog select {
    min-height: 44px;
  }

  #refreshStock {
    width: 100%;
  }

  .reviewSourceCell {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .reviewSourceCell::before {
    flex-basis: 100%;
  }

  .stockTable th:nth-child(n),
  .stockTable td:nth-child(n) {
    width: auto;
    min-width: 0;
  }

  .stockActionCell {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .stockActionCell::before {
    grid-column: 1 / -1;
  }

  .stockActionCell.singleAction {
    grid-template-columns: 1fr;
  }

  .stockActionCell button {
    width: 100%;
  }

  .stockActionCell button + button {
    margin-left: 0;
  }

  .stockEditField {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    text-align: left;
  }

  .catalogProductTable th:first-child,
  .catalogProductTable td:first-child,
  .catalogProductTable th:last-child,
  .catalogProductTable td:last-child,
  .catalogSupplierTable th:last-child,
  .catalogSupplierTable td:last-child {
    position: static;
    width: auto;
    min-width: 0;
    box-shadow: none;
  }

  table:not(.draftRowsTable) > thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    border: 0;
    white-space: nowrap;
  }

  tbody {
    display: grid;
    gap: 8px;
  }

  tr.articleRow {
    display: grid;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
  }

  tbody > tr:not(.articleRow) {
    display: block;
  }

  td {
    min-width: 0;
    display: flex;
    justify-content: flex-start;
    gap: 12px;
    padding: 9px 10px;
    overflow-wrap: anywhere;
    text-align: left;
  }

  td::before {
    content: attr(data-label);
    flex: 0 0 42%;
    max-width: 42%;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-align: left;
    text-transform: uppercase;
  }

  td.empty::before {
    content: none;
  }

  td > code,
  td > a,
  td > strong,
  td > small,
  td > span {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  td[data-label="Naziv"],
  .catalogProductTable td[data-label="Proizvod"] {
    display: grid;
    grid-template-columns: 42% minmax(0, 1fr);
    align-items: start;
    gap: 4px;
    text-align: left;
  }

  td[data-label="Naziv"]::before,
  .catalogProductTable td[data-label="Proizvod"]::before {
    grid-row: 1 / span 2;
    max-width: none;
    margin-bottom: 0;
  }

  td[data-label="Naziv"] > strong,
  td[data-label="Naziv"] > small,
  .catalogProductTable td[data-label="Proizvod"] > strong,
  .catalogProductTable td[data-label="Proizvod"] > small {
    grid-column: 2;
  }

  td:nth-child(3),
  td:nth-child(4),
  td:nth-child(5),
  th:nth-child(3),
  th:nth-child(4),
  th:nth-child(5) {
    text-align: left;
  }

  .shareCell {
    min-width: 0;
  }

  .shareCell span {
    min-width: auto;
  }

  .shareCell i {
    width: 64px;
  }

  .selectionItem {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .selectionItem button {
    grid-column: 1 / -1;
  }

  .catalogFieldRow,
  .catalogFormActions,
  .catalogFilters,
  .catalogReviewFilters {
    display: grid;
    grid-template-columns: 1fr;
  }

  .importHeaderActions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
  }

  .importHeaderActions label {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .importCount {
    justify-self: start;
  }

  .importDetailsDialog {
    width: calc(100% - 16px);
  }

  .importDetailsContent {
    max-height: calc(100dvh - 96px);
    padding: 12px;
  }

  .importReceiptCard > header {
    display: grid;
    gap: 6px;
    padding: 12px;
  }

  .importReceiptMeta {
    padding: 10px 12px;
  }

  .importReceiptTableWrap table {
    min-width: 0;
  }

  .catalogReviewHeader,
  .catalogReviewSectionTitle {
    align-items: stretch;
    flex-direction: column;
  }

  .catalogTableWrap,
  .catalogReviewTableWrap {
    max-height: none;
    overflow: visible;
  }

  .catalogReviewAction {
    width: auto;
  }

  .catalogReviewTable td[data-label="Proizvod"],
  .catalogReviewTable td[data-label="Dokument"] {
    display: grid;
    grid-template-columns: minmax(72px, 0.55fr) minmax(0, 1fr);
    align-items: start;
  }

  .catalogReviewTable td[data-label="Proizvod"]::before,
  .catalogReviewTable td[data-label="Dokument"]::before {
    grid-row: 1 / span 2;
    max-width: none;
  }

  .catalogReviewTable td[data-label="Proizvod"] > strong,
  .catalogReviewTable td[data-label="Proizvod"] > small,
  .catalogReviewTable td[data-label="Dokument"] > strong,
  .catalogReviewTable td[data-label="Dokument"] > small {
    grid-column: 2;
    text-align: left;
  }

  .draftFields,
  .supplierDetails {
    grid-template-columns: 1fr;
  }

  .wideField {
    grid-column: auto;
  }

  .supplierDetails .supplierNameField {
    grid-column: auto;
  }

  .supplierDetailsHint {
    grid-column: auto;
  }

  .draftPreview {
    height: 300px;
  }

  .draftPreviewWrap {
    min-height: 300px;
  }

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

  .draftBadges {
    justify-content: flex-start;
  }

  .draftRowsTable th:first-child,
  .draftRowsTable td:first-child {
    width: 160px;
  }

  .draftRowsTable th:last-child,
  .draftRowsTable td:last-child {
    position: static;
    right: auto;
    width: 52px;
    box-shadow: none;
  }

  .draftDocumentDeleteButton,
  .draftRowsTable .removeRow {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }

  .draftActions,
  .uploadCommands {
    display: grid;
    grid-template-columns: 1fr;
  }

  .draftActions button,
  .uploadCommands button,
  .uploadCommands .filePickerButton {
    width: 100%;
  }

  .filePickerButton {
    min-height: 44px;
  }
}

@media (max-width: 420px) {
  .tabs {
    grid-template-columns: 1fr;
  }

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

  #applyRange,
  .tabs span {
    grid-column: 1 / -1;
  }

  .metrics strong {
    font-size: 23px;
  }

  #salesChart {
    height: 235px;
  }

  #selectedChart {
    height: 290px;
  }
}
