:root {
  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-muted: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-ring: rgba(37, 99, 235, 0.35);
  --border: #94a3b8;
  --border-strong: #64748b;
  --success: #059669;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-nav: 0 1px 0 rgba(15, 23, 42, 0.05);
  --focus-ring: 0 0 0 3px var(--accent-ring);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 0.9375rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container { max-width: 960px; margin: 0 auto; padding: 32px 20px; }

.container--wide {
  max-width: 1200px;
}

.header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-nav);
}

.header::before {
  content: "";
  display: block;
  height: 3px;
  background: linear-gradient(90deg, #1d4ed8 0%, #2563eb 50%, #3b82f6 100%);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding-top: 4px;
  padding-bottom: 4px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.logo:hover {
  color: var(--accent);
}

.logo:hover .logo-wordmark-accent {
  color: var(--accent-hover);
}

.logo-wordmark-accent {
  color: var(--accent);
  font-weight: 800;
}

.logo-icon {
  display: block;
  flex-shrink: 0;
}

.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-link:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-link--active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.nav-logout {
  display: flex;
  margin: 0;
}

.nav-logout .nav-link {
  background: transparent;
  border: none;
  font-family: inherit;
  cursor: pointer;
}

.login-body {
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
}

.login-logo {
  margin-bottom: 18px;
}

.login-card h1 {
  margin: 0 0 8px;
}

.login-error {
  margin: 0 0 12px;
  color: var(--danger, #b91c1c);
  font-weight: 600;
}

.login-form {
  margin-top: 16px;
}

.nav-link--secondary { font-weight: 500; font-size: 0.875rem; }
.nav-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.nav-toggle-bar {
  display: block;
  width: 18px;
  height: 2px;
  margin: 0 auto;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 720px) {
  .nav-toggle {
    display: flex;
  }

  .nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 4px;
    padding-top: 8px;
  }

  .nav.is-open {
    display: flex;
  }

  .nav-link {
    padding: 10px 12px;
    border-radius: 8px;
  }

  .nav-link--active {
    background: var(--accent-soft);
  }

  .nav-divider {
    display: none;
  }

  .header-inner {
    flex-wrap: wrap;
  }
}

.hero {
  margin-bottom: 8px;
}

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

.hero-copy {
  min-width: 0;
}

.btn.fbs-duplicates-btn {
  background: #e5e7eb;
  color: #374151;
  border: 1px solid #d1d5db;
  box-shadow: none;
}

.btn.fbs-duplicates-btn:hover {
  background: #d1d5db;
  color: #111827;
  border-color: #9ca3af;
  box-shadow: none;
  transform: none;
}

.btn.fbs-duplicates-btn:active {
  background: #cbd5e1;
  transform: translateY(1px);
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.625rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--text);
}

.hero p {
  margin: 0;
  max-width: 42rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.grid.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.grid.stats--compact {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-xs);
}

.card h2 {
  margin: 0 0 16px;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.grid.stats .card {
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.grid.stats .card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.card-label {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-value {
  font-size: 1.875rem;
  font-weight: 700;
  margin-top: 6px;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.section { margin-top: 20px; }
.muted { color: var(--muted); }

.container a:not([class]) {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
}

.container a:not([class]):hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.form { display: grid; gap: 16px; max-width: 480px; }
.form label,
.modal-form label:not(.checkbox-label) {
  display: grid;
  gap: 6px;
  font-weight: 500;
}
.form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.form select,
.modal-form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.modal-form select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
.form select:focus,
.modal-form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
.modal-form select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.form input[type="file"],
.modal-form input[type="file"] {
  padding: 8px;
  background: var(--bg-subtle);
  cursor: pointer;
}

.form input[type="file"]::file-selector-button,
.modal-form input[type="file"]::file-selector-button {
  padding: 8px 12px;
  margin-right: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font: inherit;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.form input[type="file"]::file-selector-button:hover,
.modal-form input[type="file"]::file-selector-button:hover {
  background: #f3f4f6;
}

.btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  width: fit-content;
  flex-shrink: 0;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.25;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

.btn-secondary:hover {
  background: var(--accent-soft);
  border-color: #93c5fd;
  color: var(--accent);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.2);
  transform: translateY(-1px);
}

.btn-secondary.is-active {
  background: #eff6ff;
  border-color: #93c5fd;
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.btn-secondary.is-active:hover {
  background: #dbeafe;
  border-color: #3b82f6;
  color: var(--accent-hover);
  box-shadow: 0 3px 12px rgba(37, 99, 235, 0.26);
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: translateY(0);
}

.btn-secondary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn-danger {
  background: #b91c1c;
}

.btn-danger:hover {
  background: #991b1b;
}

.btn-danger:focus-visible {
  outline-color: rgba(185, 28, 28, 0.45);
}

.btn-danger-ghost {
  background: transparent;
  color: #b91c1c;
  border: 1px solid #f87171;
}

.btn-danger-ghost:hover {
  background: #fef2f2;
  color: #991b1b;
}

.btn-danger-ghost:focus-visible {
  outline-color: rgba(185, 28, 28, 0.45);
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}

.btn:disabled:hover,
.btn.is-disabled:hover {
  background: inherit;
}

.btn-danger-ghost:disabled,
.btn-danger-ghost.is-disabled {
  color: var(--muted);
  border-color: var(--border);
  background: transparent;
}

.btn-danger-ghost:disabled:hover,
.btn-danger-ghost.is-disabled:hover {
  background: transparent;
  color: var(--muted);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.8125rem;
}

.inline-form {
  margin: 0;
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.alert.success {
  background: #ecfdf5;
  color: var(--success);
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}

.alert.error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}

.alert.warn {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}

.alert-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.alert-item {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9375rem;
}

.alert-item.error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.alert-item.warn {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.alert-item.info {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.alert-item a {
  color: inherit;
  text-decoration: underline;
}

.collapse > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.collapse > summary::-webkit-details-marker {
  display: none;
}

.collapse-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.collapse-icon {
  margin-left: auto;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.collapse[open] .collapse-icon {
  transform: rotate(90deg);
}

.collapse-body {
  margin-top: 12px;
}

.warn-value { color: #b45309; }
.error-value { color: #b91c1c; }

.action-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.action-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.action-links a:hover {
  text-decoration: underline;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 0.875rem;
  color: var(--muted);
}

.breadcrumbs a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

.breadcrumb-sep {
  color: #cbd5e1;
}

.stepper {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  display: flex;
  gap: 0;
  overflow-x: auto;
}

.stepper-item {
  flex: 1;
  min-width: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
  text-align: center;
  padding: 0 8px 8px;
}

.stepper-item:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 14px;
  left: calc(50% + 16px);
  width: calc(100% - 32px);
  height: 2px;
  background: var(--border);
  z-index: 0;
}

.stepper-item--done:not(:last-child)::after {
  background: var(--success);
}

.stepper-marker {
  position: relative;
  z-index: 1;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.8125rem;
  font-weight: 700;
  background: #fff;
  border: 2px solid var(--border);
  color: var(--muted);
}

.stepper-item--done .stepper-marker {
  background: #ecfdf5;
  border-color: var(--success);
  color: var(--success);
}

.stepper-item--current .stepper-marker {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.stepper-label {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.2;
}

.stepper-item--current .stepper-label {
  color: var(--text);
  font-weight: 600;
}

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

.workflow-step {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  background: #fff;
}

.workflow-step--pending {
  opacity: 0.75;
  background: #fafafa;
}

.workflow-step--done {
  background: #fafafa;
}

.workflow-step--current {
  border-color: #93c5fd;
  box-shadow: 0 0 0 1px #dbeafe;
}

.workflow-step > summary {
  cursor: pointer;
  list-style: none;
}

.workflow-step > summary::-webkit-details-marker {
  display: none;
}

.workflow-step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;
}

.workflow-step[open] .workflow-step-header {
  margin-bottom: 10px;
}

.workflow-step-chevron {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.75rem;
  transition: transform 0.15s ease;
}

.workflow-step[open] .workflow-step-chevron {
  transform: rotate(90deg);
}

.workflow-step-body {
  padding-top: 2px;
}

.workflow-step-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #eef2ff;
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.workflow-step-title {
  margin: 0;
  font-size: 1rem;
  flex: 1;
}

.workflow-danger {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.workflow-regenerate {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.workflow-regenerate summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 8px;
}

.workflow-danger summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.875rem;
}

.cta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.cta-card {
  display: grid;
  gap: 6px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  background: var(--bg);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.cta-card:hover {
  border-color: #93c5fd;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.cta-card--primary {
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
  border-color: #bfdbfe;
}

.cta-card--primary .cta-title {
  color: var(--accent-hover);
}

.cta-title {
  font-weight: 600;
  color: var(--text);
}

.cta-desc {
  font-size: 0.875rem;
  color: var(--muted);
}

.setup-note {
  margin: 16px 0 0;
}

.callout {
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.callout--info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
}

.callout a {
  color: #1d4ed8;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.callout a:hover {
  text-decoration: underline;
}

.adhoc-section > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.adhoc-section > summary::-webkit-details-marker {
  display: none;
}

.adhoc-summary-title {
  font-size: 1rem;
  font-weight: 600;
}

.adhoc-summary-note {
  font-size: 0.8125rem;
  color: var(--muted);
}

.adhoc-form {
  display: grid;
  gap: 12px;
  max-width: 480px;
}

.adhoc-warning {
  margin: 12px 0;
}

.danger-zone {
  margin-top: 16px;
}

.danger-zone > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.875rem;
}

.danger-zone-body {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.expired-check-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}

.expired-check-metrics {
  margin: 16px 0 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 800px) {
  .expired-check-metrics {
    grid-template-columns: 1fr 1fr;
  }
}

.adhoc-section[open] .adhoc-summary-title {
  color: #92400e;
}

.table--compact td,
.table--compact th {
  padding: 8px;
}

.modal-warning {
  margin: 0;
  font-size: 0.875rem;
}

.checkbox-label,
.form .checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
}

.checkbox-label input {
  margin: 0;
  flex-shrink: 0;
}

.split-mode-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 10px;
}

.split-mode-fieldset legend {
  font-weight: 500;
  margin-bottom: 4px;
  padding: 0;
}

.split-mode-fieldset .checkbox-label {
  font-size: 0.9375rem;
  font-weight: 400;
  gap: 10px;
}

.split-mode-fieldset input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  border: 2px solid var(--border-strong, #94a3b8);
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.split-mode-fieldset input[type="radio"]::before {
  content: "";
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: var(--accent);
  transform: scale(0);
  transition: transform 0.12s ease;
}

.split-mode-fieldset input[type="radio"]:checked {
  border-color: var(--accent);
}

.split-mode-fieldset input[type="radio"]:checked::before {
  transform: scale(1);
}

.split-mode-fieldset input[type="radio"]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.table-toolbar h2 {
  margin: 0;
}

.table-toolbar-sub {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--muted);
}

.table-sub {
  margin-top: 2px;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.3;
}

.table-primary-link {
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}

.table-primary-link:hover {
  color: var(--accent);
}

.shipment-line-codes-btn {
  appearance: none;
  border: 0;
  background: none;
  padding: 2px 6px;
  margin: -2px -6px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  border-radius: 8px;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.shipment-line-codes-btn:hover,
.shipment-line-codes-btn:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
  outline: none;
}

.shipment-line-status-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-sizing: border-box;
  min-height: 28px;
  margin: 0;
  padding: 4px 12px;
  border: 1px solid #dbe3ef;
  border-radius: 999px;
  background: #f8fafc;
  color: #334155;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}

.shipment-line-status-btn:hover,
.shipment-line-status-btn:focus-visible {
  background: #eff6ff;
  border-color: #93c5fd;
  color: var(--accent);
  box-shadow: 0 1px 8px rgba(37, 99, 235, 0.16);
  outline: none;
}

.shipment-line-status-btn:disabled {
  cursor: wait;
  opacity: 0.75;
  box-shadow: none;
}

.shipment-line-status-btn--group {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  min-height: 0;
}

.shipment-line-status-btn--group:hover,
.shipment-line-status-btn--group:focus-visible {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: inherit;
}

.shipment-line-status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 28px;
  padding: 4px 12px;
  border: 1px solid #dbe3ef;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
}

.shipment-line-status-btn--ok,
.shipment-line-status-chip.shipment-line-status-btn--ok {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}

.shipment-line-status-btn--accent,
.shipment-line-status-chip.shipment-line-status-btn--accent {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #4338ca;
}

.shipment-line-status-btn--info,
.shipment-line-status-chip.shipment-line-status-btn--info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.shipment-line-status-btn--warn,
.shipment-line-status-chip.shipment-line-status-btn--warn {
  background: #fffbeb;
  border-color: #fde68a;
  color: #b45309;
}

.shipment-line-status-btn--error,
.shipment-line-status-chip.shipment-line-status-btn--error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.shipment-line-status-btn--muted,
.shipment-line-status-chip.shipment-line-status-btn--muted {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #64748b;
}

.shipment-line-codes-dialog {
  max-height: min(86vh, 900px);
}

.table-wrap.table-wrap--sticky.table-wrap--shipment-lines {
  overflow-x: hidden;
  overflow-y: auto;
  max-width: 100%;
}

.table--shipment-lines {
  table-layout: auto;
  width: 100%;
  max-width: 100%;
}

.table.table--shipment-lines thead th {
  text-align: center;
}

.table.table--shipment-lines .shipment-line-article,
.table.table--shipment-lines .shipment-line-status,
.table.table--shipment-lines .shipment-line-gtin,
.table.table--shipment-lines .shipment-line-qty,
.table.table--shipment-lines .shipment-line-count {
  text-align: center;
}

.table.table--shipment-lines thead th.shipment-line-qty,
.table.table--shipment-lines thead th.shipment-line-count {
  font-size: 0.75rem;
  line-height: 1.2;
}

.table--shipment-lines td {
  vertical-align: middle;
}

.table--shipment-lines .shipment-line-article,
.table--shipment-lines .shipment-line-status,
.table--shipment-lines .shipment-line-gtin,
.table--shipment-lines .shipment-line-qty,
.table--shipment-lines .shipment-line-count,
.table--shipment-lines .codes-row-actions {
  width: 1%;
  white-space: nowrap;
  overflow-wrap: normal;
}

.table--shipment-lines .shipment-line-status,
.table--shipment-lines .shipment-line-qty,
.table--shipment-lines .shipment-line-count,
.table--shipment-lines .codes-row-actions {
  padding-left: 6px;
  padding-right: 6px;
}

.table--shipment-lines .shipment-line-article .shipment-line-codes-btn {
  text-align: center;
  white-space: nowrap;
}

.table--shipment-lines .shipment-line-name {
  width: 100%;
  min-width: 8rem;
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

.table--shipment-lines .shipment-line-name .shipment-line-codes-btn {
  max-width: 100%;
  font-size: inherit;
  font-weight: 600;
  white-space: normal;
  overflow-wrap: anywhere;
}

.table--shipment-lines .shipment-line-gtin {
  font-variant-numeric: tabular-nums;
}

.table--shipment-lines .shipment-line-status-btn--group {
  flex-wrap: nowrap;
}

.table--shipment-lines code {
  word-break: break-all;
}

.table--shipment-lines .shipment-line-gtin code {
  word-break: normal;
  white-space: nowrap;
}

.shipment-line-codes-dialog .table-search {
  width: 100%;
  min-width: 0;
}

#shipment-line-codes-counts,
.status-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.codes-table .codes-row-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
  padding-right: 8px;
}

.codes-table:not(.codes-table--with-actions) .codes-row-actions {
  display: none;
}

.table-row-link {
  cursor: pointer;
}

.table-row-link:hover {
  background: var(--accent-soft);
}

.table--shipments td {
  vertical-align: top;
}

.shipment-name-row {
  display: flex;
  gap: 6px;
  align-items: center;
  max-width: 320px;
}

.shipment-name-link {
  flex: 1;
  min-width: 0;
}

.shipment-name-form {
  display: none;
  flex: 1;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.shipment-name-row.is-editing .shipment-name-form {
  display: flex;
}

.shipment-name-row.is-editing .js-shipment-name-link,
.shipment-name-row.is-editing .js-shipment-name-edit-btn {
  display: none;
}

.shipment-name-input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 0.875rem;
}

.shipment-name-input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.25);
  border-color: var(--accent);
}

.shipment-actions-cell {
  white-space: nowrap;
  width: 1%;
}

.table-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.table-search {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: inherit;
  min-width: 220px;
  background: var(--bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.table-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.table-select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: inherit;
  background: var(--bg);
  color: inherit;
  min-width: 160px;
}

.table-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.codes-cis {
  display: inline-block;
  max-width: 22ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.codes-table .codes-status {
  white-space: nowrap;
  width: 1%;
}

.codes-table .codes-gis-refresh {
  appearance: none;
  border: 0;
  font-family: inherit;
  line-height: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.codes-table .codes-gis-refresh:hover {
  filter: brightness(0.96);
}

.codes-table .codes-gis-refresh:disabled {
  cursor: wait;
  opacity: 0.7;
}

.codes-cis-link {
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
  border-radius: 6px;
}

.codes-cis-link:hover .codes-cis,
.codes-cis-link:focus-visible .codes-cis {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.codes-cis-link:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.codes-card-dialog {
  max-height: min(92vh, 860px);
  overflow: auto;
}

.codes-card-cis {
  margin: 0;
}

.codes-card-cis code {
  word-break: break-all;
  white-space: normal;
}

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

.codes-card-facts dt {
  color: var(--muted);
  font-size: 0.8125rem;
}

.codes-card-facts dd {
  margin: 4px 0 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.codes-card-history-title {
  margin: 4px 0 0;
  font-size: 1rem;
}

.codes-card-orders {
  display: grid;
  gap: 10px;
}

.codes-card-orders .codes-history-event {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 2px 12px;
}

.codes-history {
  display: grid;
  gap: 10px;
}

.codes-history-event {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--bg-subtle);
  display: grid;
  gap: 2px;
}

.codes-history-label {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.codes-history-event .codes-history-label:first-child {
  margin-top: 0;
}

.codes-history-value {
  font-variant-numeric: tabular-nums;
}

.codes-history-doc {
  word-break: break-all;
  white-space: normal;
}

@media (max-width: 640px) {
  .codes-card-facts {
    grid-template-columns: 1fr;
  }
}

.order-positions-controls .codes-filters {
  flex: 1 1 100%;
  width: 100%;
}

.codes-filters .table-search {
  min-width: 180px;
}

.codes-filters .table-search,
.codes-filters .table-select,
.codes-filters > .btn-sm,
.codes-filters > a.btn-sm,
.codes-filters .codes-list-chips .btn-sm {
  box-sizing: border-box;
  min-height: 2.375rem;
}

.codes-filters .table-select {
  height: 2.375rem;
}

.codes-filters > .btn-sm,
.codes-filters > a.btn-sm,
.codes-filters .codes-list-chips .btn-sm {
  padding: 8px 12px;
  font-size: 0.9375rem;
}

.codes-filters .codes-list-chips {
  margin-top: 0;
  width: auto;
  flex: 0 1 auto;
}

.codes-selection-bar {
  margin-top: 8px;
}

.codes-actions {
  position: relative;
  display: inline-flex;
}

.codes-actions-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 40;
  min-width: 11.5rem;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.codes-actions-menu[hidden] {
  display: none;
}

.codes-actions-item {
  appearance: none;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text, #0f172a);
  cursor: pointer;
}

.codes-actions-item:hover,
.codes-actions-item:focus-visible {
  background: #f1f5f9;
  outline: none;
}

.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.order-selection-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  width: 100%;
}

.order-selection-bar .btn-sm {
  width: auto;
}

.filter-chip {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-size: 0.8125rem;
  cursor: pointer;
  color: var(--muted);
  text-decoration: none;
}

.filter-chip:hover {
  border-color: var(--border-strong);
}

.filter-chip.is-active {
  background: #eff6ff;
  border-color: #93c5fd;
  color: var(--accent);
  font-weight: 600;
}

.gtin-list-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.gtin-list-chip > .btn-sm {
  padding-right: 1.35rem;
}

.gtin-list-chip-delete-form {
  position: absolute;
  top: -5px;
  right: -5px;
  z-index: 2;
  margin: 0;
  line-height: 0;
}

.gtin-list-chip-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.gtin-list-chip:hover .gtin-list-chip-delete,
.gtin-list-chip:has(.is-active) .gtin-list-chip-delete {
  color: #b91c1c;
  border-color: #fecaca;
}

.gtin-list-chip-delete:hover,
.gtin-list-chip-delete:focus-visible {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
  outline: none;
}

.pool-selection-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 12px;
}

.pool-selection-check {
  margin: 0;
}

.pool-selection-count {
  font-size: 0.875rem;
}

.col-check {
  width: 1%;
  white-space: nowrap;
}

.table-empty {
  margin-top: 12px;
}

.table-toolbar-meta {
  margin: 4px 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.table-toolbar--orders-positions {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.order-positions-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.order-positions-controls .table-search {
  flex: 0 1 280px;
  min-width: min(100%, 220px);
}

.order-positions-controls .order-selection-bar {
  flex: 1 1 auto;
  width: auto;
}

.order-create-list-btn {
  min-width: 2.25rem;
  padding-left: 10px;
  padding-right: 10px;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1;
}

.order-create-list-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.order-create-list-btn.is-active:not(:disabled) {
  background: #eff6ff;
  border-color: #93c5fd;
  color: var(--accent);
}

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.pagination-status {
  font-size: 0.875rem;
  color: var(--muted);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 24px;
  padding: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: fit-content;
  max-width: 100%;
}

.tab {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: calc(var(--radius-md) - 4px);
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.tab:hover {
  color: var(--accent);
}

.tab--active {
  color: var(--accent);
  background: var(--card);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
  font-weight: 600;
}

.settings-panel h2 {
  margin: 0 0 12px;
  font-size: 1.125rem;
}

.settings-cz-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
  align-items: stretch;
}

.settings-cz-block {
  max-width: none;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.settings-cz-block .settings-cz-block-footer {
  margin-top: auto;
  padding-top: 4px;
}

.settings-cz-actions {
  padding: 16px 24px;
  margin-bottom: 0;
}

.cz-balance {
  margin-bottom: 16px;
}

.cz-balance-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.cz-balance-head h2 {
  margin: 0 0 4px;
}

.cz-balance-hint {
  margin: 0;
}

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

.cz-balance-metric {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}

.cz-balance-metric .card-value {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin-top: 2px;
}

.cz-balance-metric .card-value--sm {
  font-size: 1.15rem;
}

.cz-balance-tariff-note {
  margin: 6px 0 0;
}

@media (max-width: 800px) {
  .cz-balance-metrics {
    grid-template-columns: 1fr;
  }
}

.cz-balance-groups {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.cz-balance-group {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  font-size: 0.925rem;
}

.cz-balance-group strong {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cz-balance-group--current {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.cz-balance.is-loading .cz-balance-metric .card-value {
  opacity: 0.55;
}

.settings-cz-form .form {
  gap: 14px;
}

@media (max-width: 960px) {
  .settings-cz-grid {
    grid-template-columns: 1fr;
  }
}

.settings-panel .layout-editor-header h2 {
  margin: 0 0 6px;
  font-size: 1.25rem;
}

.toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: grid;
  gap: 10px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  animation: toast-in 0.18s ease;
}

.toast--hide {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast--success {
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.toast--error {
  border-color: #fecaca;
  background: #fef2f2;
}

.toast--warn {
  border-color: #fde68a;
  background: #fffbeb;
}

.toast--info {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.toast-body {
  font-size: 0.9375rem;
  line-height: 1.45;
}

.toast-body a {
  color: inherit;
  font-weight: 600;
}

.toast-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.toast-close:hover {
  color: var(--text);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fetch-progress {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}

.fetch-progress-track {
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  margin-bottom: 10px;
}

.fetch-progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  transition: width 0.35s ease;
}

.fetch-progress-message {
  margin: 0;
  font-weight: 600;
  color: var(--text);
}

.fetch-progress-detail {
  margin: 6px 0 0;
  font-size: 0.875rem;
}

.history-error-row td {
  font-size: 0.875rem;
  padding-top: 0;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  min-width: 32px;
}

.btn-icon .icon-trash,
.btn-icon .icon-pencil {
  display: block;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge--complete {
  background: #ecfdf5;
  color: #047857;
}

.status-badge--partial {
  background: #fffbeb;
  color: #b45309;
}

.status-badge--pending {
  background: #eff6ff;
  color: #1d4ed8;
}

.status-badge--failed {
  background: #fef2f2;
  color: #b91c1c;
}

.status-badge--buffer-pending {
  background: #eff6ff;
  color: #1d4ed8;
}

.status-badge--buffer-active {
  background: #ecfdf5;
  color: #047857;
}

.status-badge--buffer-rejected {
  background: #fef2f2;
  color: #b91c1c;
}

.history-lines-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent, #2563eb);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.history-lines-toggle:hover {
  text-decoration: underline;
}

.history-lines-icon {
  color: var(--muted);
  transition: transform 0.15s ease;
}

.history-lines-toggle[aria-expanded="true"] .history-lines-icon {
  transform: rotate(90deg);
}

.history-order-line-spacer {
  border-top: none;
}

.history-order-line-gtin {
  padding-left: 8px;
}

.history-order-line[hidden] {
  display: none;
}

.is-form-loading {
  pointer-events: none;
}

.btn.is-loading,
.btn.is-loading:disabled,
.btn.is-loading:hover,
.btn.is-loading:disabled:hover {
  --btn-pulse: 37, 99, 235;
  opacity: 1;
  cursor: progress;
  pointer-events: none;
  background: var(--accent-hover);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28);
  animation: btn-wait-pulse 1.8s ease-in-out infinite;
  white-space: nowrap;
}

.btn-secondary.btn.is-loading,
.btn-secondary.btn.is-loading:disabled,
.btn-secondary.btn.is-loading:hover,
.btn-secondary.btn.is-loading:disabled:hover {
  background: var(--accent-soft);
  border-color: #93c5fd;
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.2);
}

.btn-danger.btn.is-loading,
.btn-danger.btn.is-loading:disabled,
.btn-danger.btn.is-loading:hover,
.btn-danger.btn.is-loading:disabled:hover {
  --btn-pulse: 185, 28, 28;
  background: #991b1b;
  color: #fff;
}

.btn-danger-ghost.btn.is-loading,
.btn-danger-ghost.btn.is-loading:disabled,
.btn-danger-ghost.btn.is-loading:hover,
.btn-danger-ghost.btn.is-loading:disabled:hover {
  --btn-pulse: 185, 28, 28;
  background: #fef2f2;
  color: #991b1b;
  border-color: #f87171;
}

@keyframes btn-wait-pulse {
  0%,
  100% {
    box-shadow:
      0 2px 10px rgba(var(--btn-pulse), 0.22),
      0 0 0 0 rgba(var(--btn-pulse), 0.2);
  }
  50% {
    box-shadow:
      0 2px 10px rgba(var(--btn-pulse), 0.22),
      0 0 0 5px rgba(var(--btn-pulse), 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn.is-loading,
  .btn.is-loading:disabled,
  .btn.is-loading:hover,
  .btn.is-loading:disabled:hover {
    animation: none;
  }
}

.warn-text { margin-top: 8px; font-size: 0.875rem; color: #92400e; }

.grid.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.nomenclature-upload-grid {
  align-items: stretch;
}

.nomenclature-upload-grid > * {
  margin-top: 0;
  min-height: 100%;
}

.nomenclature-upload-grid > .form {
  max-width: none;
  display: flex;
  flex-direction: column;
}

.nomenclature-upload-grid > .form .form-actions {
  margin-top: auto;
}

.nomenclature-upload-grid > .nomenclature-rules {
  display: flex;
  flex-direction: column;
}

.nomenclature-upload-grid > .nomenclature-rules .hint-list {
  flex: 1;
  margin: 0;
}

.shipment-home-grid {
  align-items: stretch;
}

.shipment-home-grid > * {
  margin-top: 0;
  min-height: 100%;
}

.shipment-home-grid > .form {
  max-width: none;
  display: flex;
  flex-direction: column;
}

.shipment-home-grid > .form .form-actions {
  margin-top: auto;
}

.hint.fbs-return-scan-error {
  color: #b91c1c;
  min-height: 1.25em;
}

.shipment-cis-search {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 20px;
}

.shipment-cis-search-label {
  font-weight: 600;
}

.shipment-cis-search .table-search {
  max-width: 36rem;
}

.table--shipment-lines tr.is-highlighted td {
  background: #fef3c7;
}

.fbs-return-dialog {
  max-height: min(90vh, 900px);
  overflow: auto;
}

.fbs-return-dialog .form-actions {
  margin-top: 20px;
}

.fbs-duplicates-dialog {
  max-height: min(92vh, 860px);
  overflow: auto;
}

.fbs-duplicates-table-wrap {
  max-height: min(62vh, 640px);
  overflow: auto;
}

.fbs-duplicates-table {
  min-width: 880px;
}

.fbs-duplicates-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--card);
}

.fbs-duplicates-table .fbs-duplicates-group td {
  border-top: 2px solid var(--border);
}

.fbs-duplicates-cis {
  vertical-align: top;
  min-width: 220px;
  max-width: 280px;
}

.fbs-duplicates-cis .fbs-code-item {
  display: inline-block;
  padding-right: 1.5rem;
}

.fbs-return-table-wrap {
  max-height: min(42vh, 420px);
  overflow: auto;
}

.fbs-return-table {
  font-size: 0.875rem;
  min-width: 1080px;
}

.fbs-return-table th,
.fbs-return-table td {
  vertical-align: middle;
  white-space: nowrap;
}

.fbs-return-table td:nth-child(3) {
  white-space: normal;
}

.fbs-return-col-check {
  width: 40px;
  text-align: center;
}

.fbs-return-table .js-return-check,
.fbs-return-table #fbs-return-master-check {
  width: 1rem;
  height: 1rem;
  margin: 0;
  cursor: pointer;
}

.fbs-return-table code {
  word-break: break-all;
}

.fbs-return-col-remove {
  width: 44px;
  text-align: center;
}

.fbs-return-table .fbs-gis-refresh {
  appearance: none;
  border: 0;
  font-family: inherit;
  line-height: inherit;
  cursor: pointer;
}

.fbs-return-table .fbs-gis-refresh:hover {
  filter: brightness(0.96);
}

.fbs-return-table .fbs-gis-refresh:disabled {
  cursor: wait;
  opacity: 0.7;
}

.fbs-return-table .js-return-remove {
  font-size: 1.25rem;
  line-height: 1;
  font-weight: 500;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.fbs-return-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.fbs-return-item {
  font-size: 0.875rem;
}

.fbs-return-item code {
  word-break: break-all;
}

@media (max-width: 720px) {
  .grid.two-col { grid-template-columns: 1fr; }
}

.hint { color: var(--muted); font-size: 0.875rem; margin: 0; }
.hint-list { margin: 0; padding-left: 20px; color: var(--muted); }

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrap--sticky {
  max-height: min(70vh, 720px);
  overflow: auto;
}

.table-wrap--sticky .table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-subtle);
  box-shadow: 0 1px 0 var(--border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.table th, .table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
}

#order-form .qty-input {
  box-sizing: border-box;
  width: 100%;
  min-width: 5rem;
  max-width: 8.5rem;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#order-form .qty-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

#order-form .qty-input:disabled {
  opacity: 0.55;
  background: var(--bg-muted);
  cursor: not-allowed;
}

.table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-subtle);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge--ok { background: #ecfdf5; color: var(--success); }
.badge--warn { background: #fffbeb; color: #b45309; }
.badge--error { background: #fef2f2; color: #b91c1c; }
.badge--info { background: #eff6ff; color: #1d4ed8; }
.badge--accent { background: #eef2ff; color: #4338ca; }
.badge--muted { background: #f3f4f6; color: #6b7280; }

code {
  background: var(--accent-soft);
  color: var(--accent-hover);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.875em;
}

.modal {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  max-width: 480px;
  width: calc(100% - 32px);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.15);
}

.modal.modal--wide {
  max-width: min(960px, calc(100% - 32px));
}

#shipment-create-dialog {
  overflow: hidden;
}

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

.modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.modal-form {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.modal-form h3 {
  margin: 0;
}

.modal .form-actions {
  min-width: 0;
  max-width: 100%;
}

.modal .btn {
  max-width: 100%;
}

.shipment-create-wait {
  display: none;
  margin: 0;
}

.is-form-loading .shipment-create-wait {
  display: block;
}

.shipment-create-dialog {
  max-height: min(92vh, 920px);
  min-width: 0;
  overflow-x: clip;
  overflow-y: auto;
  padding: 0 20px;
  grid-template-columns: minmax(0, 1fr);
}

.shipment-create-dialog > * {
  min-width: 0;
}

.shipment-create-dialog > h3:first-child {
  padding-top: 20px;
}

.shipment-create-excel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin: 0;
  padding: 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.shipment-create-excel h4 {
  margin: 0;
  font-size: 0.9375rem;
}

.shipment-create-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.shipment-create-divider::before,
.shipment-create-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.shipment-create-stick-head {
  position: sticky;
  top: 0;
  z-index: 8;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin: 0 -20px;
  padding: 16px 20px 12px;
  background: var(--card);
}

.shipment-create-stick-head .shipment-create-divider {
  margin: 0;
}

.shipment-create-manual {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin: 0;
  position: relative;
  z-index: 0;
}

.shipment-create-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin: 0 -20px;
  padding: 12px 20px 28px;
  background: var(--card);
}

.shipment-create-dialog .shipment-create-table-wrap {
  max-height: none;
  max-width: 100%;
  min-width: 0;
  overflow: visible;
}

.shipment-create-dialog .shipment-create-table-wrap .table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

.shipment-create-dialog #shipment-create-table th:nth-child(1),
.shipment-create-dialog #shipment-create-table td:nth-child(1) { width: 11%; }
.shipment-create-dialog #shipment-create-table th:nth-child(2),
.shipment-create-dialog #shipment-create-table td:nth-child(2) { width: 30%; }
.shipment-create-dialog #shipment-create-table th:nth-child(3),
.shipment-create-dialog #shipment-create-table td:nth-child(3) { width: 17%; }
.shipment-create-dialog #shipment-create-table th:nth-child(4),
.shipment-create-dialog #shipment-create-table td:nth-child(4) { width: 8%; }
.shipment-create-dialog #shipment-create-table th:nth-child(5),
.shipment-create-dialog #shipment-create-table td:nth-child(5) { width: 9%; }
.shipment-create-dialog #shipment-create-table th:nth-child(6),
.shipment-create-dialog #shipment-create-table td:nth-child(6) { width: 8%; }
.shipment-create-dialog #shipment-create-table th:nth-child(7),
.shipment-create-dialog #shipment-create-table td:nth-child(7) { width: 17%; }

.shipment-create-dialog #shipment-create-table th:nth-child(7) {
  white-space: nowrap;
}

.shipment-create-dialog #shipment-create-table th,
.shipment-create-dialog #shipment-create-table td {
  overflow-wrap: anywhere;
}

.shipment-create-dialog #shipment-create-table code {
  word-break: break-all;
}

.shipment-create-dialog .shipment-create-table-wrap .table thead th {
  top: var(--shipment-create-stick-offset, 0px);
  z-index: 4;
}

.shipment-create-dialog .shipment-create-table-wrap .table tbody td {
  position: relative;
  z-index: 0;
  background: var(--card);
}

#shipment-create-form .qty-input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}

#shipment-create-form .qty-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

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

.label-preview-caption {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted, #64748b);
  text-align: center;
}

.label-preview-frame {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 120px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
}

.label-preview-frame img {
  max-width: 100%;
  height: auto;
  display: block;
}

.label-preview-km {
  margin: 0;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.68rem;
  line-height: 1.25;
  text-align: center;
  word-break: break-all;
  color: #334155;
}

.label-preview-error {
  margin: 0;
  font-size: 0.8rem;
  color: #b91c1c;
  text-align: center;
}

.layout-editor-page {
  display: grid;
  gap: 20px;
  overflow-x: hidden;
}

.layout-editor-toolbar-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

@media (max-width: 960px) {
  .layout-editor-toolbar-row {
    grid-template-columns: 1fr;
  }
}

.layout-editor-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100%;
  margin-bottom: 0;
  max-width: none;
}

.layout-editor-block-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.layout-editor-block-hint {
  margin: 0;
}

.layout-editor-block-footer {
  margin-top: auto;
  padding-top: 4px;
}

.layout-editor-block--picker .layout-editor-toolbar-actions {
  margin-top: auto;
  padding-top: 4px;
}

.layout-editor-field {
  display: grid;
  gap: 6px;
  font-weight: 500;
  min-width: 0;
}

.layout-editor-field select {
  font-weight: 400;
}

.layout-editor-block--picker,
.layout-editor-block--numbering {
  gap: 14px;
}

.layout-editor-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.layout-toolbar-danger {
  color: #b91c1c;
}

.shipment-layout-card .form {
  max-width: 520px;
}

.layout-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.layout-editor-header h1 {
  margin: 0 0 6px;
}

.layout-editor-subtitle {
  margin: 0;
  color: var(--muted, #64748b);
  font-size: 0.9rem;
}

.layout-editor-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.layout-editor-status {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
}

.layout-editor-status.is-success {
  background: #ecfdf5;
  color: #047857;
}

.layout-editor-status.is-error {
  background: #fef2f2;
  color: #b91c1c;
}

.layout-editor-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 20px;
  align-items: start;
}

.layout-editor-canvas-wrap,
.layout-editor-sidebar {
  min-width: 0;
}

.layout-editor-canvas-wrap {
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: 20px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  overflow-x: auto;
}

.layout-editor-zoom {
  display: flex;
  gap: 8px;
}

.layout-editor-zoom button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
}

.layout-editor-zoom button.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.layout-editor-duo {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  width: 100%;
  justify-items: center;
}

.layout-editor-pane {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.layout-editor-pane .layout-editor-stage {
  box-sizing: border-box;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: visible;
  width: calc(var(--label-w-mm, 58) * var(--scale, 2) * 1mm + 48px);
  min-height: calc(var(--label-h-mm, 40) * var(--scale, 2) * 1mm + 48px);
}

.layout-editor-stage[data-zoom="2"],
.layout-preview-stage[data-zoom="2"] {
  --scale: 2;
}

.layout-editor-stage[data-zoom="3"],
.layout-preview-stage[data-zoom="3"] {
  --scale: 3;
}

.layout-editor-stage[data-zoom="4"],
.layout-preview-stage[data-zoom="4"] {
  --scale: 4;
}

.layout-editor-pane-label {
  margin: 0 0 10px;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  color: var(--muted);
}

.layout-preview-viewport {
  position: relative;
  background: #fff;
  border: 0.2mm solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
}

.layout-preview-viewport img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  position: relative;
  z-index: 1;
}

.layout-preview-placeholder {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  place-items: center;
  margin: 0;
  padding: 8px;
  color: var(--muted, #64748b);
  font-size: 0.8rem;
  text-align: center;
  background: #fff;
}

.layout-preview-viewport.is-loading .layout-preview-placeholder {
  display: grid;
}

.layout-preview-viewport.is-loading img {
  visibility: hidden;
}

.layout-preview-stage[data-zoom="2"] .layout-preview-viewport,
.layout-preview-stage[data-zoom="3"] .layout-preview-viewport,
.layout-preview-stage[data-zoom="4"] .layout-preview-viewport,
.layout-editor-stage[data-zoom="2"] .layout-canvas,
.layout-editor-stage[data-zoom="3"] .layout-canvas,
.layout-editor-stage[data-zoom="4"] .layout-canvas {
  transform: scale(var(--scale));
  transform-origin: top center;
  margin-bottom: calc(var(--label-h-mm, 40) * (var(--scale) - 1) * 1mm);
}

.layout-editor-stage {
  padding: 24px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.layout-canvas {
  position: relative;
  background: #fff;
  border: 0.2mm solid var(--border);
  overflow: hidden;
}

.layout-element {
  position: absolute;
  box-sizing: border-box;
  outline: 1px dashed #94a3b8;
  outline-offset: 0;
  border: none;
  background: rgba(37, 99, 235, 0.06);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  cursor: grab;
}

.layout-element[data-role="article"],
.layout-element[data-role="production_date"] {
  align-items: flex-start;
  justify-content: flex-start;
}

.layout-element[data-role="product_name"],
.layout-element[data-role="volume"],
.layout-element[data-role="km_hri"],
.layout-element[data-role="gtin"],
.layout-element[data-role="origin"],
.layout-element[data-role="marks"],
.layout-element[data-role="static_text"],
.layout-element[data-role="numbering"] {
  align-items: center;
  justify-content: center;
}

.layout-element[data-role="barcode"] {
  align-items: stretch;
  justify-content: stretch;
}

.layout-element[data-role="datamatrix"] {
  align-items: stretch;
  justify-content: stretch;
}

.layout-element.is-selected {
  outline: 2px solid #2563eb;
  background: rgba(37, 99, 235, 0.12);
  z-index: 2;
}

.layout-element[data-role="product_name"],
.layout-element[data-role="article"],
.layout-element[data-role="production_date"] {
  outline-color: #7c3aed;
}

.layout-element[data-role="static_text"].is-selected,
.layout-element[data-role="numbering"].is-selected,
.layout-element[data-role="gtin"].is-selected,
.layout-element[data-role="product_name"].is-selected,
.layout-element[data-role="article"].is-selected,
.layout-element[data-role="production_date"].is-selected {
  outline: 2px solid #7c3aed;
  background: rgba(124, 58, 237, 0.12);
}

.layout-element.is-dragging,
.layout-element.is-resizing {
  z-index: 3;
}

.layout-element.is-dragging {
  cursor: grabbing;
}

.layout-element-content {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  color: #0f172a;
  pointer-events: none;
  overflow: hidden;
}

.layout-element-content--product_name {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1mm;
  font-size: 6pt;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  word-break: break-word;
}

.layout-element-content--volume {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5.5pt;
  line-height: 1;
  text-align: center;
}

.layout-element-content--article {
  display: flex;
  align-items: center;
  padding-left: 1mm;
  font-size: 4.8pt;
  line-height: 1.15;
  text-align: left;
}

.layout-element-content--production_date {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 0;
  padding-left: 1mm;
  line-height: 1.15;
  text-align: left;
}

.layout-meta-line {
  display: block;
}

.layout-meta-date {
  width: 100%;
  line-height: 1.05;
  text-align: center;
}

.layout-element-content--datamatrix,
.layout-element-content--barcode {
  display: block;
  padding: 0;
  background: #fff;
}

.layout-element-preview-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.layout-element-content--datamatrix {
  font-size: 5pt;
  font-weight: 700;
  color: #1e40af;
}

.layout-element-content--km_hri {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Courier, monospace;
  font-size: 3pt;
  line-height: 1.1;
  text-align: center;
  white-space: pre-wrap;
}

.layout-element-content--barcode {
  background: #fff;
}

.layout-element-content--gtin {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Courier, monospace;
  font-size: 4.8pt;
  line-height: 1;
  text-align: center;
}

.layout-element-content--marks {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1.2mm;
  max-width: 100%;
  max-height: 100%;
}

.layout-mark {
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  color: #0f172a;
}

.layout-mark-eac {
  width: min(6.5mm, 100%);
  height: min(4.5mm, 100%);
  font-size: 4pt;
  border: 0.35mm solid #0f172a;
  border-radius: 0.3mm;
}

.layout-mark-age {
  width: min(5.5mm, 100%);
  height: min(5.5mm, 100%);
  aspect-ratio: 1;
  font-size: 5pt;
  border: 0.35mm solid #0f172a;
  border-radius: 50%;
}

.layout-element-content--origin {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4pt;
  line-height: 1;
  text-align: center;
}

.layout-element-content--static_text,
.layout-element-content--numbering {
  display: flex;
  align-items: center;
  padding-left: 1mm;
  padding-right: 1mm;
  font-size: 4.8pt;
  line-height: 1.15;
  overflow: hidden;
  word-break: break-word;
}

.layout-element-content--static_text {
  text-align: left;
}

.layout-element-content--numbering {
  justify-content: center;
  text-align: center;
  font-weight: 600;
}

.layout-editor-add-text,
.layout-editor-add-numbering {
  width: 100%;
}

.layout-editor-add-numbering {
  margin-top: 8px;
}

.layout-element-actions {
  padding-top: 4px;
}

.layout-element-props {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.layout-element-props h3 {
  margin: 0;
  font-size: 0.95rem;
}

.layout-element-props-field {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
}

.layout-element-props-field textarea {
  width: 100%;
  min-height: 72px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  resize: vertical;
}

.layout-font-size-controls {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  gap: 8px;
  align-items: center;
}

.layout-font-size-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.layout-font-size-btn:hover {
  background: #f8fafc;
}

.layout-font-size-value {
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  color: #334155;
}

.layout-element-delete {
  width: 100%;
  color: #b91c1c;
  border-color: #fecaca;
}

.layout-element-delete:hover {
  background: #fef2f2;
}

.layout-editor-sidebar {
  display: grid;
  gap: 16px;
}

.layout-editor-sidebar h2 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.layout-element-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.layout-element-list-item {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
}

.layout-element-list-item.is-selected {
  border-color: #2563eb;
  background: #eff6ff;
}

.layout-preview-panel {
  width: 100%;
  max-width: 100%;
  justify-self: stretch;
}

@media (max-width: 960px) {
  .layout-editor-workspace {
    grid-template-columns: 1fr;
  }
}

/* Заказы FBS: фильтры и действия в одну строку */
.fbs-orders-toolbar {
  align-items: center;
}

.fbs-orders-toolbar-main {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.fbs-orders-filters,
.fbs-orders-action {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.fbs-orders-filters {
  flex: 1 1 auto;
  min-width: 0;
}

.fbs-orders-toolbar .table-search,
.fbs-orders-toolbar .table-select,
.fbs-orders-toolbar .btn-sm,
.fbs-orders-toolbar a.btn-sm {
  box-sizing: border-box;
  min-height: 2.375rem;
}

.fbs-orders-toolbar .table-search {
  flex: 1 1 180px;
  min-width: 160px;
}

.fbs-orders-toolbar .table-select {
  height: 2.375rem;
  min-width: 132px;
}

.fbs-orders-toolbar .btn-sm,
.fbs-orders-toolbar a.btn-sm {
  padding: 8px 12px;
  font-size: 0.9375rem;
  align-self: center;
}

@media (max-width: 720px) {
  .fbs-orders-toolbar-main,
  .fbs-orders-filters {
    flex-wrap: wrap;
    flex: 1 1 100%;
  }
}

/* Заказы FBS: группы по поставке */
.fbs-supply-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.fbs-supply-group {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  background: #fafafa;
  padding: 0;
  overflow: hidden;
}

.fbs-supply-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
  padding: 12px 14px;
  gap: 10px;
  cursor: pointer;
  list-style: none;
  box-sizing: border-box;
}

.fbs-supply-summary::-webkit-details-marker {
  display: none;
}

.fbs-supply-chevron {
  display: inline-block;
  width: 1em;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.fbs-supply-group[open] .fbs-supply-chevron {
  transform: rotate(90deg);
}

.fbs-supply-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.95rem;
}

.fbs-supply-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-left: auto;
}

.fbs-supply-status-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fbs-supply-chip-link {
  text-decoration: none;
}

.fbs-mp-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.fbs-supply-withdraw-form {
  display: inline-flex;
  align-items: center;
  margin: 0 0 0 auto;
  flex-shrink: 0;
}

.fbs-supply-body {
  margin: 0;
  padding: 0 12px 12px;
  background: #fff;
  border-top: 1px solid var(--border, #e5e7eb);
}

.fbs-supply-body .table-wrap {
  margin-top: 10px;
  width: 100%;
  overflow-x: auto;
}

.fbs-orders-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.fbs-orders-table th,
.fbs-orders-table td {
  vertical-align: middle;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.fbs-orders-table td {
  text-align: left;
}

.table.fbs-orders-table thead th {
  text-align: center;
}

.table.fbs-orders-table tbody tr.fbs-row--return td {
  background: #fff1f2;
}

.table.fbs-orders-table tbody tr.fbs-row--return:hover td {
  background: #ffe4e6;
}

.table.fbs-orders-table td.error-cell {
  text-align: center;
}

.table.fbs-orders-table th.fbs-col-cis-cell,
.table.fbs-orders-table td.fbs-col-cis-cell {
  text-align: center;
}

.table.fbs-orders-table td.fbs-col-cis-cell .fbs-code-list {
  align-items: center;
}

.table.fbs-orders-table td.fbs-col-cis-cell .fbs-code-item {
  justify-content: center;
}

.table.fbs-orders-table th.fbs-col-wb-cell,
.table.fbs-orders-table td.fbs-col-wb-cell {
  text-align: center;
}

.table.fbs-orders-table td.fbs-col-wb-cell {
  font-size: 1em;
  line-height: 1.35;
}

.table.fbs-orders-table .fbs-col-status-cell {
  text-align: center;
  font-size: 0.75rem;
}

.table.fbs-orders-table .fbs-col-status-cell .fbs-code-list {
  align-items: center;
}

.table.fbs-orders-table .fbs-col-status-cell .badge {
  font-size: 0.6875rem;
  padding: 1px 6px;
  font-weight: 500;
}

.table.fbs-orders-table .fbs-col-status-cell .fbs-gis-refresh {
  appearance: none;
  border: 0;
  font-family: inherit;
  line-height: inherit;
  cursor: pointer;
}

.table.fbs-orders-table .fbs-col-status-cell .fbs-gis-refresh:hover {
  filter: brightness(0.96);
}

.table.fbs-orders-table .fbs-col-status-cell .fbs-gis-refresh:disabled {
  cursor: wait;
  opacity: 0.7;
}

.fbs-orders-table .fbs-col-order { width: 12%; }
.fbs-orders-table .fbs-col-article { width: 8%; }
.fbs-orders-table .fbs-col-cis { width: 14%; }
.fbs-orders-table .fbs-col-wb { width: 13%; }
.fbs-orders-table .fbs-col-status { width: 13%; }
.fbs-orders-table .fbs-col-shipped { width: 12%; }
.fbs-orders-table .fbs-col-docs { width: 14%; }
.fbs-orders-table .fbs-col-error { width: 14%; }

.fbs-orders-table--flat .fbs-col-supply { width: 16%; }
.fbs-orders-table--flat .fbs-col-order { width: 13%; }
.fbs-orders-table--flat .fbs-col-article { width: 10%; }
.fbs-orders-table--flat .fbs-col-cis { width: 16%; }
.fbs-orders-table--flat .fbs-col-wb { width: 15%; }
.fbs-orders-table--flat .fbs-col-status { width: 14%; }
.fbs-orders-table--flat .fbs-col-shipped { width: 16%; }

.fbs-sticker-id {
  margin-top: 2px;
  font-size: 0.8125rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.fbs-code-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.fbs-code-item {
  position: relative;
  display: inline-block;
  max-width: 100%;
  padding-right: 0;
}

.fbs-code-cis {
  display: inline-block;
  max-width: 100%;
  font-size: 0.85rem;
  word-break: break-all;
  min-width: 0;
}

.fbs-copy-btn {
  position: absolute;
  right: -2px;
  bottom: -2px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  color: var(--muted, #6b7280);
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}

@media (hover: hover) and (pointer: fine) {
  .fbs-copy-btn {
    opacity: 0;
  }

  .fbs-code-item:hover .fbs-copy-btn,
  .fbs-code-item:focus-within .fbs-copy-btn,
  .fbs-copy-btn:focus-visible {
    opacity: 1;
  }
}

.fbs-copy-btn:hover,
.fbs-copy-btn:focus-visible {
  background: #fff;
  color: var(--text, #111827);
  border-color: var(--border, #d1d5db);
  outline: none;
}

.fbs-copy-btn svg {
  width: 12px;
  height: 12px;
  display: block;
}

.fbs-copy-btn.is-copied {
  opacity: 1;
  color: var(--ok, #15803d);
}

@media (max-width: 720px) {
  .fbs-supply-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }

  .fbs-supply-withdraw-form {
    margin-left: auto;
  }
}
