:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #15202b;
  --muted: #5f6b7a;
  --line: #d8e0e7;
  --blue: #1167b1;
  --blue-strong: #0b4f8a;
  --green: #16803c;
  --amber: #946200;
  --red: #b42318;
  --shadow: 0 8px 24px rgba(21, 32, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  overflow: hidden;
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
  touch-action: manipulation;
}

button:hover {
  background: var(--blue-strong);
}

button.secondary {
  background: #e8eef4;
  color: var(--text);
}

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

button:disabled {
  cursor: default;
  opacity: 0.45;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
}

select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
  resize: vertical;
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
}

.topbar-action-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-admin-actions {
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.topbar-work-actions > .icon-button,
.topbar-admin-actions > .icon-button {
  background: #e0f2fe;
  color: var(--blue-strong);
  box-shadow: inset 0 0 0 1px #bfdbfe;
}

.topbar-work-actions > .icon-button:hover,
.topbar-admin-actions > .icon-button:hover,
.topbar-work-actions > .icon-button:focus-visible,
.topbar-admin-actions > .icon-button:focus-visible {
  background: #bae6fd;
  color: var(--blue-strong);
}

.topbar-sync-actions:empty {
  display: none;
}

.topbar-sync-actions .sync-actions {
  flex-wrap: nowrap;
}

.logout-menu-wrap {
  position: relative;
  display: inline-flex;
}

.logout-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  display: grid;
  gap: 6px;
  width: 180px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.16);
}

.logout-menu button {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
}

.topbar h1,
.panel h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 24px;
  line-height: 1.1;
}

.topbar p,
.panel p,
#order-meta {
  margin: 4px 0 0;
  color: var(--muted);
}

#status-line {
  display: flex;
  align-items: center;
  gap: 3px 10px;
  flex-wrap: wrap;
  min-width: 0;
  font-size: 13px;
  line-height: 1.15;
}

#status-line.error {
  color: var(--red);
}

.topbar-status-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  white-space: nowrap;
}

.topbar-status-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar-status-label {
  color: var(--muted);
  font-weight: 700;
}

.topbar-status-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

#order-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.order-detail-label {
  color: var(--text);
}

.order-ttn-link {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: left;
  cursor: pointer;
}

.order-ttn-link:hover,
.order-ttn-link:focus-visible {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.order-crm-edit-warning {
  flex-basis: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  background: #fffbeb;
  color: #92400e;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  text-align: left;
}

.order-crm-edit-warning:hover,
.order-crm-edit-warning:focus-visible {
  background: #fef3c7;
  outline: none;
}

.order-title h2,
#order-title {
  display: inline-grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 6px;
  row-gap: 2px;
  min-width: 0;
}

.order-title-number {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
}

#order-title .crm-stage-badge {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  justify-self: start;
}

.order-customer,
.order-title-customer {
  display: inline-block;
  min-width: 0;
  max-width: 100%;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-customer {
  flex: 1 1 auto;
}

.order-title-customer {
  grid-column: 1 / -1;
  grid-row: 2;
  justify-self: center;
  max-width: min(360px, 52vw);
  margin-left: 0;
}

.order-number-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  margin-bottom: 2px;
}

.order-number-row strong {
  flex: 0 0 auto;
}

.order-comment {
  flex-basis: 100%;
  color: var(--text);
  white-space: pre-wrap;
}

#main-view {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.hidden {
  display: none !important;
}

.icon-button {
  width: 42px;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
  flex: 0 0 42px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.topbar .icon-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sync-button {
  display: inline-grid;
  place-items: center;
}

.sync-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sync-button.syncing .sync-icon {
  animation: sync-spin 0.8s linear infinite;
}

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

.search-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tasks-toggle-button svg,
.analytics-toggle-button svg,
.audit-toggle-button svg,
.users-toggle-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-form,
.import-form,
.scan-form {
  display: flex;
  gap: 10px;
  align-items: end;
  margin-top: 14px;
}

.login-form label {
  flex: 1;
  color: var(--muted);
  font-weight: 700;
}

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

.trust-device-label {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.trust-device-label input {
  width: auto;
  min-height: 0;
}

.import-panel {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.import-form {
  min-width: min(360px, 100%);
  margin-top: 0;
}

.import-search {
  position: relative;
  min-width: 42px;
  flex: 0 0 42px;
}

.import-search-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 18;
  width: min(360px, calc(100vw - 32px));
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.import-search-popover input {
  border: 0;
  min-height: 46px;
  padding-right: 42px;
}

.import-search-popover input:focus {
  outline: 0;
}

.import-search-submit {
  position: absolute;
  right: 4px;
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  background: transparent;
  color: var(--muted);
}

.import-search-submit:hover {
  background: #eef4fb;
  color: var(--blue);
}

.sync-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  position: relative;
}

.app-settings {
  position: relative;
  flex: 0 0 auto;
}

.app-settings-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: min(520px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 12px;
}

.settings-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.settings-hint.error {
  color: var(--red);
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 16px;
  flex: 1 1 auto;
  min-height: 0;
}

.orders-list,
.items-list,
.problems-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.orders-panel,
.order-panel {
  min-height: 0;
  overflow: hidden;
}

.orders-panel {
  padding: 12px;
}

.orders-panel .orders-list {
  gap: 8px;
  margin-top: 8px;
}

.orders-panel,
.order-panel,
#order-detail {
  display: flex;
  flex-direction: column;
}

#order-detail {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}

#order-detail.loading .scan-form {
  display: none;
}

.order-loading-state {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 8px;
  min-height: 220px;
  padding: 24px 12px;
  color: var(--muted);
  text-align: center;
}

.order-loading-state strong {
  color: var(--text);
  font-size: 18px;
}

.order-loading-state.error {
  color: var(--red);
  font-weight: 800;
}

.order-loading-spinner {
  width: 30px;
  height: 30px;
  border: 3px solid #dbeafe;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: order-loading-spin 0.75s linear infinite;
}

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

.orders-list,
.items-list,
.problems-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

.order-card,
.item-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.order-card {
  position: relative;
  text-align: left;
  color: var(--text);
  background: #fff;
  width: 100%;
  min-height: 86px;
  font-weight: 400;
  height: auto;
  line-height: 1.25;
  overflow-wrap: anywhere;
  white-space: normal;
  padding: 8px 34px 7px 10px;
}

.order-card:hover,
.order-card.active {
  border-color: var(--blue);
  background: #eef6ff;
}

.order-card.stage-colored {
  border-color: var(--stage-color);
  box-shadow: inset 4px 0 0 var(--stage-color);
}

.order-card.stage-colored:hover,
.order-card.stage-colored.active {
  border-color: var(--stage-color);
  background: #eef6ff;
}

.order-card.complete {
  border-color: #cfd6de;
  background: #eceff3;
  color: #596675;
}

.order-card.complete.active,
.order-card.complete:hover {
  border-color: #9ea9b5;
  background: #e1e6eb;
}

.order-card.removed {
  border-color: #efb4ae;
  background: #fff5f4;
  color: #7a271a;
}

.order-card.removed.active,
.order-card.removed:hover {
  border-color: var(--red);
  background: #ffe7e4;
}

.item-card strong {
  display: block;
  margin-bottom: 4px;
}

.order-card strong {
  display: block;
  margin-bottom: 0;
}

.order-card div {
  overflow-wrap: anywhere;
  white-space: normal;
}

.order-comment-icon {
  position: absolute;
  top: 10px;
  right: 52px;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: var(--blue);
  background: #eef6ff;
}

.order-crm-edit-icon {
  position: absolute;
  top: 10px;
  right: 84px;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: #a16207;
  background: #fef3c7;
}

.order-card.has-crm-edits:not(.has-comment) .order-crm-edit-icon {
  right: 46px;
}

.order-crm-edit-icon svg,
.order-comment-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.order-complete-icon {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  color: #fff;
  background: var(--green);
}

.order-pending-icon {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  color: var(--muted);
  background: #eef4fb;
}

.order-complete-icon svg,
.order-pending-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.order-complete-icon circle {
  fill: none;
}

.order-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.order-card-count {
  position: absolute;
  top: 7px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 36px;
  padding: 0 6px;
  border-radius: 999px;
  background: #eef4fb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.crm-stage-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  min-height: 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ttn-tail {
  font-weight: 900;
}

.ttn-source-badge {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #475569;
  font-size: 11px;
  font-weight: 800;
  vertical-align: middle;
}

.ttn-source-badge.danger {
  background: var(--red);
  color: #fff;
}

.ttn-deleted-label {
  color: #92400e;
  font-weight: 900;
}

.order-complete-label,
.order-removed-label {
  color: #596675;
  font-weight: 700;
}

.order-removed-label {
  color: var(--red);
}

.order-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 14px;
}

.order-heading-actions {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.order-actions-menu {
  position: relative;
  flex: 0 0 auto;
}

.order-actions-menu .icon-button {
  display: inline-grid;
  place-items: center;
}

.order-actions-menu svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.order-actions-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 16;
  display: grid;
  gap: 8px;
  min-width: 220px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.order-actions-panel button {
  width: 100%;
  justify-content: center;
}

.ttn-preview-panel {
  display: grid;
  gap: 10px;
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 80;
  width: min(720px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  overscroll-behavior: contain;
  margin-bottom: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.ttn-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ttn-preview-title-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ttn-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.ttn-status-badge[data-tone="warning"] {
  background: #fef3c7;
  color: #92400e;
}

.ttn-status-badge[data-tone="error"] {
  background: #fee2e2;
  color: #991b1b;
}

.ttn-preview-header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.ttn-preview-header-actions .ttn-create-button,
.ttn-preview-header-actions .ttn-preview-copy {
  min-height: 36px;
  padding: 0 12px;
}

.ttn-preview-close {
  width: 36px;
  height: 36px;
  min-width: 36px;
  font-size: 24px;
  line-height: 1;
}

.ttn-debug-settings {
  position: relative;
}

.ttn-debug-settings-button {
  width: 36px;
  height: 36px;
  min-width: 36px;
}

.ttn-debug-settings-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 4;
  display: grid;
  gap: 8px;
  min-width: 190px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.ttn-debug-settings-menu span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ttn-debug-settings-menu .segmented-control {
  width: 100%;
}

.ttn-debug-settings-menu .mode-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.ttn-preview-text {
  max-height: min(260px, 34vh);
  margin: 0;
  padding: 10px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 6px;
  background: #f8fafc;
  color: var(--text);
  font: 14px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.ttn-profile-details,
.ttn-debug-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ttn-profile-details summary,
.ttn-debug-details summary {
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 800;
}

.ttn-advanced-details {
  align-self: start;
  background: #f8fafc;
}

.ttn-advanced-details .ttn-form-section {
  margin: 0 10px 10px;
  box-shadow: none;
}

.ttn-crm-form {
  display: grid;
  gap: 12px;
}

.ttn-mode-row {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 2px 4px;
  font-size: 14px;
}

.ttn-mode-row label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.ttn-form-status {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.ttn-form-status[data-tone="ok"] {
  background: #dcfce7;
  color: #166534;
}

.ttn-form-status[data-tone="warning"] {
  background: #fef3c7;
  color: #92400e;
}

.ttn-form-status[data-tone="error"] {
  background: #fee2e2;
  color: #991b1b;
}

.ttn-manual-note {
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 13px;
  line-height: 1.4;
}

.ttn-existing-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #86efac;
  border-radius: 8px;
  background: #f0fdf4;
  color: #14532d;
}

.ttn-existing-card[data-ttn-status="deleted_external"],
.ttn-existing-card[data-ttn-status="not_found"],
.ttn-existing-card[data-ttn-status="delete_failed"] {
  border-color: #f59e0b;
  background: #fffbeb;
  color: #92400e;
}

.ttn-existing-card span,
.ttn-existing-card dt {
  color: #166534;
  font-size: 12px;
  font-weight: 800;
}

.ttn-existing-card strong {
  display: block;
  margin-top: 2px;
  font-size: 24px;
  letter-spacing: 0;
}

.ttn-existing-card dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.ttn-existing-card dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  color: #0f172a;
  font-size: 13px;
}

.ttn-existing-card p {
  margin: 0;
  font-size: 13px;
}

.ttn-source-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 18px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.ttn-source-chip.danger {
  background: var(--red);
  color: #fff;
}

.ttn-deleted-card {
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
}

.ttn-deleted-card strong {
  font-size: 15px;
}

.ttn-deleted-card span {
  color: #0f172a;
  font-size: 22px;
  font-weight: 900;
}

.ttn-deleted-card p {
  margin: 0;
  font-size: 13px;
}

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

.ttn-existing-actions button {
  min-height: 38px;
  padding: 0 14px;
}

.ttn-existing-actions small {
  color: #64748b;
  font-weight: 700;
}

.ttn-validation-panel {
  display: grid;
}

.ttn-validation-card {
  display: grid;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 12px;
}

.ttn-validation-card[data-state="ok"] {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}

.ttn-validation-card[data-state="error"] {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.ttn-validation-card ul {
  margin: 3px 0 0;
  padding-left: 18px;
}

.ttn-validation-card li {
  margin: 2px 0;
}

.ttn-validation-card span {
  font-weight: 800;
}

.ttn-validation-warning {
  color: #92400e;
}

.ttn-payment-logic {
  display: grid;
  gap: 3px;
  padding-top: 6px;
  border-top: 1px solid rgba(15, 23, 42, 0.12);
  color: #334155;
}

.ttn-validation-card[data-state="ok"] .ttn-payment-logic {
  color: #14532d;
}

.ttn-validation-card[data-state="error"] .ttn-payment-logic {
  color: #7f1d1d;
}

.ttn-payment-logic strong {
  color: inherit;
}

.ttn-payment-logic span {
  font-weight: 900;
}

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

.ttn-form-section {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}

.ttn-form-section h4 {
  margin: 0 0 4px;
  font-size: 15px;
}

.ttn-sender-summary dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.ttn-sender-summary-compact {
  gap: 8px;
  padding: 0;
  overflow: hidden;
}

.ttn-sender-summary-compact summary {
  display: grid;
  grid-template-columns: minmax(108px, 0.42fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 10px;
  cursor: pointer;
}

.ttn-sender-summary-compact summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ttn-sender-summary-compact summary strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ttn-sender-warehouse-editor {
  display: grid;
  gap: 6px;
  padding: 0 10px 10px;
}

.ttn-sender-details-list {
  padding: 0 10px 2px;
}

.ttn-sender-summary div {
  display: grid;
  grid-template-columns: minmax(110px, 0.42fr) minmax(0, 1fr);
  gap: 8px;
}

.ttn-sender-summary .ttn-sender-warehouse-editor {
  grid-template-columns: 1fr;
  gap: 6px;
}

.ttn-sender-summary dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ttn-sender-summary dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.ttn-sender-summary select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font: inherit;
  padding: 0 9px;
}

.ttn-sender-summary small {
  color: var(--muted);
  font-size: 11px;
}

.ttn-sender-summary small[data-tone="ok"] {
  color: var(--success);
  font-weight: 700;
}

.ttn-sender-summary small[data-tone="error"] {
  color: var(--danger);
  font-weight: 700;
}

.ttn-form-section-wide {
  grid-column: 1 / -1;
}

.ttn-fields-grid {
  display: grid;
  grid-template-columns: minmax(130px, 0.48fr) minmax(0, 1fr);
  gap: 7px 9px;
  align-items: center;
}

.ttn-field {
  display: contents;
}

.ttn-field > span {
  color: var(--muted);
  font-size: 12px;
}

.ttn-field input,
.ttn-field select {
  min-width: 0;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font: inherit;
  padding: 0 9px;
}

.ttn-field input[readonly],
.ttn-field select:disabled {
  opacity: 1;
}

.ttn-field small {
  grid-column: 2;
  margin-top: -6px;
  color: var(--muted);
  font-size: 11px;
}

.ttn-size-summary-section {
  gap: 8px;
}

.ttn-size-summary-row {
  display: grid;
  grid-template-columns: minmax(260px, 1.2fr) minmax(110px, 0.4fr) minmax(270px, 1fr);
  gap: 12px;
  align-items: start;
}

.ttn-size-warehouse {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
  align-items: start;
  min-width: 0;
}

.ttn-size-warehouse > span {
  color: var(--muted);
  font-size: 12px;
}

.ttn-size-warehouse select {
  width: 100%;
  min-width: 0;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font: inherit;
  padding: 0 8px;
}

.ttn-size-warehouse small {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.ttn-size-warehouse small[data-tone="ok"] {
  color: var(--success);
  font-weight: 700;
}

.ttn-size-warehouse small[data-tone="error"] {
  color: var(--danger);
  font-weight: 700;
}

.ttn-size-weight {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
  align-items: start;
  min-width: 0;
}

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

.ttn-size-weight input {
  width: 100%;
  min-width: 0;
  max-width: 96px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 8px;
}

.ttn-dimensions-field {
  align-items: start;
}

.ttn-size-summary-row .ttn-dimensions-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
  align-items: start;
  min-width: 0;
}

.ttn-size-summary-row .ttn-dimensions-field > span {
  color: var(--muted);
  font-size: 12px;
}

.ttn-dimensions-control {
  display: grid;
  gap: 4px;
}

.ttn-dimensions-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(58px, 82px));
  gap: 6px;
  align-items: center;
}

.ttn-dimensions-row label {
  display: grid;
  grid-template-columns: 14px minmax(42px, 1fr);
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.ttn-dimensions-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ttn-dimensions-row input {
  width: 100%;
  min-width: 0;
  text-align: center;
}

.ttn-dimensions-control small {
  grid-column: auto;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.ttn-recipient-lookup {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.ttn-lookup-row {
  display: grid;
  grid-template-columns: 74px minmax(82px, 0.52fr) minmax(0, 1fr);
  gap: 6px;
  align-items: center;
}

.ttn-lookup-row span,
.ttn-recipient-lookup small {
  color: var(--muted);
  font-size: 12px;
}

.ttn-recipient-lookup small[data-tone="ok"] {
  color: var(--success);
  font-weight: 700;
}

.ttn-recipient-lookup small[data-tone="warning"],
.ttn-recipient-lookup small[data-tone="error"] {
  color: var(--danger);
  font-weight: 700;
}

.ttn-recipient-lookup input,
.ttn-recipient-lookup select {
  min-width: 0;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 7px;
}

.ttn-field-map {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(220px, 1.4fr);
  gap: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.ttn-field-map > div {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.ttn-field-map-head {
  font-weight: 800;
  background: #eef3f8;
}

.ttn-field-map code {
  font-weight: 800;
  color: #111827;
}

.ttn-required {
  color: var(--danger);
  margin-left: 2px;
}

.ttn-preview-copy {
  justify-self: start;
}

.ttn-create-button {
  justify-self: start;
  min-height: 38px;
  padding: 0 14px;
}

.ttn-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ttn-create-status {
  margin: 0;
  padding: 10px;
  overflow: auto;
  max-height: 180px;
  border: 1px solid #fecaca;
  border-radius: 6px;
  background: #fef2f2;
  color: var(--danger);
  white-space: pre-wrap;
  word-break: break-word;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.ttn-sender-profile {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

.ttn-sender-profile small,
.ttn-sender-status {
  color: var(--muted);
}

.ttn-sender-status[data-tone="ok"] {
  color: var(--success);
  font-weight: 700;
}

.ttn-sender-status[data-tone="warning"],
.ttn-sender-status[data-tone="error"] {
  color: var(--danger);
  font-weight: 700;
}

.ttn-sender-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.ttn-sender-grid label,
.ttn-sender-grid select,
.ttn-sender-grid button {
  min-width: 0;
}

.ttn-sender-grid select,
.ttn-sender-grid button[data-ttn-profile-save] {
  grid-column: 1 / -1;
}

@media (max-width: 700px) {
  .ttn-preview-panel {
    top: 8px;
    right: 8px;
    left: 8px;
    width: auto;
    max-height: calc(100dvh - 16px);
  }

  .ttn-preview-header {
    align-items: flex-start;
  }

  .ttn-preview-header-actions {
    gap: 6px;
  }

  .ttn-preview-header-actions .ttn-create-button,
  .ttn-preview-header-actions .ttn-preview-copy,
  .ttn-preview-close {
    min-height: 34px;
    height: 34px;
  }

  .ttn-sender-grid {
    grid-template-columns: 1fr;
  }

  .ttn-form-two-columns,
  .ttn-fields-grid {
    grid-template-columns: 1fr;
  }

  .ttn-size-summary-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

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

  .ttn-dimensions-row {
    grid-template-columns: repeat(3, minmax(54px, 1fr));
  }

  .ttn-lookup-row {
    grid-template-columns: 68px minmax(72px, 0.48fr) minmax(0, 1fr);
    gap: 5px;
  }

  .ttn-recipient-lookup {
    padding: 7px;
  }

  .ttn-field small {
    grid-column: 1;
  }

  .ttn-existing-card dl {
    grid-template-columns: 1fr;
  }
}

.orders-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 36px;
}

.orders-heading h2 {
  font-size: 20px;
  line-height: 1.05;
}

.orders-heading-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.orders-heading-actions .icon-button {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  flex-basis: 36px;
  font-size: 19px;
  border-radius: 6px;
}

.orders-heading-actions .import-form {
  min-width: 36px;
  margin: 0;
}

.orders-heading-actions .import-search-popover {
  left: auto;
  right: 0;
  width: min(260px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
}

.product-check-window,
.tasks-window,
.analytics-window,
.purchasing-window,
.api-diagnostics-window,
.audit-window,
.users-window {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  padding: 18px;
  background: rgba(15, 23, 42, 0.38);
}

.product-check-panel,
.tasks-panel,
.analytics-panel,
.purchasing-panel,
.api-diagnostics-panel,
.audit-panel,
.users-panel {
  display: flex;
  flex-direction: column;
  width: min(560px, 100%);
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}

.product-check-heading,
.tasks-heading,
.analytics-heading,
.purchasing-heading,
.api-diagnostics-heading,
.audit-heading,
.users-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.product-check-heading-actions,
.tasks-heading-actions,
.analytics-heading-actions,
.purchasing-heading-actions,
.api-diagnostics-heading-actions,
.audit-heading-actions,
.users-heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.analytics-panel {
  width: min(760px, 100%);
}

.purchasing-panel {
  width: min(1280px, calc(100vw - 24px));
  height: calc(100vh - 24px);
  max-height: calc(100vh - 24px);
}

body.purchasing-page-open {
  overflow: hidden;
}

body.purchasing-page-open .app {
  width: 100%;
  max-width: none;
}

body.purchasing-page-open .topbar {
  width: min(calc(1280px - 36px), 100%);
  margin-left: auto;
  margin-right: auto;
}

body.purchasing-page-open .layout {
  display: none;
}

body.purchasing-page-open .purchasing-window {
  position: static;
  inset: auto;
  z-index: auto;
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  padding: 0;
  background: transparent;
}

body.purchasing-page-open .purchasing-panel {
  width: 100%;
  height: auto;
  max-height: none;
  min-height: 0;
  box-shadow: none;
}

body.purchasing-page-open .purchasing-content {
  padding-right: 0;
}

body.purchasing-page-open .purchasing-table-wrap.supplier-preview {
  max-height: min(62vh, 720px);
}

.api-diagnostics-panel {
  width: min(860px, 100%);
}

.product-check-panel {
  width: min(920px, 100%);
}

.audit-panel {
  width: min(680px, 100%);
}

.users-panel {
  width: min(680px, 100%);
}

.analytics-filter-panel {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.product-check-content,
.analytics-content,
.purchasing-content,
.api-diagnostics-content,
.audit-content,
.users-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin-top: 14px;
  padding-right: 4px;
}

.product-check-form {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  margin-bottom: 12px;
}

.product-check-mode-control {
  align-self: stretch;
}

.product-check-mode-control .mode-button {
  min-height: 42px;
  padding: 0 12px;
}

.product-check-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 8px;
  min-width: 0;
}

.product-check-status {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-weight: 700;
}

.product-check-status.ok {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--green);
}

.product-check-status.warning {
  border-color: #fde68a;
  background: #fffbeb;
  color: var(--amber);
}

.product-check-status.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--red);
}

.product-check-result-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}

.product-check-results {
  display: grid;
  gap: 10px;
}

.product-check-card {
  display: grid;
  grid-template-columns: minmax(258px, 306px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.product-check-media {
  display: grid;
  grid-template-columns: clamp(124px, 15vw, 150px) minmax(108px, 1fr);
  gap: 8px;
  align-items: start;
  min-width: 0;
}

.product-check-media-details {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.product-check-image {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.product-check-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.product-check-main {
  min-width: 0;
}

.product-check-sku {
  font-size: 24px;
  line-height: 1.1;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.product-check-main h3 {
  margin: 4px 0;
  font-size: 16px;
  line-height: 1.25;
}

.product-check-main p {
  margin: 0 0 8px;
}

.product-check-links {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 6px 0;
}

.product-check-crm-link,
.product-check-site-link {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid rgba(8, 107, 216, 0.5);
  border-radius: 6px;
  background: #eef6ff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
  box-shadow: inset 0 -1px 0 rgba(8, 107, 216, 0.12);
}

.product-check-site-link {
  border-color: rgba(22, 163, 74, 0.45);
  background: #f0fdf4;
  color: #15803d;
}

.product-check-crm-link:hover,
.product-check-site-link:hover {
  filter: brightness(0.98);
  box-shadow: inset 0 -1px 0 rgba(8, 107, 216, 0.18), 0 0 0 2px rgba(8, 107, 216, 0.08);
}

.product-check-warnings {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.product-check-warnings span {
  border: 1px solid #fde68a;
  border-radius: 999px;
  padding: 3px 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 12px;
  font-weight: 800;
}

.product-check-addresses {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.product-check-address {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 86px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 5px 7px;
  background: #f8fafc;
}

.product-check-address.missing {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--red);
  font-weight: 800;
}

.product-check-address small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.product-check-address strong {
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.product-check-storage-address .storage-address,
.product-check-storage-address .item-meta {
  margin-top: 0;
}

.product-check-storage-address .item-meta {
  color: var(--text);
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.product-check-address span {
  color: var(--muted);
  font-size: 12px;
}

.product-check-work-counters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.product-check-work-counters > span {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.product-check-work-counters > span.active {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.product-check-work-counters small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.product-check-work-counters strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.product-check-split-count {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.product-check-split-count em {
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
}

.product-check-expected-purchases {
  margin-top: 8px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  background: #eff6ff;
  overflow: hidden;
}

.product-check-expected-purchases-head,
.product-check-expected-purchase-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.product-check-expected-purchases-head {
  padding: 6px 8px;
  color: #075985;
}

.product-check-expected-purchases-head strong,
.product-check-expected-purchase-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-check-expected-purchases-head span,
.product-check-expected-purchase-row span {
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.product-check-expected-purchases-list {
  border-top: 1px solid #bfdbfe;
  background: rgba(255, 255, 255, 0.78);
}

.product-check-expected-purchase-row {
  padding: 6px 8px;
  font-size: 12px;
}

.product-check-expected-purchase-row + .product-check-expected-purchase-row {
  border-top: 1px solid #dbeafe;
}

.product-check-expected-purchase-row small {
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.product-check-event-counters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.product-check-event-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.product-check-event-counter:hover {
  border-color: rgba(8, 107, 216, 0.35);
  background: #eef6ff;
}

.product-check-event-counter strong,
.product-check-event-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e8eef4;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.product-check-event-panel {
  min-width: 0;
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.product-check-event-panel summary {
  display: grid;
  grid-template-columns: 20px auto auto auto minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  min-height: 34px;
  cursor: pointer;
  list-style: none;
}

.product-check-event-panel summary::-webkit-details-marker {
  display: none;
}

.product-check-event-panel summary::before {
  content: "+";
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: #e8eef4;
  color: var(--text);
  font-weight: 900;
}

.product-check-event-panel[open] summary::before {
  content: "-";
}

.product-check-event-title {
  color: var(--text);
  font-weight: 900;
  white-space: nowrap;
}

.product-check-event-badge {
  border-radius: 999px;
  padding: 2px 7px;
  background: #eef6ff;
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.product-check-event-summary {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-check-event-body {
  margin-top: 8px;
}

.product-check-address-editor {
  display: block;
}

.product-check-address-editor-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
  font-weight: 800;
}

.product-check-address-editor-heading small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.product-check-address-form {
  display: grid;
  grid-template-columns: minmax(120px, 170px) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.product-check-address-form input,
.product-check-address-form textarea {
  min-width: 0;
}

.product-check-address-form textarea {
  min-height: 42px;
  resize: vertical;
}

.product-check-address-history {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.product-check-address-change {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
  background: #f8fafc;
}

.product-check-address-change.synced {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.product-check-address-change.failed {
  border-color: #fecaca;
  background: #fff7f7;
}

.product-check-address-change div,
.product-check-address-change small {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.product-check-address-change strong {
  overflow-wrap: anywhere;
}

.product-check-address-change small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.product-check-address-change p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.product-check-facts {
  display: grid;
  gap: 8px;
  align-content: start;
}

.product-check-facts div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #f8fafc;
}

.product-check-facts span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.product-check-fact-label {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.product-check-stock-refresh {
  min-height: 26px;
  width: 26px;
  min-width: 26px;
  padding: 0;
  border-radius: 5px;
  background: #e8eef4;
  color: var(--text);
}

.product-check-stock-refresh:hover {
  background: #d8e3ee;
}

.product-check-stock-refresh svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.product-check-stock-summary {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.product-check-stock-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
}

.product-check-stock-top span,
.product-check-stock-source {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.product-check-stock-summary > strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 20px;
  line-height: 1.05;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.product-check-facts strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.product-check-stock-updated {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.product-check-stock-rests {
  display: grid;
  gap: 2px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.product-check-stock-summary .product-check-stock-rests {
  gap: 1px;
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.2;
}

.product-check-stock-rests span {
  display: block;
}

.product-check-stock-rests strong {
  display: inline;
  margin: 0;
  color: var(--text);
}

.product-check-stock-arithmetic {
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  background: #eff6ff;
  overflow: hidden;
}

.product-check-stock-arithmetic summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px;
  cursor: pointer;
  color: #075985;
  font-size: 12px;
  font-weight: 900;
  list-style: none;
}

.product-check-stock-arithmetic summary::-webkit-details-marker {
  display: none;
}

.product-check-stock-arithmetic summary::before {
  content: "▶";
  font-size: 10px;
  color: #0f6fb7;
}

.product-check-stock-arithmetic[open] summary::before {
  content: "▼";
}

.product-check-stock-arithmetic summary span {
  flex: 1;
}

.product-check-stock-arithmetic summary strong {
  color: #0f172a;
  white-space: nowrap;
}

.product-check-stock-arithmetic-body {
  display: grid;
  gap: 5px;
  padding: 0 7px 7px;
}

.product-check-stock-arithmetic-body div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 8px;
  align-items: baseline;
  padding-top: 5px;
  border-top: 1px solid #dbeafe;
}

.product-check-stock-arithmetic-body span,
.product-check-stock-arithmetic-body small {
  color: #526173;
  font-size: 11px;
  font-weight: 800;
}

.product-check-stock-arithmetic-body strong {
  color: #0f172a;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.product-check-stock-arithmetic-body small {
  grid-column: 1 / -1;
}

.product-check-tasks {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.product-check-tasks-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 8px;
  color: var(--text);
  font-weight: 800;
}

.product-check-tasks-heading small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.product-check-task-form {
  display: grid;
  grid-template-columns: minmax(140px, 190px) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.product-check-task-form textarea {
  min-height: 54px;
  resize: vertical;
}

.product-check-task-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.product-check-task {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #f8fafc;
}

.product-check-task.in_progress {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.product-check-task.resolved {
  opacity: 0.74;
}

.product-check-task-top,
.product-check-task-actions,
.product-check-task-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.product-check-task-top {
  justify-content: space-between;
}

.product-check-task-status {
  border-radius: 999px;
  padding: 3px 8px;
  background: #e8eef4;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.product-check-task-status.in_progress {
  background: #dbeafe;
  color: #1d4ed8;
}

.product-check-task-status.resolved {
  background: #dcfce7;
  color: var(--green);
}

.product-check-task p {
  margin: 6px 0 4px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.product-check-task-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.product-check-task-actions {
  margin-top: 8px;
}

.product-check-task-actions button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.product-check-comments {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.product-check-comments-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 8px;
  color: var(--text);
  font-weight: 800;
}

.product-check-comments-heading small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.product-check-comment-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.product-check-comment-form textarea {
  min-height: 54px;
  resize: vertical;
}

.product-check-comment-save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  align-self: stretch;
}

.product-check-comment-save svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.product-check-comment-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.product-check-comment {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #f8fafc;
}

.product-check-comment div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.product-check-comment strong {
  font-size: 13px;
}

.product-check-comment small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.product-check-comment p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.product-check-order-problems {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.product-check-order-problem-list {
  display: grid;
  gap: 6px;
}

.product-check-order-problem {
  border: 1px solid #fed7aa;
  border-radius: 6px;
  background: #fff7ed;
}

.product-check-order-problem summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  cursor: pointer;
}

.product-check-order-problem summary span,
.product-check-order-problem summary small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-check-order-problem summary small {
  color: var(--muted);
  font-weight: 700;
}

.product-check-order-problem-body {
  display: grid;
  gap: 6px;
  padding: 0 8px 8px;
}

.product-check-order-problem-body p,
.product-check-order-problem-history-entry p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.product-check-order-problem-history {
  display: grid;
  gap: 5px;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid #fed7aa;
}

.product-check-order-problem-history-entry small {
  color: var(--muted);
  font-weight: 700;
}

.users-list {
  display: grid;
  gap: 10px;
}

.user-create-card {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.user-create-card h3 {
  margin: 0;
  font-size: 16px;
}

.user-create-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
}

.user-create-grid label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.user-card {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.user-card.inactive {
  background: #f1f3f5;
  color: #596675;
}

.user-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.user-card-title {
  min-width: 0;
}

.user-card-title strong,
.user-card-title span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-card-title span {
  color: var(--muted);
  font-size: 12px;
}

.user-card-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
}

.user-card-form label,
.user-active-toggle {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.user-active-toggle {
  align-content: end;
  grid-template-columns: auto auto;
  align-items: center;
  min-height: 42px;
}

.user-active-toggle input {
  width: auto;
  min-height: 0;
}

.user-card-actions {
  display: flex;
  justify-content: flex-end;
}

.user-card-actions button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
}

.trusted-devices-section {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.trusted-devices-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.trusted-devices-heading-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.trusted-devices-heading h3 {
  margin: 0;
  font-size: 16px;
}

.trusted-devices-heading span {
  padding: 4px 10px;
  border-radius: 999px;
  background: #e8eef6;
  color: var(--muted);
  font-weight: 800;
}

.trusted-devices-dedupe {
  min-height: 32px;
  padding: 6px 10px;
  background: #edf2f7;
  color: var(--ink);
  font-size: 12px;
}

.trusted-devices-list {
  display: grid;
  gap: 8px;
}

.trusted-device-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.trusted-device-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.trusted-device-main strong,
.trusted-device-main span,
.trusted-device-main small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trusted-device-main span,
.trusted-device-main small {
  color: var(--muted);
  font-size: 12px;
}

.trusted-device-revoke {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
}

.audit-list {
  display: grid;
  gap: 10px;
}

.audit-event-card {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.audit-event-card.failure {
  border-color: #efb4ae;
  background: #fff7f6;
}

.audit-event-card.success {
  border-color: #bfe8cc;
}

.audit-event-top,
.audit-event-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.audit-event-top {
  justify-content: space-between;
}

.audit-event-main {
  min-width: 0;
}

.audit-event-main strong,
.audit-event-main span,
.audit-event-meta span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-event-main span,
.audit-event-meta {
  color: var(--muted);
  font-size: 12px;
}

.audit-event-meta {
  flex-wrap: wrap;
}

.audit-event-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e8eef4;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.audit-event-badge.success {
  background: #dff7e8;
  color: var(--green);
}

.audit-event-badge.failure {
  background: #ffe7e4;
  color: var(--red);
}

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

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

.analytics-stat,
.api-diagnostic-stat,
.analytics-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.analytics-stat,
.api-diagnostic-stat {
  display: grid;
  gap: 6px;
  padding: 10px;
}

.analytics-stat span,
.api-diagnostic-stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.analytics-stat strong,
.api-diagnostic-stat strong {
  color: var(--text);
  font-size: 20px;
  line-height: 1.1;
}

.api-diagnostic-stat small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.api-diagnostic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.analytics-card {
  min-width: 0;
  padding: 12px;
}

.api-diagnostic-card,
.api-diagnostic-recent,
.analytics-card {
  min-width: 0;
}

.api-diagnostic-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.api-diagnostic-recent {
  grid-column: 1 / -1;
}

.analytics-card h3,
.api-diagnostic-card h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.analytics-list,
.api-diagnostic-list {
  display: grid;
  gap: 8px;
}

.api-diagnostic-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  background: #f6f9fc;
}

.api-diagnostic-row strong,
.api-diagnostic-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-diagnostic-row span {
  color: var(--muted);
  font-size: 12px;
}

.api-diagnostic-table {
  display: grid;
  gap: 6px;
}

.api-diagnostic-table-head,
.api-diagnostic-table-row {
  display: grid;
  grid-template-columns: 92px minmax(120px, 1fr) 80px 72px 72px;
  gap: 8px;
  align-items: center;
}

.api-diagnostic-table-head {
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.api-diagnostic-table-row {
  padding: 8px;
  border-radius: 8px;
  background: #f6f9fc;
  font-size: 12px;
}

.api-diagnostic-table-row.error {
  background: #fff0ee;
  color: var(--red);
}

.api-diagnostic-table-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-diagnostic-table-row small {
  grid-column: 1 / -1;
  min-width: 0;
  overflow: hidden;
  color: var(--red);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 10px;
  padding: 8px;
  border-radius: 8px;
  background: #f6f9fc;
}

.analytics-row-button,
.analytics-detail-row {
  width: 100%;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.analytics-row-button:hover,
.analytics-detail-row:hover {
  outline: 2px solid rgba(25, 116, 186, 0.25);
}

.analytics-row strong,
.analytics-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-row span {
  color: var(--muted);
  font-size: 12px;
}

.analytics-row b {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  font-size: 14px;
}

.analytics-detail-card {
  margin-top: 14px;
}

.analytics-detail-list {
  display: grid;
  gap: 8px;
}

.analytics-detail-row {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 8px;
  background: #f6f9fc;
}

.analytics-detail-main,
.analytics-detail-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-detail-main {
  display: flex;
  gap: 8px;
}

.analytics-detail-meta {
  color: var(--muted);
  font-size: 12px;
}

.empty-state.compact {
  min-height: 72px;
}

.purchasing-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.purchasing-file {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 6px;
  background: #e8eef4;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  overflow: hidden;
}

.purchasing-file.secondary {
  background: #e8eef5;
  color: var(--text);
}

.purchasing-file input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.purchasing-generate-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(92px, 1fr));
  flex: 1 1 660px;
  min-width: min(100%, 660px);
  gap: 10px;
  align-items: end;
}

.purchasing-toolbar > button,
.purchasing-toolbar > .purchasing-file,
.purchasing-toolbar > .purchasing-export-menu {
  flex: 0 0 auto;
}

.purchasing-local-picture-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 12px;
  padding: 9px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #0f172a;
}

.purchasing-local-picture-strip.warning {
  border-color: #fde68a;
  background: #fffbeb;
}

.purchasing-local-picture-strip > div {
  display: grid;
  gap: 2px;
  min-width: min(100%, 360px);
}

.purchasing-local-picture-strip strong {
  font-size: 13px;
}

.purchasing-local-picture-strip span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.purchasing-local-picture-strip button {
  min-height: 34px;
}

.purchasing-auto-sync-note {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: baseline;
  margin: -2px 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.purchasing-auto-sync-note span {
  color: #0f6fb7;
  font-weight: 900;
}

.purchasing-auto-sync-note small {
  font-size: 12px;
  font-weight: 700;
}

.purchasing-export-menu {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
  z-index: 20;
}

.purchasing-export-menu > button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.purchasing-export-menu > button span {
  font-size: 17px;
  line-height: 1;
}

.purchasing-export-menu > button strong {
  font: inherit;
  font-weight: 800;
}

.purchasing-export-options {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 60;
  display: none;
  width: max-content;
  min-width: 260px;
  max-width: min(360px, 92vw);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.16);
}

.purchasing-export-options.open {
  display: grid;
  gap: 4px;
}

.purchasing-export-options button {
  width: 100%;
  justify-content: flex-start;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  text-align: left;
  white-space: nowrap;
}

.purchasing-export-options button:hover {
  background: #eef6ff;
  color: var(--blue-strong);
}

.purchasing-generate-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.purchasing-generate-form input,
.purchasing-generate-form select {
  min-height: 38px;
}

.purchasing-status {
  min-height: 22px;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 700;
}

.purchasing-status.ok {
  color: var(--green);
}

.purchasing-status.warning {
  color: var(--amber);
}

.purchasing-manual-mapping,
.purchasing-report,
.purchasing-history,
.purchasing-demand,
.purchasing-mappings,
.purchasing-local-stock,
.purchasing-advanced,
.purchasing-full-plan {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.purchasing-manual-mapping summary,
.purchasing-report summary,
.purchasing-history summary,
.purchasing-demand summary,
.purchasing-mappings summary,
.purchasing-local-stock summary,
.purchasing-advanced summary,
.purchasing-full-plan summary {
  padding: 10px 12px;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.purchasing-advanced {
  background: #f8fafc;
}

.purchasing-advanced > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.purchasing-advanced-body {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
}

.purchasing-advanced-body > * {
  margin-bottom: 0;
}

.purchasing-mapping-tools-body {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
}

.purchasing-mapping-tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.purchasing-mapping-tool-actions > button,
.purchasing-mapping-tool-actions > .purchasing-file {
  flex: 0 0 auto;
}

.purchasing-local-stock-body {
  display: grid;
  gap: 12px;
  padding: 0 12px 12px;
}

.purchasing-local-stock-actions,
.purchasing-local-stock-sync {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.purchasing-local-stock-actions > button,
.purchasing-local-stock-sync > button {
  min-height: 38px;
}

.purchasing-local-stock-actions > button:disabled,
.purchasing-local-stock-sync > button:disabled,
.purchasing-local-stock-sync input:disabled {
  cursor: wait;
  opacity: 0.62;
}

.purchasing-local-stock-busy {
  display: inline-flex;
  width: fit-content;
  gap: 8px;
  align-items: center;
  border: 1px solid #9cc5f2;
  border-radius: 999px;
  padding: 6px 10px;
  background: #eaf4ff;
  color: var(--blue-strong);
  font-size: 0.86rem;
  font-weight: 700;
}

.purchasing-local-stock-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #9cc5f2;
  border-top-color: var(--blue-strong);
  border-radius: 50%;
  animation: sync-spin 0.8s linear infinite;
}

.purchasing-local-stock-sync label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.82rem;
}

.purchasing-local-stock-sync input {
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.purchasing-local-stock-sync input[type="number"] {
  min-width: 100px;
}

.purchasing-local-stock-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.purchasing-local-stock-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}

.purchasing-local-stock-summary span,
.purchasing-local-stock-meta span,
.purchasing-local-stock-links span,
.purchasing-local-stock-result span,
.purchasing-local-stock-events span,
.purchasing-local-stock-empty {
  color: var(--muted);
  font-size: 0.82rem;
}

.purchasing-local-stock-summary strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 1.05rem;
}

.purchasing-local-stock-meta,
.purchasing-local-stock-links,
.purchasing-local-stock-result,
.purchasing-local-stock-sync-state,
.purchasing-local-stock-events {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.purchasing-local-stock-meta span,
.purchasing-local-stock-links span,
.purchasing-local-stock-result span,
.purchasing-local-stock-sync-state span,
.purchasing-local-stock-events div {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: #fff;
}

.purchasing-local-stock-sync-state span.warning {
  border-color: #f5c2c7;
  background: #fff5f5;
  color: #9f1239;
}

.purchasing-local-stock-events div {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.purchasing-local-stock-events strong {
  color: var(--text);
}

.purchasing-local-stock-products {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.purchasing-local-stock-products summary {
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 800;
}

.purchasing-local-stock-products-table {
  max-height: 420px;
  overflow: auto;
  border-top: 1px solid var(--line);
}

.purchasing-local-stock-products-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.purchasing-local-stock-products-table th,
.purchasing-local-stock-products-table td {
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.purchasing-local-stock-products-table th {
  position: sticky;
  top: 0;
  background: #eef3f8;
  z-index: 1;
}

.purchasing-local-stock-products-table tr.warning td {
  background: #fff8e1;
}

.purchasing-full-plan {
  margin-bottom: 0;
}

.purchasing-full-plan .purchasing-table-wrap {
  border-width: 1px 0 0;
  border-radius: 0 0 8px 8px;
}

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

.purchasing-form-note {
  grid-column: 1 / -1;
  padding: 9px 10px;
  border-radius: 6px;
  background: #eef6ff;
  color: var(--blue-strong);
  font-size: 13px;
  font-weight: 700;
}

.purchasing-manual-form label {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.purchasing-manual-form input,
.purchasing-manual-form select {
  min-width: 0;
  min-height: 38px;
}

.purchasing-checkbox {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  align-self: end;
  min-height: 38px;
  color: var(--text);
  font-size: 13px;
}

.purchasing-checkbox input {
  width: 18px;
  height: 18px;
  min-height: 0;
}

.purchasing-manual-form button {
  align-self: end;
  min-height: 38px;
}

.purchasing-report-section {
  display: grid;
  gap: 6px;
  padding: 0 12px 12px;
}

.purchasing-report-section strong {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
}

.purchasing-history-body {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
}

.purchasing-history-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 8px;
}

.purchasing-history-grid div {
  display: grid;
  gap: 3px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.purchasing-history-grid span,
.purchasing-history-list strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.purchasing-history-grid strong {
  font-size: 20px;
}

.purchasing-history-list {
  display: grid;
  gap: 5px;
}

.purchasing-history-list span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 6px 8px;
  border-radius: 6px;
  background: #f8fafc;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.purchasing-demand-table {
  display: grid;
  gap: 1px;
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.purchasing-demand-row {
  display: grid;
  grid-template-columns: 120px minmax(220px, 1.4fr) 120px 64px 78px 70px 105px 92px 110px;
  gap: 8px;
  align-items: center;
  min-width: 980px;
  padding: 8px 10px;
  background: #fff;
  font-size: 12px;
}

.purchasing-demand-row.heading {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #e8eef4;
  color: #475569;
  font-weight: 900;
  text-transform: uppercase;
}

.purchasing-demand-row strong,
.purchasing-demand-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchasing-report-row,
.purchasing-mapping-row {
  display: grid;
  grid-template-columns: 160px 150px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: #f8fafc;
  font-size: 13px;
}

.purchasing-report-row span,
.purchasing-mapping-row span,
.purchasing-mapping-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchasing-report-row.ok {
  background: #f0fdf4;
}

.purchasing-report-row.error {
  background: #fef2f2;
  color: var(--red);
}

.purchasing-mapping-list {
  display: grid;
  gap: 6px;
  padding: 0 12px 12px;
}

.purchasing-mapping-row {
  grid-template-columns: 140px 130px 150px minmax(180px, 1fr) 100px;
}

.purchasing-mapping-row.heading {
  background: #eef3f8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.purchasing-catalog {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.purchasing-catalog-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
}

.purchasing-catalog-summary div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

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

.purchasing-catalog-summary strong {
  font-size: 22px;
}

.purchasing-catalog-groups,
.purchasing-category-tree {
  display: grid;
  gap: 8px;
}

.purchasing-category-filter {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.purchasing-category-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(15, 23, 42, 0.42);
}

.purchasing-category-drawer {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 71;
  display: grid;
  align-content: start;
  gap: 12px;
  width: min(340px, 88vw);
  padding: 16px;
  background: #fff;
  box-shadow: 12px 0 28px rgba(15, 23, 42, 0.18);
  overflow: auto;
}

.purchasing-category-filter-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.purchasing-category-filter-head strong {
  font-size: 16px;
}

.purchasing-category-filter-head button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #fee2e2;
  color: var(--red);
}

.purchasing-category-filter-head button:disabled {
  opacity: 0.45;
  cursor: default;
}

.purchasing-category-search {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
}

.purchasing-category-main-filter {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.purchasing-category-main-filter > button {
  min-height: 42px;
  padding: 0 16px;
}

.purchasing-category-current {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.purchasing-category-current span,
.purchasing-category-current small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.purchasing-category-current strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.purchasing-category-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.purchasing-catalog-group,
.purchasing-category-node {
  border: 0;
  border-radius: 0;
  background: #fff;
  overflow: visible;
}

.purchasing-catalog-group summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  cursor: pointer;
}

.purchasing-category-node summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
  cursor: default;
}

.purchasing-category-node summary::-webkit-details-marker {
  display: none;
}

.purchasing-category-node summary::marker {
  content: "";
}

.purchasing-category-choice {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  min-width: 0;
  width: 100%;
  min-height: 28px;
  align-items: center;
  gap: 4px;
  justify-content: flex-start;
  padding: 4px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.purchasing-category-toggle,
.purchasing-category-toggle-placeholder {
  display: grid;
  width: 28px;
  height: 28px;
  min-height: 28px;
  place-items: center;
  border: 0;
  border-radius: 7px;
  padding: 0;
  background: transparent;
}

.purchasing-category-toggle {
  cursor: pointer;
}

.purchasing-category-toggle::before {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid #0f172a;
  border-bottom: 2px solid #0f172a;
  transform: rotate(45deg);
}

.purchasing-category-node[open] > summary .purchasing-category-toggle::before {
  transform: rotate(-135deg);
  margin-top: 5px;
}

.purchasing-category-toggle:hover {
  background: rgba(8, 107, 216, 0.12);
}

.purchasing-category-toggle:hover::before {
  border-color: var(--blue-strong);
}

.purchasing-category-choice strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.purchasing-catalog-group summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.purchasing-category-choice > span:not(.purchasing-category-select) {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.purchasing-category-select {
  display: block;
  width: 20px;
  height: 20px;
  min-height: 20px;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  box-shadow: inset 0 0 0 4px #fff;
}

.purchasing-category-choice.active .purchasing-category-select {
  border-color: var(--blue-strong);
  background: var(--blue-strong);
}

.purchasing-category-node.selected {
  border-color: var(--blue-strong);
  box-shadow: 0 0 0 2px rgba(8, 107, 216, 0.1);
}

.purchasing-category-node.depth-1 {
  margin-left: 24px;
  padding-left: 12px;
  border-left: 1px solid #e2e8f0;
}

.purchasing-category-node.depth-2 {
  margin-left: 48px;
  padding-left: 12px;
  border-left: 1px solid #e2e8f0;
}

.purchasing-category-node.depth-3,
.purchasing-category-node.depth-4 {
  margin-left: 72px;
  padding-left: 12px;
  border-left: 1px solid #e2e8f0;
}

.purchasing-category-node-body {
  display: grid;
  gap: 2px;
  padding: 0;
}

.purchasing-category-children {
  display: grid;
  gap: 2px;
}

.purchasing-category-selected {
  grid-column: 1 / -1;
  display: grid;
  gap: 3px;
}

.purchasing-category-selected span,
.purchasing-category-selected small,
.purchasing-category-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.purchasing-category-selected strong {
  font-size: 15px;
}

.purchasing-category-empty {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.purchasing-selected-assign {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(180px, 260px) auto auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: #f8fafc;
}

.purchasing-selected-assign label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.purchasing-selected-assign select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.purchasing-selected-assign button {
  min-height: 38px;
  white-space: nowrap;
}

.purchasing-catalog-supplier-sku-input {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.purchasing-catalog-supplier-sku-input.dirty {
  border-color: #f59e0b;
  background: #fffbeb;
}

.purchasing-filtered-items {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.purchasing-filtered-items summary {
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 800;
}

.purchasing-catalog-more {
  padding: 8px 10px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.purchasing-catalog-table {
  display: grid;
  gap: 1px;
  max-height: 420px;
  overflow: auto;
  border-top: 1px solid var(--line);
  background: var(--line);
}

.purchasing-catalog-row {
  display: grid;
  grid-template-columns: 28px 44px minmax(76px, 96px) minmax(230px, 1fr) minmax(230px, 300px) 58px 78px 92px;
  gap: 8px;
  align-items: center;
  min-width: 860px;
  padding: 8px 10px;
  background: #fff;
  font-size: 13px;
}

.purchasing-catalog-check {
  display: grid;
  place-items: center;
  min-height: 24px;
}

.purchasing-catalog-check input {
  width: 18px;
  height: 18px;
}

.purchasing-catalog-row.heading {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef3f8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.purchasing-catalog-sort {
  justify-content: flex-start;
  min-height: 24px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
}

.purchasing-catalog-sort:hover {
  background: transparent;
  color: var(--blue-strong);
  text-decoration: underline;
}

.purchasing-catalog-row .catalog-suppliers-col {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchasing-catalog-row strong,
.purchasing-catalog-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchasing-catalog-row .catalog-name-col {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  line-height: 1.25;
}

.purchasing-catalog-row.heading .catalog-name-col {
  display: block;
  white-space: nowrap;
}

.purchasing-catalog-row .catalog-stock-col,
.purchasing-catalog-row .catalog-cost-col {
  text-align: right;
}

.purchasing-catalog-row .catalog-links-col,
.purchasing-catalog-row .purchasing-order-links {
  min-width: 0;
  overflow: hidden;
}

.purchasing-catalog-suppliers {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.purchasing-catalog-suppliers.empty {
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.purchasing-catalog-supplier-row {
  display: grid;
  grid-template-columns: minmax(52px, 74px) minmax(0, 1fr) 38px;
  gap: 5px;
  align-items: center;
  min-width: 0;
}

.purchasing-catalog-row .purchasing-catalog-supplier-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchasing-catalog-supplier-copy {
  min-height: 28px;
  padding: 0 6px;
  border: 0;
  border-radius: 6px;
  background: #dff0ff;
  color: var(--blue-strong);
  font-size: 11px;
  font-weight: 800;
}

.purchasing-catalog-supplier-copy:hover {
  background: #cce7ff;
}

.purchasing-catalog-supplier-add {
  justify-self: start;
  width: auto;
  max-width: 132px;
  min-height: 24px;
  border: 1px dashed #bfdbfe;
  border-radius: 6px;
  padding: 0 22px 0 7px;
  background: #f8fbff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.purchasing-catalog-supplier-add:hover,
.purchasing-catalog-supplier-add:focus {
  border-color: var(--blue);
  background: #eef7ff;
  color: var(--blue-strong);
}

.purchasing-catalog-row a {
  color: var(--blue-strong);
  font-weight: 700;
  text-decoration: none;
}

@media (max-width: 1100px) {
  .purchasing-catalog-row {
    grid-template-columns: 28px 42px minmax(72px, 90px) minmax(210px, 1fr) minmax(212px, 260px) 52px 72px 86px;
    min-width: 790px;
    gap: 7px;
  }

  .purchasing-catalog-row .catalog-name-col {
    -webkit-line-clamp: 3;
  }

  .purchasing-catalog-row.heading .catalog-name-col {
    -webkit-line-clamp: initial;
  }
}

.purchasing-plan-note {
  margin-bottom: 12px;
  padding: 9px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: var(--blue-strong);
  font-size: 13px;
  font-weight: 700;
}

.purchasing-plan-list {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.purchasing-plan-archive {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.purchasing-plan-archive > summary {
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 800;
}

.purchasing-plan-archive .purchasing-plan-list {
  margin: 0;
  padding: 0 12px 12px;
}

.purchasing-plan-result {
  display: grid;
  gap: 12px;
}

.purchasing-plan-header {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.purchasing-plan-header > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.purchasing-plan-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.purchasing-plan-header strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 16px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchasing-plan-list-card {
  flex: 0 0 auto;
  display: grid;
  gap: 6px;
  min-width: 190px;
  max-width: 280px;
  padding: 0;
}

.purchasing-plan-open-button {
  display: grid;
  gap: 2px;
  min-height: 48px;
  padding: 7px 10px;
  text-align: left;
}

.purchasing-plan-list-card.active .purchasing-plan-open-button {
  background: #d8eafb;
  color: var(--blue-strong);
}

.purchasing-plan-list-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.purchasing-plan-list-actions button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 11px;
}

.purchasing-plan-list span,
.purchasing-plan-list small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchasing-plan-list small {
  color: var(--muted);
  font-size: 11px;
}

.purchasing-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.purchasing-summary div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

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

.purchasing-summary strong {
  font-size: 22px;
}

.purchasing-supplier-preview {
  display: grid;
  gap: 10px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 12px;
  background: #f8fbff;
}

.purchasing-supplier-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.purchasing-supplier-preview-head > div:first-child {
  display: grid;
  gap: 2px;
}

.purchasing-supplier-preview-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.purchasing-supplier-preview-head strong {
  color: var(--text);
  font-size: 20px;
}

.purchasing-supplier-preview-totals {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.purchasing-supplier-preview-totals span {
  border: 1px solid #dbeafe;
  border-radius: 999px;
  padding: 5px 9px;
  background: #fff;
  color: var(--blue-strong);
}

.purchasing-supplier-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.purchasing-preview-flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 8px;
}

.purchasing-preview-flow div {
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.purchasing-preview-flow span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.purchasing-preview-flow strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 15px;
}

.purchasing-supplier-tabs button {
  flex: 0 0 auto;
  display: grid;
  gap: 2px;
  min-width: 150px;
  min-height: 48px;
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.purchasing-supplier-tabs button.active {
  border-color: var(--blue);
  background: #d8eafb;
  color: var(--blue-strong);
}

.purchasing-supplier-tabs strong,
.purchasing-supplier-tabs span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchasing-supplier-tabs span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.purchasing-table-wrap.supplier-preview {
  max-height: min(52vh, 560px);
}

.purchasing-table.purchasing-supplier-preview-table {
  min-width: 1180px;
  table-layout: fixed;
}

.purchasing-supplier-preview-table .preview-col-export {
  width: 32px;
}

.purchasing-supplier-preview-table .preview-col-cost {
  width: 62px;
}

.purchasing-supplier-preview-table .preview-col-photo {
  width: 54px;
}

.purchasing-supplier-preview-table .preview-col-links {
  width: 54px;
}

.purchasing-supplier-preview-table .preview-col-qty {
  width: 104px;
}

.purchasing-supplier-preview-table .preview-col-our-sku {
  width: clamp(104px, 9vw, 150px);
}

.purchasing-supplier-preview-table .preview-col-stock {
  width: 82px;
}

.purchasing-supplier-preview-table .preview-col-supplier-sku {
  width: 128px;
}

.purchasing-supplier-preview-table .preview-col-comment {
  width: 214px;
}

.purchasing-supplier-preview-table .preview-col-check {
  width: 160px;
}

.purchasing-supplier-preview-table th:nth-child(1),
.purchasing-supplier-preview-table td:nth-child(1),
.purchasing-supplier-preview-table th:nth-child(6),
.purchasing-supplier-preview-table td:nth-child(6),
.purchasing-supplier-preview-table th:nth-child(7),
.purchasing-supplier-preview-table td:nth-child(7) {
  padding-left: 5px;
  padding-right: 5px;
}

.purchasing-supplier-preview-table th {
  min-width: 0;
}

.purchasing-supplier-preview-table th span {
  display: block;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchasing-supplier-preview-table th.compact span {
  max-width: 54px;
}

.purchasing-supplier-preview-table th.sku span {
  max-width: 78px;
}

.purchasing-supplier-preview-table th.cost span,
.purchasing-supplier-preview-table th.stock span {
  max-width: 76px;
}

.purchasing-supplier-preview-table th.comment span {
  max-width: 88px;
}

.purchasing-supplier-preview-table th.check span {
  max-width: 92px;
}

.purchasing-supplier-preview-table tr.draft-excluded {
  opacity: 0.62;
}

.purchasing-supplier-preview-table tr.has-active-order {
  background: #fffbeb;
}

.purchasing-supplier-preview-table tr.covered-by-active-order {
  background: #f8fafc;
  color: #64748b;
}

.purchasing-supplier-preview-table .purchasing-sku-tools {
  display: block;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.purchasing-supplier-preview-table .sku-copy-button.our-sku-cell {
  display: block;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-align: left;
  text-overflow: clip;
}

.purchasing-supplier-preview-table tbody tr:not(.purchasing-preview-group-row) td {
  vertical-align: middle;
}

.purchasing-preview-group-row td {
  border-top: 1px solid #facc15;
  border-bottom: 1px solid #facc15;
  background: #fef3c7;
  color: #92400e;
  font-size: 12px;
  font-weight: 900;
}

.purchasing-preview-group-row td > span {
  margin-right: 10px;
}

.purchasing-preview-group-row button {
  min-height: 26px;
  padding: 0 8px;
  margin: 2px 4px 2px 0;
  font-size: 11px;
}

.purchasing-preview-group-row.covered td {
  border-color: #cbd5e1;
  background: #f1f5f9;
  color: #334155;
}

.purchasing-draft-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 0 2px;
}

.purchasing-draft-actions > div {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.purchasing-draft-actions span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.purchasing-draft-actions button {
  min-height: 34px;
  padding: 0 12px;
}

.purchasing-draft-export {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 24px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.purchasing-draft-export input {
  width: 16px;
  height: 16px;
}

.purchasing-supplier-preview-table input[data-purchasing-draft-name],
.purchasing-supplier-preview-table input[data-purchasing-draft-comment],
.purchasing-supplier-preview-table input[data-purchasing-draft-supplier-sku],
.purchasing-draft-qty {
  box-sizing: border-box;
  width: 100%;
  min-height: 34px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
  font: inherit;
}

.purchasing-supplier-preview-table input[data-purchasing-draft-name] {
  min-width: 0;
}

.purchasing-supplier-preview-table input[data-purchasing-draft-comment] {
  min-width: 0;
}

.purchasing-supplier-preview-table input[data-purchasing-draft-supplier-sku] {
  min-width: 0;
}

.purchasing-draft-qty {
  width: 54px;
  min-width: 54px;
}

.purchasing-preview-qty-cell {
  display: grid;
  gap: 4px;
  min-width: 84px;
  align-items: center;
}

.purchasing-preview-qty-row {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.purchasing-active-order-math {
  display: grid;
  gap: 2px;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
}

.purchasing-active-order-math span {
  white-space: nowrap;
}

.purchasing-preview-photo {
  display: block;
  width: 44px;
  height: 44px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  object-fit: contain;
  background: #fff;
}

.purchasing-preview-photo.empty {
  background: #f1f5f9;
}

.purchasing-preview-links .purchasing-order-link {
  min-width: 34px;
  min-height: 24px;
  padding: 0 6px;
  font-size: 10px;
}

.purchasing-save-permanent-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.purchasing-save-icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.purchasing-preview-name,
.purchasing-preview-checks {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex-wrap: wrap;
}

.purchasing-preview-name {
  display: grid;
  align-content: center;
  gap: 4px;
}

.purchasing-preview-name strong {
  font-size: 13px;
  line-height: 1.25;
}

.purchasing-preview-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 3px 7px;
  background: #e0f2fe;
  color: #075985;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.purchasing-preview-badge.ok {
  background: #dcfce7;
  color: #166534;
}

.purchasing-preview-badge.warn {
  background: #fef3c7;
  color: #92400e;
}

.purchasing-preview-badge.stock {
  background: #e0f2fe;
  color: #075985;
}

.purchasing-preview-badge.active-order {
  background: #fde68a;
  color: #78350f;
}

.purchasing-preview-badge.edit {
  background: #ede9fe;
  color: #5b21b6;
}

.purchasing-preview-badge.muted {
  background: #e2e8f0;
  color: #475569;
}

.purchasing-active-order-notice {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.purchasing-active-order-notice span {
  width: fit-content;
  border-radius: 999px;
  padding: 2px 7px;
  background: #fef3c7;
  color: #92400e;
  cursor: help;
  font-size: 11px;
  font-weight: 900;
}

.purchasing-active-order-notice.formula span {
  background: #dbeafe;
  color: #1d4ed8;
}

.purchasing-orders {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.purchasing-orders summary {
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
}

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

.purchasing-order-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto auto auto minmax(150px, auto) auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid #e2e8f0;
}

.purchasing-order-row:first-child {
  border-top: 0;
}

.purchasing-order-row div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.purchasing-order-row small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.purchasing-order-title-line {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.purchasing-order-title {
  justify-content: flex-start;
  min-height: auto;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--blue-strong);
  font-size: 15px;
  font-weight: 900;
  text-align: left;
  text-decoration: underline;
}

.purchasing-order-title:hover {
  color: var(--blue);
}

.purchasing-order-row-note {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchasing-order-row > span {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.purchasing-order-row select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  font-weight: 800;
}

.purchasing-order-delete-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
}

.purchasing-order-delete-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.purchasing-expected {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.purchasing-expected summary {
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
}

.purchasing-expected-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(150px, 220px) minmax(130px, 180px) auto auto;
  gap: 10px;
  align-items: end;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: #f8fafc;
}

.purchasing-expected-toolbar label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.purchasing-expected-toolbar input,
.purchasing-expected-toolbar select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

.purchasing-expected-toolbar > span {
  color: var(--blue-strong);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.purchasing-expected-table-wrap {
  border-top: 1px solid var(--line);
  border-radius: 0;
  max-height: 360px;
}

.purchasing-expected-table th,
.purchasing-expected-table td {
  font-size: 12px;
  vertical-align: top;
}

.purchasing-expected-table td:first-child {
  display: grid;
  gap: 3px;
  min-width: 150px;
}

.purchasing-order-title.compact {
  font-size: 13px;
}

.purchasing-expected-table td:first-child small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.purchasing-expected-name {
  min-width: 180px;
  max-width: 420px;
  line-height: 1.25;
  white-space: normal;
}

.purchasing-product-name-button {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--blue-strong);
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.purchasing-product-name-button:hover {
  background: transparent;
  color: var(--blue-strong);
  text-decoration: underline;
}

.purchasing-product-name-button:focus-visible {
  outline: 2px solid #bfdbfe;
  outline-offset: 2px;
}

.purchasing-expected-arrival {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  background: #eef6ff;
  color: var(--blue-strong);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.purchasing-expected-arrival.soon {
  background: #fef3c7;
  color: #92400e;
}

.purchasing-expected-arrival.today {
  background: #dcfce7;
  color: #166534;
}

.purchasing-expected-arrival.overdue {
  background: #fee2e2;
  color: #b91c1c;
}

.purchasing-expected-arrival.missing {
  background: #e2e8f0;
  color: #475569;
}

.purchasing-expected-review-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}

.purchasing-empty-row {
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.purchasing-order-review {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 12px;
  background: #f8fbff;
}

.purchasing-order-review-head,
.purchasing-order-review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.purchasing-order-review-head > div:first-child {
  display: grid;
  gap: 2px;
}

.purchasing-order-review-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.purchasing-order-review-head strong {
  font-size: 18px;
}

.purchasing-order-head-note {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.purchasing-order-review-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.purchasing-order-review-stats span {
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 5px 10px;
  background: #fff;
  color: var(--blue-strong);
  white-space: nowrap;
}

.purchasing-order-details-form {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.purchasing-order-details-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.purchasing-order-details-form input {
  min-height: 36px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.purchasing-delivery-estimate {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.purchasing-receiving-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.purchasing-receiving-summary span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.purchasing-receiving-summary span.ok {
  background: #dcfce7;
  color: #166534;
}

.purchasing-receiving-summary span.warning {
  background: #fef3c7;
  color: #92400e;
}

.purchasing-order-review-table {
  max-height: 420px;
}

.purchasing-table.purchasing-order-items-table {
  min-width: 0;
  table-layout: fixed;
}

.purchasing-order-items-table .order-col-photo {
  width: 58px;
}

.purchasing-order-items-table .order-col-our-sku {
  width: 118px;
}

.purchasing-order-items-table .order-col-supplier-sku {
  width: 78px;
}

.purchasing-order-items-table .order-col-name {
  width: auto;
}

.purchasing-order-items-table .order-col-qty,
.purchasing-order-items-table .order-col-diff {
  width: 66px;
}

.purchasing-order-items-table .order-col-cost {
  width: 82px;
}

.purchasing-order-items-table .order-col-links {
  width: 86px;
}

.purchasing-order-items-table .order-col-comment,
.purchasing-order-items-table .order-col-fact {
  width: 112px;
}

.purchasing-order-items-table .order-col-comment-wide {
  width: 190px;
}

.purchasing-order-items-table th,
.purchasing-order-items-table td {
  padding: 7px 8px;
}

.purchasing-order-items-table .sku-cell {
  white-space: nowrap;
  overflow: visible;
  font-weight: 800;
}

.purchasing-order-items-table .our-sku-cell {
  overflow: visible;
}

.purchasing-order-items-table .supplier-sku-cell {
  color: #475569;
  overflow: hidden;
}

.sku-copy-button {
  display: inline-flex;
  max-width: 100%;
  min-height: 24px;
  border: 0;
  border-radius: 5px;
  padding: 2px 4px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.15;
  white-space: nowrap;
  cursor: copy;
}

.sku-copy-button:hover {
  background: #e0f2fe;
  color: #075985;
}

.sku-copy-button.supplier {
  color: #475569;
}

.purchasing-sku-tools {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  white-space: nowrap;
}

.purchasing-sku-explain-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
  color: #075985;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.purchasing-sku-explain-button:hover {
  background: #dbeafe;
}

.purchasing-sku-explanation {
  margin: 10px 0 0;
  padding: 10px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  background: #f8fbff;
}

.purchasing-sku-explanation.warning {
  border-color: #facc15;
  background: #fefce8;
}

.purchasing-sku-explanation-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.purchasing-sku-explanation-head span,
.purchasing-sku-explanation-grid span {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
}

.purchasing-sku-explanation-head strong {
  display: block;
  color: var(--text);
  font-size: 14px;
}

.purchasing-sku-explanation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.purchasing-sku-explanation-grid div {
  padding: 8px;
  border: 1px solid #dbeafe;
  border-radius: 5px;
  background: #fff;
}

.purchasing-sku-explanation-grid strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
}

.purchasing-sku-simple-math {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.purchasing-sku-simple-math div {
  padding: 8px 10px;
  border-radius: 6px;
  background: #eef6ff;
  border: 1px solid #bfdbfe;
}

.purchasing-sku-simple-math span {
  display: block;
  color: #475569;
  font-size: 11px;
  font-weight: 800;
}

.purchasing-sku-simple-math strong {
  display: block;
  margin-top: 3px;
  color: #0f172a;
  font-size: 14px;
}

.purchasing-sku-formula {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding: 8px;
  border-radius: 5px;
  background: #e0f2fe;
  color: #0f172a;
  font-size: 12px;
  font-weight: 700;
}

.purchasing-sku-explanation-warnings {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.purchasing-sku-explanation-warnings span {
  border-radius: 999px;
  padding: 3px 7px;
  background: #fef3c7;
  color: #92400e;
  font-size: 11px;
  font-weight: 800;
}

.purchasing-order-items-table .cost-cell {
  white-space: nowrap;
}

.purchasing-order-name {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  line-height: 1.25;
}

.purchasing-order-photo {
  display: block;
  width: 38px;
  height: 38px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  object-fit: contain;
  background: #fff;
}

.purchasing-order-photo.empty {
  background: #f1f5f9;
}

.purchasing-image-hover-preview {
  position: fixed;
  z-index: 5000;
  display: none;
  width: 260px;
  height: 260px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.24);
  pointer-events: none;
}

.purchasing-image-hover-preview.visible {
  display: block;
}

.purchasing-image-hover-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.purchasing-order-links {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  flex-wrap: nowrap;
}

.purchasing-order-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  min-height: 28px;
  border-radius: 6px;
  background: #e0f2fe;
  color: #075985;
  font-size: 11px;
  font-weight: 900;
  text-decoration: none;
}

.purchasing-order-link:hover {
  background: #bae6fd;
}

.purchasing-order-links.purchasing-preview-links {
  display: grid;
  gap: 4px;
  align-items: start;
  justify-items: start;
}

.purchasing-order-review-table input {
  width: 100%;
  min-height: 34px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 0 8px;
}

.purchasing-order-review-table [data-purchasing-received-qty] {
  max-width: 92px;
}

.purchasing-receiving-diff {
  color: #b45309;
  font-weight: 900;
}

.purchasing-mode {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.purchasing-mode.optimistic {
  background: #dcfce7;
  color: #166534;
}

.purchasing-mode.conservative {
  background: #fef3c7;
  color: #92400e;
}

.purchasing-mode.balanced {
  background: #e0f2fe;
  color: #075985;
}

.purchasing-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.purchasing-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  font-size: 13px;
}

.purchasing-table th,
.purchasing-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.purchasing-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef3f8;
  color: var(--text);
  font-size: 12px;
}

.purchasing-warnings {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.purchasing-warnings span {
  padding: 2px 6px;
  border-radius: 999px;
  background: #fff4d8;
  color: #6b4a00;
  font-size: 11px;
  font-weight: 700;
}

.purchasing-stock-cell {
  display: inline-grid;
  grid-template-columns: auto auto;
  align-items: start;
  justify-content: start;
  column-gap: 7px;
  min-width: 78px;
}

.purchasing-stock-cell strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.1;
}

.purchasing-stock-cell span {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.purchasing-stock-sync {
  display: inline-grid;
  justify-items: center;
  gap: 1px;
  line-height: 1;
}

.purchasing-stock-sync svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.purchasing-stock-cell small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.15;
  white-space: nowrap;
}

.purchasing-stock-cell.warning span {
  color: #9f1239;
  font-weight: 700;
}

.purchasing-stock-cell.warning small {
  color: #9f1239;
}

.orders-filter-panel {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.orders-group-header {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 7px 2px 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.orders-group-header span:first-child {
  color: var(--muted);
}

.orders-group-separator {
  width: 1px;
  height: 11px;
  background: #cbd5e1;
}

.orders-date-group,
.orders-state-group {
  margin: 5px 2px 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.orders-period-control {
  flex-wrap: wrap;
  max-width: 390px;
}

.orders-period-control .mode-button {
  flex: 1 1 auto;
}

.orders-filter-panel .segmented-control .mode-button {
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
  line-height: 1;
}

.orders-date-jump {
  display: flex;
  gap: 6px;
}

.orders-date-jump input {
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

.orders-date-jump button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}

.problems-filter-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.tasks-status {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #b7dfc2;
  background: #e9f8ee;
  color: #176b31;
  font-weight: 800;
}

.tasks-status.error {
  border-color: #f1b5ae;
  background: #fff0ee;
  color: var(--red);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.problem-task-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: visible;
}

.problem-task-card.is-updating {
  opacity: 0.72;
  pointer-events: none;
}

.problem-task-card.new {
  border-color: #efb4ae;
}

.problem-task-card.in_progress {
  border-color: #e7c46a;
}

.problem-task-card.product {
  border-left: 4px solid var(--blue);
}

.problem-task-card.resolved {
  border-color: #cfd6de;
  background: #f1f3f5;
  color: #596675;
}

.problem-task-open {
  display: grid;
  gap: 5px;
  width: 100%;
  height: auto;
  min-height: 0;
  align-content: start;
  padding: 10px;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 400;
}

.problem-task-open:hover {
  background: #eef6ff;
  color: var(--text);
}

.problem-task-product-open {
  justify-content: flex-start;
  width: calc(100% - 20px);
  min-height: 30px;
  margin: 0 10px 8px;
  padding: 0 10px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
}

.problem-task-product-open:hover {
  background: #dbeafe;
  color: #0f3f9b;
}

.problem-task-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.problem-task-source {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e8eef4;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.problem-task-source.product {
  background: #dbeafe;
  color: #1d4ed8;
}

.problem-task-source.order_item {
  background: #f1f5f9;
  color: var(--muted);
}

.problem-task-line {
  display: block;
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.problem-task-line.muted {
  color: var(--muted);
}

.problem-task-history {
  margin: 0 10px 8px;
  border: 1px solid #dbe5ef;
  border-radius: 8px;
  background: #f8fafc;
  font-size: 12px;
}

.problem-task-history summary {
  min-height: 32px;
  padding: 7px 9px;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.problem-task-history-list {
  display: grid;
  gap: 6px;
  padding: 0 9px 9px;
}

.problem-task-history-entry {
  padding-top: 6px;
  border-top: 1px solid #e6edf5;
}

.problem-task-history-meta {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.problem-task-history-text {
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.problem-task-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.problem-task-status.new {
  background: var(--red);
}

.problem-task-status.in_progress {
  background: #ffbf00;
  color: var(--text);
}

.problem-task-status.resolved {
  background: var(--green);
}

.problem-task-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 0 0 8px 8px;
}

.problem-task-actions button {
  min-height: 32px;
  padding: 0 6px;
  font-size: 12px;
}

.progress-pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #e8eef4;
  color: var(--text);
  font-weight: 700;
  min-height: 30px;
  padding: 0 10px;
  white-space: nowrap;
}

.status-badge {
  border: 0;
  cursor: default;
}

.status-badge.is-action {
  cursor: pointer;
}

.status-badge:hover {
  background: #e8eef4;
  color: var(--text);
}

.status-badge.done:hover {
  background: #2d572c;
  color: #fff;
}

.status-badge.partial:hover {
  background: #fff4d6;
  color: var(--amber);
}

.status-badge.problem:hover,
.status-badge.overscan:hover {
  background: #ffe7e4;
  color: var(--red);
}

.progress-pill {
  display: grid;
  place-items: center;
  gap: 1px;
  position: relative;
  overflow: hidden;
  min-width: 84px;
  min-height: 38px;
  padding: 3px 10px;
  line-height: 1;
  text-align: center;
}

.progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: #9fe4b8;
  transition: width 160ms ease;
}

.progress-text {
  position: relative;
  z-index: 1;
}

.progress-sku-count {
  position: relative;
  z-index: 1;
  font-weight: 800;
  font-size: 12px;
  line-height: 1;
}

.status-badge.done {
  background: #2d572c;
  color: #fff;
}

.status-badge.partial {
  background: #fff4d6;
  color: var(--amber);
}

.status-badge.problem {
  background: #ffe7e4;
  color: var(--red);
}

.status-badge.overscan {
  background: #fff0ec;
  color: var(--red);
}

.scan-form {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin: 0 0 12px;
}

.scan-form input {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 20px;
  font-weight: 700;
}

.scan-submit-button {
  flex: 0 0 52px;
  width: 52px;
  min-width: 52px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.scan-submit-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.scan-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin: 0;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 700;
}

.segmented-control {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.segmented-control .mode-button {
  border-radius: 0;
  min-height: 38px;
  border-right: 1px solid var(--line);
}

.segmented-control .mode-button:last-child {
  border-right: 0;
}

.segmented-control .mode-button.active {
  background: var(--blue);
  color: #fff;
}

.ttn-role-permissions-group {
  align-items: flex-start;
}

.ttn-role-permissions {
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.ttn-role-permissions-row {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) repeat(4, 58px);
  align-items: center;
  gap: 4px;
  min-height: 30px;
}

.ttn-role-permissions-head {
  color: var(--muted);
  font-size: 12px;
}

.ttn-role-permissions-row label {
  display: flex;
  justify-content: center;
  margin: 0;
}

.ttn-role-permissions-row input {
  width: 18px;
  height: 18px;
}

.scan-message {
  min-height: 24px;
  color: var(--muted);
  font-weight: 700;
}

.scan-message.error {
  color: var(--red);
}

.scan-message.ok {
  color: var(--green);
}

.scan-message.warning {
  display: inline-block;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 6px;
  background: #fff4b8;
  color: #6f4e00;
  line-height: 1.2;
}

.scan-message.next-order {
  display: inline-block;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--red);
  color: #fff;
  line-height: 1.2;
}

.scan-diagnostics {
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

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

.packed-order-animation {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.72);
  animation: packed-fade 3000ms ease forwards;
}

.packed-order-box {
  width: 118px;
  height: 118px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: #f1f7f0;
  border: 2px solid #2d572c;
  color: #2d572c;
  animation: packed-pop 3000ms ease forwards;
}

.packed-order-box svg {
  width: 82px;
  height: 82px;
  fill: none;
  stroke: currentColor;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.packed-order-box .box-check {
  stroke-width: 5;
}

@keyframes packed-pop {
  0% {
    opacity: 0;
    transform: scale(0.78) translateY(12px);
  }
  35% {
    opacity: 1;
    transform: scale(1.05) translateY(0);
  }
  100% {
    opacity: 0;
    transform: scale(1) translateY(-8px);
  }
}

@keyframes packed-fade {
  0% {
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.manual-completion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 36px;
  margin: 4px 0 6px;
}

.manual-completion span {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.15;
}

.manual-completion button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 10px;
  white-space: nowrap;
}

.item-card {
  display: grid;
  grid-template-columns: 78px 88px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.item-card.partial {
  border-color: #e7c46a;
  background: #fffaf0;
}

.item-card.done {
  border-color: #2d572c;
  background: #f1f7f0;
  color: var(--text);
}

.item-card.overscan {
  border-color: #efb4ae;
  background: #fff5f4;
}

.item-card.crm-removed-item,
.item-card.removed_from_crm_order,
.item-card.crm-change-removed {
  background: #fee2e2;
  border-color: #dc2626;
  border-width: 2px;
}

.item-card.crm-removed-item .item-main strong,
.item-card.removed_from_crm_order .item-main strong,
.item-card.crm-change-removed .item-main strong {
  color: #991b1b;
}

.item-card.crm-change-quantity,
.item-card.crm-change-changed {
  background: #fef3c7;
  border-color: #f59e0b;
  border-width: 2px;
}

.item-card.crm-change-added {
  background: #e0f2fe;
  border-color: #0284c7;
  border-width: 2px;
}

.status-badge.removed_from_crm_order,
.progress-action.removed_from_crm_order {
  background: #dc2626;
  color: #fff;
}

.item-crm-change-note {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  border-radius: 6px;
  margin-top: 8px;
  padding: 6px 10px;
  font-weight: 800;
  line-height: 1.15;
}

.crm-change-removed .item-crm-change-note,
.crm-removed-item .item-crm-change-note,
.removed_from_crm_order .item-crm-change-note {
  background: #dc2626;
  color: #fff;
}

.crm-change-quantity .item-crm-change-note,
.crm-change-changed .item-crm-change-note {
  background: #f59e0b;
  color: #111827;
}

.crm-change-added .item-crm-change-note {
  background: #0284c7;
  color: #fff;
}

.item-card.next-item-highlight {
  animation: next-item-pulse 2400ms ease-out;
}

.item-card.issue-item-highlight {
  animation: issue-item-pulse 3000ms ease-out;
}

@keyframes next-item-pulse {
  0% {
    border-color: #1167b1;
    box-shadow: 0 0 0 0 rgba(17, 103, 177, 0.55);
  }
  18% {
    border-color: #1167b1;
    box-shadow: 0 0 0 5px rgba(17, 103, 177, 0.18);
  }
  100% {
    box-shadow: none;
  }
}

@keyframes issue-item-pulse {
  0% {
    border-color: var(--red);
    box-shadow: 0 0 0 0 rgba(191, 31, 25, 0.72);
  }
  18% {
    border-color: var(--red);
    box-shadow: 0 0 0 6px rgba(191, 31, 25, 0.24);
  }
  55% {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(191, 31, 25, 0.18);
  }
  100% {
    box-shadow: none;
  }
}

.item-photo-button {
  width: 88px;
  height: 88px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  display: block;
  cursor: pointer;
}

.item-photo-button:focus-visible {
  outline: 3px solid rgba(23, 111, 183, 0.38);
  outline-offset: 2px;
}

.item-photo {
  width: 88px;
  height: 88px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fafc;
  object-fit: cover;
}

.item-photo-placeholder {
  width: 88px;
  height: 88px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--muted);
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 12px;
  padding: 8px;
}

.item-pick-state {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.item-main {
  min-width: 0;
}

.item-meta {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}

.storage-address {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 8px;
  color: var(--text);
  font-weight: 800;
  line-height: 0.95;
}

.storage-address__rack,
.storage-address__tail,
.storage-address__prefix {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  min-width: 46px;
  gap: 2px;
}

.storage-address__rack,
.storage-address__tail {
  padding-left: 0;
}

.storage-address__column {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  background: #000;
  color: #fff;
  box-shadow: inset 0 0 0 999px #000;
}

.storage-address--mini {
  display: inline-grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto auto;
  column-gap: 2px;
  row-gap: 2px;
  align-items: center;
}

.storage-address--mini .storage-address__prefix {
  grid-column: 1 / span 2;
  grid-row: 1;
}

.storage-address--mini .storage-address__column {
  grid-column: 2;
  grid-row: 2;
  min-width: 30px;
}

.storage-address--mini .storage-address__tail {
  grid-column: 2;
  grid-row: 3;
  justify-self: center;
  padding-left: 0;
}

.item-actions {
  position: relative;
  display: grid;
  grid-template-columns: minmax(42px, auto);
  gap: 8px;
}

.problem-button {
  display: inline-grid;
  place-items: center;
  padding: 0;
  background: #eef4fb;
  color: var(--red);
}

.problem-button.has-note {
  background: #ffe7e4;
}

.problem-button .note-icon {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.complete-rest-button {
  background: var(--blue);
}

.problem-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 15;
  display: grid;
  gap: 8px;
  width: min(260px, calc(100vw - 48px));
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.problem-menu button {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  text-align: center;
}

.problem-menu button.active {
  background: var(--red);
  color: #fff;
}

.problem-custom {
  display: grid;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.item-problem-note {
  margin-top: 8px;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
}

.progress-action {
  min-width: 0;
  padding: 0 10px;
  background: #eef4fb;
  color: var(--text);
}

.progress-action.partial {
  background: #fff4d6;
  color: var(--amber);
}

.progress-action.done {
  background: #2d572c;
  color: #fff;
}

.progress-action.overscan {
  background: #ffe7e4;
  color: var(--red);
}

.progress-action.problem {
  background: #ffe7e4;
  color: var(--red);
}

.progress-action.idle {
  background: #eef4fb;
  color: var(--muted);
}

.empty-state {
  min-height: 160px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

body.webapp-standalone .app {
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}

body.webapp-standalone .topbar {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto;
  align-items: start;
  gap: 6px;
  margin-bottom: 8px;
}

body.webapp-standalone .topbar > div:first-child {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: start;
  column-gap: 5px;
}

body.webapp-standalone .topbar h1 {
  grid-column: 1;
  grid-row: 1 / 3;
  max-width: 84px;
  font-size: 12px;
  line-height: 1.05;
}

body.webapp-standalone .topbar p {
  grid-column: 2;
  grid-row: 1 / 3;
  display: grid;
  gap: 1px;
  align-content: start;
  min-width: 0;
  margin: 0;
  font-size: 10.5px;
  line-height: 1.05;
}

body.webapp-standalone .topbar-status-item {
  gap: 3px;
  max-width: 100%;
}

body.webapp-standalone .topbar-status-icon {
  width: 11px;
  height: 11px;
  flex-basis: 11px;
}

body.webapp-standalone .topbar-status-label {
  display: none;
}

body.webapp-standalone .topbar-status-value {
  white-space: nowrap;
}

body.webapp-standalone .topbar-actions {
  width: auto;
  justify-content: flex-end;
  gap: 2px;
  margin-left: 0;
}

body.webapp-standalone .topbar-action-group {
  gap: 2px;
  flex-wrap: nowrap;
}

body.webapp-standalone .topbar .icon-button {
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  flex-basis: 30px;
}

body.webapp-standalone .topbar .icon-button svg,
body.webapp-standalone .sync-icon {
  width: 16px;
  height: 16px;
}

body.webapp-standalone .topbar-work-actions > .icon-button,
body.webapp-standalone .topbar-admin-actions > .icon-button {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  flex-basis: 38px;
}

body.webapp-standalone .topbar-work-actions > .icon-button svg,
body.webapp-standalone .topbar-admin-actions > .icon-button svg {
  width: 21px;
  height: 21px;
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  body.purchasing-page-open {
    overflow: auto;
  }

  .app {
    padding: 12px;
    height: auto;
    min-height: 100vh;
  }

  body.purchasing-page-open .app {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
  }

  body.purchasing-page-open .purchasing-window,
  body.purchasing-page-open .purchasing-panel,
  body.purchasing-page-open .purchasing-content {
    min-height: auto;
    overflow: visible;
  }

  body.purchasing-page-open .purchasing-content {
    flex: 0 0 auto;
  }

  body.purchasing-page-open .purchasing-panel {
    display: block;
  }

  body.purchasing-page-open .purchasing-heading {
    position: sticky;
    top: 0;
    z-index: 5;
    padding-bottom: 8px;
    background: var(--panel);
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
    margin-left: 0;
  }

  .topbar-action-group {
    gap: 8px;
  }

  .topbar-admin-actions {
    padding-left: 0;
    border-left: 0;
  }

  .import-panel,
  .login-form,
  .login-grid,
  .scan-form,
  .scan-toolbar,
  .toolbar-group,
  .order-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .orders-heading,
  .tasks-heading {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .order-heading {
    flex-direction: row;
    align-items: flex-start;
  }

  body.webapp-standalone .order-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 4px 8px;
    margin-bottom: 6px;
  }

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

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

  body.webapp-standalone #order-title {
    grid-template-columns: auto minmax(0, max-content);
    column-gap: 5px;
    row-gap: 2px;
    justify-content: start;
    font-size: 22px;
    line-height: 1.05;
  }

  body.webapp-standalone #order-title .crm-stage-badge {
    align-self: start;
    max-width: min(180px, 50vw);
    min-height: 18px;
    padding: 1px 6px;
    font-size: 10px;
    line-height: 1.05;
    white-space: normal;
    text-align: center;
  }

  body.webapp-standalone .order-title-customer {
    justify-self: start;
    max-width: 100%;
    font-size: 12px;
    line-height: 1.1;
  }

  .order-heading-actions {
    flex: 0 0 auto;
  }

  body.webapp-standalone .order-heading-actions {
    align-items: flex-start;
    gap: 4px;
    margin-left: 0;
  }

  body.webapp-standalone #order-meta {
    align-items: flex-start;
    gap: 4px 6px;
    margin-top: 5px;
    font-size: 12px;
    line-height: 1.12;
  }

  body.webapp-standalone #order-meta .ttn-prefix,
  body.webapp-standalone #order-meta .ttn-tail {
    font-size: 18px;
    line-height: 1;
  }

  body.webapp-standalone .progress-pill {
    min-width: 58px;
    min-height: 34px;
    padding: 3px 7px;
    font-size: 11px;
  }

  body.webapp-standalone .progress-sku-count {
    font-size: 10px;
  }

  body.webapp-standalone .order-actions-menu .icon-button {
    width: 30px;
    min-width: 30px;
    height: 30px;
    min-height: 30px;
    flex-basis: 30px;
  }

  .sync-actions,
  .import-form {
    flex-direction: row;
    align-items: center;
  }

  .scan-form {
    flex-direction: row;
    align-items: stretch;
  }

  body.webapp-standalone .scan-form {
    gap: 5px;
    margin-bottom: 2px;
  }

  body.webapp-standalone .scan-form input {
    min-height: 34px;
    padding: 0 9px;
    font-size: 20px;
  }

  body.webapp-standalone .scan-submit-button {
    flex-basis: 38px;
    width: 38px;
    min-width: 38px;
  }

  body.webapp-standalone .items-list {
    gap: 7px;
    margin-top: 4px;
  }

  .import-form {
    flex: 0 0 42px;
  }

  .app-settings,
  .import-search {
    position: relative;
  }

  .import-search-popover {
    left: 0;
    right: 0;
    width: auto;
    max-width: none;
  }

  .orders-heading-actions .import-search-popover {
    left: auto;
    right: 0;
    width: min(260px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
  }

  .orders-heading-actions {
    gap: 4px;
  }

  .orders-panel {
    padding: 10px;
  }

  .orders-heading {
    min-height: 32px;
    gap: 6px;
  }

  .orders-heading h2 {
    font-size: 18px;
  }

  .orders-heading-actions .icon-button {
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
    flex-basis: 32px;
    font-size: 17px;
    border-radius: 5px;
  }

  .orders-heading-actions .import-form {
    min-width: 32px;
    flex-basis: auto;
  }

  .orders-heading-actions .search-icon {
    width: 17px;
    height: 17px;
  }

  .orders-filter-panel {
    gap: 6px;
    margin-top: 6px;
  }

  .orders-panel .orders-list {
    gap: 6px;
    margin-top: 6px;
  }

  .app-settings-panel {
    position: fixed;
    top: max(44px, calc(env(safe-area-inset-top) + 36px));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    width: auto;
    max-width: none;
    max-height: calc(100vh - 58px);
    max-height: calc(100dvh - 58px - env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px;
    z-index: 60;
  }

  .app-settings-panel .scan-toolbar {
    gap: 9px;
  }

  .app-settings-panel .toolbar-group {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    align-items: center;
    gap: 6px;
  }

  .app-settings-panel .segmented-control {
    width: 100%;
  }

  .app-settings-panel .segmented-control .mode-button {
    flex: 1 1 0;
    min-width: 0;
    min-height: 30px;
    padding: 0 5px;
    font-size: 12px;
    line-height: 1;
  }

  .orders-filter-panel {
    justify-content: stretch;
  }

  .filter-group,
  .orders-filter-panel .segmented-control,
  .problems-filter-panel .segmented-control {
    width: 100%;
  }

  .orders-date-jump {
    width: 100%;
  }

  .orders-date-jump input {
    flex: 1 1 auto;
    min-width: 0;
  }

  .orders-filter-panel .mode-button,
  .problems-filter-panel .mode-button {
    flex: 1 1 0;
    padding: 0 5px;
  }

  .layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .orders-panel {
    max-height: 42vh;
  }

  body.webapp-standalone .orders-panel {
    padding: 6px;
  }

  .product-check-window,
  .tasks-window,
  .analytics-window,
  .purchasing-window,
  .api-diagnostics-window,
  .audit-window,
  .users-window {
    padding: 10px;
  }

  .product-check-panel,
  .tasks-panel,
  .analytics-panel,
  .purchasing-panel,
  .api-diagnostics-panel,
  .audit-panel,
  .users-panel {
    width: 100%;
  }

  .product-check-form {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 6px;
  }

  .product-check-card {
    grid-template-columns: minmax(250px, 292px) minmax(0, 1fr);
  }

  .product-check-media {
    grid-template-columns: clamp(116px, 21vw, 136px) minmax(108px, 1fr);
  }

  .product-check-mode-control .mode-button {
    padding: 0 10px;
    font-size: 14px;
  }

  .product-check-input-row {
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 6px;
  }

  .product-check-input-row .scan-submit-button {
    width: 44px;
    min-width: 44px;
    flex-basis: 44px;
  }

  .product-check-facts {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .product-check-comment-form {
    grid-template-columns: 1fr;
  }

  .product-check-address-form {
    grid-template-columns: 1fr;
  }

  .product-check-task-form {
    grid-template-columns: 1fr;
  }

  .user-card-form {
    grid-template-columns: 1fr;
  }

  .user-create-grid {
    grid-template-columns: 1fr;
  }

  .trusted-device-card {
    grid-template-columns: 1fr;
  }

  .trusted-device-revoke {
    width: 100%;
  }

  .analytics-summary,
  .purchasing-summary,
  .purchasing-catalog-summary,
  .purchasing-history-grid,
  .api-diagnostic-summary,
  .analytics-grid,
  .api-diagnostic-grid {
    grid-template-columns: 1fr;
  }

  .purchasing-generate-form,
  .purchasing-expected-toolbar,
  .purchasing-preview-flow,
  .purchasing-selected-assign,
  .purchasing-manual-form,
  .purchasing-report-row,
  .purchasing-mapping-row,
  .purchasing-demand-row {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .purchasing-catalog-table {
    max-height: none;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
  }

  .purchasing-catalog-row {
    grid-template-columns: 28px 42px minmax(72px, 90px) minmax(210px, 1fr) minmax(212px, 260px) 52px 72px 86px;
    min-width: 790px;
  }

  .purchasing-category-layout {
    grid-template-columns: 1fr;
  }

  .api-diagnostic-table-head {
    display: none;
  }

  .api-diagnostic-table-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .api-diagnostic-table-row span:nth-child(2) {
    grid-column: 1 / -1;
  }

  .order-panel {
    height: calc(100vh - 24px);
    max-height: calc(100vh - 24px);
  }

  .item-card {
    grid-template-columns: 78px 88px minmax(0, 1fr) auto;
  }

  .item-pick-state {
    max-width: none;
  }

  .item-photo-button,
  .item-photo,
  .item-photo-placeholder {
    width: 88px;
    max-width: none;
    height: 88px;
  }

  .manual-completion {
    align-items: center;
    flex-wrap: nowrap;
  }

  .manual-completion span {
    flex: 1 1 auto;
  }

  .manual-completion button {
    flex: 0 0 auto;
    width: auto;
  }
}

@media (max-width: 640px) {
  body.webapp-standalone .orders-panel {
    padding: 6px;
  }

  .orders-heading {
    min-height: 25px;
    gap: 4px;
  }

  .orders-heading h2 {
    font-size: 15px;
  }

  .orders-heading-actions .icon-button {
    width: 25px;
    min-width: 25px;
    height: 25px;
    min-height: 25px;
    flex-basis: 25px;
    font-size: 13px;
  }

  .orders-heading-actions .import-form {
    min-width: 25px;
  }

  .orders-heading-actions .search-icon {
    width: 14px;
    height: 14px;
  }

  .orders-filter-panel {
    margin-top: 5px;
  }

  .orders-panel .orders-list {
    margin-top: 4px;
  }

  .product-check-card {
    grid-template-columns: 1fr;
  }

  .product-check-media {
    grid-template-columns: minmax(112px, 36vw) minmax(108px, 1fr);
    gap: 8px;
    max-width: 100%;
  }

  .product-check-form {
    margin-top: 10px;
    margin-bottom: 10px;
  }

  .product-check-mode-control .mode-button {
    min-height: 38px;
    padding: 0 9px;
    font-size: 13px;
  }

  .product-check-input-row {
    grid-template-columns: minmax(0, 1fr) 42px;
  }

  .product-check-input-row input {
    min-height: 38px;
    padding: 0 10px;
  }

  .product-check-input-row .scan-submit-button {
    width: 42px;
    min-width: 42px;
    min-height: 38px;
    flex-basis: 42px;
  }

  .product-check-stock-summary {
    padding: 6px;
  }

  .product-check-stock-summary > strong {
    font-size: 18px;
  }

  .item-card {
    grid-template-columns: 1fr;
  }

  .item-pick-state {
    max-width: 220px;
  }

  .item-photo-button,
  .item-photo,
  .item-photo-placeholder {
    width: 100%;
    max-width: 220px;
    height: 180px;
  }

  body.webapp-standalone .item-card {
    grid-template-columns: 180px minmax(0, 1fr) 42px;
    align-items: start;
    gap: 7px;
  }

  body.webapp-standalone .item-pick-state {
    grid-column: 1 / 3;
    grid-row: 1;
    max-width: 180px;
    gap: 4px;
  }

  body.webapp-standalone .item-pick-state .status-badge,
  body.webapp-standalone .item-pick-state .progress-action {
    min-height: 30px;
    height: 30px;
    padding: 0 8px;
    font-size: 13px;
    line-height: 1;
  }

  body.webapp-standalone .item-photo-button,
  body.webapp-standalone .item-photo,
  body.webapp-standalone .item-photo-placeholder {
    grid-column: 1;
    grid-row: 2;
    width: 180px;
    max-width: 180px;
    height: 180px;
  }

  body.webapp-standalone .item-main {
    grid-column: 2 / 4;
    grid-row: 2;
    align-self: start;
    padding-top: 0;
  }

  body.webapp-standalone .storage-address {
    margin-top: 6px;
  }

  body.webapp-standalone .item-actions {
    grid-column: 3;
    grid-row: 1;
    grid-template-columns: 42px;
    gap: 4px;
  }

  body.webapp-standalone .problem-button,
  body.webapp-standalone .complete-rest-button {
    width: 42px;
    min-width: 42px;
    min-height: 30px;
    height: 30px;
    padding: 0;
  }

  body.webapp-standalone .problem-button .note-icon {
    width: 18px;
    height: 18px;
  }
}
